#define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include "blaze822.h" void recmime(struct message *msg, int depth) { struct message *imsg = 0; char *ct, *body; size_t bodylen; if (blaze822_mime_body(msg, &ct, &body, &bodylen)) { printf("%*.sbody %s len %d\n", depth*2, "", ct, bodylen); if (strncmp(ct, "multipart/", 10) == 0) while (blaze822_multipart(msg, &imsg)) recmime(imsg, depth+1); else if (strncmp(ct, "text/", 5) == 0) { printf("---\n"); fwrite(body, bodylen, 1, stdout); printf("---\n"); } } } void unmime(char *file) { struct message *msg; msg = blaze822_file(file); if (!msg) return; if (blaze822_check_mime(msg)) printf("a mime message\n"); else return; recmime(msg, 0); } int main(int argc, char *argv[]) { blaze822_loop(argc-1, argv+1, unmime); return 0; }