[dovecot-cvs] dovecot/src/imap client.c, 1.71, 1.72 client.h, 1.37, 1.38 cmd-append.c, 1.84, 1.85 cmd-idle.c, 1.33, 1.34 imap-fetch-body.c, 1.28, 1.29 imap-fetch.c, 1.49, 1.50 imap-fetch.h, 1.21, 1.22 imap-thread.c, 1.31, 1.32

tss at dovecot.org tss at dovecot.org
Fri Dec 15 18:38:13 UTC 2006


Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv3614/imap

Modified Files:
	client.c client.h cmd-append.c cmd-idle.c imap-fetch-body.c 
	imap-fetch.c imap-fetch.h imap-thread.c 
Log Message:
Replaced void *context from a lot of callbacks with the actual context
type. Also added/fixed some context type checks.



Index: client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/client.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- client.c	18 Nov 2006 21:34:22 -0000	1.71
+++ client.c	15 Dec 2006 18:38:10 -0000	1.72
@@ -395,9 +395,8 @@
 	return TRUE;
 }
 
-void _client_input(void *context)
+void _client_input(struct client *client)
 {
-	struct client *client = context;
 	struct client_command_context *cmd = &client->cmd;
 	int ret;
 
@@ -441,9 +440,8 @@
 		client_destroy(client, NULL);
 }
 
-int _client_output(void *context)
+int _client_output(struct client *client)
 {
-	struct client *client = context;
 	struct client_command_context *cmd = &client->cmd;
 	int ret;
 	bool finished;

Index: client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/client.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- client.h	28 Jun 2006 13:10:32 -0000	1.37
+++ client.h	15 Dec 2006 18:38:10 -0000	1.38
@@ -89,7 +89,7 @@
 void clients_deinit(void);
 
 void _client_reset_command(struct client *client);
-void _client_input(void *context);
-int _client_output(void *context);
+void _client_input(struct client *client);
+int _client_output(struct client *client);
 
 #endif

Index: cmd-append.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-append.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- cmd-append.c	15 Dec 2006 16:55:31 -0000	1.84
+++ cmd-append.c	15 Dec 2006 18:38:10 -0000	1.85
@@ -29,9 +29,8 @@
 static void cmd_append_finish(struct cmd_append_context *ctx);
 static bool cmd_append_continue_message(struct client_command_context *cmd);
 
-static void client_input(void *context)
+static void client_input(struct client *client)
 {
-	struct client *client = context;
 	struct client_command_context *cmd = &client->cmd;
 
 	client->last_input = ioloop_time;

Index: cmd-idle.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-idle.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- cmd-idle.c	18 Nov 2006 21:37:21 -0000	1.33
+++ cmd-idle.c	15 Dec 2006 18:38:10 -0000	1.34
@@ -54,7 +54,7 @@
 	io_remove(&client->io);
 
 	if (client->mailbox != NULL)
-		mailbox_notify_changes(client->mailbox, 0, NULL, NULL);
+		mailbox_notify_changes_stop(client->mailbox);
 
 	if (done_ok)
 		client_send_tagline(ctx->cmd, "OK Idle completed.");
@@ -70,9 +70,8 @@
 		_client_input(client);
 }
 
-static void idle_client_input(void *context)
+static void idle_client_input(struct cmd_idle_context *ctx)
 {
-        struct cmd_idle_context *ctx = context;
 	struct client *client = ctx->client;
 	char *line;
 
@@ -113,13 +112,11 @@
 	ctx->dummy_seq = client->messages_count+1;
 	client_send_line(client,
 			 t_strdup_printf("* %u EXISTS", ctx->dummy_seq));
-	mailbox_notify_changes(client->mailbox, 0, NULL, NULL);
+	mailbox_notify_changes_stop(client->mailbox);
 }
 
-static void idle_timeout(void *context)
+static void idle_timeout(struct cmd_idle_context *ctx)
 {
-	struct cmd_idle_context *ctx = context;
-
 	/* outlook workaround - it hasn't sent anything for a long time and
 	   we're about to disconnect unless it does something. send a fake
 	   EXISTS to see if it responds. it's expunged later. */
@@ -135,10 +132,8 @@
 	idle_send_fake_exists(ctx);
 }
 
-static void keepalive_timeout(void *context)
+static void keepalive_timeout(struct cmd_idle_context *ctx)
 {
-	struct cmd_idle_context *ctx = context;
-
 	if (ctx->client->output_pending) {
 		/* it's busy sending output */
 		return;
@@ -156,10 +151,8 @@
 	cmd_idle_continue(ctx->cmd);
 }
 
-static void idle_callback(struct mailbox *box, void *context)
+static void idle_callback(struct mailbox *box, struct cmd_idle_context *ctx)
 {
-        struct cmd_idle_context *ctx = context;
-
 	if (ctx->sync_ctx != NULL)
 		ctx->sync_pending = TRUE;
 	else {
@@ -192,7 +185,7 @@
 		if (imap_sync_deinit(ctx->sync_ctx) < 0) {
 			client_send_untagged_storage_error(client,
 				mailbox_get_storage(client->mailbox));
-			mailbox_notify_changes(client->mailbox, 0, NULL, NULL);
+			mailbox_notify_changes_stop(client->mailbox);
 		}
 		ctx->sync_ctx = NULL;
 	}

Index: imap-fetch-body.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/imap-fetch-body.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- imap-fetch-body.c	26 Feb 2006 11:24:35 -0000	1.28
+++ imap-fetch-body.c	15 Dec 2006 18:38:10 -0000	1.29
@@ -297,9 +297,8 @@
 }
 
 static int fetch_body(struct imap_fetch_context *ctx, struct mail *mail,
-		      void *context)
+		      const struct imap_fetch_body_data *body)
 {
-	const struct imap_fetch_body_data *body = context;
 	const struct message_size *fetch_size;
 	struct message_size hdr_size, body_size;
 
@@ -335,10 +334,9 @@
 }
 
 static void header_filter_eoh(struct message_header_line *hdr,
-			      bool *matched __attr_unused__, void *context)
+			      bool *matched __attr_unused__,
+			      struct imap_fetch_context *ctx)
 {
-	struct imap_fetch_context *ctx = context;
-
 	if (hdr != NULL && hdr->eoh)
 		ctx->cur_have_eoh = TRUE;
 }
