+Wed Dec 2 20:37:05 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * 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 <bryant@cs.usm.maine.edu>
* weekly is now generated by configure
}
/* 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. */
/* 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);
* 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) {
/* 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);
}
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);