From ac0fca508e591afcc37ee6d97af485618ea95486 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Thu, 7 Apr 2022 04:09:22 +0000 Subject: [PATCH] WIP read_mime_data FossilOrigin-Name: 96027a35fddcf99ed6f9ec4249178aa15a5325b2a1c7be94e5a44769b0d146d9 --- src/mime.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mime.c b/src/mime.c index 6f9e358..ec6676c 100644 --- a/src/mime.c +++ b/src/mime.c @@ -59,3 +59,19 @@ error: free(content_type); return 1; } + +/* TODO Write a function like strchr but it checks a non-whitespace character */ + +char* read_mime_data(char* boundary, char* begin, struct http_mime_info* info) +{ + char* begin_header; + size_t bound_len = strlen(boundary); + if (strncmp(begin, "--", 2) != 0 || + strncmp(begin+2, boundary, bound_len) != 0) + return NULL; + + begin_header = begin + 2 + bound+len + 2; /* Skip over LRSF */ + + if (strncmp(begin_header, "content-disposition", sizeof("content-disposition")) != 0) + return NULL; +}