Skip to content

Commit

Permalink
imap-login: Move forward_fields updating code to login-common
Browse files Browse the repository at this point in the history
This allows using the new client_add_forward_field() in e.g. plugins.
  • Loading branch information
sirainen committed Mar 27, 2017
1 parent a440c98 commit 5f7ffdb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
11 changes: 1 addition & 10 deletions src/imap-login/imap-login-client.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 14 additions & 0 deletions src/login-common/client-common.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/login-common/client-common.h
Expand Up @@ -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);
Expand Down

0 comments on commit 5f7ffdb

Please sign in to comment.