rfc2045: add blaze822_mime_parameter

pull/1/merge
Christian Neukirchen 8 years ago
parent d1e4b5f503
commit 248ed48727

@ -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);

@ -58,6 +58,47 @@ blaze822_mime_body(struct message *msg,
return 1;
}
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)
{

Loading…
Cancel
Save