X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fimap%2Fimap_tools.c;h=e32320d000beabe5286d46f08e4e256b7b8454a4;hb=2b80e75820618944e1c75b9c01aeeefc8b6b0c81;hp=e3cc6bffce11a878c15b5f25e8783ae4c51ccd89;hpb=721e2cc8f2ea53d2b3b21c7fb0bda27138545006;p=citadel.git diff --git a/citadel/modules/imap/imap_tools.c b/citadel/modules/imap/imap_tools.c index e3cc6bffc..e32320d00 100644 --- a/citadel/modules/imap/imap_tools.c +++ b/citadel/modules/imap/imap_tools.c @@ -34,10 +34,6 @@ #include "imap_tools.h" #include "ctdl_module.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif - /* String handling helpers */ /* This code uses some pretty nasty string manipulation. To make everything @@ -556,11 +552,12 @@ int imap_parameterize(citimap_command *Cmd) /* Convert a struct ctdlroom to an IMAP-compatible mailbox name. */ -void imap_mailboxname(char *buf, int bufsize, struct ctdlroom *qrbuf) +long imap_mailboxname(char *buf, int bufsize, struct ctdlroom *qrbuf) { char* bufend = buf+bufsize; struct floor *fl; char* p = buf; + const char *pend; /* For mailboxes, just do it straight. * Do the Cyrus-compatible thing: all private folders are @@ -569,13 +566,17 @@ void imap_mailboxname(char *buf, int bufsize, struct ctdlroom *qrbuf) if (qrbuf->QRflags & QR_MAILBOX) { if (strcasecmp(qrbuf->QRname+11, MAILROOM) == 0) - toimap(p, bufend, "INBOX"); + { + pend = toimap(p, bufend, "INBOX"); + return pend - p; + } else { p = toimap(p, bufend, "INBOX"); if (p < bufend) *p++ = '/'; - toimap(p, bufend, qrbuf->QRname+11); + pend = toimap(p, bufend, qrbuf->QRname+11); + return pend - p; } } else @@ -586,7 +587,8 @@ void imap_mailboxname(char *buf, int bufsize, struct ctdlroom *qrbuf) p = toimap(p, bufend, fl->f_name); if (p < bufend) *p++ = '/'; - toimap(p, bufend, qrbuf->QRname); + pend = toimap(p, bufend, qrbuf->QRname); + return pend - p; } } @@ -685,33 +687,6 @@ exit: return(ret); } -/* - * Output a struct internet_address_list in the form an IMAP client wants - */ -void imap_ial_out(struct internet_address_list *ialist) -{ - struct internet_address_list *iptr; - - if (ialist == NULL) { - IAPuts("NIL"); - return; - } - IAPuts("("); - - for (iptr = ialist; iptr != NULL; iptr = iptr->next) { - IAPuts("("); - plain_imap_strout(iptr->ial_name); - IAPuts(" NIL "); - plain_imap_strout(iptr->ial_user); - IAPuts(" "); - plain_imap_strout(iptr->ial_node); - IAPuts(")"); - } - - IAPuts(")"); -} - - /* * Determine whether the supplied string is a valid message set. @@ -983,42 +958,6 @@ void IReplyPrintf(const char *Format, ...) } - -/* Output a string to the IMAP client, either as a literal or quoted. - * (We do a literal if it has any double-quotes or backslashes.) */ - -void plain_imap_strout(char *buf) -{ - int i; - int is_literal = 0; - long Len; - citimap *Imap = IMAP; - - if (buf == NULL) { /* yeah, we handle this */ - IAPuts("NIL"); - return; - } - - Len = strlen(buf); - for (i = 0; i < Len; ++i) { - if ((buf[i] == '\"') || (buf[i] == '\\')) - is_literal = 1; - } - - if (is_literal) { - StrBufAppendPrintf(Imap->Reply, "{%ld}\r\n", Len); - StrBufAppendBufPlain(Imap->Reply, buf, Len, 0); - } else { - StrBufAppendBufPlain(Imap->Reply, - HKEY("\""), 0); - StrBufAppendBufPlain(Imap->Reply, - buf, Len, 0); - StrBufAppendBufPlain(Imap->Reply, - HKEY("\""), 0); - } -} - - /* Output a string to the IMAP client, either as a literal or quoted. * (We do a literal if it has any double-quotes or backslashes.) */