diff options
| author | zhuzhenjun <[email protected]> | 2024-11-18 10:19:53 +0000 |
|---|---|---|
| committer | zhuzhenjun <[email protected]> | 2024-11-18 10:20:14 +0000 |
| commit | 185a61e8aa06e0f9f4e561947af43c86940babf1 (patch) | |
| tree | b5334138897ded709196ce391785ee54f3e27138 /include | |
| parent | d0a868591470a4a9d71a65a5d540058e72c8d92c (diff) | |
mail decoder refactoringdev-mail-refactoring-back
Diffstat (limited to 'include')
| -rw-r--r-- | include/stellar/mail.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/include/stellar/mail.h b/include/stellar/mail.h new file mode 100644 index 0000000..a7e8a27 --- /dev/null +++ b/include/stellar/mail.h @@ -0,0 +1,96 @@ +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include <stddef.h> +#include <stdint.h> + +#include "stellar/session.h" +#include "stellar/module.h" + +#define MAIL_MODULE_NAME "MAIL_MODULE" + +enum MAIL_COMMAND { + MAIL_CMD_USERNAME, + MAIL_CMD_PASSWORD, + MAIL_CMD_STARTTLS, + MAIL_CMD_MAIL_FROM, + MAIL_CMD_RCPT_TO, + MAIL_CMD_EHLO, + MAIL_CMD_OTHER, + MAIL_CMD_MAX, +}; + +enum MAIL_PROTOCOL { + MAIL_PROTOCOL_SMTP, + MAIL_PROTOCOL_POP3, + MAIL_PROTOCOL_IMAP, + MAIL_PROTOCOL_MAX, +}; + +struct mail_header_field { + char *field_name; + size_t field_name_len; + char *field_value; + size_t field_value_len; +}; + +struct mail_header { + struct mail_header_field *from; + struct mail_header_field *to; + struct mail_header_field *cc; + struct mail_header_field *bcc; + struct mail_header_field *reply_to; + struct mail_header_field *date; + struct mail_header_field *subject; + + struct mail_header_field *header_fields; + size_t n_header_fields; +}; + +typedef void mail_command_callback_func(struct session *sess, + enum MAIL_PROTOCOL mail_protocol, size_t mail_seq, + enum MAIL_COMMAND command, + char *cmd_arg, size_t cmd_arg_len, + char *cmd_line, size_t cmd_line_len, + void *arg); + +typedef void mail_header_callback_func(struct session *sess, + enum MAIL_PROTOCOL mail_protocol, size_t mail_seq, + struct mail_header *header, + void *arg); + +typedef void mail_body_callback_func(struct session *sess, + enum MAIL_PROTOCOL mail_protocol, size_t mail_seq, + char *body, size_t body_len, size_t offset, int is_finish, + void *arg); + +typedef void mail_attachment_callback_func(struct session *sess, + enum MAIL_PROTOCOL mail_protocol, size_t mail_seq, + char *name, size_t name_len, + char *attachment, size_t attachment_len, size_t offset, int is_finish, + void *arg); + +typedef void mail_eml_callback_func(struct session *sess, + enum MAIL_PROTOCOL mail_protocol, + char *eml, size_t eml_len, size_t offset, int is_finish, + void *arg); + + +struct mail_decoder; +struct mail_decoder *module_to_mail_decoder(struct module *module); +int mail_subscribe(struct mail_decoder *decoder, + mail_command_callback_func *command_cb, + mail_header_callback_func *header_cb, + mail_body_callback_func *data_cb, + mail_attachment_callback_func *attachment_cb, + mail_eml_callback_func *eml_cb, + void *arg); + +#ifdef __cplusplus +} +#endif + |
