Refactoring!
This commit is contained in:
@@ -302,9 +302,11 @@ void EzycomInit(const char* msgbasepath, const char* userbasepath, int userno) {
|
||||
|
||||
const char* _username = WideUsername[0];
|
||||
ezycomwide->user->ver = ezycomwide->ver;
|
||||
if(ezycomwide->userno == -1) {
|
||||
ezycomwide->user->fh = ::sopen(AddPath(ezycomwide->userbasepath, "USERS.BBS"), O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
|
||||
if(ezycomwide->user->fh != -1) {
|
||||
if (ezycomwide->userno == -1)
|
||||
{
|
||||
ezycomwide->user->gufh = ::sopen(AddPath(ezycomwide->userbasepath, "USERS.BBS"), O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
|
||||
if (ezycomwide->user->gufh != -1)
|
||||
{
|
||||
ezycomwide->user->extfh = ::sopen(AddPath(ezycomwide->userbasepath, "USERSEXT.BBS"), O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
|
||||
if(ezycomwide->user->extfh != -1) {
|
||||
ezycomwide->user->find(_username);
|
||||
@@ -315,7 +317,7 @@ void EzycomInit(const char* msgbasepath, const char* userbasepath, int userno) {
|
||||
}
|
||||
close(ezycomwide->user->extfh);
|
||||
}
|
||||
close(ezycomwide->user->fh);
|
||||
close(ezycomwide->user->gufh);
|
||||
}
|
||||
ezycomwide->userno = ezycomwide->user->index;
|
||||
}
|
||||
|
@@ -32,12 +32,13 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
char* EzycomArea::user_lookup(char* __lookfor) {
|
||||
|
||||
wide->user->fh = ::sopen(AddPath(wide->userbasepath, "USERS.BBS"), O_RDWR|O_BINARY, WideSharemode, S_STDRW);
|
||||
if(wide->user->fh) {
|
||||
char* EzycomArea::user_lookup(char* __lookfor)
|
||||
{
|
||||
wide->user->gufh = ::sopen(AddPath(wide->userbasepath, "USERS.BBS"), O_RDWR|O_BINARY, WideSharemode, S_STDRW);
|
||||
if (wide->user->gufh)
|
||||
{
|
||||
wide->user->findwild(__lookfor, __lookfor);
|
||||
::close(wide->user->fh);
|
||||
::close(wide->user->gufh);
|
||||
}
|
||||
|
||||
if(wide->user->found)
|
||||
|
@@ -139,15 +139,16 @@ void FidoInit(const char* fidolastread, int fidohwmarks, int fidonullfix, int fi
|
||||
if(fidowide->userno == -1) {
|
||||
Path userfile;
|
||||
strxcpy(userfile, AddPath(fidowide->squishuserpath, "USER.BBS"), sizeof(Path));
|
||||
fidowide->user->fh = ::sopen(userfile, O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
|
||||
if(fidowide->user->fh != -1) {
|
||||
fidowide->user->gufh = ::sopen(userfile, O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
|
||||
if (fidowide->user->gufh != -1)
|
||||
{
|
||||
fidowide->user->find(_username);
|
||||
if(not fidowide->user->found) {
|
||||
WideLog->printf("* User \"%s\" not found in %s.", _username, userfile);
|
||||
fidowide->user->add(_username);
|
||||
WideLog->printf("* Now added with user number %u.", fidowide->user->index);
|
||||
}
|
||||
::close(fidowide->user->fh);
|
||||
::close(fidowide->user->gufh);
|
||||
}
|
||||
fidowide->userno = fidowide->user->index;
|
||||
}
|
||||
|
@@ -33,13 +33,13 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
char* FidoArea::user_lookup(char* __lookfor) {
|
||||
|
||||
char* FidoArea::user_lookup(char* __lookfor)
|
||||
{
|
||||
Path userfile;
|
||||
strxcpy(userfile, AddPath(fidowide->squishuserpath, "USER.BBS"), sizeof(Path));
|
||||
wide->user->fh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
wide->user->gufh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
wide->user->findwild(__lookfor, __lookfor);
|
||||
::close(wide->user->fh);
|
||||
::close(wide->user->gufh);
|
||||
|
||||
if(wide->user->found)
|
||||
return __lookfor;
|
||||
|
@@ -199,15 +199,15 @@ struct _HudsWide {
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
int fhtxt;
|
||||
int fhhdr;
|
||||
int fhidx;
|
||||
int fhinf;
|
||||
int fhlrd;
|
||||
int fhtoi;
|
||||
int fhusr;
|
||||
int fhuix;
|
||||
int fhuxi;
|
||||
gfile fhtxt;
|
||||
gfile fhhdr;
|
||||
gfile fhidx;
|
||||
gfile fhinf;
|
||||
gfile fhlrd;
|
||||
gfile fhtoi;
|
||||
gfile fhusr;
|
||||
gfile fhuix;
|
||||
gfile fhuxi;
|
||||
int isopen;
|
||||
int islocked;
|
||||
int timesposted;
|
||||
@@ -246,7 +246,7 @@ struct _HudsWide {
|
||||
|
||||
void update_netecho(char* __name, msgn_t __hdridx, int __delete);
|
||||
|
||||
int test_open(char* __file, int __oaccess);
|
||||
void test_open(gfile &__file, char* __fname, int __oaccess);
|
||||
void raw_open(int __oaccess=0, int __all=true);
|
||||
void raw_close();
|
||||
void refresh();
|
||||
|
@@ -66,12 +66,9 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
|
||||
|
||||
GFTRK("HudsInit");
|
||||
|
||||
if(WideDebug)
|
||||
if (WideDebug)
|
||||
WideLog->printf("- Begin init for %s.", path);
|
||||
|
||||
fhusr = -1;
|
||||
fhtxt = fhhdr = fhidx = -1;
|
||||
fhinf = fhlrd = fhtoi = -1;
|
||||
isopen = 0;
|
||||
islocked = false;
|
||||
timesposted = 0;
|
||||
@@ -81,16 +78,20 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
|
||||
scn = NULL;
|
||||
|
||||
// Open complete msgbase, create if none exists
|
||||
if(not fexist(AddPath(path, __HUDSON ? "msghdr" HUDS_EXT : "msghdr" GOLD_EXT))) {
|
||||
if (not fexist(AddPath(path, __HUDSON ? "msghdr" HUDS_EXT : "msghdr" GOLD_EXT)))
|
||||
{
|
||||
WideLog->printf("* Creating new msgbase at %s", path);
|
||||
raw_open(O_CREAT);
|
||||
if(filelength(fhinf) == 0) {
|
||||
|
||||
if (fhinf.FileLength() == 0)
|
||||
{
|
||||
memset(&msginfo, 0, sizeof(HudsInfo));
|
||||
write(fhinf, &msginfo, sizeof(HudsInfo));
|
||||
fhinf.Write(&msginfo, sizeof(HudsInfo));
|
||||
}
|
||||
if(filelength(fhlrd) == 0) {
|
||||
if (fhlrd.FileLength() == 0)
|
||||
{
|
||||
memset(lastrec, 0, sizeof(HudsLast));
|
||||
write(fhlrd, lastrec, sizeof(HudsLast));
|
||||
fhlrd.Write(lastrec, sizeof(HudsLast));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -101,14 +102,15 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
|
||||
lock();
|
||||
|
||||
// Check if MSGTXT.BBS is approaching dangerous size
|
||||
if(__HUDSON and (filelength(fhtxt) > sizewarn))
|
||||
if (__HUDSON and (fhtxt.FileLength() > sizewarn))
|
||||
HudsSizewarn();
|
||||
|
||||
// Check for mismatch between the header and the index files
|
||||
uint _hdrsize = filelength(fhhdr)/sizeof(HudsHdr);
|
||||
uint _idxsize = filelength(fhidx)/sizeof(HudsIdx);
|
||||
uint _toisize = filelength(fhtoi)/sizeof(HudsToIdx);
|
||||
if((_hdrsize != _idxsize) or (_hdrsize != _toisize)) {
|
||||
uint _hdrsize = fhhdr.FileLength()/sizeof(HudsHdr);
|
||||
uint _idxsize = fhidx.FileLength()/sizeof(HudsIdx);
|
||||
uint _toisize = fhtoi.FileLength()/sizeof(HudsToIdx);
|
||||
if ((_hdrsize != _idxsize) or (_hdrsize != _toisize))
|
||||
{
|
||||
raw_close();
|
||||
HGWarnRebuild();
|
||||
WideLog->ErrIndex();
|
||||
@@ -124,7 +126,7 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
|
||||
if(__HUDSON and (ra2usersbbs == 0)) {
|
||||
|
||||
// Get size of USERS.BBS
|
||||
int len = filelength(fhusr);
|
||||
int len = fhusr.FileLength();
|
||||
|
||||
// Does size match Hudson format?
|
||||
int hudsmatch = (len % sizeof(HudsUsers)) == 0;
|
||||
@@ -137,23 +139,23 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
|
||||
ra2usersbbs = 2;
|
||||
|
||||
// If it matches both of them
|
||||
if(hudsmatch and ra2match) {
|
||||
|
||||
if (hudsmatch and ra2match)
|
||||
{
|
||||
// Check version in CONFIG.RA to make sure
|
||||
Path rapath, file;
|
||||
char* ptr = getenv("RA");
|
||||
if(ptr)
|
||||
AddBackslash(strcpy(rapath, ptr));
|
||||
if (ptr) AddBackslash(strcpy(rapath, ptr));
|
||||
MakePathname(file, rapath, "messages.ra");
|
||||
int fh = ::sopen(file, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
if(fh != -1) {
|
||||
|
||||
gfile fh(file, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
if (fh.isopen())
|
||||
{
|
||||
word VersionID = 0;
|
||||
read(fh, &VersionID, sizeof(word));
|
||||
if(VersionID >= 0x200)
|
||||
fh.Read(&VersionID, sizeof(word));
|
||||
if (VersionID >= 0x200)
|
||||
ra2usersbbs = 2;
|
||||
else
|
||||
ra2usersbbs = 1;
|
||||
::close(fh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,10 +173,11 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
|
||||
}
|
||||
}
|
||||
|
||||
if(__HUDSON) {
|
||||
fhuix = fhuxi = -1;
|
||||
if(ra2usersbbs == 2) {
|
||||
if(WideDebug)
|
||||
if (__HUDSON)
|
||||
{
|
||||
if (ra2usersbbs == 2)
|
||||
{
|
||||
if (WideDebug)
|
||||
WideLog->printf("- Using a RA2 format userbase.");
|
||||
user = new RA2User;
|
||||
}
|
||||
@@ -189,16 +192,20 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
|
||||
throw_new(user);
|
||||
|
||||
// Open RA2 files
|
||||
if(__HUDSON and (ra2usersbbs == 2)) {
|
||||
if (__HUDSON and (ra2usersbbs == 2))
|
||||
{
|
||||
RA2User* _user2 = (RA2User*)user;
|
||||
_user2->idxfh = fhuix = test_open("usersidx.bbs", O_CREAT);
|
||||
_user2->xifh = fhuxi = test_open("usersxi.bbs", O_CREAT);
|
||||
test_open(fhuix, "usersidx.bbs", O_CREAT);
|
||||
test_open(fhuxi, "usersxi.bbs", O_CREAT);
|
||||
_user2->idxfh = &fhuix;
|
||||
_user2->xifh = &fhuxi;
|
||||
}
|
||||
|
||||
// Find user
|
||||
const char* _username = WideUsername[0];
|
||||
if(userno == -1) {
|
||||
user->fh = fhusr;
|
||||
if (userno == -1)
|
||||
{
|
||||
user->gufh = fhusr.fh;
|
||||
user->find(_username);
|
||||
if(not user->found) {
|
||||
WideLog->printf("* User \"%s\" not found in %susers%s.", _username, path, __HUDSON ? HUDS_EXT : GOLD_EXT);
|
||||
@@ -212,9 +219,10 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
|
||||
WideLog->printf("- Using user record number %u.", userno);
|
||||
|
||||
// Close RA2 files
|
||||
if(__HUDSON and (ra2usersbbs == 2)) {
|
||||
::close(fhuix);
|
||||
::close(fhuxi);
|
||||
if (__HUDSON and (ra2usersbbs == 2))
|
||||
{
|
||||
fhuix.Close();
|
||||
fhuxi.Close();
|
||||
}
|
||||
|
||||
// Unlock and close
|
||||
@@ -237,15 +245,16 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_lastread(
|
||||
|
||||
// Update lastread record
|
||||
msgn_t _lastread = lastrec[board-1] = msgno;
|
||||
lseekset(fhlrd, userno*sizeof(HudsLast));
|
||||
write(fhlrd, lastrec, sizeof(HudsLast));
|
||||
fhlrd.LseekSet(userno*sizeof(HudsLast));
|
||||
fhlrd.Write(lastrec, sizeof(HudsLast));
|
||||
|
||||
// Update user record
|
||||
user->fh = fhusr;
|
||||
user->gufh = fhusr.fh;
|
||||
user->moveto(userno);
|
||||
if(user->lastread() < _lastread)
|
||||
if (user->lastread() < _lastread)
|
||||
user->lastread(_lastread);
|
||||
if(timesposted) {
|
||||
if (timesposted)
|
||||
{
|
||||
user->inctimesposted(timesposted);
|
||||
timesposted = 0;
|
||||
}
|
||||
|
@@ -29,17 +29,17 @@
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON>
|
||||
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::raw_close() {
|
||||
|
||||
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::raw_close()
|
||||
{
|
||||
GFTRK("HudsRawClose");
|
||||
|
||||
if(fhtxt != -1) ::close(fhtxt); fhtxt = -1;
|
||||
if(fhhdr != -1) ::close(fhhdr); fhhdr = -1;
|
||||
if(fhidx != -1) ::close(fhidx); fhidx = -1;
|
||||
if(fhinf != -1) ::close(fhinf); fhinf = -1;
|
||||
if(fhlrd != -1) ::close(fhlrd); fhlrd = -1;
|
||||
if(fhtoi != -1) ::close(fhtoi); fhtoi = -1;
|
||||
if(fhusr != -1) ::close(fhusr); fhusr = -1;
|
||||
fhtxt.Close();
|
||||
fhhdr.Close();
|
||||
fhidx.Close();
|
||||
fhinf.Close();
|
||||
fhlrd.Close();
|
||||
fhtoi.Close();
|
||||
fhusr.Close();
|
||||
|
||||
GFTRK(NULL);
|
||||
}
|
||||
@@ -48,25 +48,26 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::raw_close() {
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON>
|
||||
int _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::test_open(char* __file, int __oaccess) {
|
||||
|
||||
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::test_open(gfile &__file, char* __fname, int __oaccess)
|
||||
{
|
||||
GFTRK("HudsTestOpen");
|
||||
|
||||
int _fh;
|
||||
long _tries = 0;
|
||||
|
||||
__oaccess |= O_RDWR|O_BINARY;
|
||||
|
||||
do {
|
||||
|
||||
do
|
||||
{
|
||||
Path _testfn;
|
||||
strcpy(_testfn, AddPath(path, __file));
|
||||
strcpy(_testfn, AddPath(path, __fname));
|
||||
int _omode = (__oaccess & O_CREAT) ? S_STDRW : S_STDRD;
|
||||
_fh = ::sopen(_testfn, __oaccess, WideSharemode, _omode);
|
||||
if(_fh == -1) {
|
||||
|
||||
if(errno == ENOENT) {
|
||||
if(_tries == 0) {
|
||||
__file.Open(_testfn, __oaccess, WideSharemode, _omode);
|
||||
if (!__file.isopen())
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
if (_tries == 0)
|
||||
{
|
||||
__oaccess |= O_CREAT;
|
||||
_tries++;
|
||||
continue;
|
||||
@@ -74,12 +75,12 @@ int _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::test_open(char*
|
||||
}
|
||||
|
||||
// Request the other program to unlock
|
||||
if(errno != ENOENT)
|
||||
if (errno != ENOENT)
|
||||
TouchFile(AddPath(path, "mbunlock.now"));
|
||||
|
||||
// Tell the world
|
||||
if(PopupLocked(++_tries, false, _testfn) == false) {
|
||||
|
||||
if (PopupLocked(++_tries, false, _testfn) == false)
|
||||
{
|
||||
// User requested to exit
|
||||
WideLog->ErrOpen();
|
||||
raw_close();
|
||||
@@ -89,15 +90,14 @@ int _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::test_open(char*
|
||||
OpenErrorExit();
|
||||
}
|
||||
}
|
||||
} while(_fh == -1);
|
||||
}
|
||||
while (!__file.isopen());
|
||||
|
||||
// Remove the popup window
|
||||
if(_tries)
|
||||
if (_tries)
|
||||
PopupLocked(0, 0, NULL);
|
||||
|
||||
GFTRK(NULL);
|
||||
|
||||
return _fh;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,14 +108,15 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::raw_open(int _
|
||||
|
||||
GFTRK("HudsRawOpen");
|
||||
|
||||
fhidx = test_open(__HUDSON ? "msgidx" HUDS_EXT : "msgidx" GOLD_EXT, __oaccess);
|
||||
fhinf = test_open(__HUDSON ? "msginfo" HUDS_EXT : "msginfo" GOLD_EXT, __oaccess);
|
||||
fhlrd = test_open(__HUDSON ? "lastread" HUDS_EXT : "lastread" GOLD_EXT, __oaccess);
|
||||
fhtoi = test_open(__HUDSON ? "msgtoidx" HUDS_EXT : "msgtoidx" GOLD_EXT, __oaccess);
|
||||
if(__all) {
|
||||
fhhdr = test_open(__HUDSON ? "msghdr" HUDS_EXT : "msghdr" GOLD_EXT, __oaccess);
|
||||
fhtxt = test_open(__HUDSON ? "msgtxt" HUDS_EXT : "msgtxt" GOLD_EXT, __oaccess);
|
||||
fhusr = test_open(__HUDSON ? "users" HUDS_EXT : "users" GOLD_EXT, __oaccess);
|
||||
test_open(fhidx, __HUDSON ? "msgidx" HUDS_EXT : "msgidx" GOLD_EXT, __oaccess);
|
||||
test_open(fhinf, __HUDSON ? "msginfo" HUDS_EXT : "msginfo" GOLD_EXT, __oaccess);
|
||||
test_open(fhlrd, __HUDSON ? "lastread" HUDS_EXT : "lastread" GOLD_EXT, __oaccess);
|
||||
test_open(fhtoi, __HUDSON ? "msgtoidx" HUDS_EXT : "msgtoidx" GOLD_EXT, __oaccess);
|
||||
if (__all)
|
||||
{
|
||||
test_open(fhhdr, __HUDSON ? "msghdr" HUDS_EXT : "msghdr" GOLD_EXT, __oaccess);
|
||||
test_open(fhtxt, __HUDSON ? "msgtxt" HUDS_EXT : "msgtxt" GOLD_EXT, __oaccess);
|
||||
test_open(fhusr, __HUDSON ? "users" HUDS_EXT : "users" GOLD_EXT, __oaccess);
|
||||
}
|
||||
|
||||
GFTRK(NULL);
|
||||
@@ -143,20 +144,20 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::refresh() {
|
||||
GFTRK("HudsRefresh");
|
||||
|
||||
// (Re)Allocate memory to hold the complete MSGIDX.BBS/DAT
|
||||
msgidxsize = filelength(fhidx);
|
||||
msgidxsize = fhidx.FileLength();
|
||||
msgidxptr = (HudsIdx*)throw_realloc(msgidxptr, (uint)(msgidxsize+sizeof(HudsIdx)));
|
||||
|
||||
// Load MSGIDX.BBS/DAT
|
||||
lseek(fhidx, 0, SEEK_SET);
|
||||
read(fhidx, msgidxptr, (uint)msgidxsize);
|
||||
fhidx.LseekSet(0);
|
||||
fhidx.Read(msgidxptr, (uint)msgidxsize);
|
||||
|
||||
// Load MSGINFO.BBS/DAT
|
||||
lseek(fhinf, 0, SEEK_SET);
|
||||
read(fhinf, &msginfo, sizeof(HudsInfo));
|
||||
fhinf.LseekSet(0);
|
||||
fhinf.Read(&msginfo, sizeof(HudsInfo));
|
||||
|
||||
// Load LASTREAD.BBS/DAT
|
||||
lseek(fhlrd, userno*sizeof(HudsLast), SEEK_SET);
|
||||
read(fhlrd, lastrec, sizeof(HudsLast));
|
||||
fhlrd.LseekSet(userno*sizeof(HudsLast));
|
||||
fhlrd.Read(lastrec, sizeof(HudsLast));
|
||||
|
||||
GFTRK(NULL);
|
||||
}
|
||||
@@ -211,8 +212,8 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::lock() {
|
||||
long _tries = 0;
|
||||
|
||||
// Try to get the lock
|
||||
while(::lock(fhinf, sizeof(HudsInfo)+1, 1) == -1) {
|
||||
|
||||
while (fhinf.Lock(sizeof(HudsInfo)+1, 1) == -1)
|
||||
{
|
||||
// Tell the world
|
||||
if(PopupLocked(++_tries, true, AddPath(path, __HUDSON ? "msginfo" HUDS_EXT : "msginfo" GOLD_EXT)) == false) {
|
||||
|
||||
@@ -251,8 +252,9 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::unlock() {
|
||||
|
||||
GFTRK("HudsUnlock");
|
||||
|
||||
if(islocked and WideCanLock) {
|
||||
::unlock(fhinf, sizeof(HudsInfo)+1, 1);
|
||||
if (islocked and WideCanLock)
|
||||
{
|
||||
fhinf.Unlock(sizeof(HudsInfo)+1, 1);
|
||||
islocked = false;
|
||||
}
|
||||
|
||||
@@ -578,7 +580,7 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::scan_pm() {
|
||||
ispmscanned = true;
|
||||
|
||||
HudsToIdx* toidxbuf = (HudsToIdx*)throw_calloc(TOIDXBUFSZ, sizeof(HudsToIdx));
|
||||
uint totrecs = (uint)(filelength(fhtoi) / sizeof(HudsToIdx));
|
||||
uint totrecs = (uint)(fhtoi.FileLength() / sizeof(HudsToIdx));
|
||||
HudsIdx* idxptr = msgidxptr;
|
||||
throw_release(pmscan);
|
||||
pmscantotal = 0;
|
||||
@@ -592,7 +594,7 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::scan_pm() {
|
||||
rec = 0;
|
||||
gotpm = false;
|
||||
getrecs = MinV(TOIDXBUFSZ, totrecs);
|
||||
read(fhtoi, toidxbuf, getrecs*sizeof(HudsToIdx));
|
||||
fhtoi.Read(toidxbuf, getrecs*sizeof(HudsToIdx));
|
||||
|
||||
for(toidx=toidxbuf; rec<getrecs; idxptr++,toidx++,rec++) {
|
||||
|
||||
|
@@ -97,8 +97,8 @@ int _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::load_message(in
|
||||
|
||||
// Read header
|
||||
msgn_t _hdridx = get_hdr_idx(__msg, __FILE__, __LINE__);
|
||||
lseek(wide->fhhdr, (int32_t)_hdridx*(int32_t)sizeof(HudsHdr), SEEK_SET);
|
||||
read(wide->fhhdr, &__hdr, sizeof(HudsHdr));
|
||||
wide->fhhdr.LseekSet((int32_t)_hdridx*(int32_t)sizeof(HudsHdr));
|
||||
wide->fhhdr.Read(&__hdr, sizeof(HudsHdr));
|
||||
|
||||
__msg->msgno = __hdr.msgno;
|
||||
__msg->link.to_set(__hdr.replyto);
|
||||
@@ -174,8 +174,8 @@ int _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::load_message(in
|
||||
if(_numrecs) {
|
||||
|
||||
// Seek to, and read the raw text
|
||||
lseek(wide->fhtxt, (int32_t)__hdr.startrec*256L, SEEK_SET);
|
||||
read(wide->fhtxt, __msg->txt, _numrecs*256);
|
||||
wide->fhtxt.LseekSet((int32_t)__hdr.startrec*256L);
|
||||
wide->fhtxt.Read(__msg->txt, _numrecs*256);
|
||||
|
||||
// Set up loop variables
|
||||
char* _src = __msg->txt;
|
||||
|
@@ -29,25 +29,27 @@
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON>
|
||||
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::update_netecho(char* __name, msgn_t __hdridx, int __delete) {
|
||||
|
||||
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::update_netecho(char* __name, msgn_t __hdridx, int __delete)
|
||||
{
|
||||
GFTRK("HudsUpdateNetEcho");
|
||||
|
||||
Path name;
|
||||
strcpy(name, AddPath(syspath, __name));
|
||||
int _fh = test_open(name, O_CREAT);
|
||||
|
||||
gfile _fh;
|
||||
test_open(_fh, name, O_CREAT);
|
||||
|
||||
// Get size of the file
|
||||
uint _total = (uint)(filelength(_fh)/sizeof(msgn_t));
|
||||
uint _total = (uint)(_fh.FileLength()/sizeof(msgn_t));
|
||||
|
||||
// Allocate memory for the scanning index
|
||||
msgn_t* _scanidx = (msgn_t*)throw_calloc(_total+5, sizeof(msgn_t));
|
||||
|
||||
// Read the scanning index
|
||||
read(_fh, _scanidx, _total*sizeof(msgn_t));
|
||||
_fh.Read(_scanidx, _total*sizeof(msgn_t));
|
||||
|
||||
// Close the file
|
||||
::close(_fh);
|
||||
_fh.Close();
|
||||
|
||||
// Search for the specified header index
|
||||
uint _pos = 0;
|
||||
@@ -85,10 +87,11 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::update_netecho
|
||||
}
|
||||
|
||||
// Write the changed scanning file from scratch
|
||||
if(_total) {
|
||||
_fh = test_open(__name, O_CREAT|O_TRUNC);
|
||||
write(_fh, _scanidx, _total*sizeof(msgn_t));
|
||||
::close(_fh);
|
||||
if (_total)
|
||||
{
|
||||
test_open(_fh, __name, O_CREAT|O_TRUNC);
|
||||
_fh.Write(_scanidx, _total*sizeof(msgn_t));
|
||||
_fh.Close();
|
||||
}
|
||||
else {
|
||||
// If the last header index was removed, delete the file
|
||||
@@ -114,9 +117,10 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
|
||||
|
||||
// Find header index
|
||||
msgn_t _hdridx;
|
||||
if(__mode & GMSG_NEW) {
|
||||
if (__mode & GMSG_NEW)
|
||||
{
|
||||
__msg->msgno = wide->msginfo.high + 1;
|
||||
_hdridx = (msgn_t)(filelength(wide->fhhdr)/sizeof(HudsHdr));
|
||||
_hdridx = (msgn_t)(wide->fhhdr.FileLength()/sizeof(HudsHdr));
|
||||
}
|
||||
else {
|
||||
_hdridx = get_hdr_idx(__msg, __FILE__, __LINE__);
|
||||
@@ -182,7 +186,7 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
|
||||
// If the msg is new or the text is too large to fit
|
||||
uint _txtlen = strlen(__msg->txt)+1;
|
||||
if((__mode & GMSG_NEW) or (_txtlen > __msg->txtlength*255L))
|
||||
__hdr.startrec = (msgn_t)(filelength(wide->fhtxt)/256L);
|
||||
__hdr.startrec = (msgn_t)(wide->fhtxt.FileLength()/256L);
|
||||
|
||||
// Calculate the number of text records to write
|
||||
register uint _fullrecs = _txtlen / 255;
|
||||
@@ -190,7 +194,7 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
|
||||
__hdr.numrecs = (word)(_fullrecs + (_extrarec ? 1 : 0));
|
||||
|
||||
// Seek to the text write position
|
||||
lseek(wide->fhtxt, __hdr.startrec*256L, SEEK_SET);
|
||||
wide->fhtxt.LseekSet(__hdr.startrec*256L);
|
||||
|
||||
// Write the message text
|
||||
register uint _count = 0;
|
||||
@@ -198,23 +202,25 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
|
||||
char _txtbuf[256];
|
||||
char* _txtptr = _txtbuf + 1;
|
||||
*_txtbuf = 255;
|
||||
while(_count < _fullrecs) {
|
||||
while (_count < _fullrecs)
|
||||
{
|
||||
memcpy(_txtptr, _txt, 255);
|
||||
write(wide->fhtxt, _txtbuf, 256);
|
||||
wide->fhtxt.Write(_txtbuf, 256);
|
||||
_txt += 255;
|
||||
_count++;
|
||||
}
|
||||
if(_extrarec) {
|
||||
if (_extrarec)
|
||||
{
|
||||
*_txtbuf = _extrarec;
|
||||
memset(_txtptr, 0, 255);
|
||||
memcpy(_txtptr, _txt, _extrarec);
|
||||
write(wide->fhtxt, _txtbuf, 256);
|
||||
wide->fhtxt.Write(_txtbuf, 256);
|
||||
}
|
||||
}
|
||||
|
||||
// Write to MSGHDR.BBS/DAT
|
||||
lseek(wide->fhhdr, _hdridx*sizeof(HudsHdr), SEEK_SET);
|
||||
write(wide->fhhdr, &__hdr, sizeof(HudsHdr));
|
||||
wide->fhhdr.LseekSet(_hdridx*sizeof(HudsHdr));
|
||||
wide->fhhdr.Write(&__hdr, sizeof(HudsHdr));
|
||||
|
||||
// Write to MSGIDX.BBS/DAT
|
||||
if(__mode & GMSG_NEW) {
|
||||
@@ -224,17 +230,17 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
|
||||
HudsIdx* _idxp = wide->msgidxptr + (uint)_hdridx;
|
||||
_idxp->board = __hdr.board;
|
||||
_idxp->msgno = (msgn_t)((__mode & GMSG_DELETE) ? (__HUDSON ? HUDS_DELETEDMSGNO : GOLD_DELETEDMSGNO) : __hdr.msgno);
|
||||
lseek(wide->fhidx, _hdridx*sizeof(HudsIdx), SEEK_SET);
|
||||
write(wide->fhidx, _idxp, sizeof(HudsIdx));
|
||||
wide->fhidx.LseekSet(_hdridx*sizeof(HudsIdx));
|
||||
wide->fhidx.Write(_idxp, sizeof(HudsIdx));
|
||||
|
||||
// Write to MSGTOIDX.BBS/DAT
|
||||
lseek(wide->fhtoi, _hdridx*sizeof(HudsToIdx), SEEK_SET);
|
||||
if(__mode & GMSG_DELETE)
|
||||
write(wide->fhtoi, "\xB* Deleted *\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(HudsToIdx));
|
||||
wide->fhtoi.LseekSet(_hdridx*sizeof(HudsToIdx));
|
||||
if (__mode & GMSG_DELETE)
|
||||
wide->fhtoi.Write("\xB* Deleted *\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(HudsToIdx));
|
||||
else if(__hdr.msgattr & HUDS_RECEIVED)
|
||||
write(wide->fhtoi, "\xC* Received *\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(HudsToIdx));
|
||||
wide->fhtoi.Write("\xC* Received *\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(HudsToIdx));
|
||||
else
|
||||
write(wide->fhtoi, __hdr.to, sizeof(HudsToIdx));
|
||||
wide->fhtoi.Write(__hdr.to, sizeof(HudsToIdx));
|
||||
|
||||
// Write to MSGINFO.BBS/DAT
|
||||
if(__mode & GMSG_DELETE) {
|
||||
@@ -272,8 +278,8 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
|
||||
if(__hdr.msgno > wide->msginfo.high)
|
||||
wide->msginfo.high = __hdr.msgno;
|
||||
}
|
||||
lseek(wide->fhinf, 0, SEEK_SET);
|
||||
write(wide->fhinf, &wide->msginfo, sizeof(HudsInfo));
|
||||
wide->fhinf.LseekSet(0);
|
||||
wide->fhinf.Write(&wide->msginfo, sizeof(HudsInfo));
|
||||
|
||||
// Update scanning files
|
||||
if((__hdr.msgattr & HUDS_NETTRANS) or (__mode & GMSG_DELETE))
|
||||
@@ -357,15 +363,15 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::update_timesre
|
||||
lock();
|
||||
|
||||
msgn_t hdridx = get_hdr_idx(msg, __FILE__, __LINE__);
|
||||
::lseekset(wide->fhhdr, hdridx*sizeof(HudsHdr));
|
||||
wide->fhhdr.LseekSet(hdridx*sizeof(HudsHdr));
|
||||
|
||||
HudsHdr hdr;
|
||||
::read(wide->fhhdr, &hdr, sizeof(HudsHdr));
|
||||
wide->fhhdr.Read(&hdr, sizeof(HudsHdr));
|
||||
|
||||
hdr.timesread = (word)msg->timesread;
|
||||
|
||||
::lseekset(wide->fhhdr, hdridx*sizeof(HudsHdr));
|
||||
::write(wide->fhhdr, &hdr, sizeof(HudsHdr));
|
||||
wide->fhhdr.LseekSet(hdridx*sizeof(HudsHdr));
|
||||
wide->fhhdr.Write(&hdr, sizeof(HudsHdr));
|
||||
|
||||
unlock();
|
||||
|
||||
|
@@ -29,9 +29,9 @@
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON>
|
||||
char* _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::user_lookup(char* __lookfor) {
|
||||
|
||||
wide->user->fh = wide->fhusr;
|
||||
char* _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::user_lookup(char* __lookfor)
|
||||
{
|
||||
wide->user->gufh = wide->fhusr.fh;
|
||||
wide->user->findwild(__lookfor, __lookfor);
|
||||
|
||||
if(wide->user->found)
|
||||
|
@@ -132,8 +132,9 @@ void PcbInit(const char* path, int userno) {
|
||||
fp.Fclose();
|
||||
|
||||
const char* _username = WideUsername[0];
|
||||
pcbwide->user->fh = ::sopen(AddPath(_path, pcbwide->users), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
if(pcbwide->user->fh != -1) {
|
||||
pcbwide->user->gufh = ::sopen(AddPath(_path, pcbwide->users), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
if (pcbwide->user->gufh != -1)
|
||||
{
|
||||
pcbwide->user->fhinf = ::sopen(AddPath(_path, pcbwide->usersinf), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
if(pcbwide->user->fhinf != -1) {
|
||||
::read(pcbwide->user->fhinf, &pcbwide->usershdr, sizeof(PcbUsersInfHdr));
|
||||
@@ -151,7 +152,7 @@ void PcbInit(const char* path, int userno) {
|
||||
}
|
||||
close(pcbwide->user->fhinf);
|
||||
}
|
||||
close(pcbwide->user->fh);
|
||||
close(pcbwide->user->gufh);
|
||||
}
|
||||
pcbwide->userno = pcbwide->user->index;
|
||||
}
|
||||
|
@@ -101,7 +101,7 @@ void PcbWideOpen() {
|
||||
|
||||
pcbwide->fhusr = PcbWideTestOpen(pcbwide->users);
|
||||
pcbwide->fhinf = PcbWideTestOpen(pcbwide->usersinf);
|
||||
pcbwide->user->fh = pcbwide->fhusr;
|
||||
pcbwide->user->gufh = pcbwide->fhusr;
|
||||
pcbwide->user->fhinf = pcbwide->fhinf;
|
||||
|
||||
// Read lastreads from USERS file
|
||||
|
@@ -89,16 +89,18 @@ void SquishInit(const char* userpath, int userno, int direct, int recycle, int s
|
||||
Path userfile;
|
||||
strxcpy(userfile, AddPath(userpath, "USER.BBS"), sizeof(Path));
|
||||
const char* _username = WideUsername[0];
|
||||
if(squishwide->userno == -1) {
|
||||
squishwide->user->fh = ::sopen(userfile, O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
|
||||
if(squishwide->user->fh != -1) {
|
||||
if (squishwide->userno == -1)
|
||||
{
|
||||
squishwide->user->gufh = ::sopen(userfile, O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
|
||||
if (squishwide->user->gufh != -1)
|
||||
{
|
||||
squishwide->user->find(_username);
|
||||
if(not squishwide->user->found) {
|
||||
WideLog->printf("* User \"%s\" not found in %s.", _username, userfile);
|
||||
squishwide->user->add(_username);
|
||||
WideLog->printf("* Now added with user number %u.", squishwide->user->index);
|
||||
}
|
||||
close(squishwide->user->fh);
|
||||
close(squishwide->user->gufh);
|
||||
}
|
||||
squishwide->userno = squishwide->user->index;
|
||||
}
|
||||
|
@@ -33,13 +33,13 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
char* SquishArea::user_lookup(char* __lookfor) {
|
||||
|
||||
char* SquishArea::user_lookup(char* __lookfor)
|
||||
{
|
||||
Path userfile;
|
||||
strxcpy(userfile, AddPath(wide->userpath, "USER.BBS"), sizeof(Path));
|
||||
wide->user->fh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
wide->user->gufh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
wide->user->findwild(__lookfor, __lookfor);
|
||||
::close(wide->user->fh);
|
||||
::close(wide->user->gufh);
|
||||
|
||||
if(wide->user->found)
|
||||
return __lookfor;
|
||||
|
@@ -64,11 +64,14 @@ void XbbsArea::raw_close() {
|
||||
if(data->fhindex != -1) ::close(data->fhindex); data->fhindex = -1;
|
||||
if(data->fhtext != -1) ::close(data->fhtext); data->fhtext = -1;
|
||||
|
||||
if(wide->isopen) {
|
||||
if(wide->isopen == 1) {
|
||||
if(wide->user->fh != -1) {
|
||||
::close(wide->user->fh);
|
||||
wide->user->fh= -1;
|
||||
if (wide->isopen)
|
||||
{
|
||||
if (wide->isopen == 1)
|
||||
{
|
||||
if (wide->user->gufh != -1)
|
||||
{
|
||||
::close(wide->user->gufh);
|
||||
wide->user->gufh = -1;
|
||||
}
|
||||
}
|
||||
wide->isopen--;
|
||||
@@ -128,8 +131,8 @@ void XbbsArea::raw_open() {
|
||||
data->fhindex = test_open(AddPath(real_path(), ".Index"));
|
||||
data->fhtext = test_open(AddPath(real_path(), ".Text"));
|
||||
wide->isopen++;
|
||||
if(wide->isopen == 1)
|
||||
wide->user->fh = ::sopen(AddPath(wide->path, "Users"), O_RDONLY|O_BINARY, WideSharemode, S_STDRW);
|
||||
if (wide->isopen == 1)
|
||||
wide->user->gufh = ::sopen(AddPath(wide->path, "Users"), O_RDONLY|O_BINARY, WideSharemode, S_STDRW);
|
||||
|
||||
GFTRK(NULL);
|
||||
}
|
||||
@@ -159,15 +162,17 @@ void XbbsInit(const char* path, int userno) {
|
||||
xbbswide->user = new XbbsUser;
|
||||
throw_new(xbbswide->user);
|
||||
|
||||
xbbswide->user->fh = -1;
|
||||
xbbswide->user->gufh = -1;
|
||||
xbbswide->fhpmi = -1;
|
||||
xbbswide->pmi = NULL;
|
||||
xbbswide->isopen = 0;
|
||||
|
||||
const char* _username = WideUsername[0];
|
||||
if(xbbswide->userno == -1) {
|
||||
xbbswide->user->fh = ::sopen(AddPath(xbbswide->path, "Users"), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
if(xbbswide->user->fh != -1) {
|
||||
if (xbbswide->userno == -1)
|
||||
{
|
||||
xbbswide->user->gufh = ::sopen(AddPath(xbbswide->path, "Users"), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
|
||||
if (xbbswide->user->gufh != -1)
|
||||
{
|
||||
xbbswide->user->find(_username);
|
||||
if(not xbbswide->user->found) {
|
||||
xbbswide->userno = 0;
|
||||
@@ -175,7 +180,7 @@ void XbbsInit(const char* path, int userno) {
|
||||
//xbbswide->user->add(_username);
|
||||
//WideLog->printf("* Now added with user number %u.", xbbswide->user->index);
|
||||
}
|
||||
close(xbbswide->user->fh);
|
||||
close(xbbswide->user->gufh);
|
||||
}
|
||||
xbbswide->userno = xbbswide->user->index;
|
||||
}
|
||||
|
@@ -31,12 +31,13 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
char* XbbsArea::user_lookup(char* __lookfor) {
|
||||
|
||||
wide->user->fh = ::sopen(AddPath(wide->path, "Users"), O_RDWR|O_BINARY, WideSharemode, S_STDRD);
|
||||
if(wide->user->fh) {
|
||||
char* XbbsArea::user_lookup(char* __lookfor)
|
||||
{
|
||||
wide->user->gufh = ::sopen(AddPath(wide->path, "Users"), O_RDWR|O_BINARY, WideSharemode, S_STDRD);
|
||||
if (wide->user->gufh)
|
||||
{
|
||||
wide->user->findwild(__lookfor, __lookfor);
|
||||
::close(wide->user->fh);
|
||||
::close(wide->user->gufh);
|
||||
}
|
||||
|
||||
if(wide->user->found)
|
||||
|
Reference in New Issue
Block a user