Mstdlib-1.24.0
|
Data Structures | |
struct | M_email_reader_callbacks |
Typedefs | |
typedef struct M_email_reader | M_email_reader_t |
typedef M_email_error_t(* | M_email_reader_header_func) (const char *key, const char *val, void *thunk) |
typedef M_email_error_t(* | M_email_reader_to_func) (const char *group, const char *name, const char *address, void *thunk) |
typedef M_email_error_t(* | M_email_reader_from_func) (const char *group, const char *name, const char *address, void *thunk) |
typedef M_email_error_t(* | M_email_reader_cc_func) (const char *group, const char *name, const char *address, void *thunk) |
typedef M_email_error_t(* | M_email_reader_bcc_func) (const char *group, const char *name, const char *address, void *thunk) |
typedef M_email_error_t(* | M_email_reader_reply_to_func) (const char *group, const char *name, const char *address, void *thunk) |
typedef M_email_error_t(* | M_email_reader_subject_func) (const char *subject, void *thunk) |
typedef M_email_error_t(* | M_email_reader_header_done_func) (M_email_data_format_t format, void *thunk) |
typedef M_email_error_t(* | M_email_reader_body_func) (const char *data, size_t len, void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_preamble_func) (const char *data, size_t len, void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_preamble_done_func) (void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_header_func) (const char *key, const char *val, size_t idx, void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_header_attachment_func) (const char *content_type, const char *transfer_encoding, const char *filename, size_t idx, void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_header_done_func) (size_t idx, void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_data_func) (const char *data, size_t len, size_t idx, void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_data_done_func) (size_t idx, void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_data_finished_func) (void *thunk) |
typedef M_email_error_t(* | M_email_reader_multipart_epilouge_func) (const char *data, size_t len, void *thunk) |
Enumerations | |
enum | M_email_reader_flags_t { M_EMAIL_READER_NONE = 0 } |
Functions | |
M_email_reader_t * | M_email_reader_create (struct M_email_reader_callbacks *cbs, M_uint32 flags, void *thunk) |
void | M_email_reader_destroy (M_email_reader_t *emailr) |
M_email_error_t | M_email_reader_read (M_email_reader_t *emailr, const char *data, size_t data_len, size_t *len_read) |
Stream reader used for parsing using callbacks. Very useful for large Email messages.
struct M_email_reader_callbacks |
Callbacks for various stages of parsing.
Data Fields | ||
---|---|---|
M_email_reader_header_func | header_func | |
M_email_reader_to_func | to_func | |
M_email_reader_from_func | from_func | |
M_email_reader_cc_func | cc_func | |
M_email_reader_bcc_func | bcc_func | |
M_email_reader_reply_to_func | reply_to_func | |
M_email_reader_subject_func | subject_func | |
M_email_reader_header_done_func | header_done_func | |
M_email_reader_body_func | body_func | |
M_email_reader_multipart_preamble_func | multipart_preamble_func | |
M_email_reader_multipart_preamble_done_func | multipart_preamble_done_func | |
M_email_reader_multipart_header_func | multipart_header_func | |
M_email_reader_multipart_header_attachment_func | multipart_header_attachment_func | |
M_email_reader_multipart_header_done_func | multipart_header_done_func | |
M_email_reader_multipart_data_func | multipart_data_func | |
M_email_reader_multipart_data_done_func | multipart_data_done_func | |
M_email_reader_multipart_data_finished_func | multipart_data_finished_func | |
M_email_reader_multipart_epilouge_func | multipart_epilouge_func |
typedef struct M_email_reader M_email_reader_t |
typedef M_email_error_t(* M_email_reader_header_func) (const char *key, const char *val, void *thunk) |
Function definition for reading headers.
This will provide the full unparsed header. This is always called for every header. It may be called multiple times if a header appears multiple times.
All headers will trigger this function including ones that have their own dedicated callbacks. If headers are handled in their resistive dedicated callback, they should be checked for and ignored when this callback is called.
A header appearing multiple times here means it was present multiple times.
[in] | key | Header key. |
[in] | val | Header value. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_to_func) (const char *group, const char *name, const char *address, void *thunk) |
Function definition for To recipients
This will be called for every address that appears as a To recipient. A group with no listed recipients can also be received. If address only is desired then address should be checked if empty before processing.
Data combinations that could be passed as parameters:
[in] | group | Email group. |
[in] | name | Pretty name of recipient. |
[in] | address | Email address of recipient. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_from_func) (const char *group, const char *name, const char *address, void *thunk) |
Function definition for From sender
Data combinations that could be passed as parameters:
[in] | group | Email group. |
[in] | name | Pretty name of recipient. |
[in] | address | Email address of recipient. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_cc_func) (const char *group, const char *name, const char *address, void *thunk) |
Function definition for CC recipients
This will be called for every address that appears as a CC recipient. A group with no listed recipients can also be received. If address only is desired then address should be checked if empty before processing.
Data combinations that could be passed as parameters:
[in] | group | Email group. |
[in] | name | Pretty name of recipient. |
[in] | address | Email address of recipient. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_bcc_func) (const char *group, const char *name, const char *address, void *thunk) |
Function definition for BCC recipients
This will be called for every address that appears as a BCC recipient. A group with no listed recipients can also be received. If address only is desired then address should be checked if empty before processing.
Data combinations that could be passed as parameters:
[in] | group | Email group. |
[in] | name | Pretty name of recipient. |
[in] | address | Email address of recipient. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_reply_to_func) (const char *group, const char *name, const char *address, void *thunk) |
Function definition for Reply-To address
Data combinations that could be passed as parameters:
[in] | group | Email group. |
[in] | name | Pretty name of recipient. |
[in] | address | Email address of recipient. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_subject_func) (const char *subject, void *thunk) |
Function definition for the email Subject
[in] | subject | The subject. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_header_done_func) (M_email_data_format_t format, void *thunk) |
Function definition for header parsing completion.
[in] | format | The format data was sent using. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_body_func) (const char *data, size_t len, void *thunk) |
Function definition for reading body data.
[in] | data | Data. |
[in] | len | Length of data. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_preamble_func) (const char *data, size_t len, void *thunk) |
Function definition for reading multipart preamble.
Typically the preamble should be ignored if present.
[in] | data | Data. |
[in] | len | Length of data. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_preamble_done_func) (void *thunk) |
Function definition for completion of multipart preamble parsing.
Only called if a preamble was present.
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_header_func) (const char *key, const char *val, size_t idx, void *thunk) |
Function definition for reading multi part headers.
This will provide the full unparsed header. This is always called for every header. It may be called multiple times if a header appears multiple times. This is intended for informational use or if passing along data and not altering any headers in the process.
A header appearing multiple times here means it was present multiple times.
[in] | key | Header key. |
[in] | val | Header value. |
[in] | idx | Part number the header belongs to. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_header_attachment_func) (const char *content_type, const char *transfer_encoding, const char *filename, size_t idx, void *thunk) |
Function definition for multipart attachment meta data.
Will only be called when a part is marked as an attachment. Will be called immediately before M_email_reader_multipart_header_done_func.
[in] | content_type | The content type. |
[in] | transfer_encoding | The format the data was received in. E.g. Base64, clear text, ext.. |
[in] | filename | The filename of the attachment. |
[in] | idx | Part number. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_header_done_func) (size_t idx, void *thunk) |
Function definition for completion of multipart part header parsing.
[in] | idx | Part number. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_data_func) (const char *data, size_t len, size_t idx, void *thunk) |
Function definition for reading multipart part data.
[in] | data | Data. |
[in] | len | Length of data. |
[in] | idx | Partnumber the data belongs to. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_data_done_func) (size_t idx, void *thunk) |
Function definition for completion of multipart part data.
[in] | idx | Chunk number that has been completely processed. |
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_data_finished_func) (void *thunk) |
Function definition for completion of parsing all multipart parts.
Only called when data is chunked.
[in] | thunk | Thunk. |
typedef M_email_error_t(* M_email_reader_multipart_epilouge_func) (const char *data, size_t len, void *thunk) |
Function definition for completion of multipart epilogue parsing.
Only called if a epilogue was present.
[in] | data | Data. |
[in] | len | Length of data. |
[in] | thunk | Thunk. |
M_email_reader_t * M_email_reader_create | ( | struct M_email_reader_callbacks * | cbs, |
M_uint32 | flags, | ||
void * | thunk | ||
) |
Create an email reader object.
[in] | cbs | Callbacks for processing. |
[in] | flags | Flags controlling behavior. |
[in] | thunk | Thunk passed to callbacks. |
void M_email_reader_destroy | ( | M_email_reader_t * | emailr | ) |
Destroy an email object.
[in] | emailr | email reader object. |
M_email_error_t M_email_reader_read | ( | M_email_reader_t * | emailr, |
const char * | data, | ||
size_t | data_len, | ||
size_t * | len_read | ||
) |
Parse email email from given data.
When a parse returns without error but a full email has not been read, the parse should be run again starting where the last parse stopped. The reader can only be used once per complete email.
Will not return M_EMAIL_ERROR_MOREDATA. It is up to the caller to determine when a full email has been read based on the callbacks that have been called. The _done callbacks can indicate if all processing has completed. If the email is not multipart it is impossible to determine if a parse is complete.
[in] | emailr | email reader object. |
[in] | data | Data to parse. |
[in] | data_len | Length of data. |
[out] | len_read | How much data was read. |