Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5835:d59ed6a31b66 HEAD
Added more consts to imap-parser API
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 29 Jun 2007 19:03:45 +0300 |
parents | fd21588ef7aa |
children | 9f869a7a3d73 |
files | src/imap-login/client-authenticate.c src/imap-login/client-authenticate.h src/imap-login/client.c src/imap/client.c src/imap/client.h src/imap/cmd-append.c src/imap/cmd-expunge.c src/imap/cmd-fetch.c src/imap/cmd-list.c src/imap/cmd-search.c src/imap/cmd-sort.c src/imap/cmd-status.c src/imap/cmd-store.c src/imap/cmd-thread.c src/imap/commands-util.c src/imap/commands-util.h src/imap/imap-fetch-body.c src/imap/imap-fetch.c src/imap/imap-fetch.h src/imap/imap-search.c src/imap/imap-search.h src/lib-imap/imap-bodystructure.c src/lib-imap/imap-envelope.c src/lib-imap/imap-parser.c src/lib-imap/imap-parser.h src/plugins/imap-quota/imap-quota-plugin.c |
diffstat | 26 files changed, 121 insertions(+), 108 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap-login/client-authenticate.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap-login/client-authenticate.c Fri Jun 29 19:03:45 2007 +0300 @@ -242,7 +242,7 @@ client_unref(client); } -int cmd_authenticate(struct imap_client *client, struct imap_arg *args) +int cmd_authenticate(struct imap_client *client, const struct imap_arg *args) { const char *mech_name, *init_resp = NULL; @@ -275,7 +275,7 @@ return 0; } -int cmd_login(struct imap_client *client, struct imap_arg *args) +int cmd_login(struct imap_client *client, const struct imap_arg *args) { const char *user, *pass; string_t *plain_login, *base64;
--- a/src/imap-login/client-authenticate.h Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap-login/client-authenticate.h Fri Jun 29 19:03:45 2007 +0300 @@ -3,7 +3,7 @@ const char *client_authenticate_get_capabilities(bool secured); -int cmd_login(struct imap_client *client, struct imap_arg *args); -int cmd_authenticate(struct imap_client *client, struct imap_arg *args); +int cmd_login(struct imap_client *client, const struct imap_arg *args); +int cmd_authenticate(struct imap_client *client, const struct imap_arg *args); #endif
--- a/src/imap-login/client.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap-login/client.c Fri Jun 29 19:03:45 2007 +0300 @@ -213,7 +213,7 @@ } static int client_command_execute(struct imap_client *client, const char *cmd, - struct imap_arg *args) + const struct imap_arg *args) { cmd = t_str_ucase(cmd); if (strcmp(cmd, "LOGIN") == 0) @@ -234,7 +234,7 @@ static bool client_handle_input(struct imap_client *client) { - struct imap_arg *args; + const struct imap_arg *args; const char *msg; int ret; bool fatal;
--- a/src/imap/client.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/client.c Fri Jun 29 19:03:45 2007 +0300 @@ -224,13 +224,13 @@ } bool client_read_args(struct client_command_context *cmd, unsigned int count, - unsigned int flags, struct imap_arg **args) + unsigned int flags, const struct imap_arg **args_r) { int ret; i_assert(count <= INT_MAX); - ret = imap_parser_read_args(cmd->parser, count, flags, args); + ret = imap_parser_read_args(cmd->parser, count, flags, args_r); if (ret >= (int)count) { /* all parameters read successfully */ i_assert(cmd->client->input_lock == NULL || @@ -251,7 +251,7 @@ bool client_read_string_args(struct client_command_context *cmd, unsigned int count, ...) { - struct imap_arg *imap_args; + const struct imap_arg *imap_args; va_list va; const char *str; unsigned int i;
--- a/src/imap/client.h Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/client.h Fri Jun 29 19:03:45 2007 +0300 @@ -95,7 +95,7 @@ /* Read a number of arguments. Returns TRUE if everything was read or FALSE if either needs more data or error occurred. */ bool client_read_args(struct client_command_context *cmd, unsigned int count, - unsigned int flags, struct imap_arg **args); + unsigned int flags, const struct imap_arg **args_r); /* Reads a number of string arguments. ... is a list of pointers where to store the arguments. */ bool client_read_string_args(struct client_command_context *cmd,
--- a/src/imap/cmd-append.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-append.c Fri Jun 29 19:03:45 2007 +0300 @@ -83,34 +83,35 @@ /* Returns -1 = error, 0 = need more data, 1 = successful. flags and internal_date may be NULL as a result, but mailbox and msg_size are always set when successful. */ -static int validate_args(struct imap_arg *args, struct imap_arg_list **flags, - const char **internal_date, uoff_t *msg_size, - bool *nonsync) +static int validate_args(const struct imap_arg *args, + const struct imap_arg_list **flags_r, + const char **internal_date_r, uoff_t *msg_size_r, + bool *nonsync_r) { /* [<flags>] */ if (args->type != IMAP_ARG_LIST) - *flags = NULL; + *flags_r = NULL; else { - *flags = IMAP_ARG_LIST(args); + *flags_r = IMAP_ARG_LIST(args); args++; } /* [<internal date>] */ if (args->type != IMAP_ARG_STRING) - *internal_date = NULL; + *internal_date_r = NULL; else { - *internal_date = IMAP_ARG_STR(args); + *internal_date_r = IMAP_ARG_STR(args); args++; } if (args->type != IMAP_ARG_LITERAL_SIZE && args->type != IMAP_ARG_LITERAL_SIZE_NONSYNC) { - *nonsync = FALSE; + *nonsync_r = FALSE; return FALSE; } - *nonsync = args->type == IMAP_ARG_LITERAL_SIZE_NONSYNC; - *msg_size = IMAP_ARG_LITERAL_SIZE(args); + *nonsync_r = args->type == IMAP_ARG_LITERAL_SIZE_NONSYNC; + *msg_size_r = IMAP_ARG_LITERAL_SIZE(args); return TRUE; } @@ -199,8 +200,8 @@ { struct client *client = cmd->client; struct cmd_append_context *ctx = cmd->context; - struct imap_arg *args; - struct imap_arg_list *flags_list; + const struct imap_arg *args; + const struct imap_arg_list *flags_list; enum mail_flags flags; const char *const *keywords_list; struct mail_keywords *keywords;
--- a/src/imap/cmd-expunge.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-expunge.c Fri Jun 29 19:03:45 2007 +0300 @@ -8,7 +8,7 @@ bool cmd_uid_expunge(struct client_command_context *cmd) { struct client *client = cmd->client; - struct imap_arg *args; + const struct imap_arg *args; struct mail_search_arg *search_arg; const char *uidset;
--- a/src/imap/cmd-fetch.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-fetch.c Fri Jun 29 19:03:45 2007 +0300 @@ -18,12 +18,12 @@ }; static bool -fetch_parse_args(struct imap_fetch_context *ctx, struct imap_arg *arg) +fetch_parse_args(struct imap_fetch_context *ctx, const struct imap_arg *arg) { const char *str, *const *macro; if (arg->type == IMAP_ARG_ATOM) { - str = str_ucase(IMAP_ARG_STR(arg)); + str = t_str_ucase(IMAP_ARG_STR(arg)); arg++; /* handle macros first */ @@ -48,7 +48,7 @@ } else { arg = IMAP_ARG_LIST(arg)->args; while (arg->type == IMAP_ARG_ATOM) { - str = str_ucase(IMAP_ARG_STR(arg)); + str = t_str_ucase(IMAP_ARG_STR(arg)); arg++; if (!imap_fetch_init_handler(ctx, str, &arg)) return FALSE; @@ -118,7 +118,7 @@ bool cmd_fetch(struct client_command_context *cmd) { struct imap_fetch_context *ctx; - struct imap_arg *args; + const struct imap_arg *args; struct mail_search_arg *search_arg; const char *messageset; int ret;
--- a/src/imap/cmd-list.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-list.c Fri Jun 29 19:03:45 2007 +0300 @@ -87,7 +87,8 @@ } static bool -parse_select_flags(struct client_command_context *cmd, struct imap_arg *args, +parse_select_flags(struct client_command_context *cmd, + const struct imap_arg *args, enum mailbox_list_flags *list_flags) { const char *atom; @@ -124,7 +125,8 @@ } static bool -parse_return_flags(struct client_command_context *cmd, struct imap_arg *args, +parse_return_flags(struct client_command_context *cmd, + const struct imap_arg *args, enum mailbox_list_flags *list_flags) { const char *atom; @@ -705,7 +707,7 @@ bool _cmd_list_full(struct client_command_context *cmd, bool lsub) { struct client *client = cmd->client; - struct imap_arg *args; + const struct imap_arg *args; enum mailbox_list_flags list_flags = 0; struct cmd_list_context *ctx; const char *ref, *mask;
--- a/src/imap/cmd-search.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-search.c Fri Jun 29 19:03:45 2007 +0300 @@ -125,7 +125,7 @@ { struct imap_search_context *ctx; struct mail_search_arg *sargs; - struct imap_arg *args; + const struct imap_arg *args; int args_count; const char *error, *charset;
--- a/src/imap/cmd-sort.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-sort.c Fri Jun 29 19:03:45 2007 +0300 @@ -24,7 +24,8 @@ }; static int -get_sort_program(struct client_command_context *cmd, struct imap_arg *args, +get_sort_program(struct client_command_context *cmd, + const struct imap_arg *args, enum mail_sort_type program[MAX_SORT_PROGRAM_SIZE]) { enum mail_sort_type mask = 0; @@ -86,7 +87,7 @@ struct client *client = cmd->client; struct mail_search_arg *sargs; enum mail_sort_type sorting[MAX_SORT_PROGRAM_SIZE]; - struct imap_arg *args; + const struct imap_arg *args; int args_count; pool_t pool; const char *error, *charset;
--- a/src/imap/cmd-status.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-status.c Fri Jun 29 19:03:45 2007 +0300 @@ -8,7 +8,8 @@ /* Returns status items, or -1 if error */ static enum mailbox_status_items -get_status_items(struct client_command_context *cmd, struct imap_arg *args) +get_status_items(struct client_command_context *cmd, + const struct imap_arg *args) { const char *item; enum mailbox_status_items items; @@ -22,7 +23,7 @@ return -1; } - item = str_ucase(IMAP_ARG_STR(args)); + item = t_str_ucase(IMAP_ARG_STR(args)); if (strcmp(item, "MESSAGES") == 0) items |= STATUS_MESSAGES; @@ -80,7 +81,7 @@ bool cmd_status(struct client_command_context *cmd) { struct client *client = cmd->client; - struct imap_arg *args; + const struct imap_arg *args; struct mailbox_status status; enum mailbox_status_items items; struct mail_storage *storage;
--- a/src/imap/cmd-store.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-store.c Fri Jun 29 19:03:45 2007 +0300 @@ -39,7 +39,7 @@ bool cmd_store(struct client_command_context *cmd) { struct client *client = cmd->client; - struct imap_arg *args; + const struct imap_arg *args; enum mail_flags flags; const char *const *keywords_list; struct mail_keywords *keywords;
--- a/src/imap/cmd-thread.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/cmd-thread.c Fri Jun 29 19:03:45 2007 +0300 @@ -11,7 +11,7 @@ struct client *client = cmd->client; enum mail_thread_type threading; struct mail_search_arg *sargs; - struct imap_arg *args; + const struct imap_arg *args; int args_count; pool_t pool; const char *error, *charset, *str;
--- a/src/imap/commands-util.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/commands-util.c Fri Jun 29 19:03:45 2007 +0300 @@ -216,11 +216,12 @@ } bool client_parse_mail_flags(struct client_command_context *cmd, - struct imap_arg *args, enum mail_flags *flags_r, + const struct imap_arg *args, + enum mail_flags *flags_r, const char *const **keywords_r) { const char *const *keywords; - char *atom; + const char *atom; buffer_t *buffer; size_t size, i; @@ -238,7 +239,7 @@ atom = IMAP_ARG_STR(args); if (*atom == '\\') { /* system flag */ - str_ucase(atom); + atom = t_str_ucase(atom); if (strcmp(atom, "\\ANSWERED") == 0) *flags_r |= MAIL_ANSWERED; else if (strcmp(atom, "\\FLAGGED") == 0)
--- a/src/imap/commands-util.h Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/commands-util.h Fri Jun 29 19:03:45 2007 +0300 @@ -46,7 +46,8 @@ /* Parse flags. Returns TRUE if successful, if not sends an error message to client. */ bool client_parse_mail_flags(struct client_command_context *cmd, - struct imap_arg *args, enum mail_flags *flags_r, + const struct imap_arg *args, + enum mail_flags *flags_r, const char *const **keywords_r); /* Send FLAGS + PERMANENTFLAGS to client. */
--- a/src/imap/imap-fetch-body.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/imap-fetch-body.c Fri Jun 29 19:03:45 2007 +0300 @@ -748,7 +748,7 @@ if (i != 0) str_append_c(str, ' '); - arr[i] = str_ucase(IMAP_ARG_STR(&list->args[i])); + arr[i] = t_str_ucase(IMAP_ARG_STR(&list->args[i])); if (list->args[i].type == IMAP_ARG_ATOM) str_append(str, arr[i]); @@ -768,7 +768,7 @@ } bool fetch_body_section_init(struct imap_fetch_context *ctx, const char *name, - struct imap_arg **args) + const struct imap_arg **args) { struct imap_fetch_body_data *body; const char *partial; @@ -948,7 +948,7 @@ } bool fetch_rfc822_init(struct imap_fetch_context *ctx, const char *name, - struct imap_arg **args __attr_unused__) + const struct imap_arg **args __attr_unused__) { if (name[6] == '\0') { ctx->fetch_data |= MAIL_FETCH_STREAM_HEADER |
--- a/src/imap/imap-fetch.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/imap-fetch.c Fri Jun 29 19:03:45 2007 +0300 @@ -61,7 +61,7 @@ } bool imap_fetch_init_handler(struct imap_fetch_context *ctx, const char *name, - struct imap_arg **args) + const struct imap_arg **args) { const struct imap_fetch_handler *handler; @@ -417,7 +417,7 @@ } static bool fetch_body_init(struct imap_fetch_context *ctx, const char *name, - struct imap_arg **args) + const struct imap_arg **args) { if (name[4] == '\0') { ctx->fetch_data |= MAIL_FETCH_IMAP_BODY; @@ -452,9 +452,9 @@ return 1; } -static bool fetch_bodystructure_init(struct imap_fetch_context *ctx, - const char *name, - struct imap_arg **args __attr_unused__) +static bool +fetch_bodystructure_init(struct imap_fetch_context *ctx, const char *name, + const struct imap_arg **args __attr_unused__) { ctx->fetch_data |= MAIL_FETCH_IMAP_BODYSTRUCTURE; imap_fetch_add_handler(ctx, FALSE, FALSE, name, @@ -486,9 +486,9 @@ return 1; } -static bool fetch_envelope_init(struct imap_fetch_context *ctx, - const char *name, - struct imap_arg **args __attr_unused__) +static bool +fetch_envelope_init(struct imap_fetch_context *ctx, const char *name, + const struct imap_arg **args __attr_unused__) { ctx->fetch_data |= MAIL_FETCH_IMAP_ENVELOPE; imap_fetch_add_handler(ctx, FALSE, FALSE, name, @@ -521,9 +521,9 @@ return 1; } -static bool fetch_flags_init(struct imap_fetch_context *ctx, - const char *name, - struct imap_arg **args __attr_unused__) +static bool +fetch_flags_init(struct imap_fetch_context *ctx, const char *name, + const struct imap_arg **args __attr_unused__) { ctx->flags_have_handler = TRUE; ctx->fetch_data |= MAIL_FETCH_FLAGS; @@ -545,9 +545,9 @@ return 1; } -static bool fetch_internaldate_init(struct imap_fetch_context *ctx, - const char *name, - struct imap_arg **args __attr_unused__) +static bool +fetch_internaldate_init(struct imap_fetch_context *ctx, const char *name, + const struct imap_arg **args __attr_unused__) { ctx->fetch_data |= MAIL_FETCH_RECEIVED_DATE; imap_fetch_add_handler(ctx, TRUE, FALSE, name, @@ -563,9 +563,9 @@ return 1; } -static bool fetch_uid_init(struct imap_fetch_context *ctx __attr_unused__, - const char *name, - struct imap_arg **args __attr_unused__) +static bool +fetch_uid_init(struct imap_fetch_context *ctx __attr_unused__, const char *name, + const struct imap_arg **args __attr_unused__) { imap_fetch_add_handler(ctx, TRUE, FALSE, name, NULL, fetch_uid, NULL); return TRUE;
--- a/src/imap/imap-fetch.h Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/imap-fetch.h Fri Jun 29 19:03:45 2007 +0300 @@ -13,7 +13,7 @@ /* Returns FALSE if arg is invalid. */ bool (*init)(struct imap_fetch_context *ctx, const char *name, - struct imap_arg **args); + const struct imap_arg **args); }; struct imap_fetch_context_handler { @@ -90,15 +90,15 @@ struct imap_fetch_context *imap_fetch_init(struct client_command_context *cmd); int imap_fetch_deinit(struct imap_fetch_context *ctx); bool imap_fetch_init_handler(struct imap_fetch_context *ctx, const char *name, - struct imap_arg **args); + const struct imap_arg **args); void imap_fetch_begin(struct imap_fetch_context *ctx, struct mail_search_arg *search_arg); int imap_fetch(struct imap_fetch_context *ctx); bool fetch_body_section_init(struct imap_fetch_context *ctx, const char *name, - struct imap_arg **args); + const struct imap_arg **args); bool fetch_rfc822_init(struct imap_fetch_context *ctx, const char *name, - struct imap_arg **args); + const struct imap_arg **args); #endif
--- a/src/imap/imap-search.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/imap-search.c Fri Jun 29 19:03:45 2007 +0300 @@ -79,7 +79,8 @@ #define ARG_NEW_HEADER(type, hdr_name) \ arg_new(data, args, next_sarg, type, TRUE, hdr_name) -static bool arg_new(struct search_build_data *data, struct imap_arg **args, +static bool arg_new(struct search_build_data *data, + const struct imap_arg **args, struct mail_search_arg **next_sarg, enum mail_search_arg_type type, bool have_value, const char *hdr_name) @@ -125,13 +126,13 @@ } static bool search_arg_build(struct search_build_data *data, - struct imap_arg **args, + const struct imap_arg **args, struct mail_search_arg **next_sarg) { struct mail_search_seqset *seqset; struct mail_search_arg **subargs; - struct imap_arg *arg; - char *str; + const struct imap_arg *arg; + const char *str; if ((*args)->type == IMAP_ARG_EOL) { data->error = "Missing argument"; @@ -147,7 +148,7 @@ } if (arg->type == IMAP_ARG_LIST) { - struct imap_arg *listargs = IMAP_ARG_LIST(arg)->args; + const struct imap_arg *listargs = IMAP_ARG_LIST(arg)->args; if (listargs->type == IMAP_ARG_EOL) { data->error = "Empty list not allowed"; @@ -172,7 +173,7 @@ /* string argument - get the name and jump to next */ str = IMAP_ARG_STR(arg); *args += 1; - str_ucase(str); + str = t_str_ucase(str); switch (*str) { case 'A': @@ -228,7 +229,7 @@ return FALSE; } - key = str_ucase(IMAP_ARG_STR(*args)); + key = t_str_ucase(IMAP_ARG_STR(*args)); *args += 1; return ARG_NEW_HEADER(SEARCH_HEADER, key); } @@ -414,8 +415,8 @@ } struct mail_search_arg * -imap_search_args_build(pool_t pool, struct mailbox *box, struct imap_arg *args, - const char **error_r) +imap_search_args_build(pool_t pool, struct mailbox *box, + const struct imap_arg *args, const char **error_r) { struct search_build_data data; struct mail_search_arg *first_sarg, **sargs;
--- a/src/imap/imap-search.h Fri Jun 29 17:58:01 2007 +0300 +++ b/src/imap/imap-search.h Fri Jun 29 19:03:45 2007 +0300 @@ -7,8 +7,8 @@ /* Builds search arguments based on IMAP arguments. */ struct mail_search_arg * -imap_search_args_build(pool_t pool, struct mailbox *box, struct imap_arg *args, - const char **error_r); +imap_search_args_build(pool_t pool, struct mailbox *box, + const struct imap_arg *args, const char **error_r); struct mail_search_arg * imap_search_get_arg(struct client_command_context *cmd,
--- a/src/lib-imap/imap-bodystructure.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/lib-imap/imap-bodystructure.c Fri Jun 29 19:03:45 2007 +0300 @@ -559,8 +559,8 @@ static bool imap_parse_bodystructure_args(const struct imap_arg *args, string_t *str) { - struct imap_arg *subargs; - struct imap_arg_list *list; + const struct imap_arg *subargs; + const struct imap_arg_list *list; bool multipart, text, message_rfc822; int i; @@ -669,7 +669,7 @@ { struct istream *input; struct imap_parser *parser; - struct imap_arg *args; + const struct imap_arg *args; int ret; input = i_stream_create_from_data(pool_datastack_create(),
--- a/src/lib-imap/imap-envelope.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/lib-imap/imap-envelope.c Fri Jun 29 19:03:45 2007 +0300 @@ -211,10 +211,10 @@ str_append(str, NVL(data->message_id, "NIL")); } -static bool imap_address_arg_append(struct imap_arg *arg, string_t *str, +static bool imap_address_arg_append(const struct imap_arg *arg, string_t *str, bool *in_group) { - struct imap_arg_list *list; + const struct imap_arg_list *list; const char *args[4]; int i; @@ -288,9 +288,9 @@ return TRUE; } -static const char *imap_envelope_parse_address(struct imap_arg *arg) +static const char *imap_envelope_parse_address(const struct imap_arg *arg) { - struct imap_arg_list *list; + const struct imap_arg_list *list; string_t *str; size_t i; bool in_group; @@ -310,9 +310,9 @@ return str_c(str); } -static const char *imap_envelope_parse_first_mailbox(struct imap_arg *arg) +static const char *imap_envelope_parse_first_mailbox(const struct imap_arg *arg) { - struct imap_arg_list *list; + const struct imap_arg_list *list; /* ((name route mailbox domain) ...) */ if (arg->type != IMAP_ARG_LIST) @@ -334,7 +334,8 @@ } static bool -imap_envelope_parse_arg(struct imap_arg *arg, enum imap_envelope_field field, +imap_envelope_parse_arg(const struct imap_arg *arg, + enum imap_envelope_field field, const char *envelope, enum imap_envelope_result_type result_type, const char **result) @@ -376,7 +377,7 @@ { struct istream *input; struct imap_parser *parser; - struct imap_arg *args; + const struct imap_arg *args; int ret; i_assert(field < IMAP_ENVELOPE_FIELDS);
--- a/src/lib-imap/imap-parser.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/lib-imap/imap-parser.c Fri Jun 29 19:03:45 2007 +0300 @@ -199,6 +199,7 @@ const unsigned char *data, size_t size) { struct imap_arg *arg; + char *str; arg = imap_arg_create(parser); @@ -218,15 +219,15 @@ i_assert(size > 0); arg->type = IMAP_ARG_STRING; - arg->_data.str = p_strndup(parser->pool, data+1, size-1); + str = p_strndup(parser->pool, data+1, size-1); /* remove the escapes */ if (parser->str_first_escape >= 0 && (parser->flags & IMAP_PARSE_FLAG_NO_UNESCAPE) == 0) { /* -1 because we skipped the '"' prefix */ - str_unescape(arg->_data.str + - parser->str_first_escape-1); + str_unescape(str + parser->str_first_escape-1); } + arg->_data.str = str; break; case ARG_PARSE_LITERAL_DATA: if ((parser->flags & IMAP_PARSE_FLAG_LITERAL_SIZE) != 0) { @@ -536,7 +537,7 @@ (parser)->cur_list != parser->root_list) static int finish_line(struct imap_parser *parser, unsigned int count, - struct imap_arg **args) + const struct imap_arg **args_r) { parser->line_size += parser->cur_pos; i_stream_skip(parser->input, parser->cur_pos); @@ -544,7 +545,7 @@ if (parser->list_arg != NULL) { parser->error = "Missing ')'"; - *args = NULL; + *args_r = NULL; return -1; } @@ -557,12 +558,13 @@ parser->root_list->args[parser->root_list->size].type = IMAP_ARG_EOL; - *args = parser->root_list->args; + *args_r = parser->root_list->args; return parser->root_list->size; } int imap_parser_read_args(struct imap_parser *parser, unsigned int count, - enum imap_parser_flags flags, struct imap_arg **args) + enum imap_parser_flags flags, + const struct imap_arg **args_r) { parser->flags = flags; @@ -582,28 +584,28 @@ parser->line_size += parser->cur_pos; i_stream_skip(parser->input, parser->cur_pos); parser->cur_pos = 0; - *args = NULL; + *args_r = NULL; return -1; } else if ((!IS_UNFINISHED(parser) && count > 0 && parser->root_list->size >= count) || parser->eol) { /* all arguments read / end of line. */ - return finish_line(parser, count, args); + return finish_line(parser, count, args_r); } else { /* need more data */ - *args = NULL; + *args_r = NULL; return -2; } } int imap_parser_finish_line(struct imap_parser *parser, unsigned int count, enum imap_parser_flags flags, - struct imap_arg **args) + const struct imap_arg **args_r) { const unsigned char *data; size_t data_size; int ret; - ret = imap_parser_read_args(parser, count, flags, args); + ret = imap_parser_read_args(parser, count, flags, args_r); if (ret == -2) { /* we should have noticed end of everything except atom */ if (parser->cur_type == ARG_PARSE_ATOM) { @@ -611,7 +613,7 @@ imap_parser_save_arg(parser, data, data_size); } } - return finish_line(parser, count, args); + return finish_line(parser, count, args_r); } const char *imap_parser_read_word(struct imap_parser *parser) @@ -636,7 +638,7 @@ } } -const char *imap_arg_string(struct imap_arg *arg) +const char *imap_arg_string(const struct imap_arg *arg) { switch (arg->type) { case IMAP_ARG_NIL:
--- a/src/lib-imap/imap-parser.h Fri Jun 29 17:58:01 2007 +0300 +++ b/src/lib-imap/imap-parser.h Fri Jun 29 19:03:45 2007 +0300 @@ -41,7 +41,7 @@ struct imap_arg *parent; /* always of type IMAP_ARG_LIST */ union { - char *str; + const char *str; uoff_t literal_size; struct imap_arg_list *list; } _data; @@ -65,7 +65,8 @@ #define IMAP_ARG_LIST(arg) \ ((arg)->type == IMAP_ARG_LIST ? \ - (arg)->_data.list : _imap_arg_list_error(arg)) + (const struct imap_arg_list *)(arg)->_data.list : \ + _imap_arg_list_error(arg)) struct imap_arg_list { size_t size, alloc; @@ -105,20 +106,21 @@ can be set to 0 to read all arguments in the line. Last element in args is always of type IMAP_ARG_EOL. */ int imap_parser_read_args(struct imap_parser *parser, unsigned int count, - enum imap_parser_flags flags, struct imap_arg **args); + enum imap_parser_flags flags, + const struct imap_arg **args_r); /* just like imap_parser_read_args(), but assume \n at end of data in input stream. */ int imap_parser_finish_line(struct imap_parser *parser, unsigned int count, enum imap_parser_flags flags, - struct imap_arg **args); + const struct imap_arg **args_r); /* Read one word - used for reading tag and command name. Returns NULL if more data is needed. */ const char *imap_parser_read_word(struct imap_parser *parser); /* Returns the imap argument as string. NIL returns "" and list returns NULL. */ -const char *imap_arg_string(struct imap_arg *arg); +const char *imap_arg_string(const struct imap_arg *arg); /* Error functions */ char *_imap_arg_str_error(const struct imap_arg *arg) __attr_noreturn__;
--- a/src/plugins/imap-quota/imap-quota-plugin.c Fri Jun 29 17:58:01 2007 +0300 +++ b/src/plugins/imap-quota/imap-quota-plugin.c Fri Jun 29 19:03:45 2007 +0300 @@ -133,7 +133,7 @@ static bool cmd_setquota(struct client_command_context *cmd) { struct quota_root *root; - struct imap_arg *args, *arg; + const struct imap_arg *args, *arg; const char *root_name, *name, *error; uint64_t value;