X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/b5f3b7451e01f3dc9fe144b2706fc2aae1e0546c..10fafb48f4d247e86cc499bf220367c651f67637:/uip/mhoutsbr.c diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index db64c4b8..7c3cbe99 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include #include #include @@ -83,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 (! mh_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; } } @@ -165,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); } @@ -228,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); @@ -248,17 +248,17 @@ writeExternalBody (CT ct, FILE *out) continue; case 'N': - for (ap = ci2->ci_attrs, ep = ci2->ci_values; *ap; ap++, ep++) - if (!mh_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': @@ -300,7 +300,7 @@ write8Bit (CT ct, FILE *out) int fd; size_t inbytes; char c, *file, buffer[BUFSIZ]; - CE ce = ct->c_cefile; + CE ce = &ct->c_cefile; file = NULL; if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK) @@ -328,15 +328,15 @@ writeQuoted (CT ct, FILE *out) { int fd; char *cp, *file; - char c, buffer[BUFSIZ]; - CE ce = ct->c_cefile; + 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') @@ -344,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); @@ -381,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; } @@ -400,13 +401,13 @@ writeBase64ct (CT ct, FILE *out) { int fd, result; char *file; - CE ce = ct->c_cefile; + CE ce = &ct->c_cefile; file = NULL; 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; }