#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
*destp = 0;
string_init(&dest, destp, destend-destp);
- /* syslog(LOG_DEBUG, "toimap %s", src); */
+ /* IMAP_syslog(LOG_DEBUG, "toimap %s", src); */
for (;;)
{
if (state == 1)
utf7_closeb64(&dest, v, i);
- /* syslog(LOG_DEBUG, " -> %s", destp); */
+ /* IMAP_syslog(LOG_DEBUG, " -> %s", destp); */
return string_end(&dest);
}
*destp = 0;
string_init(&dest, destp, destend-destp);
- /* syslog(LOG_DEBUG, "fromimap %s", src); */
+ /* IMAP_syslog(LOG_DEBUG, "fromimap %s", src); */
do {
c = *p++;
}
} while (c != '\0');
- /* syslog(LOG_DEBUG, " -> %s", destp); */
+ /* IMAP_syslog(LOG_DEBUG, " -> %s", destp); */
return string_end(&dest);
}
/* 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
if (qrbuf->QRflags & QR_MAILBOX)
{
if (strcasecmp(qrbuf->QRname+11, MAILROOM) == 0)
- p = toimap(p, bufend, "INBOX");
+ {
+ pend = toimap(p, bufend, "INBOX");
+ return pend - buf;
+ }
else
{
p = toimap(p, bufend, "INBOX");
if (p < bufend)
*p++ = '/';
- p = toimap(p, bufend, qrbuf->QRname+11);
+ pend = toimap(p, bufend, qrbuf->QRname+11);
+ return pend - buf;
}
}
else
p = toimap(p, bufend, fl->f_name);
if (p < bufend)
*p++ = '/';
- p = toimap(p, bufend, qrbuf->QRname);
+ pend = toimap(p, bufend, qrbuf->QRname);
+ return pend - buf;
}
}
int imap_roomname(char *rbuf, int bufsize, const char *foldername)
{
+ struct CitContext *CCC = CC;
int levels;
char floorname[ROOMNAMELEN*2];
char roomname[ROOMNAMELEN];
ret = (0 | IR_MAILBOX);
exit:
- syslog(LOG_DEBUG, "(That translates to \"%s\")", rbuf);
+ IMAP_syslog(LOG_DEBUG, "(That translates to \"%s\")", rbuf);
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.
}
return WILDMAT_TRUE;
}
- while (!IsEmptyStr(text) && (*(text - 1) != WILDMAT_DELIM)) {
+ while (!IsEmptyStr(text) &&
+ /* make shure texst - 1 isn't before lcase_p */
+ ((text == lcase_text) || (*(text - 1) != WILDMAT_DELIM)))
+ {
if ((matched = do_imap_match(text++, p))
!= WILDMAT_FALSE) {
return matched;
}
-
-/* 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.) */