39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch#ifndef SMTP_PARAMS_H
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch#define SMTP_PARAMS_H
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch#include "array-decl.h"
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch#include "smtp-common.h"
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschstruct smtp_param;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan BoschARRAY_DEFINE_TYPE(smtp_param, struct smtp_param);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschenum smtp_param_mail_body_type {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_MAIL_BODY_TYPE_UNSPECIFIED = 0,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_MAIL_BODY_TYPE_7BIT,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_MAIL_BODY_TYPE_8BITMIME,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_MAIL_BODY_TYPE_BINARYMIME,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_MAIL_BODY_TYPE_EXTENSION
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch};
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschenum smtp_param_mail_ret {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_MAIL_RET_UNSPECIFIED = 0,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_MAIL_RET_HDRS,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_MAIL_RET_FULL,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch};
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschenum smtp_param_rcpt_notify {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_RCPT_NOTIFY_UNSPECIFIED = 0x00,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_RCPT_NOTIFY_SUCCESS = 0x01,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_RCPT_NOTIFY_FAILURE = 0x02,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_RCPT_NOTIFY_DELAY = 0x04,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_RCPT_NOTIFY_NEVER = 0x80
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch};
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschstruct smtp_param {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const char *keyword;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const char *value;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch};
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschstruct smtp_params_mail {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* AUTH: RFC 4954 */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const struct smtp_address *auth;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* BODY: RFC 6152 */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch struct {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_param_mail_body_type type;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const char *ext;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch } body;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* ENVID: RFC 3461, Section 4.4 */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const char *envid;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* RET: RFC 3461, Section 4.3 */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_param_mail_ret ret;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* SIZE: RFC 1870 */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch uoff_t size;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* extra parameters */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch ARRAY_TYPE(smtp_param) extra_params;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch};
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschstruct smtp_params_rcpt {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* ORCPT: RFC 3461, Section 4.2 */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch struct {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const char *addr_type;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* addr_type=rfc822 */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const struct smtp_address *addr;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* raw value */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const char *addr_raw;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch } orcpt;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* NOTIFY: RFC 3461, Section 4.1 */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_param_rcpt_notify notify;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch /* extra parameters */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch ARRAY_TYPE(smtp_param) extra_params;
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch};
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschenum smtp_param_parse_error {
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_PARSE_ERROR_BAD_SYNTAX = 0,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch SMTP_PARAM_PARSE_ERROR_NOT_SUPPORTED
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch};
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch/*
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch * Parser
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschint smtp_param_parse(pool_t pool, const char *text,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch struct smtp_param *param_r, const char **error_r);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschvoid smtp_param_write(string_t *out, const struct smtp_param *param);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch/*
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch * MAIL parameters
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschint smtp_params_mail_parse(pool_t pool, const char *args,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_capability caps, bool extensions,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch struct smtp_params_mail *params_r,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_param_parse_error *error_code_r,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const char **error_r);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschvoid smtp_params_mail_copy(pool_t pool,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch struct smtp_params_mail *dst, const struct smtp_params_mail *src)
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch ATTR_NULL(3);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschvoid smtp_params_mail_write(string_t *buffer,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_capability caps,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const struct smtp_params_mail *params);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
7c99fd4ea26239a4bb66dca6b3bb238e86adb3e4Stephan Boschconst struct smtp_param *
7c99fd4ea26239a4bb66dca6b3bb238e86adb3e4Stephan Boschsmtp_params_mail_get_extra(const struct smtp_params_mail *params,
7c99fd4ea26239a4bb66dca6b3bb238e86adb3e4Stephan Bosch const char *keyword);
7c99fd4ea26239a4bb66dca6b3bb238e86adb3e4Stephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch/*
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch * RCPT parameters
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch */
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschint smtp_params_rcpt_parse(pool_t pool, const char *args,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_capability caps, bool extensions,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch struct smtp_params_rcpt *params_r,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_param_parse_error *error_code_r,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const char **error_r);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschvoid smtp_params_rcpt_copy(pool_t pool,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch struct smtp_params_rcpt *dst, const struct smtp_params_rcpt *src)
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch ATTR_NULL(3);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Boschvoid smtp_params_rcpt_write(string_t *buffer,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch enum smtp_capability caps,
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch const struct smtp_params_rcpt *params);
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch
7c99fd4ea26239a4bb66dca6b3bb238e86adb3e4Stephan Boschconst struct smtp_param *
7c99fd4ea26239a4bb66dca6b3bb238e86adb3e4Stephan Boschsmtp_params_rcpt_get_extra(const struct smtp_params_rcpt *params,
7c99fd4ea26239a4bb66dca6b3bb238e86adb3e4Stephan Bosch const char *keyword);
7c99fd4ea26239a4bb66dca6b3bb238e86adb3e4Stephan Bosch
3afa83c450379a4b0e645525f3dca7f2da91b2f6Stephan Boschbool smtp_params_rcpt_equals(const struct smtp_params_rcpt *params1,
3afa83c450379a4b0e645525f3dca7f2da91b2f6Stephan Bosch const struct smtp_params_rcpt *params2);
3afa83c450379a4b0e645525f3dca7f2da91b2f6Stephan Bosch
39bf54004e8ef15baa4c18c7969e87c51b8f197bStephan Bosch#endif