about summary refs log tree commit diff
path: root/decode.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-19 11:27:26 -0400
committerJune McEnroe <june@causal.agency>2020-04-20 11:17:56 -0400
commit4d35c86401b4a947689eac375ec4ba29b3c99d6d (patch)
tree70b71841a1114c88f4d4c0bea0e645ff3b301ca7 /decode.c
parentSkip leading whitespace in message IDs (diff)
downloadbubger-4d35c86401b4a947689eac375ec4ba29b3c99d6d.tar.gz
bubger-4d35c86401b4a947689eac375ec4ba29b3c99d6d.zip
Use template system for paths and URLs
This probably still needs a lot of cleaning up.
Diffstat (limited to 'decode.c')
-rw-r--r--decode.c14
1 files changed, 2 insertions, 12 deletions
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);