Fix GoldED style LastRead records
This commit is contained in:
parent
9b545491ca
commit
b7aaed6491
@ -25,6 +25,9 @@ v0.91.10 21-Aug-2007
|
|||||||
disk i/o.
|
disk i/o.
|
||||||
LastRead records that don't belong to a valid user are
|
LastRead records that don't belong to a valid user are
|
||||||
purged.
|
purged.
|
||||||
|
LastRead pointers are searched via an alternate method if the
|
||||||
|
record is created by GoldED.
|
||||||
|
Don't purge GoldED style LastRead records but fix them.
|
||||||
|
|
||||||
mbcico:
|
mbcico:
|
||||||
Fixed a lot of compiler warnings.
|
Fixed a lot of compiler warnings.
|
||||||
|
57
lib/jammsg.c
57
lib/jammsg.c
@ -386,7 +386,20 @@ int JAM_GetLastRead(lastread *LR)
|
|||||||
lseek(fdJlr, 0, SEEK_SET);
|
lseek(fdJlr, 0, SEEK_SET);
|
||||||
|
|
||||||
while (read(fdJlr, &lr, sizeof(lastread)) == sizeof(lastread)) {
|
while (read(fdJlr, &lr, sizeof(lastread)) == sizeof(lastread)) {
|
||||||
if (lr.UserID == LR->UserID) {
|
/*
|
||||||
|
* Check for GoldED bug, the CRC == ID so the ID is invalid.
|
||||||
|
* Test for a valid CRC to find the right record.
|
||||||
|
*/
|
||||||
|
if ((lr.UserID == lr.UserCRC) && (lr.UserCRC == LR->UserCRC)) {
|
||||||
|
Syslog('m', "Found LR record for user %d using a workaround", LR->UserID);
|
||||||
|
LR->LastReadMsg = lr.LastReadMsg;
|
||||||
|
LR->HighReadMsg = lr.HighReadMsg;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* The way it should be.
|
||||||
|
*/
|
||||||
|
if ((lr.UserID != lr.UserCRC) && (lr.UserID == LR->UserID)) {
|
||||||
LR->LastReadMsg = lr.LastReadMsg;
|
LR->LastReadMsg = lr.LastReadMsg;
|
||||||
LR->HighReadMsg = lr.HighReadMsg;
|
LR->HighReadMsg = lr.HighReadMsg;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -636,7 +649,7 @@ void JAM_Pack(void)
|
|||||||
int ToRead, Readed, i, count;
|
int ToRead, Readed, i, count;
|
||||||
char *File, *New, *Subfield, *Temp;
|
char *File, *New, *Subfield, *Temp;
|
||||||
JAMIDXREC jamIdx;
|
JAMIDXREC jamIdx;
|
||||||
unsigned int NewNumber = 0, RefNumber = 0, Written = 0, mycrc;
|
unsigned int NewNumber = 0, RefNumber = 0, Written = 0, mycrc, myrec;
|
||||||
lastread LR;
|
lastread LR;
|
||||||
FILE *usrF;
|
FILE *usrF;
|
||||||
struct userhdr usrhdr;
|
struct userhdr usrhdr;
|
||||||
@ -784,21 +797,37 @@ void JAM_Pack(void)
|
|||||||
Syslog('m', "JAM_Pack %s recno %d user %d HighRead is reset to %d", BaseName, i, LR.UserID, LR.HighReadMsg);
|
Syslog('m', "JAM_Pack %s recno %d user %d HighRead is reset to %d", BaseName, i, LR.UserID, LR.HighReadMsg);
|
||||||
}
|
}
|
||||||
if (usrF) {
|
if (usrF) {
|
||||||
/*
|
if ((LR.UserID == LR.UserCRC) && LR.UserCRC) {
|
||||||
* Search user record for LR pointer. If the record is valid and the
|
/*
|
||||||
* user still exists then copy the LR record, else we drop it.
|
* GoldED bug, try to fix it. This might leave double records, we
|
||||||
*/
|
* will deal with that later. TODO: write that code!
|
||||||
fseek(usrF, usrhdr.hdrsize + (usrhdr.recsize * LR.UserID), SEEK_SET);
|
*/
|
||||||
memset(&usr, 0, sizeof(usr));
|
fseek(usrF, usrhdr.hdrsize, SEEK_SET);
|
||||||
if (fread(&usr, usrhdr.recsize, 1, usrF) == 1) {
|
myrec = 0;
|
||||||
mycrc = StringCRC32(tl(usr.sUserName));
|
while (fread(&usr, usrhdr.recsize, 1, usrF) == 1) {
|
||||||
if (mycrc == LR.UserCRC) {
|
mycrc = StringCRC32(tl(usr.sUserName));
|
||||||
write(fdnJlr, &LR, sizeof(lastread));
|
if (LR.UserCRC == mycrc) {
|
||||||
|
LR.UserID = myrec;
|
||||||
|
Syslog('m', "JAM_Pack %s recno %d LastRead UserID set to %d", BaseName, i, myrec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Search user record for LR pointer. If the record is valid and the
|
||||||
|
* user still exists then copy the LR record, else we drop it.
|
||||||
|
*/
|
||||||
|
fseek(usrF, usrhdr.hdrsize + (usrhdr.recsize * LR.UserID), SEEK_SET);
|
||||||
|
memset(&usr, 0, sizeof(usr));
|
||||||
|
if (fread(&usr, usrhdr.recsize, 1, usrF) == 1) {
|
||||||
|
mycrc = StringCRC32(tl(usr.sUserName));
|
||||||
|
if (mycrc == LR.UserCRC) {
|
||||||
|
write(fdnJlr, &LR, sizeof(lastread));
|
||||||
|
} else {
|
||||||
|
Syslog('-', "JAM_Pack %s purged LR record %d", BaseName, i);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Syslog('-', "JAM_Pack %s purged LR record %d", BaseName, i);
|
Syslog('-', "JAM_Pack %s purged LR record %d", BaseName, i);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Syslog('-', "JAM_Pack %s purged LR record %d", BaseName, i);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user