]> diplodocus.org Git - nmh/blobdiff - uip/mhoutsbr.c
Document argsplit changes in mh-profile man page.
[nmh] / uip / mhoutsbr.c
index 57a5df93db59fa6a9320789d7fa5f28bddc46885..aac061dd2a4f218ef1851d86cb5710cb420a7b1a 100644 (file)
@@ -62,12 +62,14 @@ output_message (CT ct, char *file)
     FILE *fp;
     int status;
 
-    if ((fp = fopen (file, "w")) == NULL) {
+    if (! strcmp (file, "-")) {
+       fp = stdout;
+    } else if ((fp = fopen (file, "w")) == NULL) {
        advise (file, "unable to open for writing");
        return NOTOK;
     }
     status = output_message_fp(ct, fp, file);
-    fclose(fp);
+    if (strcmp (file, "-")) fclose(fp);
     return status;
 }
 
@@ -81,6 +83,14 @@ output_content (CT ct, FILE *out)
 {
     int result = 0;
     CI ci = &ct->c_ctinfo;
+    char *boundary = ci->ci_values[0], **ap, **vp;
+
+    for (ap = ci->ci_attrs, vp = ci->ci_values; *ap; ++ap, ++vp) {
+        if (! mh_strcasecmp ("boundary", *ap)) {
+            boundary = *vp;
+            break;
+        }
+    }
 
     /*
      * Output all header fields for this content
@@ -108,14 +118,23 @@ output_content (CT ct, FILE *out)
            putc ('\n', out);
 
        m = (struct multipart *) ct->c_ctparams;
+
+        if (m->mp_content_before) {
+           fprintf (out, "%s", m->mp_content_before);
+        }
+
        for (part = m->mp_parts; part; part = part->mp_next) {
            CT p = part->mp_part;
 
-           fprintf (out, "\n--%s\n", ci->ci_values[0]);
+           fprintf (out, "\n--%s\n", boundary);
            if (output_content (p, out) == NOTOK)
                return NOTOK;
        }
-       fprintf (out, "\n--%s--\n", ci->ci_values[0]);
+       fprintf (out, "\n--%s--\n", boundary);
+
+        if (m->mp_content_after) {
+           fprintf (out, "%s", m->mp_content_after);
+        }
     }
     break;