diff options
-rw-r--r-- | blaze822.h | 1 | ||||
-rw-r--r-- | rfc2045.c | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/blaze822.h b/blaze822.h index a2ee6c2..0d3d60b 100644 --- a/blaze822.h +++ b/blaze822.h @@ -37,3 +37,4 @@ int blaze822_decode_b64(char *start, char *stop, char **deco, size_t *decleno); int blaze822_check_mime(struct message *msg); int blaze822_mime_body(struct message *msg, char **cto, char **bodyo, size_t *bodyleno, char **bodychunko); int blaze822_multipart(struct message *msg, struct message **imsg); +int blaze822_mime_parameter(char *s, char *name, char **starto, char **stopo); diff --git a/rfc2045.c b/rfc2045.c index c34d03f..881bd5f 100644 --- a/rfc2045.c +++ b/rfc2045.c @@ -59,6 +59,47 @@ blaze822_mime_body(struct message *msg, } int +blaze822_mime_parameter(char *s, char *name, char **starto, char **stopo) +{ + s = strchr(s, ';'); + if (!s) + return 0; + s++; + + size_t namelen = strlen(name); + + while (*s) { + while (iswsp(*s)) + s++; + if (strncasecmp(s, name, namelen) == 0 && s[namelen] == '=') { + s += namelen + 1; + break; + } + s = strchr(s+1, ';'); + if (!s) + return 0; + s++; + } + if (!s || !*s) + return 0; + char *e; + if (*s == '"') { + s++; + e = strchr(s, '"'); + if (!e) + return 0; + } else { + e = s; + while (*e && !iswsp(*e) && *e != ';') + e++; + } + + *starto = s; + *stopo = e; + return 1; +} + +int blaze822_multipart(struct message *msg, struct message **imsg) { char *s = blaze822_hdr(msg, "content-type"); |