+/* $Id$ */
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
/*
- * get a message off disk.
+ * Get a message off disk. (return value is the message's timestamp)
*
*/
-void output_message(char *msgid, int mode,
+time_t output_message(char *msgid, int mode,
int headers_only, int desired_section) {
long msg_num;
int a;
char snode[256];
char lnode[256];
char mid[256];
- time_t xtime;
+ time_t xtime = 0L;
/* */
strcpy(boundary, "");
msg_num = atol(msgid);
- if ((!(CC->logged_in))&&(!(CC->internal_pgm))) {
+ if ((!(CC->logged_in))&&(!(CC->internal_pgm))&&(mode!=MT_DATE)) {
cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
- return;
+ return(xtime);
}
/* We used to need to check in the current room's message list
}
if (!msg_ok) {
- cprintf("%d Message %ld is not in this room.\n",
- ERROR, msg_num);
- return;
+ if (mode != MT_DATE)
+ cprintf("%d Message %ld is not in this room.\n",
+ ERROR, msg_num);
+ return(xtime);
}
dmsgtext = cdb_fetch(CDB_MSGMAIN, &msg_num, sizeof(long));
if (dmsgtext == NULL) {
- cprintf("%d Can't find message %ld\n", ERROR+INTERNAL_ERROR);
- return;
+ if (mode != MT_DATE)
+ cprintf("%d Can't find message %ld\n",
+ ERROR+INTERNAL_ERROR);
+ return(xtime);
}
msg_len = (long) dmsgtext->len;
cprintf("%d %ld\n", BINARY_FOLLOWS, msg_len);
client_write(dmsgtext->ptr, (int) msg_len);
cdb_free(dmsgtext);
- return;
+ return(xtime);
}
/* Otherwise, we'll start parsing it field by field... */
cprintf("%d Illegal message format on disk\n",
ERROR+INTERNAL_ERROR);
cdb_free(dmsgtext);
- return;
+ return(xtime);
}
anon_flag = *mptr++;
format_type = *mptr++;
+ /* Are we just looking for the message date? */
+ if (mode == MT_DATE) while(ch = *mptr++, (ch!='M' && ch!=0)) {
+ buf[0] = 0;
+ do {
+ buf[strlen(buf)+1] = 0;
+ rch = *mptr++;
+ buf[strlen(buf)] = rch;
+ } while (rch > 0);
+
+ if (ch=='T') {
+ xtime = atol(buf);
+ cdb_free(dmsgtext);
+ return(xtime);
+ }
+ }
+
+
/* now for the user-mode message reading loops */
cprintf("%d Message %ld:\n",LISTING_FOLLOWS,msg_num);
if (ch==0) {
cprintf("text\n*** ?Message truncated\n000\n");
cdb_free(dmsgtext);
- return;
+ return(xtime);
}
if (headers_only) {
cprintf("mlen=%ld\n", msg_len);
cprintf("000\n");
cdb_free(dmsgtext);
- return;
+ return(xtime);
}
/* signify start of msg text */
/* now we're done */
cprintf("000\n");
cdb_free(dmsgtext);
+ return(xtime);
}
desired_section = extract_int(cmdbuf, 2);
output_message(msgid,MT_CITADEL, headers_only, desired_section);
+ return;
}
/* read in the quickroom record, obtaining a lock... */
lgetroom(&CC->quickroom, actual_rm);
- get_msglist(&CC->quickroom);
-
- /* FIX here's where we have to handle message expiry!! */
- /* Now add the new message */
- CC->num_msgs = CC->num_msgs + 1;
- CC->msglist = realloc(CC->msglist,
- ((CC->num_msgs) * sizeof(long)) );
- if (CC->msglist == NULL) {
- lprintf(3, "ERROR: can't realloc message list!\n");
- }
- SetMessageInList(CC->num_msgs - 1, newmsgid);
-
- /* Write it back to disk. */
- put_msglist(&CC->quickroom);
+ /* Add the message pointer to the room */
+ AddMessageToRoom(&CC->quickroom, newmsgid);
/* update quickroom */
CC->quickroom.QRhighest = newmsgid;
}
/* put the message into the target room */
+ lgetroom(&qtemp, targ);
+ AddMessageToRoom(&qtemp, num);
+ lputroom(&qtemp, targ);
- cprintf("%d FIX FIX FIX implement this!!!!!\n", ERROR);
+ cprintf("%d Message moved.\n", OK);
}