]> code.citadel.org Git - citadel.git/blobdiff - citadel/imap_fetch.c
* I dunno
[citadel.git] / citadel / imap_fetch.c
index 099b643cd5dae8029b045e0d7cecdd832ba61263..6f07f64ffcec71bf455da58f2c2236268a2c569c 100644 (file)
@@ -380,7 +380,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek,
                if (partial[i]=='>') partial[i] = 0;
        }
        if (is_partial == 0) strcpy(partial, "");
-       lprintf(9, "Partial is %s\n", partial);
+       if (strlen(partial) > 0) lprintf(9, "Partial is %s\n", partial);
 
        tmp = tmpfile();
        if (tmp == NULL) {
@@ -417,7 +417,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek,
                imfp.output_fp = tmp;
 
                mime_parser(msg->cm_fields['M'], NULL,
-                               *imap_load_part,
+                               *imap_load_part, NULL, NULL,
                                (void *)&imfp,
                                1);
        }
@@ -456,6 +456,36 @@ void imap_fetch_body(long msgnum, char *item, int is_peek,
        }
 }
 
+/*
+ * Called immediately before outputting a multipart bodystructure
+ */
+void imap_fetch_bodystructure_pre(
+               char *name, char *filename, char *partnum, char *disp,
+               void *content, char *cbtype, size_t length, char *encoding,
+               void *cbuserdata
+               ) {
+
+       cprintf("(");
+}
+
+
+
+/*
+ * Called immediately after outputting a multipart bodystructure
+ */
+void imap_fetch_bodystructure_post(
+               char *name, char *filename, char *partnum, char *disp,
+               void *content, char *cbtype, size_t length, char *encoding,
+               void *cbuserdata
+               ) {
+
+       char subtype[SIZ];
+
+       extract_token(subtype, cbtype, 1, '/');
+       imap_strout(subtype);
+       cprintf(")");
+}
+
 
 
 /*
@@ -552,19 +582,20 @@ void imap_fetch_bodystructure (long msgnum, char *item,
 
                cprintf("BODYSTRUCTURE (\"TEXT\" \"PLAIN\" "
                        "(\"CHARSET\" \"US-ASCII\") NIL NIL "
-                       "\"7BIT\" %ld %ld) ", bytes, lines);
+                       "\"7BIT\" %ld %ld)", bytes, lines);
 
                return;
        }
 
        /* For messages already stored in RFC822 format, we have to parse. */
-       cprintf("BODYSTRUCTURE (");
+       cprintf("BODYSTRUCTURE ");
        mime_parser(msg->cm_fields['M'],
                        NULL,
-                       *imap_fetch_bodystructure_part,
+                       *imap_fetch_bodystructure_part, /* part */
+                       *imap_fetch_bodystructure_pre,  /* pre-multi */
+                       *imap_fetch_bodystructure_post, /* post-multi */
                        NULL,
                        0);
-       cprintf(") ");
 }