X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/252f672ba218d1ed1f5018844dd007b5d2e6a860..665dfc96:/uip/mhlistsbr.c?ds=sidebyside diff --git a/uip/mhlistsbr.c b/uip/mhlistsbr.c index fea4ea28..f7ecbc89 100644 --- a/uip/mhlistsbr.c +++ b/uip/mhlistsbr.c @@ -1,6 +1,4 @@ - -/* - * mhlistsbr.c -- routines to list information about the +/* mhlistsbr.c -- routines to list information about the * -- contents of MIME messages * * This code is Copyright (c) 2002, by the authors of nmh. See the @@ -10,7 +8,6 @@ #include #include -#include #include #include #include @@ -18,7 +15,7 @@ #include /* mhmisc.c */ -int part_ok (CT, int); +int part_ok (CT); int type_ok (CT, int); void flush_errors (void); @@ -40,12 +37,14 @@ static int list_encoding (CT); #define LSTFMT1 "%4s %-5s %-24s %5s %s\n" #define LSTFMT2a "%4d " #define LSTFMT2b "%-5s %-24.24s " +#define LSTFMT2bv "%-5s %-24s " #define LSTFMT2c1 "%5lu" #define LSTFMT2c2 "%4lu%c" #define LSTFMT2c3 "huge " #define LSTFMT2c4 " " #define LSTFMT2d1 " %.36s" -#define LSTFMT2d2 "\t %-65.65s\n" +#define LSTFMT2d1v " %s" +#define LSTFMT2d2 "\t %-65s\n" /* @@ -134,8 +133,6 @@ list_switch (CT ct, int toplevel, int realsize, int verbose, int debug, } -#define empty(s) ((s) ? (s) : "") - /* * Method for listing information about a simple/generic content */ @@ -150,13 +147,16 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug, PM pm; if (toplevel > 0) - printf (LSTFMT2a, atoi (r1bindex (empty (ct->c_file), '/'))); + printf (LSTFMT2a, atoi (r1bindex (FENDNULL(ct->c_file), '/'))); else printf(toplevel < 0 ? "part " : " "); - snprintf (buffer, sizeof(buffer), "%s/%s", empty (ci->ci_type), - empty (ci->ci_subtype)); - printf (LSTFMT2b, empty (ct->c_partno), buffer); + snprintf (buffer, sizeof(buffer), "%s/%s", FENDNULL(ci->ci_type), + FENDNULL(ci->ci_subtype)); + if (verbose) + printf (LSTFMT2bv, FENDNULL(ct->c_partno), buffer); + else + printf (LSTFMT2b, FENDNULL(ct->c_partno), buffer); if (ct->c_cesizefnx && realsize) size = (*ct->c_cesizefnx) (ct); @@ -190,11 +190,14 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug, char *dp; dp = cpytrim (ct->c_descr); - printf (LSTFMT2d1, dp); + if (verbose) + printf (LSTFMT2d1v, dp); + else + printf (LSTFMT2d1, dp); free (dp); } - printf ("\n"); + putchar('\n'); if (verbose) { CI ci = &ct->c_ctinfo; @@ -247,7 +250,7 @@ list_debug (CT ct) PM pm; fflush (stdout); - fprintf (stderr, " partno \"%s\"\n", empty (ct->c_partno)); + fprintf (stderr, " partno \"%s\"\n", FENDNULL(ct->c_partno)); /* print MIME-Version line */ if (ct->c_vrsn) @@ -258,10 +261,10 @@ list_debug (CT ct) fprintf (stderr, " %s:%s\n", TYPE_FIELD, ct->c_ctline); /* print parsed elements of content type */ - fprintf (stderr, " type \"%s\"\n", empty (ci->ci_type)); - fprintf (stderr, " subtype \"%s\"\n", empty (ci->ci_subtype)); - fprintf (stderr, " comment \"%s\"\n", empty (ci->ci_comment)); - fprintf (stderr, " magic \"%s\"\n", empty (ci->ci_magic)); + fprintf (stderr, " type \"%s\"\n", FENDNULL(ci->ci_type)); + fprintf (stderr, " subtype \"%s\"\n", FENDNULL(ci->ci_subtype)); + fprintf (stderr, " comment \"%s\"\n", FENDNULL(ci->ci_comment)); + fprintf (stderr, " magic \"%s\"\n", FENDNULL(ci->ci_magic)); /* print parsed parameters attached to content type */ fprintf (stderr, " parameters\n"); @@ -274,9 +277,9 @@ list_debug (CT ct) ct->c_type, ct->c_subtype, (unsigned int)(unsigned long) ct->c_ctparams); - fprintf (stderr, " showproc \"%s\"\n", empty (ct->c_showproc)); - fprintf (stderr, " termproc \"%s\"\n", empty (ct->c_termproc)); - fprintf (stderr, " storeproc \"%s\"\n", empty (ct->c_storeproc)); + fprintf (stderr, " showproc \"%s\"\n", FENDNULL(ct->c_showproc)); + fprintf (stderr, " termproc \"%s\"\n", FENDNULL(ct->c_termproc)); + fprintf (stderr, " storeproc \"%s\"\n", FENDNULL(ct->c_storeproc)); /* print transfer encoding information */ if (ct->c_celine) @@ -298,14 +301,14 @@ list_debug (CT ct) if (ct->c_dispo) fprintf (stderr, " %s:%s", DISPO_FIELD, ct->c_dispo); - fprintf(stderr, " disposition \"%s\"\n", empty (ct->c_dispo_type)); + fprintf(stderr, " disposition \"%s\"\n", FENDNULL(ct->c_dispo_type)); fprintf(stderr, " disposition parameters\n"); for (pm = ct->c_dispo_first; pm; pm = pm->pm_next) fprintf (stderr, " %s=\"%s\"\n", pm->pm_name, get_param_value(pm, '?')); fprintf (stderr, " read fp 0x%x file \"%s\" begin %ld end %ld\n", - (unsigned int)(unsigned long) ct->c_fp, empty (ct->c_file), + (unsigned int)(unsigned long) ct->c_fp, FENDNULL(ct->c_file), ct->c_begin, ct->c_end); /* print more information about transfer encoding */ @@ -314,8 +317,6 @@ list_debug (CT ct) return OK; } -#undef empty - /* * list content information for type "multipart" @@ -335,7 +336,7 @@ list_multi (CT ct, int toplevel, int realsize, int verbose, int debug, for (part = m->mp_parts; part; part = part->mp_next) { CT p = part->mp_part; - if (part_ok (p, 1) && type_ok (p, 1)) + if (part_ok (p) && type_ok (p, 1)) list_switch (p, 0, realsize, verbose, debug, dispo); } @@ -358,7 +359,7 @@ list_partial (CT ct, int toplevel, int realsize, int verbose, int debug, printf ("\t [message %s, part %d", p->pm_partid, p->pm_partno); if (p->pm_maxno) printf (" of %d", p->pm_maxno); - printf ("]\n"); + puts("]"); } return OK; @@ -404,7 +405,7 @@ list_external (CT ct, int toplevel, int realsize, int verbose, int debug, printf ("\t permission=\"%s\"\n", e->eb_permission); if (e->eb_flags == NOTOK) - printf ("\t [service unavailable]\n"); + puts("\t [service unavailable]"); } @@ -447,7 +448,7 @@ list_encoding (CT ct) fprintf (stderr, " decoded fp 0x%x file \"%s\"\n", (unsigned int)(unsigned long) ce->ce_fp, - ce->ce_file ? ce->ce_file : ""); + FENDNULL(ce->ce_file)); return OK; }