MIME handling functions.
More...
#include <qremote/mime.h>
#include <mime_chars.h>
#include <netio.h>
#include <qremote/qrdata.h>
#include <qremote/qremote.h>
#include <sstring.h>
#include <assert.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
off_t find_boundary |
( |
const char * |
buf, |
|
|
const off_t |
len, |
|
|
const cstring * |
boundary |
|
) |
| |
find next mime boundary
- Parameters
-
buf | buffer to scan |
len | length of buffer |
boundary | boundary limit string |
- Returns
- offset of first character behind next boundary
- Return values
-
size_t getfieldlen |
( |
const char * |
msg, |
|
|
const size_t |
len |
|
) |
| |
get length of a MIME header field, even if it is folded
- Parameters
-
msg | message data to scan |
len | length of data |
- Returns
- length of header field
- Return values
-
0 | if field does not end until end of data |
scan "Content-Type" header line and check if type is multipart/(*)
- Parameters
-
line | header field |
boundary | reference to boundary is stored here |
- Return values
-
1 | line contains multipart/(*) declaration |
0 | other type |
-1 | syntax error |
static size_t mime_param |
( |
const char * |
line, |
|
|
const size_t |
len |
|
) |
| |
|
static |
get length of MIME header parameter
- Parameters
-
line | header line to scan |
len | length of line |
- Returns
- length of parameter
- Return values
-
static size_t mime_token |
( |
const char * |
line, |
|
|
const size_t |
len |
|
) |
| |
|
static |
get length of MIME header token as defined in RfC 2045, section 5.1
- Parameters
-
line | header line to scan |
len | length of line |
- Returns
- length of parameter
- Return values
-
const char* skipwhitespace |
( |
const char * |
line, |
|
|
const size_t |
len |
|
) |
| |
skip whitespaces in header line
- Parameters
-
line | header field |
len | length of data, must be > 0 |
- Returns
- pointer to first character after whitespace
- Return values
-
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