Removed all references to CC->msglist and CC->num_msgs, and all utility
authorArt Cancro <ajc@citadel.org>
Tue, 27 Jul 1999 20:00:24 +0000 (20:00 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 27 Jul 1999 20:00:24 +0000 (20:00 +0000)
functions which relied upon them.  Citadel Is Now Better.

citadel/ChangeLog
citadel/citserver.c
citadel/room_ops.c
citadel/room_ops.h
citadel/serv_expire.c
citadel/server.h
citadel/user_ops.c

index ece60004c8c2737057925d762bf456b5ec492aee..6ab1bc45c70685cde9dc183377e3c725b1149cf7 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 1.333  1999/07/27 20:00:24  ajc
+Removed all references to CC->msglist and CC->num_msgs, and all utility
+functions which relied upon them.  Citadel Is Now Better.
+
 Revision 1.332  1999/07/27 19:32:22  ajc
 Removed serv_upgrade.c and all references to it in Makefile.in
 Reworked new-mail-count to not use MessageFromList() etc.
@@ -1118,6 +1122,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import
-
-
index 45d23b95e9f5c879bd8b6ee8debcb1a97d6182f6..e0785b680bb729f946f4ec316d73ccb299ee3b45 100644 (file)
@@ -140,9 +140,6 @@ void cleanup_stuff(void *arg)
 
        syslog(LOG_NOTICE,"session %d ended", CC->cs_pid);
        
-       /* Deallocate any message list we might have in memory */
-       if (CC->msglist != NULL) phree(CC->msglist);
-
        /* Deallocate any user-data attached to this session */
        deallocate_user_data(CC);
 
@@ -821,8 +818,6 @@ void *context_loop(struct CitContext *con)
        CC->upload_fp = NULL;
        CC->cs_pid = con->client_socket;        /* not necessarily portable */
        CC->FirstExpressMessage = NULL;
-       CC->msglist = NULL;
-       CC->num_msgs = 0;
        time(&CC->lastcmd);
        time(&CC->lastidle);
        strcpy(CC->lastcmdname, "    ");
index f208849deafe62c8ce16beea5fd0d954c39ef4f7..bc93a1314e0e41153ee70adeac8a73c4b4fb1120 100644 (file)
@@ -314,43 +314,6 @@ void ForEachRoom(void (*CallBack) (struct quickroom * EachRoom))
 }
 
 
-
-/*
- * get_msglist()  -  retrieve room message pointers
- */
-void get_msglist(struct quickroom *whichroom)
-{
-       struct cdbdata *cdbfr;
-
-       if (CC->msglist != NULL) {
-               phree(CC->msglist);
-       }
-       CC->msglist = NULL;
-       CC->num_msgs = 0;
-
-       cdbfr = cdb_fetch(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
-       if (cdbfr == NULL) {
-               return;
-       }
-       CC->msglist = mallok(cdbfr->len);
-       memcpy(CC->msglist, cdbfr->ptr, cdbfr->len);
-       CC->num_msgs = cdbfr->len / sizeof(long);
-       cdb_free(cdbfr);
-}
-
-
-/*
- * put_msglist()  -  retrieve room message pointers
- */
-void put_msglist(struct quickroom *whichroom)
-{
-
-       if (CC->msglist != NULL)
-               cdb_store(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long),
-                         CC->msglist, CC->num_msgs * sizeof(long));
-}
-
-
 /*
  * delete_msglist()  -  delete room message pointers
  * FIX - this really should check first to make sure there's actually a
@@ -419,34 +382,6 @@ long AddMessageToRoom(struct quickroom *whichroom, long newmsgid)
 }
 
 
-/*
- * MessageFromList()  -  get a message number from the list currently in memory
- */
-long MessageFromList(int whichpos)
-{
-
-       /* Return zero if the position is invalid */
-       if (whichpos >= CC->num_msgs)
-               return 0L;
-
-       return (CC->msglist[whichpos]);
-}
-
-/* 
- * SetMessageInList()  -  set a message number in the list currently in memory
- */
-void SetMessageInList(int whichpos, long newmsgnum)
-{
-
-       /* Return zero if the position is invalid */
-       if (whichpos >= CC->num_msgs)
-               return;
-
-       CC->msglist[whichpos] = newmsgnum;
-}
-
-
-
 /*
  * sort message pointers
  * (returns new msg count)
@@ -476,7 +411,7 @@ int sort_msglist(long listptrs[], int oldcount)
        /* and yank any nulls */
        while ((numitems > 0) && (listptrs[0] == 0L)) {
                memcpy(&listptrs[0], &listptrs[1],
-                      (sizeof(long) * (CC->num_msgs - 1)));
+                      (sizeof(long) * (numitems - 1)));
                --numitems;
        }
 
@@ -724,6 +659,9 @@ void usergoto(char *where, int display_result)
        int newmailcount = 0;
        struct visit vbuf;
        char truncated_roomname[ROOMNAMELEN];
+        struct cdbdata *cdbfr;
+       long *msglist = NULL;
+       int num_msgs = 0;
 
        strcpy(CC->quickroom.QRname, where);
        getroom(&CC->quickroom, where);
@@ -747,16 +685,25 @@ void usergoto(char *where, int display_result)
                info = 1;
 
        get_mm();
