]> code.citadel.org Git - citadel.git/commitdiff
* tools.c: striplt() strips all whitespace, not just spaces
authorArt Cancro <ajc@citadel.org>
Thu, 9 Nov 2000 04:48:50 +0000 (04:48 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 9 Nov 2000 04:48:50 +0000 (04:48 +0000)
citadel/ChangeLog
citadel/imap_fetch.c
citadel/tools.c

index f654af93e4386e5baf16fe7b404003b8f95f1a82..e700239588e5d824a0e17e878614f2d52ed6c592 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 573.23  2000/11/09 04:48:50  ajc
+ * tools.c: striplt() strips all whitespace, not just spaces
+
  Revision 573.22  2000/11/07 20:47:21  ajc
  * imap_fetch.c: added a skeleton "ENVELOPE" fetch.  Currently sends NIL's.
 
@@ -2125,3 +2128,4 @@ 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 bea66046ecea2ac265b35d7607de414230ae5a65..6e18fcc60d5bca923999d5ef0b413272e2ed8006 100644 (file)
@@ -231,6 +231,24 @@ void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
 }
 
 
+/*
+ * Strip any non header information out of a chunk of RFC822 data on disk
+ */
+void imap_strip_headers(FILE *fp) {
+       char buf[1024];
+
+       rewind(fp);
+       while (fgets(buf, sizeof buf, fp) != NULL) {
+               striplt(buf);
+               if (strlen(buf) == 0) {
+                       ftruncate(fileno(fp), ftell(fp));
+               }
+       }
+       fflush(fp);
+       fprintf(fp, "\r\n");    /* add the trailing newline */
+       rewind(fp);
+}
+
 
 /*
  * Implements the BODY and BODY.PEEK fetch items
@@ -293,7 +311,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek,
                CtdlRedirectOutput(tmp, -1);
                CtdlOutputMsg(msgnum, MT_RFC822, 1, 0, 1);
                CtdlRedirectOutput(NULL, -1);
-               fprintf(tmp, "\r\n");   /* add the trailing newline */
+               imap_strip_headers(tmp);
        }
 
        /*
index e868f93afeac1e0e83e633aef7b551d3eb585908..b96b264bd894c4a8614271573da8548e52db417a 100644 (file)
@@ -291,9 +291,9 @@ void decode_base64(char *dest, char *source)
  */
 void striplt(char *buf)
 {
-        while ((strlen(buf) > 0) && (buf[0] == 32))
+        while ((strlen(buf) > 0) && (isspace(buf[0])))
                 strcpy(buf, &buf[1]);
-        while (buf[strlen(buf) - 1] == 32)
+        while (isspace(buf[strlen(buf) - 1]))
                 buf[strlen(buf) - 1] = 0;
 }