]> diplodocus.org Git - nmh/blobdiff - uip/mhlistsbr.c
Some tests for RFC 2231 decoding; seems like it works, but need to stress
[nmh] / uip / mhlistsbr.c
index bc29243b8e6ee1e4d2b41c49745685f055ff0ed0..f5676a4990e2751fcc62e1ac2b327ba468e786a4 100644 (file)
@@ -11,8 +11,6 @@
 #include <h/mh.h>
 #include <fcntl.h>
 #include <h/signals.h>
-#include <errno.h>
-#include <signal.h>
 #include <h/mts.h>
 #include <h/tws.h>
 #include <h/mime.h>
@@ -46,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"
 
 
@@ -108,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 */
@@ -161,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);
@@ -206,11 +199,13 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug)
     printf ("\n");
 
     if (verbose) {
-       char **ap, **ep;
        CI ci = &ct->c_ctinfo;
+       PM pm;
 
-       for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++)
-           printf ("\t     %s=\"%s\"\n", *ap, *ep);
+       for (pm = ci->ci_first_pm; pm; pm = pm->pm_next) {
+           printf ("\t     %s=\"%s\"\n", pm->pm_name,
+                   get_param_value(pm, '?'));
+       }
 
        /*
         * If verbose, print any RFC-822 comments in the
@@ -240,8 +235,8 @@ list_content (CT ct, int toplevel, int realsize, int verbose, int debug)
 static int
 list_debug (CT ct)
 {
-    char **ap, **ep;
     CI ci = &ct->c_ctinfo;
+    PM pm;
 
     fflush (stdout);
     fprintf (stderr, "  partno \"%s\"\n", empty (ct->c_partno));
@@ -262,8 +257,9 @@ list_debug (CT ct)
 
     /* print parsed parameters attached to content type */
     fprintf (stderr, "    parameters\n");
-    for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++)
-       fprintf (stderr, "      %s=\"%s\"\n", *ap, *ep);
+    for (pm = ci->ci_first_pm; pm; pm = pm->pm_next)
+       fprintf (stderr, "      %s=\"%s\"\n", pm->pm_name,
+                get_param_value(pm, '?'));
 
     /* print internal flags for type/subtype */
     fprintf (stderr, "    type 0x%x subtype 0x%x params 0x%x\n",
@@ -280,7 +276,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)(unsigned long) ct->c_cefile);
+            ct->c_encoding, (unsigned int)(unsigned long) &ct->c_cefile);
 
     /* print Content-ID */
     if (ct->c_id)
@@ -422,12 +418,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)(unsigned long) 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;
 }