X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/aad5d20016b28bb8c28592c1ebe4213aafaa43c3..ec173fd2c:/uip/mhlistsbr.c diff --git a/uip/mhlistsbr.c b/uip/mhlistsbr.c index 5a45d036..ae1becf4 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 @@ -8,18 +6,16 @@ * complete copyright information. */ -#include +#include "h/mh.h" +#include "sbr/r1bindex.h" +#include "sbr/trimcpy.h" #include -#include -#include -#include -#include -#include - -/* mhmisc.c */ -int part_ok (CT); -int type_ok (CT, int); -void flush_errors (void); +#include "h/mts.h" +#include "h/tws.h" +#include "h/mime.h" +#include "h/mhparse.h" +#include "h/utils.h" +#include "mhmisc.h" /* * static prototypes @@ -29,7 +25,6 @@ static int list_debug (CT); static int list_multi (CT, int, int, int, int, int); static int list_partial (CT, int, int, int, int, int); static int list_external (CT, int, int, int, int, int); -static int list_application (CT, int, int, int, int, int); static int list_encoding (CT); @@ -123,20 +118,15 @@ list_switch (CT ct, int toplevel, int realsize, int verbose, int debug, case CT_AUDIO: case CT_IMAGE: case CT_VIDEO: - return list_content (ct, toplevel, realsize, verbose, debug, dispo); - case CT_APPLICATION: default: - return list_application (ct, toplevel, realsize, verbose, debug, - dispo); + return list_content (ct, toplevel, realsize, verbose, debug, dispo); } return 0; /* NOT REACHED */ } -#define empty(s) ((s) ? (s) : "") - /* * Method for listing information about a simple/generic content */ @@ -151,16 +141,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)); + snprintf (buffer, sizeof(buffer), "%s/%s", FENDNULL(ci->ci_type), + FENDNULL(ci->ci_subtype)); if (verbose) - printf (LSTFMT2bv, empty (ct->c_partno), buffer); + printf (LSTFMT2bv, FENDNULL(ct->c_partno), buffer); else - printf (LSTFMT2b, empty (ct->c_partno), buffer); + printf (LSTFMT2b, FENDNULL(ct->c_partno), buffer); if (ct->c_cesizefnx && realsize) size = (*ct->c_cesizefnx) (ct); @@ -201,7 +191,7 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug, free (dp); } - printf ("\n"); + putchar('\n'); if (verbose) { CI ci = &ct->c_ctinfo; @@ -254,7 +244,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) @@ -265,10 +255,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"); @@ -277,21 +267,20 @@ list_debug (CT ct) get_param_value(pm, '?')); /* 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)(unsigned long) ct->c_ctparams); + fprintf(stderr, " type %#x subtype %#x params %p\n", + ct->c_type, ct->c_subtype, (void *)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) fprintf (stderr, " %s:%s", ENCODING_FIELD, ct->c_celine); /* print internal flags for transfer encoding */ - fprintf (stderr, " transfer encoding 0x%x params 0x%x\n", - ct->c_encoding, (unsigned int)(unsigned long) &ct->c_cefile); + fprintf(stderr, " transfer encoding %#x params %p\n", + ct->c_encoding, (void *)&ct->c_cefile); /* print Content-ID */ if (ct->c_id) @@ -305,15 +294,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), - ct->c_begin, ct->c_end); + fprintf(stderr, " read fp %p file \"%s\" begin %ld end %ld\n", + (void *)ct->c_fp, FENDNULL(ct->c_file), ct->c_begin, ct->c_end); /* print more information about transfer encoding */ list_encoding (ct); @@ -321,8 +309,6 @@ list_debug (CT ct) return OK; } -#undef empty - /* * list content information for type "multipart" @@ -365,7 +351,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; @@ -389,30 +375,10 @@ list_external (CT ct, int toplevel, int realsize, int verbose, int debug, list_content (ct, toplevel, realsize, verbose, debug, dispo); if (verbose) { - if (e->eb_name) - printf ("\t name=\"%s\"\n", e->eb_name); - if (e->eb_dir) - printf ("\t directory=\"%s\"\n", e->eb_dir); - if (e->eb_site) - printf ("\t site=\"%s\"\n", e->eb_site); - if (e->eb_server) - printf ("\t server=\"%s\"\n", e->eb_server); - if (e->eb_subject) - printf ("\t subject=\"%s\"\n", e->eb_subject); - if (e->eb_url) - printf ("\t url=\"%s\"\n", e->eb_url); - - /* This must be defined */ - printf ("\t access-type=\"%s\"\n", e->eb_access); - - if (e->eb_mode) - printf ("\t mode=\"%s\"\n", e->eb_mode); - if (e->eb_permission) - printf ("\t permission=\"%s\"\n", e->eb_permission); - + if (!e->eb_access) + puts("\t [missing access-type]"); /* Must be defined. */ if (e->eb_flags == NOTOK) - printf ("\t [service unavailable]\n"); - + puts("\t [service unavailable]"); } /* @@ -425,23 +391,6 @@ 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, - int dispo) -{ - list_content (ct, toplevel, realsize, verbose, debug, dispo); - - return OK; -} - - /* * list information about the Content-Transfer-Encoding * used by a content. @@ -452,9 +401,8 @@ list_encoding (CT ct) { CE ce = &ct->c_cefile; - fprintf (stderr, " decoded fp 0x%x file \"%s\"\n", - (unsigned int)(unsigned long) ce->ce_fp, - ce->ce_file ? ce->ce_file : ""); + fprintf(stderr, " decoded fp %p file \"%s\"\n", + (void *)ce->ce_fp, FENDNULL(ce->ce_file)); return OK; }