X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8f4c5da8971926f7eccc912f7998c343aef3c33b..b4f2851d:/uip/mhlistsbr.c diff --git a/uip/mhlistsbr.c b/uip/mhlistsbr.c index 42e0b05a..9380c3d7 100644 --- a/uip/mhlistsbr.c +++ b/uip/mhlistsbr.c @@ -3,20 +3,19 @@ * mhlistsbr.c -- routines to list information about the * -- contents of MIME messages * - * $Id$ + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include #include #include -#include -#include -#include +#include #include #include #include - -extern int errno; +#include /* mhmisc.c */ int part_ok (CT, int); @@ -45,14 +44,14 @@ static int list_encoding (CT); /* * various formats for -list option */ -#define LSTFMT1 "%4s %-5s %-24s %5s %-36s\n" +#define LSTFMT1 "%4s %-5s %-24s %5s %s\n" #define LSTFMT2a "%4d " #define LSTFMT2b "%-5s %-24.24s " #define LSTFMT2c1 "%5lu" #define LSTFMT2c2 "%4lu%c" #define LSTFMT2c3 "huge " #define LSTFMT2c4 " " -#define LSTFMT2d1 " %-36.36s" +#define LSTFMT2d1 " %.36s" #define LSTFMT2d2 "\t %-65.65s\n" @@ -107,40 +106,32 @@ list_switch (CT ct, int toplevel, int realsize, int verbose, int debug) switch (ct->c_type) { case CT_MULTIPART: return list_multi (ct, toplevel, realsize, verbose, debug); - break; case CT_MESSAGE: switch (ct->c_subtype) { case MESSAGE_PARTIAL: return list_partial (ct, toplevel, realsize, verbose, debug); - break; case MESSAGE_EXTERNAL: return list_external (ct, toplevel, realsize, verbose, debug); - break; case MESSAGE_RFC822: default: return list_content (ct, toplevel, realsize, verbose, debug); - break; } - break; case CT_TEXT: case CT_AUDIO: case CT_IMAGE: case CT_VIDEO: return list_content (ct, toplevel, realsize, verbose, debug); - break; case CT_APPLICATION: return list_application (ct, toplevel, realsize, verbose, debug); - break; default: /* list_debug (ct); */ adios (NULL, "unknown content type %d", ct->c_type); - break; } return 0; /* NOT REACHED */ @@ -160,8 +151,11 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug) char *cp, buffer[BUFSIZ]; CI ci = &ct->c_ctinfo; - printf (toplevel > 0 ? LSTFMT2a : toplevel < 0 ? "part " : " ", - atoi (r1bindex (empty (ct->c_file), '/'))); + if (toplevel > 0) + printf (LSTFMT2a, atoi (r1bindex (empty (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); @@ -197,26 +191,32 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug) if (ct->c_descr) { char *dp; - dp = trimcpy (cp = add (ct->c_descr, NULL)); - free (cp); + dp = cpytrim (ct->c_descr); printf (LSTFMT2d1, dp); free (dp); } printf ("\n"); - /* - * If verbose, print any RFC-822 comments in the - * Content-Type line. - */ - if (verbose && ci->ci_comment) { - char *dp; + if (verbose) { + char **ap, **ep; + CI ci = &ct->c_ctinfo; - dp = trimcpy (cp = add (ci->ci_comment, NULL)); - free (cp); - snprintf (buffer, sizeof(buffer), "(%s)", dp); - free (dp); - printf (LSTFMT2d2, buffer); + for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) + printf ("\t %s=\"%s\"\n", *ap, *ep); + + /* + * If verbose, print any RFC-822 comments in the + * Content-Type line. + */ + if (ci->ci_comment) { + char *dp; + + dp = cpytrim (ci->ci_comment); + snprintf (buffer, sizeof(buffer), "(%s)", dp); + free (dp); + printf (LSTFMT2d2, buffer); + } } if (debug) @@ -260,7 +260,8 @@ list_debug (CT ct) /* print internal flags for type/subtype */ fprintf (stderr, " type 0x%x subtype 0x%x params 0x%x\n", - ct->c_type, ct->c_subtype, (unsigned int) ct->c_ctparams); + 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)); @@ -272,7 +273,7 @@ list_debug (CT ct) /* print internal flags for transfer encoding */ fprintf (stderr, " transfer encoding 0x%x params 0x%x\n", - ct->c_encoding, (unsigned int) ct->c_cefile); + ct->c_encoding, (unsigned int)(unsigned long) &ct->c_cefile); /* print Content-ID */ if (ct->c_id) @@ -283,7 +284,7 @@ list_debug (CT ct) fprintf (stderr, " %s:%s", DESCR_FIELD, ct->c_descr); fprintf (stderr, " read fp 0x%x file \"%s\" begin %ld end %ld\n", - (unsigned int) ct->c_fp, empty (ct->c_file), + (unsigned int)(unsigned long) ct->c_fp, empty (ct->c_file), ct->c_begin, ct->c_end); /* print more information about transfer encoding */ @@ -392,19 +393,15 @@ list_external (CT ct, int toplevel, int realsize, int verbose, int debug) /* * list content information for type "application" + * This no longer needs to be a separate function. It used to + * produce some output with verbose enabled, but that has been + * moved to list_content (). */ static int list_application (CT ct, int toplevel, int realsize, int verbose, int debug) { list_content (ct, toplevel, realsize, verbose, debug); - if (verbose) { - char **ap, **ep; - CI ci = &ct->c_ctinfo; - - for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) - printf ("\t %s=\"%s\"\n", *ap, *ep); - } return OK; } @@ -418,11 +415,11 @@ list_application (CT ct, int toplevel, int realsize, int verbose, int debug) static int list_encoding (CT ct) { - CE ce; + CE ce = &ct->c_cefile; - if ((ce = ct->c_cefile)) - fprintf (stderr, " decoded fp 0x%x file \"%s\"\n", - (unsigned int) ce->ce_fp, ce->ce_file ? ce->ce_file : ""); + fprintf (stderr, " decoded fp 0x%x file \"%s\"\n", + (unsigned int)(unsigned long) ce->ce_fp, + ce->ce_file ? ce->ce_file : ""); return OK; }