* CtdlOutputPreLoadedMsg() calling syntax has changed. It no longer needs
authorArt Cancro <ajc@citadel.org>
Tue, 4 Oct 2005 16:38:17 +0000 (16:38 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 4 Oct 2005 16:38:17 +0000 (16:38 +0000)
  the message number, because it is being supplied a preloaded message.
* msgbase.c: fixed a problem where HEADERS_NONE mode was broken when
  outputting a message in RFC822 format.  This was breaking IMAP commands
  such as xx FETCH nn BODY[TEXT]

citadel/ChangeLog
citadel/citserver.c
citadel/imap_fetch.c
citadel/msgbase.c
citadel/msgbase.h
citadel/serv_network.c
citadel/serv_spam.c

index fac7b52334b014bc6e1b0d5256e729296323c000..f2d05f7840da957f908a55f52c84703ab3c8e004 100644 (file)
@@ -1,4 +1,11 @@
 $Log$
+Revision 655.20  2005/10/04 16:38:17  ajc
+* CtdlOutputPreLoadedMsg() calling syntax has changed.  It no longer needs
+  the message number, because it is being supplied a preloaded message.
+* msgbase.c: fixed a problem where HEADERS_NONE mode was broken when
+  outputting a message in RFC822 format.  This was breaking IMAP commands
+  such as xx FETCH nn BODY[TEXT]
+
 Revision 655.19  2005/10/02 04:40:58  ajc
 * The EUID index is now built, and replication checks are being performed
   using it.  It is much faster now because we don't have to scan the entire
@@ -7190,4 +7197,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index edbffb3d8d747e263c04e51047b0752abe8957c6..a42fd088239ee9c97d094d7e57ac176c59552365 100644 (file)
@@ -1290,6 +1290,22 @@ void do_command_loop(void) {
                cmd_isme(&cmdbuf[5]);
        }
 
+       else if (!strncasecmp(cmdbuf, "FUCK", 4)) {
+               cprintf("100\n");
+
+               struct CtdlMessage *msg;
+               msg = CtdlFetchMessage(3115, 1);
+               cprintf("\nCtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1);\n--\n");
+               CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1);
+               cprintf("--\nCtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);\n--\n");
+               CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);
+               cprintf("--\nCtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);\n--\n");
+               CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
+               cprintf("--\n");
+               cprintf("000\n");
+               CtdlFreeMessage(msg);
+       }
+
        else if (!DLoader_Exec_Cmd(cmdbuf)) {
                cprintf("%d Unrecognized or unsupported command.\n",
                        ERROR + CMD_NOT_SUPPORTED);
index e601645a23d36b67d46ba44f2bb620a8c03be000..b2506051fd1bc7695248b97257f2da3a3d002dc1 100644 (file)
@@ -584,7 +584,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
        if (strchr(section, '[') != NULL) {
                stripallbut(section, '[', ']');
        }
-       /* lprintf(CTDL_DEBUG, "Section is: %s%s\n", section, ((strlen(section)==0) ? "(empty)" : "") ); */
+       lprintf(CTDL_DEBUG, "Section is: %s%s\n", section, ((strlen(section)==0) ? "(empty)" : "") );
        if (!strncasecmp(section, "HEADER", 6)) {
                need_body = 0;
        }
@@ -636,11 +636,11 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
        }
 
        else if ( (!strcmp(section, "1")) && (msg->cm_format_type != 4) ) {
-               CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_NONE, 0, 1);
+               CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);
        }
 
        else if (!strcmp(section, "")) {
-               CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_ALL, 0, 1);
+               CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
        }
 
        /*
@@ -648,7 +648,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
         * fields, strip it down.
         */
        else if (!strncasecmp(section, "HEADER", 6)) {
-               CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_ONLY, 0, 1);
+               CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1);
                imap_strip_headers(section);
        }
 
