From: Mark Stenglein Date: Tue, 1 Jan 2019 00:57:37 +0000 (-0500) Subject: imap: command: Adds unique sequence IDs X-Git-Tag: 2019-10-25~412 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df6c592475d5a8a3a7af73df6fcc237ef6cb7cd4;p=neomutt imap: command: Adds unique sequence IDs This patch adds support for unique sequence IDs to be logged. Each new imap account is assigned an ID letter (seqid) which increments to the next letter (and wraps at 'z') each time a new imap account is created. Signed-off-by: Mark Stenglein --- diff --git a/imap/command.c b/imap/command.c index a7a2f67f2..40f8f3d4c 100644 --- a/imap/command.c +++ b/imap/command.c @@ -109,7 +109,7 @@ static struct ImapCommand *cmd_new(struct ImapAccountData *adata) cmd = adata->cmds + adata->nextcmd; adata->nextcmd = (adata->nextcmd + 1) % adata->cmdslots; - snprintf(cmd->seq, sizeof(cmd->seq), "a%04u", adata->seqno++); + snprintf(cmd->seq, sizeof(cmd->seq), "%c%04u", adata->seqid, adata->seqno++); if (adata->seqno > 9999) adata->seqno = 0; diff --git a/imap/imap_private.h b/imap/imap_private.h index 646103440..2d62ffba4 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -185,7 +185,8 @@ struct ImapAccountData * it's just no fun to get the same information twice */ char *capstr; unsigned char capabilities[(IMAP_CAP_MAX + 7) / 8]; - unsigned int seqno; ///< tag sequence number, e.g. 'a0001' + unsigned char seqid; /* tag sequence prefix */ + unsigned int seqno; ///< tag sequence number, e.g. '{seqid}0001' time_t lastread; /**< last time we read a command for the server */ char *buf; size_t blen; diff --git a/imap/util.c b/imap/util.c index 2411d364a..bad357482 100644 --- a/imap/util.c +++ b/imap/util.c @@ -99,11 +99,16 @@ void imap_adata_free(void **ptr) struct ImapAccountData *imap_adata_new(void) { struct ImapAccountData *adata = mutt_mem_calloc(1, sizeof(struct ImapAccountData)); + static unsigned char new_seqid = 'a'; + adata->seqid = new_seqid; adata->cmdbuf = mutt_buffer_new(); adata->cmdslots = ImapPipelineDepth + 2; adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds)); + if (++new_seqid > 'z') + new_seqid = 'a'; + return adata; }