$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.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
}
+/*
+ * 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
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);
}
/*
*/
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;
}