This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-goldedplus/goldlib/gmb3/gmosmb2.cpp

140 lines
3.9 KiB
C++
Raw Normal View History

2000-02-25 10:15:17 +00:00
// This may look like C code, but it is really -*- C++ -*-
// ------------------------------------------------------------------
// The Goldware Library
// Copyright (C) 2000 Alexander S. Aganichev
// ------------------------------------------------------------------
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// ------------------------------------------------------------------
// $Id$
// ------------------------------------------------------------------
// Synchronet message base
// ------------------------------------------------------------------
#include <gdbgtrk.h>
#include <gmemdbg.h>
#include <gstrall.h>
#include <gmosmb.h>
// ------------------------------------------------------------------
void SMBArea::raw_scan(bool keep_index, bool scanpm)
{
GFTRK("SMBArea::raw_scan");
2001-10-27 06:57:20 +00:00
smb_t *_was_data = data;
2000-02-25 10:15:17 +00:00
if(_was_data == NULL)
data_open();
ulong firstmsgno = 0;
ulong lastmsgno = 0;
Msgn->Reset();
PMrk->Reset();
2001-10-27 06:57:20 +00:00
if(isopen or smb_open(data) == 0) {
if(smb_locksmbhdr(data) == 0) {
int res = smb_getstatus(data);
smb_unlocksmbhdr(data);
2000-02-25 10:15:17 +00:00
ulong total_msgs = 0;
if(res == 0) {
2001-10-27 06:57:20 +00:00
total_msgs = data->status.total_msgs;
lastmsgno = data->status.last_msg;
2000-02-25 10:15:17 +00:00
if(keep_index or scanpm) {
smbmsg_t msg;
int umax = (WidePersonalmail & PM_ALLNAMES) ? WideUsernames : 1;
ulong l = 1;
rewind(data->sid_fp);
while(l <= total_msgs) {
if(not fread(&msg.idx, 1, sizeof(idxrec_t), data->sid_fp))
break;
2001-10-27 06:57:20 +00:00
if(smb_lockmsghdr(data, &msg) == 0) {
int rc = smb_getmsghdr(data, &msg);
smb_unlockmsghdr(data, &msg);
2000-02-25 10:15:17 +00:00
if(rc == 0) {
if(firstmsgno == 0)
firstmsgno = msg.hdr.number;
if(keep_index)
Msgn->Append(msg.hdr.number);
if(scanpm) {
bool gotpm = false;
for(int u=0; u<umax; u++) {
if(strieql(WideUsername[u], (char *)msg.to)) {
gotpm = true;
break;
}
}
if(gotpm) {
if(not (msg.idx.attr & MSG_READ))
PMrk->Append(msg.hdr.number);
gotpm = false;
}
}
2001-10-27 06:57:20 +00:00
smb_freemsgmem(&msg);
2000-02-25 10:15:17 +00:00
}
}
l++;
}
total_msgs = l-1;
}
}
if(not isopen)
2001-10-27 06:57:20 +00:00
smb_close(data);
2000-02-25 10:15:17 +00:00
Msgn->SetCount(total_msgs);
}
}
if(WideDebug) {
WideLog->printf("- %s: t:%u, l:%u, fm:%lu, hm:%lu, lr:%u, u:%u, pm: %i",
echoid(),
Msgn->Count(),
0,
firstmsgno,
lastmsgno,
0,
0,
scanpm ? (int)PMrk->Count() : -1
);
}
if(_was_data == NULL)
data_close();
GFTRK(NULL);
}
// ------------------------------------------------------------------
void SMBArea::scan()
{
raw_scan(true);
}
// ------------------------------------------------------------------
void SMBArea::scan_area()
{
raw_scan();
}
// ------------------------------------------------------------------
void SMBArea::scan_area_pm()
{
raw_scan(true, true);
}
// ------------------------------------------------------------------