Qsmtp
0.37
|
functions for parsing MIME messages More...
Go to the source code of this file.
Functions | |
const char * | skipwhitespace (const char *line, const size_t len) |
int | is_multipart (const cstring *, cstring *) |
size_t | getfieldlen (const char *, const size_t) |
off_t | find_boundary (const char *, const off_t, const cstring *) |
functions for parsing MIME messages
off_t find_boundary | ( | const char * | buf, |
const off_t | len, | ||
const cstring * | boundary | ||
) |
find next mime boundary
buf | buffer to scan |
len | length of buffer |
boundary | boundary limit string |
0 | no boundary found |
size_t getfieldlen | ( | const char * | msg, |
const size_t | len | ||
) |
get length of a MIME header field, even if it is folded
msg | message data to scan |
len | length of data |
0 | if field does not end until end of data |
scan "Content-Type" header line and check if type is multipart/(*)
line | header field |
boundary | reference to boundary is stored here |
1 | line contains multipart/(*) declaration |
0 | other type |
-1 | syntax error |
The passed line must start with the "Content-Type:" string, i.e. the whole header line must be passed, or it must be empty, i.e len==0.
initial text to skip over
const char* skipwhitespace | ( | const char * | line, |
const size_t | len | ||
) |
skip whitespaces in header line
line | header field |
len | length of data, must be > 0 |
NULL | syntax error (e.g. unfinished comment) |
This function skips whitespace and comments from the current position. If a newline is encountered before a non-whitespace and non-comment character it is also skipped, including all following whitespace.
If it returns (line + len) everything from line until end of data block is a comment
line has to be a valid (but unparsed) and may be a folded header line. For this it has to meet this constraints: -it has to end with CR, LF or CRLF -it may have CR, LF or CRLF in the middle, but this has to be directly followed by either SPACE or TAB