]> code.citadel.org Git - citadel.git/blobdiff - citadel/msgbase.c
* Coded up the "bounce" functions. Still a coupla bugs.
[citadel.git] / citadel / msgbase.c
index 6b4e645a434e5cf04e85a7c3f6cfe3c8ea5c31d8..9dde1f53549da3d3844011ac017237296eec50a6 100644 (file)
@@ -28,6 +28,7 @@
 #include "tools.h"
 #include "mime_parser.h"
 #include "html.h"
+#include "genstamp.h"
 
 #define desired_section ((char *)CtdlGetUserData(SYM_DESIRED_SECTION))
 #define ma ((struct ma_info *)CtdlGetUserData(SYM_MA_INFO))
@@ -673,10 +674,13 @@ void CtdlFreeMessage(struct CtdlMessage *msg)
        if (is_valid_message(msg) == 0) return;
 
        for (i = 0; i < 256; ++i)
-               if (msg->cm_fields[i] != NULL)
+               if (msg->cm_fields[i] != NULL) {
+                       lprintf(9, "phreeing %c\n", i);
                        phree(msg->cm_fields[i]);
+               }
 
        msg->cm_magic = 0;      /* just in case */
+       lprintf(9, "phreeing msg\n");
        phree(msg);
 }
 
@@ -747,9 +751,8 @@ int CtdlOutputMsg(long msg_num,             /* message number (local) to fetch */
                int do_proto,           /* do Citadel protocol responses? */
                int crlf                /* Use CRLF newlines instead of LF? */
 ) {
-       int a, i, k;
+       int i, k;
        char buf[1024];
-       time_t xtime;
        CIT_UBYTE ch;
        char allkeys[256];
        char display_name[256];
@@ -764,6 +767,7 @@ int CtdlOutputMsg(long msg_num,             /* message number (local) to fetch */
        char snode[256];
        char lnode[256];
        char mid[256];
+       char datestamp[256];
        /*                                       */
 
        lprintf(7, "CtdlOutputMsg() msgnum=%ld, mode=%d\n", 
@@ -910,16 +914,12 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
 
                                if (i == 'A') {
                                        strcpy(luser, mptr);
-                               } else if (i == 'P') {
-                                       cprintf("Path: %s%s", mptr, nl);
-                                       for (a = 0; a < strlen(mptr); ++a) {
-                                               if (mptr[a] == '!') {
-                                                       strcpy(mptr, &mptr[a + 1]);
-                                                       a = 0;
-                                               }
-                                       }
                                        strcpy(suser, mptr);
-                               } else if (i == 'U')
+                               }
+                               else if (i == 'P') {
+                                       cprintf("Path: %s%s", mptr, nl);
+                               }
+                               else if (i == 'U')
                                        cprintf("Subject: %s%s", mptr, nl);
                                else if (i == 'I')
                                        strcpy(mid, mptr);
@@ -933,13 +933,19 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
                                else if (i == 'R')
                                        cprintf("To: %s%s", mptr, nl);
                                else if (i == 'T') {
-                                       xtime = atol(mptr);
-                                       cprintf("Date: %s", asctime(localtime(&xtime)));
+                                       generate_rfc822_datestamp(datestamp,
+                                                               atol(mptr) );
+                                       cprintf("Date: %s%s", datestamp, nl);
                                }
                        }
                }
        }
 
+       for (i=0; i<strlen(suser); ++i) {
+               suser[i] = tolower(suser[i]);
+               if (!isalnum(suser[i])) suser[i]='_';
+       }
+
        if (mode == MT_RFC822) {
                if (!strcasecmp(snode, NODENAME)) {
                        strcpy(snode, FQDN);
@@ -999,6 +1005,9 @@ int CtdlOutputMsg(long msg_num,            /* message number (local) to fetch */
        if (mode == MT_CITADEL)
                if (do_proto) cprintf("text\n");
        if (mode == MT_RFC822) {
+               if (TheMessage->cm_fields['U'] == NULL) {
+                       cprintf("Subject: (no subject)%s", nl);
+               }
                cprintf("%s", nl);
        }
 
@@ -1669,8 +1678,11 @@ long CtdlSaveMsg(struct CtdlMessage *msg,        /* message to save */
                instr = mallok(2048);
                sprintf(instr,
                        "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
+                       "bounceto|%s@%s\n"
                        "remote|%s|0||\n",
-                       SPOOLMIME, newmsgid, time(NULL), recipient );
+                       SPOOLMIME, newmsgid, time(NULL),
+                       msg->cm_fields['A'], msg->cm_fields['N'],
+                       recipient );
 
                imsg = mallok(sizeof(struct CtdlMessage));
                memset(imsg, 0, sizeof(struct CtdlMessage));