From: Ken Hornstein Date: Wed, 26 Mar 2014 02:41:13 +0000 (-0400) Subject: Start of changes for mhshow; compiles, but does nothing (yet). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/22de44b40389f3c6ec7f5d811eb8349cc9d499bf?hp=-c Start of changes for mhshow; compiles, but does nothing (yet). --- 22de44b40389f3c6ec7f5d811eb8349cc9d499bf diff --git a/h/mhparse.h b/h/mhparse.h index 700c0cc3..cfa1e53f 100644 --- a/h/mhparse.h +++ b/h/mhparse.h @@ -472,4 +472,20 @@ char *get_param(PM first, const char *name, char replace, int fetchonly); */ char *get_param_value(PM pm, char replace); +/* + * Display MIME message(s) on standard out. + * + * Arguments are: + * + * cts - NULL terminated array of CT structures for messages + * to display + * concat - If true, concatenate all MIME parts. If false, show each + * MIME part under a separate pager. + * textonly - If true, only display "text" MIME parts + * inlineonly - If true, only display MIME parts that are marked with + * a disposition of "inline" (includes parts that lack a + * Content-Disposition header). + */ +void show_all_messages(CT *cts, int concat, int textonly, int inlineonly); + extern int checksw; /* Add Content-MD5 field */ diff --git a/uip/mhn.c b/uip/mhn.c index 09aa1671..8a4ab318 100644 --- a/uip/mhn.c +++ b/uip/mhn.c @@ -119,9 +119,6 @@ int part_ok (CT, int); int type_ok (CT, int); void flush_errors (void); -/* mhshowsbr.c */ -void show_all_messages (CT *); - /* mhstoresbr.c */ typedef struct mhstoreinfo *mhstoreinfo_t; mhstoreinfo_t mhstoreinfo_create(CT *, char *, const char *, int, int); @@ -555,7 +552,7 @@ do_cache: * Show the message content */ if (showsw) - show_all_messages (cts); + show_all_messages (cts, 0, 0, 0); /* Now free all the structures for the content */ for (ctp = cts; *ctp; ctp++) diff --git a/uip/mhshow.c b/uip/mhshow.c index e897f2b6..edf3f1e3 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -23,6 +23,8 @@ X("nocheck", 0, NCHECKSW) \ X("verbose", 0, VERBSW) \ X("noverbose", 0, NVERBSW) \ + X("concat", 0, CONCATSW) \ + X("noconcat", 0, NCONCATSW) \ X("file file", 0, FILESW) \ X("form formfile", 0, FORMSW) \ X("part number", 0, PARTSW) \ @@ -83,9 +85,6 @@ int part_ok (CT, int); int type_ok (CT, int); void flush_errors (void); -/* mhshowsbr.c */ -void show_all_messages (CT *); - /* mhfree.c */ extern CT *cts; void freects_done (int) NORETURN; @@ -99,7 +98,7 @@ static void pipeser (int); int main (int argc, char **argv) { - int msgnum, *icachesw; + int msgnum, *icachesw, concatsw = 1, textonly = 1, inlineonly = 1; char *cp, *file = NULL, *folder = NULL; char *maildir, buf[100], **argp; char **arguments; @@ -162,6 +161,13 @@ do_cache: checksw = 0; continue; + case CONCATSW: + concatsw = 1; + continue; + case NCONCATSW: + concatsw = 0; + continue; + case PARTSW: if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); @@ -235,6 +241,16 @@ do_cache: parts[npart] = NULL; types[ntype] = NULL; + /* + * If we had any specific parts or types specified, turn off text only + * content. + */ + + if (npart > 0 || ntype > 0) { + textonly = 0; + inlineonly = 0; + } + /* * Check if we've specified an additional profile */ @@ -369,7 +385,7 @@ do_cache: /* * Show the message content */ - show_all_messages (cts); + show_all_messages (cts, concatsw, textonly, inlineonly); /* Now free all the structures for the content */ for (ctp = cts; *ctp; ctp++) diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index c53f22f3..c418b21d 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -41,24 +41,23 @@ void flush_errors (void); /* * prototypes */ -void show_all_messages (CT *); int show_content_aux (CT, int, char *, char *); /* * static prototypes */ -static void show_single_message (CT, char *); -static void DisplayMsgHeader (CT, char *); -static int show_switch (CT, int); +static void show_single_message (CT, char *, int, int, int); +static void DisplayMsgHeader (CT, char *, int); +static int show_switch (CT, int, int, int, int); static int show_content (CT, int); static int show_content_aux2 (CT, int, char *, char *, int, int, int); static int show_text (CT, int); -static int show_multi (CT, int); -static int show_multi_internal (CT, int); +static int show_multi (CT, int, int, int, int); +static int show_multi_internal (CT, int, int, int, int); static int show_multi_aux (CT, int, char *); static int show_message_rfc822 (CT, int); static int show_partial (CT, int); -static int show_external (CT, int); +static int show_external (CT, int, int, int, int); static int parse_display_string (CT, char *, int *, int *, char *, char *, size_t, int multipart); static int convert_content_charset (CT, char **); @@ -70,7 +69,7 @@ static int pidcheck(int); */ void -show_all_messages (CT *cts) +show_all_messages (CT *cts, int concat, int textonly, int inlineonly) { CT ct, *ctp; @@ -92,7 +91,7 @@ show_all_messages (CT *cts) /* if top-level type is ok, then display message */ if (type_ok (ct, 1)) - show_single_message (ct, formsw); + show_single_message (ct, formsw, concat, textonly, inlineonly); } } @@ -102,7 +101,8 @@ show_all_messages (CT *cts) */ static void -show_single_message (CT ct, char *form) +show_single_message (CT ct, char *form, int concat, int textonly, + int inlineonly) { sigset_t set, oset; @@ -117,10 +117,10 @@ show_single_message (CT ct, char *form) * the message headers. */ if (form) - DisplayMsgHeader(ct, form); + DisplayMsgHeader(ct, form, concat); /* Show the body of the message */ - show_switch (ct, 0); + show_switch (ct, 0, concat, textonly, inlineonly); if (ct->c_fp) { fclose (ct->c_fp); @@ -154,7 +154,7 @@ show_single_message (CT ct, char *form) */ static void -DisplayMsgHeader (CT ct, char *form) +DisplayMsgHeader (CT ct, char *form, int concat) { pid_t child_id; int i, vecp; @@ -171,7 +171,7 @@ DisplayMsgHeader (CT ct, char *form) * If we've specified -(no)moreproc, * then just pass that along. */ - if (nomore) { + if (nomore || concat) { vec[vecp++] = getcpy("-nomoreproc"); } else if (progsw) { vec[vecp++] = getcpy("-moreproc"); @@ -211,11 +211,11 @@ DisplayMsgHeader (CT ct, char *form) */ static int -show_switch (CT ct, int alternate) +show_switch (CT ct, int alternate, int concat, int textonly, int inlineonly) { switch (ct->c_type) { case CT_MULTIPART: - return show_multi (ct, alternate); + return show_multi (ct, alternate, concat, textonly, inlineonly); case CT_MESSAGE: switch (ct->c_subtype) { @@ -223,7 +223,8 @@ show_switch (CT ct, int alternate) return show_partial (ct, alternate); case MESSAGE_EXTERNAL: - return show_external (ct, alternate); + return show_external (ct, alternate, concat, textonly, + inlineonly); case MESSAGE_RFC822: default: @@ -444,7 +445,7 @@ show_text (CT ct, int alternate) */ static int -show_multi (CT ct, int alternate) +show_multi (CT ct, int alternate, int concat, int textonly, int inlineonly) { char *cp, buffer[BUFSIZ]; CI ci = &ct->c_ctinfo; @@ -468,7 +469,7 @@ show_multi (CT ct, int alternate) * unknown types are displayable, since they're treated as mixed * per RFC 2046. */ - return show_multi_internal (ct, alternate); + return show_multi_internal (ct, alternate, concat, textonly, inlineonly); } @@ -478,7 +479,8 @@ show_multi (CT ct, int alternate) */ static int -show_multi_internal (CT ct, int alternate) +show_multi_internal (CT ct, int alternate, int concat, int textonly, + int inlineonly) { int alternating, nowalternate, result; struct multipart *m = (struct multipart *) ct->c_ctparams; @@ -506,7 +508,8 @@ show_multi_internal (CT ct, int alternate) if (part_ok (p, 1) && type_ok (p, 1)) { int inneresult; - inneresult = show_switch (p, nowalternate); + inneresult = show_switch (p, nowalternate, concat, textonly, + inlineonly); switch (inneresult) { case NOTOK: if (alternate && !alternating) { @@ -652,7 +655,7 @@ show_partial (CT ct, int alternate) */ static int -show_external (CT ct, int alternate) +show_external (CT ct, int alternate, int concat, int textonly, int inlineonly) { struct exbody *e = (struct exbody *) ct->c_ctparams; CT p = e->eb_content; @@ -660,7 +663,7 @@ show_external (CT ct, int alternate) if (!type_ok (p, 0)) return OK; - return show_switch (p, alternate); + return show_switch (p, alternate, concat, textonly, inlineonly); }