#ifndef IMAP_ARG_H
#define IMAP_ARG_H
#include "array.h"
/* ABNF:
CHAR = %x01-7F
CTL = %x00-1F / %x7F
SP = %x20
DQUOTE = %x22 */
/* ASTRING-CHAR = ATOM-CHAR / resp-specials */
/* ATOM-CHAR = <any CHAR except atom-specials> */
/* atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards /
quoted-specials / resp-specials
Since atoms are only 7bit, we'll also optimize a bit by assuming 8bit chars
are also atom-specials. */
#define IS_ATOM_SPECIAL(c) \
((unsigned char)(c) <= 0x20 || (unsigned char)(c) >= 0x7f || \
IS_QUOTED_SPECIAL(c) || IS_RESP_SPECIAL(c))
/* list-wildcards = "%" / "*" */
/* quoted-specials = DQUOTE / "\" */
/* resp-specials = "]" */
enum imap_arg_type {
IMAP_ARG_NIL = 0,
/* literals are returned as IMAP_ARG_STRING by default */
};
struct imap_arg {
/* Set when _data.str is set */
union {
const char *str;
} _data;
};
/* RFC 3501's astring type. Note that this doesn't return TRUE for
IMAP_ARG_NIL, although it should be treated the same as "NIL" string when
reading an astring. */
((type) == IMAP_ARG_ATOM || \
(type) == IMAP_ARG_STRING || \
(type) == IMAP_ARG_LITERAL)
/* str is set to NULL for NIL. */
unsigned int *list_count_r) ATTR_WARN_UNUSED_RESULT;
/* Similar to above, but assumes that arg is already of correct type. */
/* Returns TRUE if arg is atom and case-insensitively matches str */
#endif