+/* $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;
}
strcpy(actual_rm, CC->quickroom.QRname);
strcpy(hold_rm, "");
strcpy(recipient, rec);
+ strproc(recipient);
/* If the user is a twit, move to the twit room for posting... */
if (TWITDETECT) if (CC->usersupp.axlevel==2) {
strcpy(actual_rm, AIDEROOM);
}
-
/* This call to usergoto() changes rooms if necessary. It also
* causes the latest message list to be read into memory.
*/
/* 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");
+ /* Fix an obscure bug */
+ if (!strcasecmp(CC->quickroom.QRname, AIDEROOM)) {
+ CC->quickroom.QRflags = CC->quickroom.QRflags & ~QR_MAILBOX;
}
- 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;
/* Don't confuse the poor folks if it's not routed mail. */
strcpy(dest_node, "");
+
/* If net_type is M_BINARY, split out the destination node. */
if (net_type == M_BINARY) {
strcpy(dest_node,NODENAME);
fprintf(fp,"A%s%c",fake_name,0);
else
fprintf(fp,"A%s%c",author->fullname,0); /* author */
- fprintf(fp,"O%s%c",CC->quickroom.QRname,0); /* room */
+
+ if (CC->quickroom.QRflags & QR_MAILBOX) { /* room */
+ fprintf(fp,"O%s%c", &CC->quickroom.QRname[11], 0);
+ }
+ else {
+ fprintf(fp,"O%s%c",CC->quickroom.QRname,0);
+ }
+
fprintf(fp,"N%s%c",NODENAME,0); /* nodename */
fprintf(fp,"H%s%c",HUMANNODE,0); /* human nodename */
/* put the message into the target room */
lgetroom(&qtemp, targ);
- get_msglist(&qtemp);
- CC->num_msgs = CC->num_msgs + 1;
- CC->msglist = realloc(CC->msglist, (CC->num_msgs * sizeof(long)) );
- SetMessageInList(CC->num_msgs - 1, num);
- CC->num_msgs = sort_msglist(CC->msglist, CC->num_msgs);
- put_msglist(&qtemp);
+ AddMessageToRoom(&qtemp, num);
lputroom(&qtemp, targ);
- cprintf("%d I think this worked, FIX check to make sure\n", OK);
+ cprintf("%d Message moved.\n", OK);
}