Skip to content

Commit

Permalink
lib-smtp: params: Add functions to evaluate any extra (non-standard) …
Browse files Browse the repository at this point in the history
…MAIL and RCPT parameters.

These allow looking up the parameter based on its name.
  • Loading branch information
stephanbosch authored and villesavolainen committed Mar 6, 2018
1 parent 52d9196 commit 7eb098b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/lib-smtp/smtp-params.c
Expand Up @@ -596,6 +596,24 @@ void smtp_params_mail_write(string_t *buffer,
str_truncate(buffer, str_len(buffer)-1);
}

/* evaluate */

const struct smtp_param *
smtp_params_mail_get_extra(const struct smtp_params_mail *params,
const char *keyword)
{
const struct smtp_param *param;

if (!array_is_created(&params->extra_params))
return NULL;

array_foreach(&params->extra_params, param) {
if (strcasecmp(param->keyword, keyword) == 0)
return param;
}
return NULL;
}

/*
* RCPT parameters
*/
Expand Down Expand Up @@ -986,3 +1004,21 @@ void smtp_params_rcpt_write(string_t *buffer,
if (str_len(buffer) > init_len)
str_truncate(buffer, str_len(buffer)-1);
}

/* evaluate */

const struct smtp_param *
smtp_params_rcpt_get_extra(const struct smtp_params_rcpt *params,
const char *keyword)
{
const struct smtp_param *param;

if (!array_is_created(&params->extra_params))
return NULL;

array_foreach(&params->extra_params, param) {
if (strcasecmp(param->keyword, keyword) == 0)
return param;
}
return NULL;
}
8 changes: 8 additions & 0 deletions src/lib-smtp/smtp-params.h
Expand Up @@ -100,6 +100,10 @@ void smtp_params_mail_write(string_t *buffer,
enum smtp_capability caps,
const struct smtp_params_mail *params);

const struct smtp_param *
smtp_params_mail_get_extra(const struct smtp_params_mail *params,
const char *keyword);

/*
* RCPT parameters
*/
Expand All @@ -118,4 +122,8 @@ void smtp_params_rcpt_write(string_t *buffer,
enum smtp_capability caps,
const struct smtp_params_rcpt *params);

const struct smtp_param *
smtp_params_rcpt_get_extra(const struct smtp_params_rcpt *params,
const char *keyword);

#endif

0 comments on commit 7eb098b

Please sign in to comment.