]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-login: Move forward_fields updating code to login-common
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 23 Mar 2017 18:16:44 +0000 (20:16 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 27 Mar 2017 10:05:10 +0000 (13:05 +0300)
This allows using the new client_add_forward_field() in e.g. plugins.

src/imap-login/imap-login-client.c
src/login-common/client-common.c
src/login-common/client-common.h

index 755dc8e93f79479252663e3a0db64ed67f7c6069..ab764594945694ddc8ad71baf54edc3e967ee888 100644 (file)
@@ -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 @@ client_update_info(struct imap_client *client,
                }
        } 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;
        }
index 29a278bc71173a59f6dd9241a1998a9c341f432f..713695eb9fff5635935c61ccf5400320a0329e6c 100644 (file)
@@ -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 @@ unsigned int clients_get_count(void)
        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;
index f7628b581b64bcee46441ff29a88a4487a005c82..522ad63db5305bc7a55703e16c29be9fb3977d8c 100644 (file)
@@ -228,6 +228,8 @@ void client_cmd_starttls(struct client *client);
 
 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);