dovecot: Added more consts to imap-parser API

dovecot at dovecot.org dovecot at dovecot.org
Sat Jun 30 00:48:20 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/d59ed6a31b66
changeset: 5835:d59ed6a31b66
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 29 19:03:45 2007 +0300
description:
Added more consts to imap-parser API

diffstat:

26 files changed, 124 insertions(+), 111 deletions(-)
src/imap-login/client-authenticate.c       |    4 +--
src/imap-login/client-authenticate.h       |    4 +--
src/imap-login/client.c                    |    4 +--
src/imap/client.c                          |    6 ++--
src/imap/client.h                          |    2 -
src/imap/cmd-append.c                      |   25 ++++++++++----------
src/imap/cmd-expunge.c                     |    2 -
src/imap/cmd-fetch.c                       |    8 +++---
src/imap/cmd-list.c                        |    8 ++++--
src/imap/cmd-search.c                      |    2 -
src/imap/cmd-sort.c                        |    5 ++--
src/imap/cmd-status.c                      |    7 +++--
src/imap/cmd-store.c                       |    2 -
src/imap/cmd-thread.c                      |    2 -
src/imap/commands-util.c                   |    7 +++--
src/imap/commands-util.h                   |    3 +-
src/imap/imap-fetch-body.c                 |    6 ++--
src/imap/imap-fetch.c                      |   34 ++++++++++++++--------------
src/imap/imap-fetch.h                      |    8 +++---
src/imap/imap-search.c                     |   19 ++++++++-------
src/imap/imap-search.h                     |    4 +--
src/lib-imap/imap-bodystructure.c          |    6 ++--
src/lib-imap/imap-envelope.c               |   21 +++++++++--------
src/lib-imap/imap-parser.c                 |   32 ++++++++++++++------------
src/lib-imap/imap-parser.h                 |   12 +++++----
src/plugins/imap-quota/imap-quota-plugin.c |    2 -

diffs (truncated from 853 to 300 lines):

diff -r fd21588ef7aa -r d59ed6a31b66 src/imap-login/client-authenticate.c
--- 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 @@ static void sasl_callback(struct client 
 	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 @@ int cmd_authenticate(struct imap_client 
 	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;
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap-login/client-authenticate.h
--- 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
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap-login/client.c
--- 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 cmd_logout(struct imap_client
 }
 
 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 int client_command_execute(struct
 
 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;
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/client.c
--- 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 @@ void client_send_command_error(struct cl
 }
 
 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 clie
 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;
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/client.h
--- 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 @@ void client_send_command_error(struct cl
 /* 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,
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/cmd-append.c
--- 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 @@ static void client_input(struct client_c
 /* 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 @@ static bool cmd_append_continue_parsing(
 {
 	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;
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/cmd-expunge.c
--- 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_comma
 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;
 
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/cmd-fetch.c
--- 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 @@ const char *full_macro[] = {
 };
 
 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 @@ fetch_parse_args(struct imap_fetch_conte
 	} 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_con
 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;
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/cmd-list.c
--- 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 @@ mailbox_childinfo2str(struct cmd_list_co
 }
 
 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 @@ parse_select_flags(struct client_command
 }
 
 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_comman
 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;
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/cmd-search.c
--- 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 @@ bool cmd_search(struct client_command_co
 {
 	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;
 
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/cmd-sort.c
--- 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 struct sort_name sort_names[] = {
 };
 
 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 @@ bool cmd_sort(struct client_command_cont
 	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;
diff -r fd21588ef7aa -r d59ed6a31b66 src/imap/cmd-status.c
--- 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 @@ get_status_items(struct client_command_c
 			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_co
 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;


More information about the dovecot-cvs mailing list