25 #ifndef MIME_DECODE_H_ 26 #define MIME_DECODE_H_ 39 #define CTNT_IS_ENCAP 4 40 #define CTNT_IS_BODYPART 8 41 #define CTNT_IS_MULTIPART 16 42 #define CTNT_IS_ATTACHMENT 32 43 #define CTNT_IS_BASE64 64 44 #define CTNT_IS_QP 128 45 #define CTNT_IS_TEXT 256 46 #define CTNT_IS_HTML 512 54 #define ANOM_INVALID_BASE64 1 55 #define ANOM_INVALID_QP 2 56 #define ANOM_LONG_HEADER_NAME 4 57 #define ANOM_LONG_HEADER_VALUE 8 59 #define ANOM_LONG_LINE 16 60 #define ANOM_LONG_ENC_LINE 32 61 #define ANOM_MALFORMED_MSG 64 62 #define ANOM_LONG_BOUNDARY 128 65 #define DATA_CHUNK_SIZE 3072 66 #define LINEREM_SIZE 256 69 #define HEADER_READY 0x01 70 #define HEADER_STARTED 0x02 71 #define HEADER_DONE 0x03 72 #define BODY_STARTED 0x04 73 #define BODY_DONE 0x05 74 #define BODY_END_BOUND 0x06 75 #define PARSE_DONE 0x07 76 #define PARSE_ERROR 0x08 200 HASHContext *md5_ctx;
201 uint8_t md5[MD5_LENGTH];
210 int (*DataChunkProcessorFunc) (
const uint8_t *chunk, uint32_t
len,
244 int MimeParserDataFromFile(
char *filename);
struct MimeDecField MimeDecField
This represents a header field name and associated value.
MimeDecField * field_list
Structure for containing configuration options.
int MimeDecFindFieldsForEach(const MimeDecEntity *entity, const char *name, int(*DataCallback)(const uint8_t *val, const size_t, void *data), void *data)
Searches for header fields with the specified name.
struct DataValue DataValue
Structure contains a list of value and lengths for robust data processing.
struct MimeDecField * next
uint32_t decoded_body_len
void MimeDecFreeUrl(MimeDecUrl *url)
Iteratively frees a URL entry list.
const char * MimeDecParseStateGetStatus(MimeDecParseState *state)
uint8_t current_line_delimiter_len
void MimeDecFreeEntity(MimeDecEntity *entity)
Frees a mime entity tree.
struct MimeDecUrl MimeDecUrl
This represents a URL value node in a linked list.
struct MimeDecStackNode MimeDecStackNode
Structure contains boundary and entity for the current node (entity) in the stack.
MimeDecField * MimeDecFindField(const MimeDecEntity *entity, const char *name)
Searches for a header field with the specified name.
void MimeDecDeInitParser(MimeDecParseState *state)
De-Init parser by freeing up any residual memory.
MimeDecConfig * MimeDecGetConfig(void)
Get global config policy.
MimeDecEntity * MimeDecParseFullMsg(const uint8_t *buf, uint32_t blen, void *data, int(*DataChunkProcessorFunc)(const uint8_t *chunk, uint32_t len, MimeDecParseState *state))
Parses an entire message when available in its entirety (wraps the line-based parsing functions) ...
This represents the MIME Entity (or also top level message) in a child-sibling tree.
Structure contains a list of value and lengths for robust data processing.
int decode_quoted_printable
MimeDecField * MimeDecAddField(MimeDecEntity *entity)
Creates and adds a header field entry to an entity.
void MimeDecSetConfig(MimeDecConfig *config)
Set global config policy.
struct MimeDecEntity * child
struct MimeDecStackNode * next
void MimeDecRegisterTests(void)
int MimeDecParseLine(const uint8_t *line, const uint32_t len, const uint8_t delim_len, MimeDecParseState *state)
Parse a line of a MIME message and update the parser state.
MimeDecEntity * MimeDecAddEntity(MimeDecEntity *parent)
Creates and adds a child entity to the specified parent entity.
void MimeDecFreeField(MimeDecField *field)
Iteratively frees a header field entry list.
MimeDecStackNode * free_nodes
Structure contains boundary and entity for the current node (entity) in the stack.
MimeDecRetCode
Mime Decoder Error Codes.
int MimeDecParseComplete(MimeDecParseState *state)
Called to indicate that the last message line has been processed and the parsing operation is complet...
struct MimeDecConfig MimeDecConfig
Structure for containing configuration options.
struct MimeDecEntity MimeDecEntity
This represents the MIME Entity (or also top level message) in a child-sibling tree.
struct MimeDecParseState MimeDecParseState
Structure contains the current state of the MIME parser.
uint32_t header_value_depth
Structure holds the top of the stack along with some free reusable nodes.
MimeDecParseState * MimeDecInitParser(void *data, int(*dcpfunc)(const uint8_t *chunk, uint32_t len, MimeDecParseState *state))
Init the parser by allocating memory for the state and top-level entity.
struct MimeDecStack MimeDecStack
Structure holds the top of the stack along with some free reusable nodes.
Structure contains the current state of the MIME parser.
int(* DataChunkProcessorFunc)(const uint8_t *chunk, uint32_t len, struct MimeDecParseState *state)
This represents a header field name and associated value.
This represents a URL value node in a linked list.
struct MimeDecEntity * next