From 96915dd6f3f8e7475fe8f4cc3e8462a95e5cc677 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 3 Dec 1998 01:39:38 +0000 Subject: [PATCH] * msgbase.c: modified AddMessageToRoom() and all functions that call it to use a more reliable/accurate method to set quickroom.QRhighest * weekly.in: don't sort/purge filedir where filedir doesn't exist --- citadel/ChangeLog | 5 +++++ citadel/msgbase.c | 5 ++--- citadel/room_ops.c | 11 ++++++++++- citadel/room_ops.h | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index a1513d8d6..cfc01e9a3 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 2 20:37:05 EST 1998 Art Cancro + * msgbase.c: modified AddMessageToRoom() and all functions that call it + to use a more reliable/accurate method to set quickroom.QRhighest + * weekly.in: don't sort/purge filedir where filedir doesn't exist + 1998-12-02 Nathan Bryant * weekly is now generated by configure diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 8ab426acf..4785df0a6 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -784,10 +784,9 @@ void save_message(char *mtmp, /* file containing proper message */ } /* Add the message pointer to the room */ - AddMessageToRoom(&CC->quickroom, newmsgid); + CC->quickroom.QRhighest = AddMessageToRoom(&CC->quickroom, newmsgid); /* update quickroom */ - CC->quickroom.QRhighest = newmsgid; lputroom(&CC->quickroom, actual_rm); /* Network mail - send a copy to the network program. */ @@ -1232,7 +1231,7 @@ void cmd_move(char *args) /* put the message into the target room */ lgetroom(&qtemp, targ); - AddMessageToRoom(&qtemp, num); + qtemp.QRhighest = AddMessageToRoom(&qtemp, num); lputroom(&qtemp, targ); cprintf("%d Message moved.\n", OK); diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 3d64b8fe4..2dac9c90e 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -332,11 +332,16 @@ void delete_msglist(struct quickroom *whichroom) { * So, why doesn't this function use the get_msglist() and put_msglist() stuff * defined above? Because the room the message number is being written to * may not be the current room (as is the case with cmd_move() for example). + * + * This function returns the highest message number present in the room after + * the add operation is performed - which is not necessarily the message + * being added. */ -void AddMessageToRoom(struct quickroom *whichroom, long newmsgid) { +long AddMessageToRoom(struct quickroom *whichroom, long newmsgid) { struct cdbdata *cdbfr; int num_msgs; long *msglist; + long highest_msg = 0L; cdbfr = cdb_fetch(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long)); if (cdbfr == NULL) { @@ -364,12 +369,16 @@ void AddMessageToRoom(struct quickroom *whichroom, long newmsgid) { /* Sort the message list, so all the msgid's are in order */ num_msgs = sort_msglist(msglist, num_msgs); + /* Determine the highest message number */ + highest_msg = msglist[num_msgs - 1]; + /* Write it back to disk. */ cdb_store(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long), msglist, num_msgs * sizeof(long)); /* And finally, free up the memory we used. */ free(msglist); + return(highest_msg); } diff --git a/citadel/room_ops.h b/citadel/room_ops.h index 775f64f10..22788e728 100644 --- a/citadel/room_ops.h +++ b/citadel/room_ops.h @@ -15,7 +15,7 @@ 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); -void AddMessageToRoom(struct quickroom *whichroom, long newmsgid); +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); -- 2.39.2