From: Stephan Bosch Date: Wed, 3 Oct 2018 20:05:10 +0000 (+0200) Subject: lib-smtp: params: Add functions for adding extra MAIL/RCPT parameters. X-Git-Tag: 2.3.9~1239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4536a7b03fad029173e6ee26dbede9c489536e5f;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: params: Add functions for adding extra MAIL/RCPT parameters. --- diff --git a/src/lib-smtp/smtp-params.c b/src/lib-smtp/smtp-params.c index 9217d3ffdf..d849c840af 100644 --- a/src/lib-smtp/smtp-params.c +++ b/src/lib-smtp/smtp-params.c @@ -404,11 +404,8 @@ int smtp_params_mail_parse(pool_t pool, const char *args, str_array_icase_find(extensions, param.keyword)) { /* add the rest to ext_param for specific applications */ - if (!array_is_created(¶ms_r->extra_params)) - p_array_init(¶ms_r->extra_params, pool, 4); - param.keyword = p_strdup(pool, param.keyword); - param.value = p_strdup(pool, param.value); - array_append(¶ms_r->extra_params, ¶m, 1); + smtp_params_mail_add_extra(params_r, pool, + param.keyword, param.value); } else { /* RFC 5321, Section 4.1.1.11: If the server SMTP does not recognize or cannot @@ -459,6 +456,20 @@ void smtp_params_mail_copy(pool_t pool, } } +void smtp_params_mail_add_extra(struct smtp_params_mail *params, pool_t pool, + const char *keyword, const char *value) +{ + struct smtp_param param; + + if (!array_is_created(¶ms->extra_params)) + p_array_init(¶ms->extra_params, pool, 4); + + i_zero(¶m); + param.keyword = p_strdup(pool, keyword); + param.value = p_strdup(pool, value); + array_append(¶ms->extra_params, ¶m, 1); +} + /* write */ static void @@ -877,11 +888,8 @@ int smtp_params_rcpt_parse(pool_t pool, const char *args, str_array_icase_find(extensions, param.keyword)) { /* add the rest to ext_param for specific applications */ - if (!array_is_created(¶ms_r->extra_params)) - p_array_init(¶ms_r->extra_params, pool, 4); - param.keyword = p_strdup(pool, param.keyword); - param.value = p_strdup(pool, param.value); - array_append(¶ms_r->extra_params, ¶m, 1); + smtp_params_rcpt_add_extra(params_r, pool, + param.keyword, param.value); } else { /* RFC 5321, Section 4.1.1.11: If the server SMTP does not recognize or cannot @@ -930,6 +938,20 @@ void smtp_params_rcpt_copy(pool_t pool, } } +void smtp_params_rcpt_add_extra(struct smtp_params_rcpt *params, pool_t pool, + const char *keyword, const char *value) +{ + struct smtp_param param; + + if (!array_is_created(¶ms->extra_params)) + p_array_init(¶ms->extra_params, pool, 4); + + i_zero(¶m); + param.keyword = p_strdup(pool, keyword); + param.value = p_strdup(pool, value); + array_append(¶ms->extra_params, ¶m, 1); +} + /* write */ static void diff --git a/src/lib-smtp/smtp-params.h b/src/lib-smtp/smtp-params.h index 11cfb66ed4..6e89425b37 100644 --- a/src/lib-smtp/smtp-params.h +++ b/src/lib-smtp/smtp-params.h @@ -98,6 +98,11 @@ void smtp_params_mail_copy(pool_t pool, struct smtp_params_mail *dst, const struct smtp_params_mail *src) ATTR_NULL(3); +void smtp_params_mail_add_extra(struct smtp_params_mail *params, pool_t pool, + const char *keyword, const char *value); + +/* write */ + void smtp_params_mail_write(string_t *buffer, enum smtp_capability caps, const struct smtp_params_mail *params); @@ -121,6 +126,11 @@ void smtp_params_rcpt_copy(pool_t pool, struct smtp_params_rcpt *dst, const struct smtp_params_rcpt *src) ATTR_NULL(3); +void smtp_params_rcpt_add_extra(struct smtp_params_rcpt *params, pool_t pool, + const char *keyword, const char *value); + +/* write */ + void smtp_params_rcpt_write(string_t *buffer, enum smtp_capability caps, const struct smtp_params_rcpt *params);