@@ -656,7 +656,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
         * Strip it down if the client asked for everything _except_ headers.
         */
        else if (!strncasecmp(section, "TEXT", 4)) {
-               CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, HEADERS_NONE, 0, 1);
+               CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_NONE, 0, 1);
        }
 
        /*
@@ -887,7 +887,7 @@ void imap_fetch_bodystructure (long msgnum, char *item,
                CC->redirect_buffer = malloc(SIZ);
                CC->redirect_len = 0;
                CC->redirect_alloc = SIZ;
-               CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, 0, 0, 1);
+               CtdlOutputPreLoadedMsg(msg, MT_RFC822, 0, 0, 1);
                rfc822 = CC->redirect_buffer;
                rfc822_len = CC->redirect_len;
                CC->redirect_buffer = NULL;
index 71a769022a54381cc694fbc992a3b8765ac5a0a1..36eda40de649dce75dd7fcdca473c167e3a60f92 100644 (file)
@@ -1265,7 +1265,7 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
        }
        
        retcode = CtdlOutputPreLoadedMsg(
-                       TheMessage, msg_num, mode,
+                       TheMessage, mode,
                        headers_only, do_proto, crlf);
 
        CtdlFreeMessage(TheMessage);
@@ -1280,7 +1280,6 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
  */
 int CtdlOutputPreLoadedMsg(
                struct CtdlMessage *TheMessage,
-               long msg_num,
                int mode,               /* how would you like that message? */
                int headers_only,       /* eschew the message body? */
                int do_proto,           /* do Citadel protocol responses? */
@@ -1309,12 +1308,11 @@ int CtdlOutputPreLoadedMsg(
        char mid[100];
        char datestamp[100];
 
-       lprintf(CTDL_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %ld, %d, %d, %d, %d\n",
+       lprintf(CTDL_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %d, %d, %d, %d\n",
                ((TheMessage == NULL) ? "NULL" : "not null"),
-               msg_num,
                mode, headers_only, do_proto, crlf);
 
-       snprintf(mid, sizeof mid, "%ld", msg_num);
+       strcpy(mid, "unknown");
        nl = (crlf ? "\r\n" : "\n");
 
        if (!is_valid_message(TheMessage)) {
@@ -1351,7 +1349,7 @@ int CtdlOutputPreLoadedMsg(
        }
 
        /* now for the user-mode message reading loops */
-       if (do_proto) cprintf("%d Message %ld:\n", LISTING_FOLLOWS, msg_num);
+       if (do_proto) cprintf("%d msg:\n", LISTING_FOLLOWS);
 
        /* Does the caller want to skip the headers? */
        if (headers_only == HEADERS_NONE) goto START_TEXT;
@@ -1535,46 +1533,36 @@ START_TEXT:
                                (void *)&ma, 0);
                }
                else if (mode == MT_RFC822) {   /* unparsed RFC822 dump */
-                       /* FIXME ... we have to put some code in here to avoid
-                        * printing duplicate header information when both
-                        * Citadel and RFC822 headers exist.  Preference should
-                        * probably be given to the RFC822 headers.
-                        */
-                       int done_rfc822_hdrs = 0;
-                       while (ch=*(mptr++), ch!=0) {
+                       char *start_of_text = NULL;
+                       start_of_text = strstr(mptr, "\n\r\n");
+                       if (start_of_text == NULL) start_of_text = strstr(mptr, "\n\n");
+                       if (start_of_text == NULL) start_of_text = mptr;
+                       ++start_of_text;
+                       start_of_text = strstr(start_of_text, "\n");
+                       ++start_of_text;
+                       while (ch=*mptr, ch!=0) {
                                if (ch==13) {
                                        /* do nothing */
                                }
-                               else if (ch==10) {
-                                       if (!done_rfc822_hdrs) {
-                                               if (headers_only != HEADERS_NONE) {
-                                                       cprintf("%s", nl);
+                               else switch(headers_only) {
+                                       case HEADERS_NONE:
+                                               if (mptr >= start_of_text) {
+                                                       if (ch == 10) cprintf("%s", nl);
+                                                       else cprintf("%c", ch);
                                                }
-                                       }
-                                       else {
-                                               if (headers_only != HEADERS_ONLY) {
-                                                       cprintf("%s", nl);
+                                               break;
+                                       case HEADERS_ONLY:
+                                               if (mptr < start_of_text) {
+                                                       if (ch == 10) cprintf("%s", nl);
+                                                       else cprintf("%c", ch);
                                                }
-                                       }
-                                       if ((*(mptr) == 13) || (*(mptr) == 10)) {
-                                               done_rfc822_hdrs = 1;
-                                       }
-                               }
-                               else {
-                                       if (done_rfc822_hdrs) {
-                                               if (headers_only != HEADERS_NONE) {
-                                                       cprintf("%c", ch);
-                                               }
-                                       }
-                                       else {
-                                               if (headers_only != HEADERS_ONLY) {
-                                                       cprintf("%c", ch);
-                                               }
-                                       }
-                                       if ((*mptr == 13) || (*mptr == 10)) {
-                                               done_rfc822_hdrs = 1;
-                                       }
+                                               break;
+                                       default:
+                                               if (ch == 10) cprintf("%s", nl);
+                                               else cprintf("%c", ch);
+                                               break;
                                }
+                               ++mptr;
                        }
                        goto DONE;
                }
@@ -2212,7 +2200,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        CC->redirect_buffer = malloc(SIZ);
        CC->redirect_len = 0;
        CC->redirect_alloc = SIZ;
-       CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, HEADERS_ALL, 0, 1);
+       CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
        smi.meta_rfc822_length = CC->redirect_len;
        free(CC->redirect_buffer);
        CC->redirect_buffer = NULL;
index ead3bbf2daa89115a382ae0f42d9232ccd5e641a..c88e1ea0185f393f98e86904c70155c62a041121 100644 (file)
@@ -119,7 +119,6 @@ int CtdlOutputMsg(long msg_num,             /* message number (local) to fetch */
                int do_proto,           /* do Citadel protocol responses? */
                int crlf);
 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
-               long,
                int mode,               /* how would you like that message? */
                int headers_only,       /* eschew the message body? */
                int do_proto,           /* do Citadel protocol responses? */
index e474ee784424f6d509f0285c1ea2ef03a1f05975..7ff3ea35a069ca251a9c5cced68ff7ca3f8aea96 100644 (file)
@@ -683,7 +683,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                        CC->redirect_alloc = SIZ;
 
                        safestrncpy(CC->preferred_formats, "text/plain", sizeof CC->preferred_formats);
-                       CtdlOutputPreLoadedMsg(msg, 0L, MT_CITADEL, HEADERS_NONE, 0, 0);
+                       CtdlOutputPreLoadedMsg(msg, MT_CITADEL, HEADERS_NONE, 0, 0);
 
                        striplt(CC->redirect_buffer);
                        fprintf(sc->digestfp, "\n%s\n", CC->redirect_buffer);
index 8cdca5648ba1551767a6dfff89609a82eb246705..5a9ba94b1632700efd1a1c33ec86914fee9b6a13 100644 (file)
@@ -141,7 +141,7 @@ int spam_assassin(struct CtdlMessage *msg) {
        CC->redirect_buffer = malloc(SIZ);
        CC->redirect_len = 0;
        CC->redirect_alloc = SIZ;
-       CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, HEADERS_ALL, 0, 1);
+       CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
        msgtext = CC->redirect_buffer;
        msglen = CC->redirect_len;
        CC->redirect_buffer = NULL;