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/gmoezyc2.cpp

163 lines
4.0 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) 1990-1999 Odinn Sorensen
// ------------------------------------------------------------------
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
// MA 02111-1307, USA
// ------------------------------------------------------------------
// $Id$
// ------------------------------------------------------------------
// Ezycom msgbase handling
// ------------------------------------------------------------------
#include <gdbgtrk.h>
#include <gmoezyc.h>
// ------------------------------------------------------------------
void EzycomArea::raw_scan(int __keep_index) {
GFTRK("EzycomRawScan");
int _wasopen = isopen;
2001-04-15 19:24:44 +00:00
if(not _wasopen) {
2002-05-12 13:07:37 +00:00
if(ispacked()) {
const char* newpath = Unpack(path());
if(newpath == NULL)
packed(false);
set_real_path(newpath ? newpath : path());
}
2000-02-25 10:15:17 +00:00
isopen++;
data_open();
test_raw_open(__LINE__);
}
Msgn->Resize((uint)(filelength(data->fhhdr) / sizeof(EzycHdr)));
for(uint _count=0; _count<Msgn->Count(); _count++)
Msgn->at(_count) = _count + 1;
int _fh = ::sopen(AddPath(wide->userbasepath, "LASTCOMB.BBS"), O_RDONLY|O_BINARY, SH_DENYNO, S_STDRD);
if(_fh != -1) {
word _lastread;
2005-10-07 12:41:11 +00:00
lseekset(_fh, wide->userno * (wide->maxmess / 16) * sizeof(EzycLast) +
2000-02-25 10:15:17 +00:00
(((board() - 1) / 16) * sizeof(EzycLast) + sizeof(word)) +
(board()-1) % 16 * sizeof(word)
);
read(_fh, &_lastread, sizeof(word));
if(_lastread)
_lastread--;
2005-10-07 12:41:11 +00:00
uint _active = Msgn->Count();
uint _count = 1;
uint32_t* _msgnoptr = Msgn->tag;
uint _lastread_reln = 0;
uint _firstmsgno = 0;
uint _lastmsgno = 0;
uint _lastreadfound = 0;
2000-02-25 10:15:17 +00:00
if(_active) {
_firstmsgno = Msgn->at(0);
_lastmsgno = Msgn->at(_active-1);
while(1) {
// Set lastread pointer
2001-04-15 19:24:44 +00:00
if((*_msgnoptr >= _lastread) and (_lastread_reln == 0)) {
2000-02-25 10:15:17 +00:00
_lastreadfound = *_msgnoptr;
_lastread_reln = _count - (*_msgnoptr != _lastread ? 1 : 0);
break;
}
if((++_count) > _active)
break;
_msgnoptr++;
}
}
// If the exact lastread was not found
2001-04-15 19:24:44 +00:00
if(_active and (_lastreadfound != _lastread)) {
2000-02-25 10:15:17 +00:00
// Higher than highest or lower than lowest?
if(_lastread > _lastmsgno)
_lastread_reln = _active;
else if(_lastread < _firstmsgno)
_lastread_reln = 0;
}
// Update area data
lastread = _lastread_reln;
lastreadentry = _lastreadfound;
::close(_fh);
}
2001-04-15 19:24:44 +00:00
if(not __keep_index)
2000-02-25 10:15:17 +00:00
Msgn->Reset();
2001-04-15 19:24:44 +00:00
if(not _wasopen) {
2000-02-25 10:15:17 +00:00
raw_close();
data_close();
2002-05-12 13:07:37 +00:00
if(ispacked()) {
CleanUnpacked(real_path());
}
2000-02-25 10:15:17 +00:00
isopen--;
}
GFTRK(NULL);
}
// ------------------------------------------------------------------
void EzycomArea::scan() {
GFTRK("EzycomScan");
raw_scan(true);
GFTRK(NULL);
}
// ------------------------------------------------------------------
void EzycomArea::scan_area() {
GFTRK("EzycomScanArea");
raw_scan(false);
GFTRK(NULL);
}
// ------------------------------------------------------------------
void EzycomArea::scan_area_pm() {
GFTRK("EzycomScanArea*M");
scan_area();
GFTRK(NULL);
}
// ------------------------------------------------------------------