From 0e30afe6f462d398328cd582e6dfe570857e032f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 4 Oct 2005 16:38:17 +0000 Subject: [PATCH] * 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] --- citadel/ChangeLog | 8 ++++- citadel/citserver.c | 16 ++++++++++ citadel/imap_fetch.c | 12 ++++---- citadel/msgbase.c | 70 +++++++++++++++++------------------------- citadel/msgbase.h | 1 - citadel/serv_network.c | 2 +- citadel/serv_spam.c | 2 +- 7 files changed, 60 insertions(+), 51 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index fac7b5233..f2d05f784 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citserver.c b/citadel/citserver.c index edbffb3d8..a42fd0882 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -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); diff --git a/citadel/imap_fetch.c b/citadel/imap_fetch.c index e601645a2..b2506051f 100644 --- a/citadel/imap_fetch.c +++ b/citadel/imap_fetch.c @@ -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; diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 71a769022..36eda40de 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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; diff --git a/citadel/msgbase.h b/citadel/msgbase.h index ead3bbf2d..c88e1ea01 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -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? */ diff --git a/citadel/serv_network.c b/citadel/serv_network.c index e474ee784..7ff3ea35a 100644 --- a/citadel/serv_network.c +++ b/citadel/serv_network.c @@ -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); diff --git a/citadel/serv_spam.c b/citadel/serv_spam.c index 8cdca5648..5a9ba94b1 100644 --- a/citadel/serv_spam.c +++ b/citadel/serv_spam.c @@ -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; -- 2.39.2