]> code.citadel.org Git - citadel.git/commitdiff
* Tweaks to msgbase.c and imap_fetch.c to fix slightly incorrect byte counts
authorArt Cancro <ajc@citadel.org>
Mon, 10 Mar 2003 05:38:21 +0000 (05:38 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 10 Mar 2003 05:38:21 +0000 (05:38 +0000)
  reported in the numerous variations of IMAP FETCH.  This silences a number of
  error messages reported by Pine.

citadel/ChangeLog
citadel/imap_fetch.c
citadel/msgbase.c
citadel/routines2.c
citadel/server.h

index 14eb342094006022c4358e98b3470c622b2ef321..eca3d4973f943727fae67b3b5496e7e592b91c39 100644 (file)
@@ -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 <R>eplying to certain messages
 
@@ -4528,4 +4533,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 a17e47da347e1fb65a89669456a6eea06db603be..add0024039b9da74ddc74089fea71dfe23517f6e 100644 (file)
@@ -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;
        }
index 6d6f8313e8eb4671acd69f67246335b06f69a722..3654b65f1992e50c8286bae5f69837a2b68c1eea 100644 (file)
@@ -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; i<strlen(suser); ++i) {
@@ -1305,6 +1311,9 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
                }
 
                cprintf("Organization: %s%s", lnode, nl);
+
+               /* Blank line signifying RFC822 end-of-headers */
+               cprintf("%s", nl);
        }
 
        /* end header processing loop ... at this point, we're in the text */
@@ -1345,12 +1354,6 @@ START_TEXT:
        if ( (mode == MT_CITADEL) || (mode == MT_MIME) ) {
                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);
-       }
 
        /* If the format type on disk is 1 (fixed-format), then we want
         * everything to be output completely literally ... regardless of
index 9e5e420e60925fef161b71fbfa66adcd86c53c9c..669fba49e67d173a2ec950c37cceec466833415e 100644 (file)
@@ -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");
                                }
index 261f2793845f02fb50c70d305cdb8c49a285bb91..1866d3c3d5e1925437c7ec6f700fa8f8b72832c0 100644 (file)
@@ -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 */