X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fimap%2Fimap_tools.c;h=7173d3adb7e39321a58abdd6b78e92b202317c3e;hb=9f3b914e91665cb14de25b5c80658c184f374b70;hp=3805b47244412487868f8a355b9386ee78b107e9;hpb=d071894ceddc5d81693c70da424066c3db1628e8;p=citadel.git diff --git a/citadel/modules/imap/imap_tools.c b/citadel/modules/imap/imap_tools.c index 3805b4724..7173d3adb 100644 --- a/citadel/modules/imap/imap_tools.c +++ b/citadel/modules/imap/imap_tools.c @@ -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; inum_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;