X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/859d1e1a78f6c61a062bfb534652f5ce3ffb672f..2e1fefc99cc267b1eba7484f740d8bee7c2f59fb:/uip/mhbuildsbr.c diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 121978d7..e4499170 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -19,8 +19,6 @@ #include #include #include -#include -#include #include #include #include @@ -71,11 +69,6 @@ int find_cache (CT, int, int *, char *, char *, int); void free_ctinfo (CT); void free_encoding (CT, int); -/* - * prototypes - */ -CT build_mime (char *, int); - /* * static prototypes */ @@ -130,7 +123,7 @@ static void directive_pop(void) */ CT -build_mime (char *infile, int directives) +build_mime (char *infile, int directives, int header_encoding) { int compnum, state; char buf[BUFSIZ], name[NAMESZ]; @@ -139,6 +132,7 @@ build_mime (char *infile, int directives) struct part **pp; CT ct; FILE *in; + HF hp; m_getfld_state_t gstate = 0; directive_init(directives); @@ -176,15 +170,15 @@ build_mime (char *infile, int directives) compnum++; /* abort if draft has Mime-Version header field */ - if (!mh_strcasecmp (name, VRSN_FIELD)) + if (!strcasecmp (name, VRSN_FIELD)) adios (NULL, "draft shouldn't contain %s: field", VRSN_FIELD); /* abort if draft has Content-Transfer-Encoding header field */ - if (!mh_strcasecmp (name, ENCODING_FIELD)) + if (!strcasecmp (name, ENCODING_FIELD)) adios (NULL, "draft shouldn't contain %s: field", ENCODING_FIELD); /* ignore any Content-Type fields in the header */ - if (!mh_strcasecmp (name, TYPE_FIELD)) { + if (!strcasecmp (name, TYPE_FIELD)) { while (state == FLDPLUS) { bufsz = sizeof buf; state = m_getfld (&gstate, name, buf, &bufsz, in); @@ -229,6 +223,17 @@ finish_field: } m_getfld_state_destroy (&gstate); + /* + * Iterate through the list of headers and call the function to MIME-ify + * them if required. + */ + + for (hp = ct->c_first_hf; hp != NULL; hp = hp->next) { + if (encode_rfc2047(hp->name, &hp->value, header_encoding, NULL)) { + adios(NULL, "Unable to encode header \"%s\"", hp->name); + } + } + /* * Now add the MIME-Version header field * to the list of header fields. @@ -541,7 +546,7 @@ rock_and_roll: done (1); for (s2i = str2cts; s2i->si_key; s2i++) - if (!mh_strcasecmp (ci->ci_type, s2i->si_key)) + if (!strcasecmp (ci->ci_type, s2i->si_key)) break; if (!s2i->si_key && !uprf (ci->ci_type, "X-")) s2i++; @@ -551,7 +556,7 @@ rock_and_roll: */ switch (ct->c_type = s2i->si_val) { case CT_MESSAGE: - if (!mh_strcasecmp (ci->ci_subtype, "rfc822")) { + if (!strcasecmp (ci->ci_subtype, "rfc822")) { ct->c_encoding = CE_7BIT; goto call_init; } @@ -587,7 +592,7 @@ call_init: /* check directive against the list of MIME types */ for (s2i = str2cts; s2i->si_key; s2i++) - if (!mh_strcasecmp (ci->ci_type, s2i->si_key)) + if (!strcasecmp (ci->ci_type, s2i->si_key)) break; /* @@ -608,10 +613,10 @@ call_init: /* NOTREACHED */ case CT_MESSAGE: - if (!mh_strcasecmp (ci->ci_subtype, "partial")) + if (!strcasecmp (ci->ci_subtype, "partial")) adios (NULL, "sorry, \"#%s/%s\" isn't supported", ci->ci_type, ci->ci_subtype); - if (!mh_strcasecmp (ci->ci_subtype, "external-body")) + if (!strcasecmp (ci->ci_subtype, "external-body")) adios (NULL, "use \"#@type/subtype ... [] ...\" instead of \"#%s/%s\"", ci->ci_type, ci->ci_subtype); use_forw: @@ -718,7 +723,7 @@ use_forw: * Message directive * #forw [+folder] [msgs] */ - if (!mh_strcasecmp (ci->ci_type, "forw")) { + if (!strcasecmp (ci->ci_type, "forw")) { int msgnum; char *folder, *arguments[MAXARGS]; struct msgs *mp; @@ -747,7 +752,7 @@ use_forw: if (!folder) folder = add (getfolder (1), NULL); - if (!(mp = folder_read (folder))) + if (!(mp = folder_read (folder, 0))) adios (NULL, "unable to read folder %s", folder); for (ap = arguments; *ap; ap++) { cp = *ap; @@ -824,7 +829,7 @@ use_forw: /* * #end */ - if (!mh_strcasecmp (ci->ci_type, "end")) { + if (!strcasecmp (ci->ci_type, "end")) { free_content (ct); *ctp = NULL; return DONE; @@ -833,14 +838,14 @@ use_forw: /* * #begin [ alternative | parallel ] */ - if (!mh_strcasecmp (ci->ci_type, "begin")) { + if (!strcasecmp (ci->ci_type, "begin")) { if (!ci->ci_magic) { vrsn = MULTI_MIXED; cp = SubMultiPart[vrsn - 1].kv_key; - } else if (!mh_strcasecmp (ci->ci_magic, "alternative")) { + } else if (!strcasecmp (ci->ci_magic, "alternative")) { vrsn = MULTI_ALTERNATE; cp = SubMultiPart[vrsn - 1].kv_key; - } else if (!mh_strcasecmp (ci->ci_magic, "parallel")) { + } else if (!strcasecmp (ci->ci_magic, "parallel")) { vrsn = MULTI_PARALLEL; cp = SubMultiPart[vrsn - 1].kv_key; } else if (uprf (ci->ci_magic, "digest")) { @@ -1410,7 +1415,7 @@ build_headers (CT ct) * the end of the Content-Type line. */ for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { - if (mailbody && !mh_strcasecmp (*ap, "body")) + if (mailbody && !strcasecmp (*ap, "body")) continue; vp = add (";", vp); @@ -1421,7 +1426,7 @@ build_headers (CT ct) * we have to break it across multiple lines */ - if (extbody && mh_strcasecmp (*ap, "url") == 0) { + if (extbody && strcasecmp (*ap, "url") == 0) { char *value = *ep; /* 7 here refers to " url=\"\"" */