]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/modules/expire/serv_expire.c
cdb_next_item() now returns both key and value
[citadel.git] / citadel / server / modules / expire / serv_expire.c
index 20ac197ddd9c4a33fc712256eab4235d0a694c85..876edc9fa4c8b167ee1960be256ce246a2d2e390 100644 (file)
@@ -486,7 +486,7 @@ int PurgeUsers(void) {
 // 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;
@@ -505,32 +505,29 @@ int PurgeVisits(void) {
 
        // 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;
@@ -576,7 +573,7 @@ int PurgeVisits(void) {
 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));
 
@@ -584,13 +581,13 @@ int PurgeUseTable(StrBuf *ErrMsg) {
 
        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 ) {
@@ -616,7 +613,7 @@ int PurgeUseTable(StrBuf *ErrMsg) {
 // 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;
@@ -625,9 +622,9 @@ int PurgeEuidIndexTable(void) {
        // 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) {
@@ -637,9 +634,9 @@ int PurgeEuidIndexTable(void) {
                        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;