- if (room_num != 1) {
- cdb_store(CDB_FULLROOM, &room_num, sizeof(int),
- frbuf, sizeof(struct fullroom));
+ /* 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)
+ */
+int sort_msglist(long listptrs[], int oldcount)
+{
+ int a,b;
+ long hold1, hold2;
+ int numitems;
+
+ numitems = oldcount;
+ if (numitems < 2) return(oldcount);
+
+ /* do the sort */
+ for (a=numitems-2; a>=0; --a) {
+ for (b=0; b<=a; ++b) {
+ if (listptrs[b] > (listptrs[b+1])) {
+ hold1 = listptrs[b];
+ hold2 = listptrs[b+1];
+ listptrs[b] = hold2;
+ listptrs[b+1] = hold1;
+ }
+ }