]> diplodocus.org Git - nmh/blobdiff - uip/mhoutsbr.c
A new test for longer lines.
[nmh] / uip / mhoutsbr.c
index 246d99b49d16d4b8c28af362d0929dfb3330a710..7c3cbe99285a6cf3fa873ddecafb4c97a44fe87d 100644 (file)
@@ -12,7 +12,6 @@
 #include <fcntl.h>
 #include <h/signals.h>
 #include <h/md5.h>
-#include <signal.h>
 #include <h/mts.h>
 #include <h/tws.h>
 #include <h/mime.h>
@@ -82,11 +81,12 @@ output_content (CT ct, FILE *out)
 {
     int result = 0;
     CI ci = &ct->c_ctinfo;
-    char *boundary = ci->ci_values[0], **ap, **vp;
+    PM pm;
+    char *boundary = "";
 
-    for (ap = ci->ci_attrs, vp = ci->ci_values; *ap; ++ap, ++vp) {
-        if (! strcasecmp ("boundary", *ap)) {
-            boundary = *vp;
+    for (pm = ci->ci_first_pm; pm; pm = pm->pm_next) {
+        if (! strcasecmp ("boundary", pm->pm_name)) {
+            boundary = pm->pm_value;
             break;
         }
     }
@@ -164,7 +164,7 @@ output_content (CT ct, FILE *out)
               body, don't emit the newline that would appear between
               the headers and body.  In that case, the call to
               write8Bit() shouldn't be needed, but is harmless. */
-           if (ct->c_ctinfo.ci_attrs[0] != NULL  ||
+           if (ct->c_ctinfo.ci_first_pm != NULL  ||
                ct->c_begin != ct->c_end) {
                putc ('\n', out);
            }
@@ -227,7 +227,8 @@ output_headers (CT ct, FILE *out)
 static int
 writeExternalBody (CT ct, FILE *out)
 {
-    char **ap, **ep, *cp;
+    char *cp;
+    PM pm;
     struct exbody *e = (struct exbody *) ct->c_ctparams;
                
     putc ('\n', out);
@@ -247,17 +248,17 @@ writeExternalBody (CT ct, FILE *out)
                continue;
 
            case 'N':
-               for (ap = ci2->ci_attrs, ep = ci2->ci_values; *ap; ap++, ep++)
-                   if (!strcasecmp (*ap, "name")) {
-                       fprintf (out, "%s", *ep);
+               for (pm = ci2->ci_first_pm; pm; pm = pm->pm_next)
+                   if (!strcasecmp (pm->pm_name, "name")) {
+                       fprintf (out, "%s", pm->pm_value);
                        break;
                    }
                continue;
 
            case 'T':
                fprintf (out, "%s/%s", ci2->ci_type, ci2->ci_subtype);
-               for (ap = ci2->ci_attrs, ep = ci2->ci_values; *ap; ap++, ep++)
-                   fprintf (out, "; %s=\"%s\"", *ap, *ep);
+               for (pm = ci2->ci_first_pm; pm; pm = pm->pm_next)
+                   fprintf (out, "; %s=\"%s\"", pm->pm_name, pm->pm_value);
                continue;
 
            case 'n':
@@ -327,15 +328,15 @@ writeQuoted (CT ct, FILE *out)
 {
     int fd;
     char *cp, *file;
-    char c, buffer[BUFSIZ];
+    char c = '\0', buffer[BUFSIZ];
     CE ce = &ct->c_cefile;
+    int n = 0;
 
     file = NULL;
     if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
        return NOTOK;
 
     while (fgets (buffer, sizeof(buffer) - 1, ce->ce_fp)) {
-       int n;
 
        cp = buffer + strlen (buffer) - 1;
        if ((c = *cp) == '\n')
@@ -343,10 +344,9 @@ writeQuoted (CT ct, FILE *out)
 
        if (strncmp (cp = buffer, "From ", sizeof("From ") - 1) == 0) {
            fprintf (out, "=%02X", *cp++ & 0xff);
-           n = 3;
-       } else {
-           n = 0;
+           n += 3;
        }
+
        for (; *cp; cp++) {
            if (n > CPERLIN - 3) {
                fputs ("=\n", out);
@@ -380,11 +380,13 @@ three_print:
                fputs ("=\n", out);
 
            putc ('\n', out);
-       } else {
-           fputs ("=\n", out);
+           n = 0;
        }
     }
 
+    if (c != '\n')
+       putc ('\n', out);
+
     (*ct->c_ceclosefnx) (ct);
     return OK;
 }
@@ -405,7 +407,7 @@ writeBase64ct (CT ct, FILE *out)
     if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
        return NOTOK;
 
-    result = writeBase64aux (ce->ce_fp, out);
+    result = writeBase64aux (ce->ce_fp, out, (ct->c_type == CT_TEXT));
     (*ct->c_ceclosefnx) (ct);
     return result;
 }