X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fmhparse.c;h=8cfa89980ee9e37d8fee9a61104ab107124f5aaa;hb=492101aee1185135f239b3aabd5b2494f748c931;hp=91cc4116d27a2d1654606b995c71bf4ef8e89e96;hpb=436e6b477fa6dabe40404c84334e148b49682708;p=mmh diff --git a/uip/mhparse.c b/uip/mhparse.c index 91cc411..8cfa899 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -22,8 +22,6 @@ extern int debugsw; -extern int endian; /* mhmisc.c */ - extern pid_t xpid; /* mhshowsbr.c */ /* cache policies */ @@ -48,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 @@ -1079,14 +1073,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; } @@ -1728,8 +1716,8 @@ openBase64 (CT ct, char **file) { int bitno, cc, digested; int fd, len, skip, own_ct_fp = 0; - unsigned long bits; - unsigned char value, *b, *b1, *b2, *b3; + uint32_t bits; + unsigned char value, b; unsigned char *cp, *ep; char buffer[BUFSIZ]; /* sbeck -- handle suffixes */ @@ -1737,16 +1725,6 @@ openBase64 (CT ct, char **file) CE ce; MD5_CTX mdContext; - /* the decoder works on the least-significant three bytes of the bits integer, - but their position in memory depend on both endian-ness and size of - long int... for little-endian architectures the size is irrelevant, for - big-endian archs it's crucial... ideally we'd adopt posix and use a64l instead - of this mess. */ - b = (unsigned char *) &bits; - b1 = &b[endian > 0 ? sizeof(bits)==8?5:1 : 2]; - b2 = &b[endian > 0 ? sizeof(bits)==8?6:2 : 1]; - b3 = &b[endian > 0 ? sizeof(bits)==8?7:3 : 0]; - ce = ct->c_cefile; if (ce->ce_fp) { fseek (ce->ce_fp, 0L, SEEK_SET); @@ -1855,17 +1833,20 @@ openBase64 (CT ct, char **file) bits |= value << bitno; test_end: if ((bitno -= 6) < 0) { - putc ((char) *b1, ce->ce_fp); + b = (bits >> 16) & 0xff; + putc ((char) b, ce->ce_fp); if (digested) - MD5Update (&mdContext, b1, 1); + MD5Update (&mdContext, &b, 1); if (skip < 2) { - putc ((char) *b2, ce->ce_fp); + b = (bits >> 8) & 0xff; + putc ((char) b, ce->ce_fp); if (digested) - MD5Update (&mdContext, b2, 1); + MD5Update (&mdContext, &b, 1); if (skip < 1) { - putc ((char) *b3, ce->ce_fp); + b = bits & 0xff; + putc ((char) b, ce->ce_fp); if (digested) - MD5Update (&mdContext, b3, 1); + MD5Update (&mdContext, &b, 1); } } @@ -2825,20 +2806,9 @@ static int readDigest (CT ct, char *cp) { int bitno, skip; - unsigned long bits; + uint32_t bits; char *bp = cp; unsigned char *dp, value, *ep; - unsigned char *b, *b1, *b2, *b3; - - /* the decoder works on the least-significant three bytes of the bits integer, - but their position in memory depend on both endian-ness and size of - long int... for little-endian architectures the size is irrelevant, for - big-endian archs it's crucial... ideally we'd adopt posix and use a64l instead - of this mess. */ - b = (unsigned char *) &bits; - b1 = &b[endian > 0 ? sizeof(bits)==8?5:1 : 2]; - b2 = &b[endian > 0 ? sizeof(bits)==8?6:2 : 1]; - b3 = &b[endian > 0 ? sizeof(bits)==8?7:3 : 0]; bitno = 18; bits = 0L; @@ -2861,11 +2831,11 @@ test_end: if ((bitno -= 6) < 0) { if (dp + (3 - skip) > ep) goto invalid_digest; - *dp++ = *b1; + *dp++ = (bits >> 16) & 0xff; if (skip < 2) { - *dp++ = *b2; + *dp++ = (bits >> 8) & 0xff; if (skip < 1) - *dp++ = *b3; + *dp++ = bits & 0xff; } bitno = 18; bits = 0L;