Mercurial > dovecot > core-2.2
changeset 21820:de6920764b89
imap-login: Move forward_fields updating code to login-common
This allows using the new client_add_forward_field() in e.g. plugins.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 23 Mar 2017 20:16:44 +0200 |
parents | c7c9d84d9be3 |
children | 4e3fcaa8ab3f |
files | src/imap-login/imap-login-client.c src/login-common/client-common.c src/login-common/client-common.h |
diffstat | 3 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap-login/imap-login-client.c Fri Mar 24 04:21:49 2017 +0200 +++ b/src/imap-login/imap-login-client.c Thu Mar 23 20:16:44 2017 +0200 @@ -7,7 +7,6 @@ #include "ostream.h" #include "safe-memset.h" #include "str.h" -#include "strescape.h" #include "imap-parser.h" #include "imap-id.h" #include "imap-resp-code.h" @@ -188,15 +187,7 @@ } } else if (strncasecmp(key, "x-forward-", 10) == 0) { /* handle extra field */ - if (client->common.forward_fields == NULL) - client->common.forward_fields = str_new(client->common.preproxy_pool, 32); - else - str_append_c(client->common.forward_fields, '\t'); - /* prefixing is done by auth process */ - str_append_tabescaped(client->common.forward_fields, - key+10); - str_append_c(client->common.forward_fields, '='); - str_append_tabescaped(client->common.forward_fields, value); + client_add_forward_field(&client->common, key+10, value); } else { return FALSE; }
--- a/src/login-common/client-common.c Fri Mar 24 04:21:49 2017 +0200 +++ b/src/login-common/client-common.c Thu Mar 23 20:16:44 2017 +0200 @@ -11,6 +11,7 @@ #include "hook-build.h" #include "buffer.h" #include "str.h" +#include "strescape.h" #include "base64.h" #include "str-sanitize.h" #include "safe-memset.h" @@ -488,6 +489,19 @@ return clients_count; } +void client_add_forward_field(struct client *client, const char *key, + const char *value) +{ + if (client->forward_fields == NULL) + client->forward_fields = str_new(client->preproxy_pool, 32); + else + str_append_c(client->forward_fields, '\t'); + /* prefixing is done by auth process */ + str_append_tabescaped(client->forward_fields, key); + str_append_c(client->forward_fields, '='); + str_append_tabescaped(client->forward_fields, value); +} + const char *client_get_session_id(struct client *client) { buffer_t *buf, *base64_buf;
--- a/src/login-common/client-common.h Fri Mar 24 04:21:49 2017 +0200 +++ b/src/login-common/client-common.h Thu Mar 23 20:16:44 2017 +0200 @@ -228,6 +228,8 @@ unsigned int clients_get_count(void) ATTR_PURE; +void client_add_forward_field(struct client *client, const char *key, + const char *value); void client_set_title(struct client *client); void client_log(struct client *client, const char *msg); void client_log_err(struct client *client, const char *msg);