]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Simplify logout format variable handling
authorAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 4 Dec 2017 09:03:45 +0000 (11:03 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 5 Dec 2017 12:53:36 +0000 (14:53 +0200)
src/imap/imap-client.c

index 163426039c55aca4b8700bdead9d7ab63753bed1..78848d7ec721ab9f396f9cc9e41296a4bc659088 100644 (file)
@@ -233,41 +233,23 @@ void client_command_cancel(struct client_command_context **_cmd)
 
 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);
 }