From 4d35c86401b4a947689eac375ec4ba29b3c99d6d Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 19 Apr 2020 11:27:26 -0400 Subject: Use template system for paths and URLs This probably still needs a lot of cleaning up. --- decode.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'decode.c') diff --git a/decode.c b/decode.c index 35e6dfd..2604f73 100644 --- a/decode.c +++ b/decode.c @@ -244,25 +244,15 @@ char *decodeHeader(const char *header) { return bufferString(&buf); } -static const char *partCharset(const struct BodyPart *part) { - const char *charset = NULL; - for (size_t i = 0; i + 1 < part->params.len; i += 2) { - const char *key = dataCheck(part->params.ptr[i], String).string; - if (strcasecmp(key, "charset")) continue; - charset = dataCheck(part->params.ptr[i + 1], String).string; - } - return charset; -} - char *decodeToString(const struct BodyPart *part, const char *src) { struct Buffer dst = bufferAlloc(strlen(src) + 1); - decode(&dst, part->encoding, partCharset(part), src); + decode(&dst, part->encoding, paramGet(part->params, "charset"), src); return bufferString(&dst); } int decodeToFile(FILE *file, const struct BodyPart *part, const char *src) { struct Buffer dst = bufferAlloc(strlen(src)); - decode(&dst, part->encoding, partCharset(part), src); + decode(&dst, part->encoding, paramGet(part->params, "charset"), src); size_t n = fwrite(dst.ptr, dst.len, 1, file); free(dst.ptr); return (n ? 0 : -1); -- cgit 1.4.1