]> granicus.if.org Git - neomutt/commitdiff
imap: command: Adds unique sequence IDs
authorMark Stenglein <mark@stengle.in>
Tue, 1 Jan 2019 00:57:37 +0000 (19:57 -0500)
committerRichard Russon <rich@flatcap.org>
Tue, 1 Jan 2019 01:35:12 +0000 (01:35 +0000)
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 <mark@stengle.in>
imap/command.c
imap/imap_private.h
imap/util.c

index a7a2f67f281ac7856e7f479a4405910002d9995c..40f8f3d4c905852da8110cb467b4d14d4c5814a8 100644 (file)
@@ -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;
 
index 6461034407b2b3249c2733d27bd1fa1af4b247c2..2d62ffba4f38999eb44dc8e2f181df1f7b691c3c 100644 (file)
@@ -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;
index 2411d364a6ca5c00c730bd51fcc6ba558efc5375..bad357482d809dffaeb490e8998f2d4374ecc575 100644 (file)
@@ -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;
 }