X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/3dccb685fb1b879e8910e8732e748b22e7ff8dc7..683e0fb1a14da5b9ce7bc5db6e76951d14d79348:/uip/mhparse.c diff --git a/uip/mhparse.c b/uip/mhparse.c index 25bbad75..f5a5983a 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -46,11 +46,7 @@ struct k2v SubText[] = { { NULL, TEXT_UNKNOWN } /* this one must be last! */ }; -struct k2v Charset[] = { - { "us-ascii", CHARSET_USASCII }, - { "iso-8859-1", CHARSET_LATIN }, - { NULL, CHARSET_UNKNOWN } /* this one must be last! */ -}; +/* Charset[] removed -- yozo. Mon Oct 8 01:03:41 JST 2012 */ /* * Structures for MULTIPART messages @@ -266,6 +262,7 @@ get_content (FILE *in, char *file, int toplevel) char *np, *vp; CT ct; HF hp; + long filepos; /* allocate the content structure */ if (!(ct = (CT) calloc (1, sizeof(*ct)))) @@ -273,18 +270,20 @@ get_content (FILE *in, char *file, int toplevel) ct->c_fp = in; ct->c_file = add (file, NULL); - ct->c_begin = ftell (ct->c_fp) + 1; + ct->c_begin = (filepos = ftell (ct->c_fp)) + 1; /* * Parse the header fields for this * content into a linked list. */ for (compnum = 1, state = FLD;;) { - switch (state = m_getfld (state, name, buf, sizeof(buf), in)) { + int bufsz = sizeof buf; + switch (state = m_getfld (state, name, buf, &bufsz, in)) { case FLD: case FLDPLUS: case FLDEOF: compnum++; + filepos += bufsz; /* get copies of the buffers */ np = add (name, NULL); @@ -292,7 +291,8 @@ get_content (FILE *in, char *file, int toplevel) /* if necessary, get rest of field */ while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof(buf), in); + bufsz = sizeof buf; + state = m_getfld (state, name, buf, &bufsz, in); vp = add (buf, vp); /* add to previous value */ } @@ -301,18 +301,20 @@ get_content (FILE *in, char *file, int toplevel) /* continue, if this isn't the last header field */ if (state != FLDEOF) { - ct->c_begin = ftell (in) + 1; + ct->c_begin = filepos + 1; continue; } /* else fall... */ case BODY: case BODYEOF: - ct->c_begin = ftell (in) - strlen (buf); + filepos += bufsz; + ct->c_begin = filepos - strlen (buf); break; case FILEEOF: - ct->c_begin = ftell (in); + filepos += bufsz; + ct->c_begin = filepos; break; case LENERR: @@ -1077,14 +1079,8 @@ InitText (CT ct) /* check if content specified a character set */ if (*ap) { - /* match character set or set to CHARSET_UNKNOWN */ - for (kv = Charset; kv->kv_key; kv++) { - if (!mh_strcasecmp (*ep, kv->kv_key)) { - chset = *ep; - break; - } - } - t->tx_charset = kv->kv_value; + chset = *ep; + t->tx_charset = CHARSET_SPECIFIED; } else { t->tx_charset = CHARSET_UNSPECIFIED; }