From ef999efb49d431d344fb8fc06882dcfbe2f285ac Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 10 Mar 2003 05:38:21 +0000 Subject: [PATCH] * Tweaks to msgbase.c and imap_fetch.c to fix slightly incorrect byte counts reported in the numerous variations of IMAP FETCH. This silences a number of error messages reported by Pine. --- citadel/ChangeLog | 6 +++++- citadel/imap_fetch.c | 25 ++++++++++++++++++++----- citadel/msgbase.c | 17 ++++++++++------- citadel/routines2.c | 2 +- citadel/server.h | 2 +- 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 14eb34209..eca3d4973 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ + Revision 605.12 2003/03/10 05:38:21 ajc + * Tweaks to msgbase.c and imap_fetch.c to fix slightly incorrect byte counts + reported in the numerous variations of IMAP FETCH. This silences a number of + error messages reported by Pine. + Revision 605.11 2003/03/10 03:40:08 ajc * Fixed bug that caused segv when eplying to certain messages @@ -4528,4 +4533,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/imap_fetch.c b/citadel/imap_fetch.c index a17e47da3..add002403 100644 --- a/citadel/imap_fetch.c +++ b/citadel/imap_fetch.c @@ -407,7 +407,6 @@ void imap_strip_headers(FILE *fp, char *section) { fflush(fp); ftruncate(fileno(fp), ftell(fp)); fflush(fp); - fprintf(fp, "\r\n"); /* add the trailing newline */ rewind(fp); phree(which_fields); phree(boiled_headers); @@ -488,6 +487,16 @@ void imap_fetch_body(long msgnum, char *item, int is_peek, imap_strip_headers(tmp, section); } + /* + * Strip it down if the client asked for everything _except_ headers. + */ + else if (!strncasecmp(section, "TEXT", 4)) { + CtdlRedirectOutput(tmp, -1); + CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, + HEADERS_NONE, 0, 1); + CtdlRedirectOutput(NULL, -1); + } + /* * Anything else must be a part specifier. * (Note value of 1 passed as 'dont_decode' so client gets it encoded) @@ -643,7 +652,8 @@ void imap_fetch_bodystructure (long msgnum, char *item, FILE *tmp; char buf[1024]; long lines = 0L; - long bytes = 0L; + long start_of_body = 0L; + long body_bytes = 0L; /* For non-RFC822 (ordinary Citadel) messages, this is short and * sweet... @@ -660,13 +670,18 @@ void imap_fetch_bodystructure (long msgnum, char *item, CtdlRedirectOutput(NULL, -1); rewind(tmp); - while (fgets(buf, sizeof buf, tmp) != NULL) ++lines; - bytes = ftell(tmp); + while (fgets(buf, sizeof buf, tmp) != NULL) { + ++lines; + if ((!strcmp(buf, "\r\n")) && (start_of_body == 0L)) { + start_of_body = ftell(tmp); + } + } + body_bytes = ftell(tmp) - start_of_body; fclose(tmp); cprintf("BODYSTRUCTURE (\"TEXT\" \"PLAIN\" " "(\"CHARSET\" \"US-ASCII\") NIL NIL " - "\"7BIT\" %ld %ld)", bytes, lines); + "\"7BIT\" %ld %ld)", body_bytes, lines); return; } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 6d6f8313e..3654b65f1 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1096,6 +1096,7 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage, char *mptr; char *nl; /* newline string */ int suppress_f = 0; + int subject_found = 0; /* buffers needed for RFC822 translation */ char suser[SIZ]; @@ -1254,8 +1255,10 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage, cprintf("Path: %s%s", mptr, nl); } ****/ - else if (i == 'U') + else if (i == 'U') { cprintf("Subject: %s%s", mptr, nl); + subject_found = 1; + } else if (i == 'I') safestrncpy(mid, mptr, sizeof mid); else if (i == 'H') @@ -1276,6 +1279,9 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage, } } } + if (subject_found == 0) { + cprintf("Subject: (no subject)%s", nl); + } } for (i=0; icm_fields['U'] == NULL) { - cprintf("Subject: (no subject)%s", nl); - } - cprintf("%s", nl); - } /* If the format type on disk is 1 (fixed-format), then we want * everything to be output completely literally ... regardless of diff --git a/citadel/routines2.c b/citadel/routines2.c index 9e5e420e6..669fba49e 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -874,7 +874,7 @@ void do_internet_configuration(CtdlIPC *ipc) err_printf("Can't save config - out of memory!\n"); logoff(ipc, 1); } - for (i = 0; i < num_recs; i++) { + if (num_recs) for (i = 0; i < num_recs; i++) { strcat(resp, recs[i]); strcat(resp, "\n"); } diff --git a/citadel/server.h b/citadel/server.h index 261f27938..1866d3c3d 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -474,6 +474,6 @@ struct ser_ret { /* ********** Important fields */ /* *************** Semi-important fields */ /* * Message text (MUST be last) */ -#define FORDER "IPTAFONHRDBCEGJKLQSUVWXYZM" +#define FORDER "IPTAFONHRDBCEGJKLQSVWXYZUM" #endif /* SERVER_H */ -- 2.39.2