]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/imap/imap_tools.c
* casting int to char* doesn't work out on 64 bit architectures
[citadel.git] / citadel / modules / imap / imap_tools.c
index 3805b47244412487868f8a355b9386ee78b107e9..8e86c9999642183e479f427f32eeeb931a6f31b5 100644 (file)
@@ -436,8 +436,22 @@ void imap_strout(ConstStr *args)
        }
 }
 
+
+
+
 /* Break a command down into tokens, unquoting any escaped characters. */
 
+void MakeStringOf(StrBuf *Buf, int skip)
+{
+       int i;
+       citimap_command *Cmd = &IMAP->Cmd;
+
+       for (i=skip; i<Cmd->num_parms; ++i) {
+               StrBufAppendBufPlain(Buf, Cmd->Params[i].Key, Cmd->Params[i].len, 0);
+               if (i < (Cmd->num_parms-1)) StrBufAppendBufPlain(Buf, HKEY(" "), 0);
+       }
+}
+
 
 void TokenCutRight(citimap_command *Cmd, 
                   ConstStr *CutMe,
@@ -491,8 +505,11 @@ int CmdAdjust(citimap_command *Cmd,
                               sizeof(ConstStr) * Cmd->avail_parms 
                                );
                }
-               else 
+               else {
                        Cmd->num_parms = 0;
+                       memset(Params, 0, 
+                              sizeof(ConstStr) * nArgs);
+               }
                Cmd->avail_parms = nArgs;
                if (Cmd->Params != NULL)
                        free (Cmd->Params);
@@ -506,7 +523,7 @@ int CmdAdjust(citimap_command *Cmd,
                        Cmd->num_parms = 0;
                }
        }
-       return Cmd->num_parms;
+       return Cmd->avail_parms;
 }
 
 int imap_parameterize(citimap_command *Cmd)
@@ -580,10 +597,10 @@ int imap_parameterize(citimap_command *Cmd)
                StrBufPeek(Cmd->CmdBuf, In, -1, '\0');
                Cmd->Params[Cmd->num_parms].len = 
                        In - Cmd->Params[Cmd->num_parms].Key;
-               Cmd->num_parms ++;
-               if (Cmd->num_parms >= Cmd->avail_parms) {
+               if (Cmd->num_parms + 1 >= Cmd->avail_parms) {
                        nArgs = CmdAdjust(Cmd, nArgs * 2, 1);
                }
+               Cmd->num_parms ++;
                In++;
        }
        return Cmd->num_parms;
@@ -942,7 +959,7 @@ star:
  * Support function for mailbox pattern name matching in LIST and LSUB
  * Returns nonzero if the supplied mailbox name matches the supplied pattern.
  */
-int imap_mailbox_matches_pattern(char *pattern, char *mailboxname)
+int imap_mailbox_matches_pattern(const char *pattern, char *mailboxname)
 {
        /* handle just-star case quickly */
        if ((pattern[0] == '*') && (pattern[1] == '\0')) {