4 * Utility functions for the IMAP module.
14 #include "imap_tools.h"
17 * Break a command down into tokens, taking into consideration the
18 * possibility of escaping spaces using quoted tokens
20 int imap_parameterize(char **args, char *buf) {
29 original_len = strlen(buf);
31 for (i=0; i<original_len; ++i) {
33 if ( (isspace(buf[i])) && (!in_quote) ) {
35 args[num] = &buf[start];
37 if (args[num][0] == '\"') {
39 args[num][strlen(args[num])-1] = 0;
44 else if ( (buf[i] == '\"') && (!in_quote) ) {
48 else if ( (buf[i] == '\"') && (in_quote) ) {
58 * Convert a struct quickroom to an IMAP-compatible mailbox name.
60 void imap_mailboxname(char *buf, int bufsize, struct quickroom *qrbuf) {
62 safestrncpy(buf, qrbuf->QRname, bufsize);
63 if (qrbuf->QRflags & QR_MAILBOX) {
64 strcpy(buf, &buf[11]);
65 if (!strcasecmp(buf, MAILROOM)) strcpy(buf, "INBOX");