static void show_preview(const char *filename) { char *header, *value; struct rfc2045 *rfcp; FILE *fp; int fd; fp=0; fd=maildir_safeopen(filename, O_RDONLY, 0); if (fd >= 0) if ((fp=fdopen(fd, "r")) == 0) close(fd); if (!fp) return; while ((header=maildir_readheader(fp, &value, 1)) != 0) { /* Don't show X-, From, and Content- headers in preview */ if (strncmp(header, "x-", 2) == 0) continue; if (strcmp(header, "mime-version") == 0) continue; if (strncmp(header, "content-", 8) == 0) continue; printf("%c", toupper(*header)); output_attrencoded_oknl(header+1); printf(": "); value=rfc2047_decode_enhanced(value, sqwebmail_content_charset); if (value) { output_attrencoded_oknl(value); free(value); } printf("\n"); } printf("\n"); rfcp=rfc2045_fromfp(fp); if (!rfcp) return; filter_start(FILTER_FOR_PREVIEW, &preview_show_func_s); { struct rfc2045 *q= rfc2045_searchcontenttype(rfcp, "text/plain"); if (q) rfc2045_decodemimesection(fileno(fp), q, &filter_stub, NULL); } rfc2045_free(rfcp); filter_end(); }
void newmsg_showfp(FILE *fp, int *attachcnt) { struct rfc2045 *p=rfc2045_fromfp(fp), *q; if (!p) enomem(); /* Here's a nice opportunity to count all attachments */ *attachcnt=0; for (q=p->firstpart; q; q=q->next) if (!q->isdummy) ++*attachcnt; if (*attachcnt) --*attachcnt; /* Not counting the 1st MIME part */ q=rfc2045_searchcontenttype(p, "text/plain"); if (q) rfc2045_decodemimesection(fileno(fp), q, &show_textarea, NULL); rfc2045_free(p); }
int rfc2045_decodetextmimesection(struct rfc2045src *src, struct rfc2045 *rfc, const char *mychset, int *conv_err, int (*handler)(const char *, size_t, void *), void *voidarg) { const char *dummy; const char *src_chset; libmail_u_convert_handle_t ci; int rc; int dummy_flag; if (!conv_err) conv_err= &dummy_flag; rfc2045_mimeinfo(rfc, &dummy, &dummy, &src_chset); *conv_err=0; if ((ci=libmail_u_convert_init(src_chset, mychset, handler, voidarg)) == NULL) { *conv_err=1; return -1; } rc=rfc2045_decodemimesection(src, rfc, &myhandler, &ci); dummy_flag=0; if (libmail_u_convert_deinit(ci, &dummy_flag)) rc= -1; if (dummy_flag) *conv_err=1; return (rc); }
static void decodenoconvert(int fd, struct rfc2045 *p, const char *chset, int (*func)(const char *, size_t, void *), void *arg) { rfc2045_decodemimesection(fd, p, func, arg); }