Qsmtp  0.30dev
Functions
mime.h File Reference

functions for parsing MIME messages More...

#include "qrdata.h"
#include <sstring.h>
#include <sys/types.h>

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 *)
 

Detailed Description

functions for parsing MIME messages

Function Documentation

off_t find_boundary ( const char *  buf,
const off_t  len,
const cstring boundary 
)

find next mime boundary

Parameters
bufbuffer to scan
lenlength of buffer
boundaryboundary limit string
Returns
offset of first character behind next boundary
Return values
0no boundary found
size_t getfieldlen ( const char *  msg,
const size_t  len 
)

get length of a MIME header field, even if it is folded

Parameters
msgmessage data to scan
lenlength of data
Returns
length of header field
Return values
0if field does not end until end of data
int is_multipart ( const cstring line,
cstring boundary 
)

scan "Content-Type" header line and check if type is multipart/(*)

Parameters
lineheader field
boundaryreference to boundary is stored here
Return values
1line contains multipart/(*) declaration
0other type
-1syntax error
const char* skipwhitespace ( const char *  line,
const size_t  len 
)

skip whitespaces in header line

Parameters
lineheader field
lenlength of data, must be > 0
Returns
pointer to first character after whitespace
Return values
NULLsyntax 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