imap-parser.h revision 1879416e000b4509087e05098512b7af9a4cc5f6
#ifndef __IMAP_PARSER_H
#define __IMAP_PARSER_H
enum imap_parser_flags {
/* Set this flag if you wish to read only size of literal argument
and not convert literal into string. Useful when you need to deal
with large literal sizes. The literal must be the last read
parameter. */
IMAP_PARSE_FLAG_LITERAL_SIZE = 0x01,
/* Don't remove '\' chars from string arguments */
IMAP_PARSE_FLAG_NO_UNESCAPE = 0x02,
};
enum imap_arg_type {
IMAP_ARG_NIL = 0,
IMAP_ARG_EOL /* end of argument list */
};
struct imap_parser;
struct imap_arg {
enum imap_arg_type type;
union {
char *str;
struct imap_arg_list *list;
} _data;
};
#define IMAP_ARG_STR(arg) \
#define IMAP_ARG_LITERAL_SIZE(arg) \
#define IMAP_ARG_LIST(arg) \
struct imap_arg_list {
};
/* Create new IMAP argument parser. There's no limit in argument sizes, only
the maximum buffer size of input stream limits it. max_literal_size limits
the maximum size of internally handled literals (ie. FLAG_LITERAL_SIZE is
unset). max_elements sets the number of elements we allow entirely so that
user can't give huge lists or lists inside lists. output is used for sending
command continuation requests for literals. */
struct imap_parser *
/* Reset the parser to initial state. */
/* Return the last error in parser. */
/* Read a number of arguments. This function doesn't call i_stream_read(), you
need to do that. Returns number of arguments read (may be less than count
in case of EOL), -2 if more data is needed or -1 if error occured.
count-sized array of arguments are stored into args when return value is
0 or larger. If all arguments weren't read, they're set to NIL. count
can be set to 0 to read all arguments in the line. Last element in
args is always of type IMAP_ARG_EOL. */
/* Read one word - used for reading tag and command name.
Returns NULL if more data is needed. */
/* Read the rest of the line. Returns NULL if more data is needed. */
/* Returns the imap argument as string. NIL returns "" and list returns NULL. */
/* Error functions */
#endif