-       get_msglist(&CC->quickroom);
-       for (a = 0; a < CC->num_msgs; ++a) {
-               if (MessageFromList(a) > 0L) {
+        cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->quickroom.QRnumber, sizeof(long));
+        if (cdbfr != NULL) {
+               msglist = mallok(cdbfr->len);
+               memcpy(msglist, cdbfr->ptr, cdbfr->len);
+               num_msgs = cdbfr->len / sizeof(long);
+               cdb_free(cdbfr);
+       }
+
+       if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) {
+               if (msglist[a] > 0L) {
                        ++total_messages;
-                       if (MessageFromList(a) > vbuf.v_lastseen) {
+                       if (msglist[a] > vbuf.v_lastseen) {
                                ++new_messages;
                        }
                }
        }
 
+       if (msglist != NULL) phree(msglist);
+
        if (CC->quickroom.QRflags & QR_MAILBOX)
                rmailflag = 1;
        else
index 12431fbd96ebf860598194b13431fc5d010213b5..4a596ea8eeaf94e432f5b69b31a59a4598ed262d 100644 (file)
@@ -15,11 +15,7 @@ void getfloor (struct floor *flbuf, int floor_num);
 void lgetfloor (struct floor *flbuf, int floor_num);
 void putfloor (struct floor *flbuf, int floor_num);
 void lputfloor (struct floor *flbuf, int floor_num);
-void get_msglist (struct quickroom *whichroom);
-void put_msglist (struct quickroom *whichroom);
 long AddMessageToRoom(struct quickroom *whichroom, long newmsgid);
-long int MessageFromList (int whichpos);
-void SetMessageInList (int whichpos, long int newmsgnum);
 int sort_msglist (long int *listptrs, int oldcount);
 void cmd_lrms (char *argbuf);
 void cmd_lkra (char *argbuf);
index bc93cb92470603044773227d89eeca20d0543503..5bfb0be56970b1cda60cc934ce1ed052c4bbf9c3 100644 (file)
@@ -115,6 +115,9 @@ void DoPurgeMessages(struct quickroom *qrbuf) {
        time_t xtime, now;
        char msgid[64];
        int a;
+        struct cdbdata *cdbfr;
+       long *msglist = NULL;
+       int num_msgs = 0;
 
        time(&now);
        GetExpirePolicy(&epbuf, qrbuf);
@@ -129,31 +132,38 @@ void DoPurgeMessages(struct quickroom *qrbuf) {
        if (epbuf.expire_mode == EXPIRE_MANUAL) return;
 
        begin_critical_section(S_QUICKROOM);
-       get_msglist(qrbuf);
+        cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf->QRnumber, sizeof(long));
+
+        if (cdbfr != NULL) {
+               msglist = mallok(cdbfr->len);
+               memcpy(msglist, cdbfr->ptr, cdbfr->len);
+               num_msgs = cdbfr->len / sizeof(long);
+               cdb_free(cdbfr);
+       }
        
        /* Nothing to do if there aren't any messages */
-       if (CC->num_msgs == 0) {
+       if (num_msgs == 0) {
                end_critical_section(S_QUICKROOM);
                return;
                }
 
        /* If the room is set to expire by count, do that */
        if (epbuf.expire_mode == EXPIRE_NUMMSGS) {
-               while (CC->num_msgs > epbuf.expire_value) {
-                       delnum = MessageFromList(0);
+               while (num_msgs > epbuf.expire_value) {
+                       delnum = msglist[0];
                        lprintf(5, "Expiring message %ld\n", delnum);
                        AdjRefCount(delnum, -1); 
-                       memcpy(&CC->msglist[0], &CC->msglist[1],
-                               (sizeof(long)*(CC->num_msgs - 1)));
-                       CC->num_msgs = CC->num_msgs - 1;
+                       memcpy(&msglist[0], &msglist[1],
+                               (sizeof(long)*(num_msgs - 1)));
+                       --num_msgs;
                        ++messages_purged;
                        }
                }
 
        /* If the room is set to expire by age... */
        if (epbuf.expire_mode == EXPIRE_AGE) {
-               for (a=0; a<(CC->num_msgs); ++a) {
-                       delnum = MessageFromList(a);
+               for (a=0; a<num_msgs; ++a) {
+                       delnum = msglist[a];
                        sprintf(msgid, "%ld", delnum);
                        xtime = output_message(msgid, MT_DATE, 0);
 
@@ -161,13 +171,21 @@ void DoPurgeMessages(struct quickroom *qrbuf) {
                           && (now - xtime > (time_t)(epbuf.expire_value * 86400L))) {
                                lprintf(5, "Expiring message %ld\n", delnum);
                                AdjRefCount(delnum, -1); 
-                               SetMessageInList(a, 0L);
+                               msglist[a] = 0L;
                                ++messages_purged;
                                }
                        }
                }
-       CC->num_msgs = sort_msglist(CC->msglist, CC->num_msgs);
-       put_msglist(qrbuf);
+
+       if (num_msgs > 0) {
+               num_msgs = sort_msglist(msglist, num_msgs);
+       }
+       
+       cdb_store(CDB_MSGLISTS, &qrbuf->QRnumber, sizeof(long),
+               msglist, (num_msgs * sizeof(long)) );
+
+       if (msglist != NULL) phree(msglist);
+
        end_critical_section(S_QUICKROOM);
        }
 
index 4cd091f3672d597ec15986a895889e349172b3eb..46233912a70129f4227e0251423ec67f7003790a 100644 (file)
@@ -40,9 +40,6 @@ struct CitContext {
        struct usersupp usersupp;       /* Database record buffers */
        struct quickroom quickroom;
 
-       long *msglist;
-       int num_msgs;
-
        char curr_user[32];     /* name of current user */
        int logged_in;          /* logged in */
        int internal_pgm;       /* authenticated as internal program */
index 9904a5823d949b696b04c196c63157ad04cc97b8..60dfcc6b346e6fd4619bdc217ff239056505e3f5 100644 (file)
@@ -1372,5 +1372,7 @@ int NewMailCount() {
                        }
                }
 
+       if (msglist != NULL) phree(msglist);
+
        return(num_newmsgs);
        }