Mercurial > dovecot > core-2.2
changeset 22700:59c0869770eb
imap: Simplify logout format variable handling
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Mon, 04 Dec 2017 11:03:45 +0200 |
parents | 324bc758ebf7 |
children | 8dcf3b113b6d |
files | src/imap/imap-client.c |
diffstat | 1 files changed, 13 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-client.c Wed Nov 29 15:20:29 2017 +0200 +++ b/src/imap/imap-client.c Mon Dec 04 11:03:45 2017 +0200 @@ -233,41 +233,23 @@ const char *client_stats(struct client *client) { - static struct var_expand_table static_tab[] = { - { 'i', NULL, "input" }, - { 'o', NULL, "output" }, - { '\0', NULL, "session" }, - { '\0', NULL, "fetch_hdr_count" }, - { '\0', NULL, "fetch_hdr_bytes" }, - { '\0', NULL, "fetch_body_count" }, - { '\0', NULL, "fetch_body_bytes" }, - { '\0', NULL, "deleted" }, - { '\0', NULL, "expunged" }, - { '\0', NULL, "trashed" }, - { '\0', NULL, "autoexpunged" }, - { '\0', NULL, "appended" }, + const struct var_expand_table tab[] = { + { 'i', dec2str(i_stream_get_absolute_offset(client->input)), "input" }, + { 'o', dec2str(client->output->offset), "output" }, + { '\0', client->session_id, "session" }, + { '\0', dec2str(client->fetch_hdr_count), "fetch_hdr_count" }, + { '\0', dec2str(client->fetch_hdr_bytes), "fetch_hdr_bytes" }, + { '\0', dec2str(client->fetch_body_count), "fetch_body_count" }, + { '\0', dec2str(client->fetch_body_bytes), "fetch_body_bytes" }, + { '\0', dec2str(client->deleted_count), "deleted" }, + { '\0', dec2str(client->expunged_count), "expunged" }, + { '\0', dec2str(client->trashed_count), "trashed" }, + { '\0', dec2str(client->autoexpunged_count), "autoexpunged" }, + { '\0', dec2str(client->append_count), "appended" }, { '\0', NULL, NULL } }; - struct var_expand_table *tab; string_t *str; - tab = t_malloc(sizeof(static_tab)); - memcpy(tab, static_tab, sizeof(static_tab)); - - tab[0].value = dec2str(i_stream_get_absolute_offset(client->input)); - tab[1].value = dec2str(client->output->offset); - tab[2].value = client->session_id; - tab[3].value = dec2str(client->fetch_hdr_count); - tab[4].value = dec2str(client->fetch_hdr_bytes); - tab[5].value = dec2str(client->fetch_body_count); - tab[6].value = dec2str(client->fetch_body_bytes); - tab[7].value = dec2str(client->deleted_count); - tab[8].value = dec2str(client->expunged_count); - tab[9].value = dec2str(client->trashed_count); - tab[10].value = dec2str(client->autoexpunged_count); - tab[11].value = dec2str(client->append_count); - - str = t_str_new(128); var_expand(str, client->set->imap_logout_format, tab); return str_c(str); }