X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fmhlistsbr.c;h=4c788d1616ee86b32e2e80569c5d1dad6ae91ad9;hp=80c9ad69b3e383d97e0f73d1869397711513a13e;hb=0b40f7c1c35770622511eda71ec5353784ea1dc6;hpb=ced6090a330d3d83d0bce709f756aa3d7d65fea4 diff --git a/uip/mhlistsbr.c b/uip/mhlistsbr.c index 80c9ad6..4c788d1 100644 --- a/uip/mhlistsbr.c +++ b/uip/mhlistsbr.c @@ -12,34 +12,33 @@ #include #include #include -#include #include #include #include #include /* mhmisc.c */ -int part_ok (CT, int); -int type_ok (CT, int); -void flush_errors (void); +int part_ok(CT, int); +int type_ok(CT, int); +void flush_errors(void); /* ** prototypes */ -void list_all_messages (CT *, int, int, int, int); -int list_switch (CT, int, int, int, int); -int list_content (CT, int, int, int, int); +void list_all_messages(CT *, int, int, int, int); +int list_switch(CT, int, int, int, int); +int list_content(CT, int, int, int, int); /* ** static prototypes */ -static void list_single_message (CT, int, int, int); -static int list_debug (CT); -static int list_multi (CT, int, int, int, int); -static int list_partial (CT, int, int, int, int); -static int list_external (CT, int, int, int, int); -static int list_application (CT, int, int, int, int); -static int list_encoding (CT); +static void list_single_message(CT, int, int, int); +static int list_debug(CT); +static int list_multi(CT, int, int, int, int); +static int list_partial(CT, int, int, int, int); +static int list_external(CT, int, int, int, int); +static int list_application(CT, int, int, int, int); +static int list_encoding(CT); /* @@ -61,19 +60,20 @@ static int list_encoding (CT); */ void -list_all_messages (CT *cts, int headers, int realsize, int verbose, int debug) +list_all_messages(CT *cts, int headers, int realsize, int verbose, int debug) { CT ct, *ctp; if (headers) - printf (LSTFMT1, "msg", "part", "type/subtype", "size", "description"); + printf(LSTFMT1, "msg", "part", "type/subtype", "size", + "description"); for (ctp = cts; *ctp; ctp++) { ct = *ctp; - list_single_message (ct, realsize, verbose, debug); + list_single_message(ct, realsize, verbose, debug); } - flush_errors (); + flush_errors(); } @@ -82,13 +82,13 @@ list_all_messages (CT *cts, int headers, int realsize, int verbose, int debug) */ static void -list_single_message (CT ct, int realsize, int verbose, int debug) +list_single_message(CT ct, int realsize, int verbose, int debug) { - if (type_ok (ct, 1)) { - umask (ct->c_umask); - list_switch (ct, 1, realsize, verbose, debug); + if (type_ok(ct, 1)) { + umask(ct->c_umask); + list_switch(ct, 1, realsize, verbose, debug); if (ct->c_fp) { - fclose (ct->c_fp); + fclose(ct->c_fp); ct->c_fp = NULL; } if (ct->c_ceclosefnx) @@ -102,45 +102,49 @@ list_single_message (CT ct, int realsize, int verbose, int debug) */ int -list_switch (CT ct, int toplevel, int realsize, int verbose, int debug) +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); + 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 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); + case MESSAGE_EXTERNAL: + return list_external(ct, toplevel, realsize, verbose, + debug); break; + case MESSAGE_RFC822: default: - /* list_debug (ct); */ - adios (NULL, "unknown content type %d", ct->c_type); + 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 */ @@ -154,17 +158,17 @@ list_switch (CT ct, int toplevel, int realsize, int verbose, int debug) */ int -list_content (CT ct, int toplevel, int realsize, int verbose, int debug) +list_content(CT ct, int toplevel, int realsize, int verbose, int debug) { unsigned long size; char *cp, buffer[BUFSIZ]; CI ci = &ct->c_ctinfo; - printf (toplevel > 0 ? LSTFMT2a : toplevel < 0 ? "part " : " ", - atoi (r1bindex (empty (ct->c_file), '/'))); - snprintf (buffer, sizeof(buffer), "%s/%s", empty (ci->ci_type), - empty (ci->ci_subtype)); - printf (LSTFMT2b, empty (ct->c_partno), buffer); + printf(toplevel > 0 ? LSTFMT2a : toplevel < 0 ? "part " : " ", + atoi(mhbasename(empty(ct->c_file)))); + snprintf(buffer, sizeof(buffer), "%s/%s", empty(ci->ci_type), + empty(ci->ci_subtype)); + printf(LSTFMT2b, empty(ct->c_partno), buffer); if (ct->c_cesizefnx && realsize) size = (*ct->c_cesizefnx) (ct); @@ -178,32 +182,32 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug) /* print size of this body part */ switch (*cp) { - case ' ': - if (size > 0 || ct->c_encoding != CE_EXTERNAL) - printf (LSTFMT2c1, size); - else - printf (LSTFMT2c4); - break; - - default: - printf (LSTFMT2c2, size, *cp); - break; - - case '\0': - printf (LSTFMT2c3); + case ' ': + if (size > 0 || ct->c_encoding != CE_EXTERNAL) + printf(LSTFMT2c1, size); + else + printf(LSTFMT2c4); + break; + + default: + printf(LSTFMT2c2, size, *cp); + break; + + case '\0': + printf(LSTFMT2c3); } /* print Content-Description */ if (ct->c_descr) { char *dp; - dp = trimcpy (cp = add (ct->c_descr, NULL)); - free (cp); - printf (LSTFMT2d1, dp); - free (dp); + dp = trimcpy(cp = getcpy(ct->c_descr)); + free(cp); + printf(LSTFMT2d1, dp); + free(dp); } - printf ("\n"); + printf("\n"); /* ** If verbose, print any RFC-822 comments in the @@ -212,15 +216,15 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug) if (verbose && ci->ci_comment) { char *dp; - dp = trimcpy (cp = add (ci->ci_comment, NULL)); - free (cp); - snprintf (buffer, sizeof(buffer), "(%s)", dp); - free (dp); - printf (LSTFMT2d2, buffer); + dp = trimcpy(cp = getcpy(ci->ci_comment)); + free(cp); + snprintf(buffer, sizeof(buffer), "(%s)", dp); + free(dp); + printf(LSTFMT2d2, buffer); } if (debug) - list_debug (ct); + list_debug(ct); return OK; } @@ -231,64 +235,65 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug) */ static int -list_debug (CT ct) +list_debug(CT ct) { char **ap, **ep; CI ci = &ct->c_ctinfo; - fflush (stdout); - fprintf (stderr, " partno \"%s\"\n", empty (ct->c_partno)); + fflush(stdout); + fprintf(stderr, " partno \"%s\"\n", empty(ct->c_partno)); /* print MIME-Version line */ if (ct->c_vrsn) - fprintf (stderr, " %s:%s\n", VRSN_FIELD, ct->c_vrsn); + fprintf(stderr, " %s:%s\n", VRSN_FIELD, ct->c_vrsn); /* print Content-Type line */ if (ct->c_ctline) - fprintf (stderr, " %s:%s\n", TYPE_FIELD, ct->c_ctline); + 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", 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)); /* print parsed parameters attached to content type */ - fprintf (stderr, " parameters\n"); + fprintf(stderr, " parameters\n"); for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) - fprintf (stderr, " %s=\"%s\"\n", *ap, *ep); + fprintf(stderr, " %s=\"%s\"\n", *ap, *ep); /* 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 0x%x subtype 0x%x params 0x%x\n", + 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", empty(ct->c_showproc)); + fprintf(stderr, " termproc \"%s\"\n", empty(ct->c_termproc)); + fprintf(stderr, " storeproc \"%s\"\n", empty(ct->c_storeproc)); /* print transfer encoding information */ if (ct->c_celine) - fprintf (stderr, " %s:%s", ENCODING_FIELD, 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 0x%x params 0x%x\n", + ct->c_encoding, + (unsigned int)(unsigned long) ct->c_cefile); /* print Content-ID */ if (ct->c_id) - fprintf (stderr, " %s:%s", ID_FIELD, ct->c_id); + fprintf(stderr, " %s:%s", ID_FIELD, ct->c_id); /* print Content-Description */ if (ct->c_descr) - fprintf (stderr, " %s:%s", DESCR_FIELD, ct->c_descr); + fprintf(stderr, " %s:%s", DESCR_FIELD, ct->c_descr); - 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 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); /* print more information about transfer encoding */ - list_encoding (ct); + list_encoding(ct); return OK; } @@ -301,20 +306,20 @@ list_debug (CT ct) */ static int -list_multi (CT ct, int toplevel, int realsize, int verbose, int debug) +list_multi(CT ct, int toplevel, int realsize, int verbose, int debug) { struct multipart *m = (struct multipart *) ct->c_ctparams; struct part *part; /* list the content for toplevel of this multipart */ - list_content (ct, toplevel, realsize, verbose, debug); + list_content(ct, toplevel, realsize, verbose, debug); /* now list for all the subparts */ for (part = m->mp_parts; part; part = part->mp_next) { CT p = part->mp_part; - if (part_ok (p, 1) && type_ok (p, 1)) - list_switch (p, 0, realsize, verbose, debug); + if (part_ok(p, 1) && type_ok(p, 1)) + list_switch(p, 0, realsize, verbose, debug); } return OK; @@ -326,17 +331,17 @@ list_multi (CT ct, int toplevel, int realsize, int verbose, int debug) */ static int -list_partial (CT ct, int toplevel, int realsize, int verbose, int debug) +list_partial(CT ct, int toplevel, int realsize, int verbose, int debug) { struct partial *p = (struct partial *) ct->c_ctparams; - list_content (ct, toplevel, realsize, verbose, debug); + list_content(ct, toplevel, realsize, verbose, debug); if (verbose) { - printf ("\t [message %s, part %d", + printf("\t [message %s, part %d", p->pm_partid, p->pm_partno); if (p->pm_maxno) - printf (" of %d", p->pm_maxno); - printf ("]\n"); + printf(" of %d", p->pm_maxno); + printf("]\n"); } return OK; @@ -348,7 +353,7 @@ list_partial (CT ct, int toplevel, int realsize, int verbose, int debug) */ static int -list_external (CT ct, int toplevel, int realsize, int verbose, int debug) +list_external(CT ct, int toplevel, int realsize, int verbose, int debug) { struct exbody *e = (struct exbody *) ct->c_ctparams; @@ -356,37 +361,37 @@ list_external (CT ct, int toplevel, int realsize, int verbose, int debug) * First list the information for the * message/external content itself. */ - list_content (ct, toplevel, realsize, verbose, debug); + list_content(ct, toplevel, realsize, verbose, debug); if (verbose) { if (e->eb_name) - printf ("\t name=\"%s\"\n", e->eb_name); + printf("\t name=\"%s\"\n", e->eb_name); if (e->eb_dir) - printf ("\t directory=\"%s\"\n", e->eb_dir); + printf("\t directory=\"%s\"\n", e->eb_dir); if (e->eb_site) - printf ("\t site=\"%s\"\n", e->eb_site); + printf("\t site=\"%s\"\n", e->eb_site); if (e->eb_server) - printf ("\t server=\"%s\"\n", e->eb_server); + printf("\t server=\"%s\"\n", e->eb_server); if (e->eb_subject) - printf ("\t subject=\"%s\"\n", e->eb_subject); + printf("\t subject=\"%s\"\n", e->eb_subject); /* 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); + printf("\t mode=\"%s\"\n", e->eb_mode); if (e->eb_permission) - printf ("\t permission=\"%s\"\n", e->eb_permission); + printf("\t permission=\"%s\"\n", e->eb_permission); if (e->eb_flags == NOTOK) - printf ("\t [service unavailable]\n"); + printf("\t [service unavailable]\n"); } /* ** Now list the information for the external content ** to which this content points. */ - list_content (e->eb_content, 0, realsize, verbose, debug); + list_content(e->eb_content, 0, realsize, verbose, debug); return OK; } @@ -397,15 +402,15 @@ list_external (CT ct, int toplevel, int realsize, int verbose, int debug) */ static int -list_application (CT ct, int toplevel, int realsize, int verbose, int debug) +list_application(CT ct, int toplevel, int realsize, int verbose, int debug) { - list_content (ct, toplevel, realsize, verbose, 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); + printf("\t %s=\"%s\"\n", *ap, *ep); } return OK; @@ -418,12 +423,12 @@ list_application (CT ct, int toplevel, int realsize, int verbose, int debug) */ static int -list_encoding (CT ct) +list_encoding(CT ct) { CE ce; if ((ce = ct->c_cefile)) - fprintf (stderr, " decoded fp 0x%x file \"%s\"\n", + fprintf(stderr, " decoded fp 0x%x file \"%s\"\n", (unsigned int)(unsigned long) ce->ce_fp, ce->ce_file ? ce->ce_file : "");