@@ -391,11 +389,10 @@
 	return fetch_data(ctx, body, &msg_size);
 }
 
-static int fetch_body_header_partial(struct imap_fetch_context *ctx,
-				     struct mail *mail, void *context)
+static int
+fetch_body_header_partial(struct imap_fetch_context *ctx, struct mail *mail,
+			  const struct imap_fetch_body_data *body)
 {
-	const struct imap_fetch_body_data *body = context;
-
 	ctx->cur_input = mail_get_stream(mail, NULL, NULL);
 	if (ctx->cur_input == NULL)
 		return -1;
@@ -406,10 +403,10 @@
 	return fetch_header_partial_from(ctx, body, body->section);
 }
 
-static int fetch_body_header_fields(struct imap_fetch_context *ctx,
-				    struct mail *mail, void *context)
+static int
+fetch_body_header_fields(struct imap_fetch_context *ctx, struct mail *mail,
+			 struct imap_fetch_body_data *body)
 {
-	struct imap_fetch_body_data *body = context;
 	struct message_size size;
 	uoff_t old_offset;
 
@@ -490,9 +487,8 @@
 }
 
 static int fetch_body_mime(struct imap_fetch_context *ctx, struct mail *mail,
-			   void *context)
+			   const struct imap_fetch_body_data *body)
 {
-	const struct imap_fetch_body_data *body = context;
 	const struct message_part *part;
 	const char *section;
 

Index: imap-fetch.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/imap-fetch.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- imap-fetch.c	15 Dec 2006 18:10:53 -0000	1.49
+++ imap-fetch.c	15 Dec 2006 18:38:10 -0000	1.50
@@ -100,6 +100,7 @@
 	return ctx;
 }
 
+#undef imap_fetch_add_handler
 void imap_fetch_add_handler(struct imap_fetch_context *ctx,
 			    bool buffered, bool want_deinit,
 			    imap_fetch_handler_t *handler, void *context)

Index: imap-fetch.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/imap-fetch.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- imap-fetch.h	15 Dec 2006 18:10:53 -0000	1.21
+++ imap-fetch.h	15 Dec 2006 18:38:10 -0000	1.22
@@ -68,6 +68,17 @@
 void imap_fetch_add_handler(struct imap_fetch_context *ctx,
 			    bool buffered, bool want_deinit,
 			    imap_fetch_handler_t *handler, void *context);
+#ifdef CONTEXT_TYPE_SAFETY
+#  define imap_fetch_add_handler(ctx, buffered, want_deinit, handler, context) \
+	({(void)(1 ? 0 : handler((struct imap_fetch_context *)NULL, \
+				 (struct mail *)NULL, context)); \
+	  imap_fetch_add_handler(ctx, buffered, want_deinit, \
+		(imap_fetch_handler_t *)handler, context); })
+#else
+#  define imap_fetch_add_handler(ctx, buffered, want_deinit, handler, context) \
+	  imap_fetch_add_handler(ctx, buffered, want_deinit, \
+		(imap_fetch_handler_t *)handler, context)
+#endif
 
 struct imap_fetch_context *imap_fetch_init(struct client_command_context *cmd);
 int imap_fetch_deinit(struct imap_fetch_context *ctx);

Index: imap-thread.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/imap-thread.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- imap-thread.c	15 Dec 2006 16:55:31 -0000	1.31
+++ imap-thread.c	15 Dec 2006 18:38:10 -0000	1.32
@@ -337,9 +337,8 @@
 }
 
 static bool mail_thread_hash_cmp(const void *key, const void *data,
-				 void *context)
+				 struct imap_thread_mailbox *tbox)
 {
-	struct imap_thread_mailbox *tbox = context;
 	struct thread_context *ctx = tbox->ctx;
 	const struct msgid_rec *key_rec = key;
 	const struct mail_thread_rec *rec = data;
@@ -1936,9 +1935,9 @@
 static int
 imap_thread_expunge_handler(struct mail_index_sync_map_ctx *sync_ctx,
 			    uint32_t seq, const void *data __attr_unused__,
-			    void **sync_context __attr_unused__, void *context)
+			    void **sync_context __attr_unused__,
+			    struct imap_thread_mailbox *tbox)
 {
-	struct imap_thread_mailbox *tbox = context;
 	struct thread_context *ctx = tbox->ctx;
 	struct msgid_rec key;
 	const struct mail_thread_rec *rec;



More information about the dovecot-cvs mailing list