// record is useless and should be removed.)
//
int PurgeVisits(void) {
- struct cdbdata cdbvisit;
+ struct cdbkeyval cdbvisit;
struct visit vbuf;
struct VPurgeList *VisitPurgeList = NULL;
struct VPurgeList *vptr;
// Now traverse through the visits, purging irrelevant records...
cdb_rewind(CDB_VISIT);
- while(cdbvisit = cdb_next_item(CDB_VISIT), cdbvisit.ptr!=NULL) {
+ while(cdbvisit = cdb_next_item(CDB_VISIT), cdbvisit.val.ptr!=NULL) {
memset(&vbuf, 0, sizeof(struct visit));
- memcpy(&vbuf, cdbvisit.ptr,
- ( (cdbvisit.len > sizeof(struct visit)) ?
- sizeof(struct visit) : cdbvisit.len) );
-
+ memcpy(&vbuf, cdbvisit.val.ptr, ((cdbvisit.val.len > sizeof(struct visit)) ? sizeof(struct visit) : cdbvisit.val.len));
RoomIsValid = 0;
UserIsValid = 0;
// Check to see if the room exists
for (vrptr=ValidRoomList; vrptr!=NULL; vrptr=vrptr->next) {
- if ( (vrptr->vr_roomnum==vbuf.v_roomnum)
- && (vrptr->vr_roomgen==vbuf.v_roomgen))
+ if ( (vrptr->vr_roomnum==vbuf.v_roomnum) && (vrptr->vr_roomgen==vbuf.v_roomgen)) {
RoomIsValid = 1;
+ }
}
// Check to see if the user exists
for (vuptr=ValidUserList; vuptr!=NULL; vuptr=vuptr->next) {
- if (vuptr->vu_usernum == vbuf.v_usernum)
+ if (vuptr->vu_usernum == vbuf.v_usernum) {
UserIsValid = 1;
+ }
}
// Put the record on the purge list if it's dead
if ((RoomIsValid==0) || (UserIsValid==0)) {
- vptr = (struct VPurgeList *)
- malloc(sizeof(struct VPurgeList));
+ vptr = (struct VPurgeList *) malloc(sizeof(struct VPurgeList));
vptr->next = VisitPurgeList;
vptr->vp_roomnum = vbuf.v_roomnum;
vptr->vp_roomgen = vbuf.v_roomgen;
int PurgeUseTable(StrBuf *ErrMsg) {
int purged = 0;
int total = 0;
- struct cdbdata cdbut;
+ struct cdbkeyval cdbut;
struct UseTable ut;
Array *purge_list = array_new(sizeof(int));
syslog(LOG_DEBUG, "Purge use table: phase 1");
cdb_rewind(CDB_USETABLE);
- while(cdbut = cdb_next_item(CDB_USETABLE), cdbut.ptr!=NULL) {
+ while(cdbut = cdb_next_item(CDB_USETABLE), cdbut.val.ptr!=NULL) {
++total;
- if (cdbut.len > sizeof(struct UseTable))
- memcpy(&ut, cdbut.ptr, sizeof(struct UseTable));
+ if (cdbut.val.len > sizeof(struct UseTable))
+ memcpy(&ut, cdbut.val.ptr, sizeof(struct UseTable));
else {
memset(&ut, 0, sizeof(struct UseTable));
- memcpy(&ut, cdbut.ptr, cdbut.len);
+ memcpy(&ut, cdbut.val.ptr, cdbut.val.len);
}
if ( (time(NULL) - ut.timestamp) > USETABLE_RETAIN ) {
// Purge the EUID Index of old records.
int PurgeEuidIndexTable(void) {
int purged = 0;
- struct cdbdata cdbei;
+ struct cdbkeyval cdbei;
struct EPurgeList *el = NULL;
struct EPurgeList *eptr;
long msgnum;
// Phase 1: traverse through the table, discovering old records...
syslog(LOG_DEBUG, "Purge EUID index: phase 1");
cdb_rewind(CDB_EUIDINDEX);
- while(cdbei = cdb_next_item(CDB_EUIDINDEX), cdbei.ptr!=NULL) {
+ while(cdbei = cdb_next_item(CDB_EUIDINDEX), cdbei.val.ptr!=NULL) {
- memcpy(&msgnum, cdbei.ptr, sizeof(long));
+ memcpy(&msgnum, cdbei.val.ptr, sizeof(long));
msg = CtdlFetchMessage(msgnum, 0);
if (msg != NULL) {
eptr = (struct EPurgeList *) malloc(sizeof(struct EPurgeList));
if (eptr != NULL) {
eptr->next = el;
- eptr->ep_keylen = cdbei.len - sizeof(long);
- eptr->ep_key = malloc(cdbei.len);
- memcpy(eptr->ep_key, &cdbei.ptr[sizeof(long)], eptr->ep_keylen);
+ eptr->ep_keylen = cdbei.val.len - sizeof(long);
+ eptr->ep_key = malloc(cdbei.val.len);
+ memcpy(eptr->ep_key, &cdbei.val.ptr[sizeof(long)], eptr->ep_keylen);
el = eptr;
}
++purged;