functions which relied upon them. Citadel Is Now Better.
$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.
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
-
-
-
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);
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, " ");
}
-
-/*
- * 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
}
-/*
- * 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)
/* 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;
}
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);
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
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);
time_t xtime, now;
char msgid[64];
int a;
+ struct cdbdata *cdbfr;
+ long *msglist = NULL;
+ int num_msgs = 0;
time(&now);
GetExpirePolicy(&epbuf, 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);
&& (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);
}
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 */
}
}
+ if (msglist != NULL) phree(msglist);
+
return(num_newmsgs);
}