changeset 4907:5b4c9b20eba0 HEAD

Replaced void *context from a lot of callbacks with the actual context type. Also added/fixed some context type checks.
author Timo Sirainen <tss@iki.fi>
date Fri, 15 Dec 2006 20:38:08 +0200
parents 0c3c948412c5
children 94c302ea79bd
files src/auth/auth-client-connection.c src/auth/auth-master-connection.c src/auth/auth-master-listener.c src/auth/auth-worker-client.c src/auth/auth-worker-server.c src/auth/db-ldap.c src/auth/db-sql.c src/auth/passdb-checkpassword.c src/auth/passdb-pam.c src/auth/passdb-sql.c src/auth/userdb-sql.c src/deliver/auth-client.c src/dict/dict-server.c src/imap-login/client-authenticate.c src/imap-login/client.c src/imap-login/client.h src/imap-login/imap-proxy.c src/imap/client.c src/imap/client.h src/imap/cmd-append.c src/imap/cmd-idle.c src/imap/imap-fetch-body.c src/imap/imap-fetch.c src/imap/imap-fetch.h src/imap/imap-thread.c src/lib-auth/auth-client.c src/lib-auth/auth-server-connection.c src/lib-sql/driver-pgsql.c src/lib-sql/sql-api.h src/lib-storage/index/index-mail-headers.c src/lib-storage/index/index-mail.c src/lib-storage/index/index-mailbox-check.c src/lib-storage/index/index-search.c src/lib-storage/index/maildir/maildir-copy.c src/lib-storage/index/maildir/maildir-mail.c src/lib-storage/index/maildir/maildir-sync.c src/lib-storage/index/mbox/mbox-save.c src/lib-storage/mail-storage.c src/lib-storage/mail-storage.h src/lib/ioloop-notify-inotify.c src/lib/ioloop-notify-kqueue.c src/lib/ostream-file.c src/login-common/login-proxy.c src/login-common/ssl-proxy-gnutls.c src/login-common/ssl-proxy-openssl.c src/master/auth-process.c src/master/auth-process.h src/master/dict-process.c src/master/log.c src/master/login-process.c src/master/master-settings.c src/plugins/expire/auth-client.c src/pop3-login/client-authenticate.c src/pop3-login/client.c src/pop3-login/client.h src/pop3-login/pop3-proxy.c src/pop3/client.c src/util/rawlog.c
diffstat 58 files changed, 197 insertions(+), 293 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-client-connection.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/auth-client-connection.c	Fri Dec 15 20:38:08 2006 +0200
@@ -20,7 +20,7 @@
 
 static void auth_client_connection_unref(struct auth_client_connection **_conn);
 
-static void auth_client_input(void *context);
+static void auth_client_input(struct auth_client_connection *conn);
 
 static const char *reply_line_hide_pass(const char *line)
 {
@@ -64,10 +64,9 @@
 	t_pop();
 }
 
-static void auth_callback(const char *reply, void *context)
+static void auth_callback(const char *reply,
+			  struct auth_client_connection *conn)
 {
-	struct auth_client_connection *conn = context;
-
 	if (reply == NULL) {
 		/* handler destroyed */
 		auth_client_connection_unref(&conn);
@@ -121,10 +120,8 @@
 	return TRUE;
 }
 
-static int auth_client_output(void *context)
+static int auth_client_output(struct auth_client_connection *conn)
 {
-	struct auth_client_connection *conn = context;
-
 	if (o_stream_flush(conn->output) < 0) {
 		auth_client_connection_destroy(&conn);
 		return 1;
@@ -191,9 +188,8 @@
 	return TRUE;
 }
 
-static void auth_client_input(void *context)
+static void auth_client_input(struct auth_client_connection *conn)
 {
-	struct auth_client_connection *conn = context;
 	char *line;
 	bool ret;
 
@@ -361,9 +357,8 @@
 	return NULL;
 }
 
-static void request_timeout(void *context)
+static void request_timeout(struct auth_master_listener *listener)
 {
-        struct auth_master_listener *listener = context;
 	struct auth_client_connection *const *clients;
 	unsigned int i, count;
 
--- a/src/auth/auth-master-connection.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/auth-master-connection.c	Fri Dec 15 20:38:08 2006 +0200
@@ -28,8 +28,6 @@
 	struct auth_request *auth_request;
 };
 
-static int master_output(void *context);
-
 void auth_master_request_callback(const char *reply, void *context)
 {
 	struct auth_master_connection *conn = context;
@@ -148,9 +146,8 @@
 	return TRUE;
 }
 
-static void master_input(void *context)
+static void master_input(struct auth_master_connection *conn)
 {
-	struct auth_master_connection *conn = context;
  	char *line;
 	bool ret;
 
@@ -208,9 +205,8 @@
 	}
 }
 
-static int master_output(void *context)
+static int master_output(struct auth_master_connection *conn)
 {
-	struct auth_master_connection *conn = context;
 	int ret;
 
 	if ((ret = o_stream_flush(conn->output)) < 0) {
--- a/src/auth/auth-master-listener.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/auth-master-listener.c	Fri Dec 15 20:38:08 2006 +0200
@@ -87,9 +87,8 @@
 	i_free(listener);
 }
 
-static void auth_master_listener_accept(void *context)
+static void auth_master_listener_accept(struct auth_master_listener_socket *s)
 {
-	struct auth_master_listener_socket *s = context;
 	struct auth_master_connection *master;
 	int fd;
 
--- a/src/auth/auth-worker-client.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/auth-worker-client.c	Fri Dec 15 20:38:08 2006 +0200
@@ -386,9 +386,8 @@
         return TRUE;
 }
 
-static void auth_worker_input(void *context)
+static void auth_worker_input(struct auth_worker_client *client)
 {
-	struct auth_worker_client *client = context;
 	char *line;
 	bool ret;
 
@@ -423,10 +422,8 @@
 	auth_worker_client_unref(&client);
 }
 
-static int auth_worker_output(void *context)
+static int auth_worker_output(struct auth_worker_client *client)
 {
-	struct auth_worker_client *client = context;
-
 	if (o_stream_flush(client->output) < 0) {
 		auth_worker_client_destroy(&client);
 		return 1;
@@ -441,10 +438,8 @@
 	return 1;
 }
 
-static void auth_worker_client_timeout(void *context)
+static void auth_worker_client_timeout(struct auth_worker_client *client)
 {
-	struct auth_worker_client *client = context;
-
 	if (client->last_request + AUTH_WORKER_MAX_IDLE <= ioloop_time)
                 auth_worker_client_destroy(&client);
 }
--- a/src/auth/auth-worker-server.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/auth-worker-server.c	Fri Dec 15 20:38:08 2006 +0200
@@ -43,7 +43,7 @@
 static char *worker_socket_path;
 static struct timeout *to;
 
-static void worker_input(void *context);
+static void worker_input(struct auth_worker_connection *conn);
 
 static struct auth_worker_connection *auth_worker_create(void)
 {
@@ -201,9 +201,8 @@
 		idle_count++;
 }
 
-static void worker_input(void *context)
+static void worker_input(struct auth_worker_connection *conn)
 {
-	struct auth_worker_connection *conn = context;
 	struct auth_worker_request *request;
 	const char *line, *id_str;
 	unsigned int id;
--- a/src/auth/db-ldap.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/db-ldap.c	Fri Dec 15 20:38:08 2006 +0200
@@ -276,9 +276,8 @@
 	}
 }
 
-static void ldap_input(void *context)
+static void ldap_input(struct ldap_connection *conn)
 {
-	struct ldap_connection *conn = context;
         struct ldap_request *request;
 	struct timeval timeout;
 	LDAPMessage *res;
@@ -639,10 +638,8 @@
 }
 
 static const char *parse_setting(const char *key, const char *value,
-				 void *context)
+				 struct ldap_connection *conn)
 {
-	struct ldap_connection *conn = context;
-
 	return parse_setting_from_defs(conn->pool, setting_defs,
 				       &conn->set, key, value);
 }
--- a/src/auth/db-sql.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/db-sql.c	Fri Dec 15 20:38:08 2006 +0200
@@ -48,10 +48,8 @@
 }
 
 static const char *parse_setting(const char *key, const char *value,
-				 void *context)
+				 struct sql_connection *conn)
 {
-	struct sql_connection *conn = context;
-
 	return parse_setting_from_defs(conn->pool, setting_defs,
 				       &conn->set, key, value);
 }
--- a/src/auth/passdb-checkpassword.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/passdb-checkpassword.c	Fri Dec 15 20:38:08 2006 +0200
@@ -275,9 +275,8 @@
 	exit(2);
 }
 
-static void checkpassword_child_input(void *context)
+static void checkpassword_child_input(struct chkpw_auth_request *request)
 {
-	struct chkpw_auth_request *request = context;
 	unsigned char buf[1024];
 	ssize_t ret;
 
@@ -302,13 +301,12 @@
 	}
 }
 
-static void checkpassword_child_output(void *context)
+static void checkpassword_child_output(struct chkpw_auth_request *request)
 {
 	/* Send: username \0 password \0 timestamp \0.
 	   Must be 512 bytes or less. The "timestamp" parameter is actually
 	   useful only for APOP authentication. We don't support it, so
 	   keep it empty */
-	struct chkpw_auth_request *request = context;
 	struct auth_request *auth_request = request->request;
 	buffer_t *buf;
 	const unsigned char *data;
--- a/src/auth/passdb-pam.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/passdb-pam.c	Fri Dec 15 20:38:08 2006 +0200
@@ -309,9 +309,8 @@
 	}
 }
 
-static void pam_child_input(void *context)
+static void pam_child_input(struct pam_auth_request *request)
 {
-	struct pam_auth_request *request = context;
 	struct auth_request *auth_request = request->request;
 	enum passdb_result result;
 	char buf[PIPE_BUF + 1];
--- a/src/auth/passdb-sql.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/passdb-sql.c	Fri Dec 15 20:38:08 2006 +0200
@@ -52,9 +52,9 @@
 	}
 }
 
-static void sql_query_callback(struct sql_result *result, void *context)
+static void sql_query_callback(struct sql_result *result,
+			       struct passdb_sql_request *sql_request)
 {
-	struct passdb_sql_request *sql_request = context;
 	struct auth_request *auth_request = sql_request->auth_request;
 	enum passdb_result passdb_result;
 	const char *user, *password, *scheme;
@@ -179,9 +179,9 @@
         sql_lookup_pass(sql_request);
 }
 
-static void sql_set_credentials_callback(const char *error, void *context)
+static void sql_set_credentials_callback(const char *error,
+					 struct passdb_sql_request *sql_request)
 {
-	struct passdb_sql_request *sql_request = context;
 	enum passdb_result result;
 
 	if (error == NULL)
--- a/src/auth/userdb-sql.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/auth/userdb-sql.c	Fri Dec 15 20:38:08 2006 +0200
@@ -78,9 +78,9 @@
 	return reply;
 }
 
-static void sql_query_callback(struct sql_result *sql_result, void *context)
+static void sql_query_callback(struct sql_result *sql_result,
+			       struct userdb_sql_request *sql_request)
 {
-	struct userdb_sql_request *sql_request = context;
 	struct auth_request *auth_request = sql_request->auth_request;
 	struct auth_stream_reply *reply = NULL;
 	enum userdb_result result = USERDB_RESULT_INTERNAL_FAILURE;
--- a/src/deliver/auth-client.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/deliver/auth-client.c	Fri Dec 15 20:38:08 2006 +0200
@@ -116,9 +116,8 @@
 	return_value = EX_OK;
 }
 
-static void auth_input(void *context)
+static void auth_input(struct auth_connection *conn)
 {
-	struct auth_connection *conn = context;
 	const char *line;
 
 	switch (i_stream_read(conn->input)) {
@@ -188,10 +187,8 @@
 	return conn;
 }
 
-static void auth_client_timeout(void *context)
+static void auth_client_timeout(struct auth_connection *conn)
 {
-	struct auth_connection *conn = context;
-
 	if (!conn->handshaked)
 		i_error("Connecting to dovecot-auth timed out");
 	else
--- a/src/dict/dict-server.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/dict/dict-server.c	Fri Dec 15 20:38:08 2006 +0200
@@ -358,9 +358,8 @@
 	return 0;
 }
 
-static void dict_client_connection_input(void *context)
+static void dict_client_connection_input(struct dict_client_connection *conn)
 {
-	struct dict_client_connection *conn = context;
 	const char *line;
 	unsigned int i;
 	int ret;
@@ -454,9 +453,8 @@
 	return conn;
 }
 
-static void dict_server_listener_accept(void *context)
+static void dict_server_listener_accept(struct dict_server *server)
 {
-	struct dict_server *server = context;
 	int fd;
 
 	fd = net_accept(server->fd, NULL, NULL);
--- a/src/imap-login/client-authenticate.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap-login/client-authenticate.c	Fri Dec 15 20:38:08 2006 +0200
@@ -44,9 +44,8 @@
 	return str_c(str);
 }
 
-static void client_auth_input(void *context)
+static void client_auth_input(struct imap_client *client)
 {
-	struct imap_client *client = context;
 	char *line;
 
 	if (!client_read(client))
--- a/src/imap-login/client.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap-login/client.c	Fri Dec 15 20:38:08 2006 +0200
@@ -147,9 +147,8 @@
 	client->io = io_add(client->common.fd, IO_READ, client_input, client);
 }
 
-static int client_output_starttls(void *context)
+static int client_output_starttls(struct imap_client *client)
 {
-	struct imap_client *client = context;
 	int ret;
 
 	if ((ret = o_stream_flush(client->output)) < 0) {
@@ -333,10 +332,8 @@
 	}
 }
 
-void client_input(void *context)
+void client_input(struct imap_client *client)
 {
-	struct imap_client *client = context;
-
 	client->last_input = ioloop_time;
 
 	if (!client_read(client))
--- a/src/imap-login/client.h	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap-login/client.h	Fri Dec 15 20:38:08 2006 +0200
@@ -40,7 +40,7 @@
 
 bool client_read(struct imap_client *client);
 bool client_skip_line(struct imap_client *client);
-void client_input(void *context);
+void client_input(struct imap_client *client);
 
 void client_ref(struct imap_client *client);
 bool client_unref(struct imap_client *client);
--- a/src/imap-login/imap-proxy.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap-login/imap-proxy.c	Fri Dec 15 20:38:08 2006 +0200
@@ -83,9 +83,8 @@
 }
 
 static void proxy_input(struct istream *input, struct ostream *output,
-			void *context)
+			struct imap_client *client)
 {
-	struct imap_client *client = context;
 	const char *line;
 
 	if (input == NULL) {
--- a/src/imap/client.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap/client.c	Fri Dec 15 20:38:08 2006 +0200
@@ -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;
--- a/src/imap/client.h	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap/client.h	Fri Dec 15 20:38:08 2006 +0200
@@ -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
--- a/src/imap/cmd-append.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap/cmd-append.c	Fri Dec 15 20:38:08 2006 +0200
@@ -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;
--- a/src/imap/cmd-idle.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap/cmd-idle.c	Fri Dec 15 20:38:08 2006 +0200
@@ -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;
 	}
--- a/src/imap/imap-fetch-body.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap/imap-fetch-body.c	Fri Dec 15 20:38:08 2006 +0200
@@ -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;
 
--- a/src/imap/imap-fetch.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap/imap-fetch.c	Fri Dec 15 20:38:08 2006 +0200
@@ -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)
--- a/src/imap/imap-fetch.h	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap/imap-fetch.h	Fri Dec 15 20:38:08 2006 +0200
@@ -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);
--- a/src/imap/imap-thread.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/imap/imap-thread.c	Fri Dec 15 20:38:08 2006 +0200
@@ -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;
--- a/src/lib-auth/auth-client.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-auth/auth-client.c	Fri Dec 15 20:38:08 2006 +0200
@@ -108,10 +108,8 @@
 	client->connect_notify_context = context;
 }
 
-static void reconnect_timeout(void *context)
+static void reconnect_timeout(struct auth_client *client)
 {
-	struct auth_client *client = context;
-
 	auth_client_connect_missing_servers(client);
 }
 
--- a/src/lib-auth/auth-server-connection.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-auth/auth-server-connection.c	Fri Dec 15 20:38:08 2006 +0200
@@ -124,9 +124,8 @@
 	return TRUE;
 }
 
-static void auth_client_input(void *context)
+static void auth_client_input(struct auth_server_connection *conn)
 {
-	struct auth_server_connection *conn = context;
 	const char *line;
 	int ret;
 
--- a/src/lib-sql/driver-pgsql.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-sql/driver-pgsql.c	Fri Dec 15 20:38:08 2006 +0200
@@ -101,9 +101,8 @@
 		t_strndup(msg, len-1);
 }
 
-static void connect_callback(void *context)
+static void connect_callback(struct pgsql_db *db)
 {
-	struct pgsql_db *db = context;
 	enum io_condition io_dir = 0;
 	int ret;
 
@@ -211,10 +210,8 @@
 	return 0;
 }
 
-static void consume_results(void *context)
+static void consume_results(struct pgsql_db *db)
 {
-	struct pgsql_db *db = context;
-
 	do {
 		if (!PQconsumeInput(db->pg))
 			break;
@@ -279,9 +276,8 @@
 	}
 }
 
-static void get_result(void *context)
+static void get_result(struct pgsql_result *result)
 {
-        struct pgsql_result *result = context;
         struct pgsql_db *db = (struct pgsql_db *)result->api.db;
 
 	if (!PQconsumeInput(db->pg)) {
@@ -306,9 +302,8 @@
 	result_finish(result);
 }
 
-static void flush_callback(void *context)
+static void flush_callback(struct pgsql_result *result)
 {
-	struct pgsql_result *result = context;
         struct pgsql_db *db = (struct pgsql_db *)result->api.db;
 	int ret;
 
@@ -373,10 +368,8 @@
 	i_free(queue);
 }
 
-static void queue_timeout(void *context)
+static void queue_timeout(struct pgsql_db *db)
 {
-	struct pgsql_db *db = context;
-
 	if (db->querying)
 		return;
 
@@ -742,11 +735,9 @@
 }
 
 static void
-transaction_update_callback(struct sql_result *result, void *context)
+transaction_update_callback(struct sql_result *result,
+			    struct pgsql_transaction_context *ctx)
 {
-	struct pgsql_transaction_context *ctx =
-		(struct pgsql_transaction_context *)context;
-
 	if (sql_result_next_row(result) < 0) {
 		ctx->failed = TRUE;
 		ctx->error = sql_result_get_error(result);
--- a/src/lib-sql/sql-api.h	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-sql/sql-api.h	Fri Dec 15 20:38:08 2006 +0200
@@ -93,10 +93,11 @@
 #  define sql_transaction_commit(ctx, callback, context) \
 	({(void)(1 ? 0 : callback((const char *)NULL, context)); \
 	  sql_transaction_commit(ctx, \
-		(sql_query_callback_t *)callback, context); })
+		(sql_commit_callback_t *)callback, context); })
 #else
 #  define sql_transaction_commit(ctx, callback, context) \
-	  sql_transaction_commit(ctx, (sql_query_callback_t *)callback, context)
+	  sql_transaction_commit(ctx, \
+		(sql_commit_callback_t *)callback, context)
 #endif
 /* Synchronous commit. Returns 0 if ok, -1 if error. */
 int sql_transaction_commit_s(struct sql_transaction_context **ctx,
--- a/src/lib-storage/index/index-mail-headers.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/index/index-mail-headers.c	Fri Dec 15 20:38:08 2006 +0200
@@ -327,18 +327,16 @@
 
 static void
 index_mail_parse_part_header_cb(struct message_part *part,
-				struct message_header_line *hdr, void *context)
+				struct message_header_line *hdr,
+				struct index_mail *mail)
 {
-	struct index_mail *mail = context;
-
 	index_mail_parse_header(part, hdr, mail);
 }
 
 static void
-index_mail_parse_header_cb(struct message_header_line *hdr, void *context)
+index_mail_parse_header_cb(struct message_header_line *hdr,
+			   struct index_mail *mail)
 {
-	struct index_mail *mail = context;
-
 	index_mail_parse_header(mail->data.parts, hdr, mail);
 }
 
@@ -379,10 +377,9 @@
 }
 
 static void
-imap_envelope_parse_callback(struct message_header_line *hdr, void *context)
+imap_envelope_parse_callback(struct message_header_line *hdr,
+			     struct index_mail *mail)
 {
-	struct index_mail *mail = context;
-
 	imap_envelope_parse_header(mail->data_pool,
 				   &mail->data.envelope_data, hdr);
 
@@ -592,10 +589,8 @@
 }
 
 static void header_cache_callback(struct message_header_line *hdr,
-				  bool *matched, void *context)
+				  bool *matched, struct index_mail *mail)
 {
-	struct index_mail *mail = context;
-
 	if (hdr != NULL && hdr->eoh)
 		*matched = FALSE;
 
--- a/src/lib-storage/index/index-mail.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/index/index-mail.c	Fri Dec 15 20:38:08 2006 +0200
@@ -366,10 +366,8 @@
 
 static void parse_bodystructure_part_header(struct message_part *part,
 					    struct message_header_line *hdr,
-					    void *context)
+					    pool_t pool)
 {
-	pool_t pool = context;
-
 	imap_bodystructure_parse_header(pool, part, hdr);
 }
 
--- a/src/lib-storage/index/index-mailbox-check.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/index/index-mailbox-check.c	Fri Dec 15 20:38:08 2006 +0200
@@ -21,9 +21,8 @@
 	struct io *io;
 };
 
-static void check_timeout(void *context)
+static void check_timeout(struct index_mailbox *ibox)
 {
-	struct index_mailbox *ibox = context;
 	struct index_notify_file *file;
 	struct stat st;
 	time_t last_check;
@@ -53,10 +52,8 @@
 	}
 }
 
-static void notify_callback(void *context)
+static void notify_callback(struct index_mailbox *ibox)
 {
-	struct index_mailbox *ibox = context;
-
 	ibox->notify_last_check = ioloop_time;
 	if ((unsigned int)(ioloop_time - ibox->notify_last_sent) >=
 	    ibox->min_notify_interval) {
--- a/src/lib-storage/index/index-search.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/index/index-search.c	Fri Dec 15 20:38:08 2006 +0200
@@ -126,10 +126,9 @@
 	}
 }
 
-static void search_init_seqset_arg(struct mail_search_arg *arg, void *context)
+static void search_init_seqset_arg(struct mail_search_arg *arg,
+				   struct index_search_context *ctx)
 {
-	struct index_search_context *ctx = context;
-
 	switch (arg->type) {
 	case SEARCH_SEQSET:
 		ctx->have_seqsets = TRUE;
@@ -143,10 +142,9 @@
 	}
 }
 
-static void search_seqset_arg(struct mail_search_arg *arg, void *context)
+static void search_seqset_arg(struct mail_search_arg *arg,
+			      struct index_search_context *ctx)
 {
-	struct index_search_context *ctx = context;
-
 	if (arg->type == SEARCH_SEQSET) {
 		if (seqset_contains(arg->value.seqset, ctx->mail_ctx.seq))
 			ARG_SET_RESULT(arg, 1);
@@ -155,10 +153,9 @@
 	}
 }
 
-static void search_index_arg(struct mail_search_arg *arg, void *context)
+static void search_index_arg(struct mail_search_arg *arg,
+			     struct index_search_context *ctx)
 {
-	struct index_search_context *ctx = context;
-
 	if (ctx->imail->data.rec == NULL) {
 		/* expunged message */
 		ARG_SET_RESULT(arg, 0);
@@ -258,10 +255,9 @@
 	}
 }
 
-static void search_cached_arg(struct mail_search_arg *arg, void *context)
+static void search_cached_arg(struct mail_search_arg *arg,
+			      struct index_search_context *ctx)
 {
-	struct index_search_context *ctx = context;
-
 	switch (search_arg_match_cached(ctx, arg->type,
 					arg->value.str)) {
 	case -1:
@@ -335,9 +331,9 @@
 	return arg->context;
 }
 
-static void search_header_arg(struct mail_search_arg *arg, void *context)
+static void search_header_arg(struct mail_search_arg *arg,
+			      struct search_header_context *ctx)
 {
-	struct search_header_context *ctx = context;
         struct header_search_context *hdr_search_ctx;
 	int ret;
 
@@ -437,10 +433,9 @@
 	}
 }
 
-static void search_header(struct message_header_line *hdr, void *context)
+static void search_header(struct message_header_line *hdr,
+			  struct search_header_context *ctx)
 {
-	struct search_header_context *ctx = context;
-
 	if (hdr == NULL) {
 		/* end of headers, mark all unknown SEARCH_HEADERs unmatched */
 		mail_search_args_foreach(ctx->args, search_header_unmatch, ctx);
@@ -461,9 +456,9 @@
 	}
 }
 
-static void search_body(struct mail_search_arg *arg, void *context)
+static void search_body(struct mail_search_arg *arg,
+			struct search_body_context *ctx)
 {
-	struct search_body_context *ctx = context;
         enum message_body_search_error error;
 	int ret;
 	bool retry = FALSE;
--- a/src/lib-storage/index/maildir/maildir-copy.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/index/maildir/maildir-copy.c	Fri Dec 15 20:38:08 2006 +0200
@@ -55,9 +55,8 @@
 }
 
 static int do_hardlink(struct maildir_mailbox *mbox, const char *path,
-		       void *context)
+		       struct hardlink_ctx *ctx)
 {
-	struct hardlink_ctx *ctx = context;
 	int ret;
 
 	if (mbox->storage->save_size_in_filename && !ctx->size_set) {
--- a/src/lib-storage/index/maildir/maildir-mail.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Fri Dec 15 20:38:08 2006 +0200
@@ -11,10 +11,8 @@
 #include <sys/stat.h>
 
 static int
-do_open(struct maildir_mailbox *mbox, const char *path, void *context)
+do_open(struct maildir_mailbox *mbox, const char *path, int *fd)
 {
-	int *fd = context;
-
 	*fd = open(path, O_RDONLY);
 	if (*fd != -1)
 		return 1;
@@ -27,10 +25,8 @@
 }
 
 static int
-do_stat(struct maildir_mailbox *mbox, const char *path, void *context)
+do_stat(struct maildir_mailbox *mbox, const char *path, struct stat *st)
 {
-	struct stat *st = context;
-
 	if (stat(path, st) == 0)
 		return 1;
 	if (errno == ENOENT)
--- a/src/lib-storage/index/maildir/maildir-sync.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Fri Dec 15 20:38:08 2006 +0200
@@ -394,9 +394,8 @@
 }
 
 static int maildir_sync_flags(struct maildir_mailbox *mbox, const char *path,
-			      void *context)
+			      struct maildir_index_sync_context *ctx)
 {
-        struct maildir_index_sync_context *ctx = context;
 	const struct mail_index_sync_rec *recs;
 	const char *dir, *fname, *newfname, *newpath;
 	enum mail_flags flags;
--- a/src/lib-storage/index/mbox/mbox-save.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/index/mbox/mbox-save.c	Fri Dec 15 20:38:08 2006 +0200
@@ -322,10 +322,8 @@
 }
 
 static void save_header_callback(struct message_header_line *hdr,
-				 bool *matched, void *context)
+				 bool *matched, struct mbox_save_context *ctx)
 {
-	struct mbox_save_context *ctx = context;
-
 	if (hdr != NULL) {
 		if (strncmp(hdr->name, "From ", 5) == 0) {
 			/* we can't allow From_-lines in headers. there's no
--- a/src/lib-storage/mail-storage.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/mail-storage.c	Fri Dec 15 20:38:08 2006 +0200
@@ -475,12 +475,18 @@
 	return ctx->box->v.sync_deinit(ctx, status_items, status_r);
 }
 
+#undef mailbox_notify_changes
 void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,
 			    mailbox_notify_callback_t *callback, void *context)
 {
 	box->v.notify_changes(box, min_interval, callback, context);
 }
 
+void mailbox_notify_changes_stop(struct mailbox *box)
+{
+	box->v.notify_changes(box, 0, NULL, NULL);
+}
+
 struct mail_keywords *
 mailbox_keywords_create(struct mailbox_transaction_context *t,
 			const char *const keywords[])
--- a/src/lib-storage/mail-storage.h	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib-storage/mail-storage.h	Fri Dec 15 20:38:08 2006 +0200
@@ -303,10 +303,20 @@
 			enum mailbox_status_items status_items,
 			struct mailbox_status *status_r);
 
-/* Call given callback function when something changes in the mailbox.
-   It's done until this function is called with callback = NULL. */
+/* Call given callback function when something changes in the mailbox. */
 void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,
 			    mailbox_notify_callback_t *callback, void *context);
+#ifdef CONTEXT_TYPE_SAFETY
+#  define mailbox_notify_changes(box, min_interval, callback, context) \
+	({(void)(1 ? 0 : callback((struct mailbox *)NULL, context)); \
+	  mailbox_notify_changes(box, min_interval, \
+		(mailbox_notify_callback_t *)callback, context); })
+#else
+#  define mailbox_notify_changes(box, min_interval, callback, context) \
+	  mailbox_notify_changes(box, min_interval, \
+		(mailbox_notify_callback_t *)callback, context)
+#endif
+void mailbox_notify_changes_stop(struct mailbox *box);
 
 struct mailbox_transaction_context *
 mailbox_transaction_begin(struct mailbox *box,
--- a/src/lib/ioloop-notify-inotify.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib/ioloop-notify-inotify.c	Fri Dec 15 20:38:08 2006 +0200
@@ -88,10 +88,8 @@
 	return TRUE;
 }
 
-static void event_callback(void *context)
+static void event_callback(struct ioloop *ioloop)
 {
-	struct ioloop *ioloop = context;
-
 	while (event_read_next(ioloop)) ;
 }
 
--- a/src/lib/ioloop-notify-kqueue.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib/ioloop-notify-kqueue.c	Fri Dec 15 20:38:08 2006 +0200
@@ -38,9 +38,8 @@
 	struct io *event_io;
 };
 
-static void event_callback(void *context)
+static void event_callback(struct ioloop_notify_handler_context *ctx)
 {
-	struct ioloop_notify_handler_context *ctx = context;
 	struct io *io;
 	struct kevent ev;
 	struct timespec ts;
--- a/src/lib/ostream-file.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/lib/ostream-file.c	Fri Dec 15 20:38:08 2006 +0200
@@ -47,7 +47,7 @@
 	unsigned int autoclose_fd:1;
 };
 
-static void stream_send_io(void *context);
+static void stream_send_io(struct file_ostream *fstream);
 
 static void stream_closed(struct file_ostream *fstream)
 {
@@ -339,9 +339,8 @@
 	fstream->buffer_size = size;
 }
 
-static void stream_send_io(void *context)
+static void stream_send_io(struct file_ostream *fstream)
 {
-	struct file_ostream *fstream = context;
 	struct ostream *ostream = &fstream->ostream.ostream;
 	int ret;
 
--- a/src/login-common/login-proxy.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/login-common/login-proxy.c	Fri Dec 15 20:38:08 2006 +0200
@@ -29,9 +29,8 @@
 
 static struct hash_table *login_proxies;
 
-static void server_input(void *context)
+static void server_input(struct login_proxy *proxy)
 {
-	struct login_proxy *proxy = context;
 	unsigned char buf[OUTBUF_THRESHOLD];
 	ssize_t ret;
 
@@ -48,9 +47,8 @@
                 login_proxy_free(proxy);
 }
 
-static void proxy_client_input(void *context)
+static void proxy_client_input(struct login_proxy *proxy)
 {
-	struct login_proxy *proxy = context;
 	unsigned char buf[OUTBUF_THRESHOLD];
 	ssize_t ret;
 
@@ -67,10 +65,8 @@
                 login_proxy_free(proxy);
 }
 
-static int server_output(void *context)
+static int server_output(struct login_proxy *proxy)
 {
-	struct login_proxy *proxy = context;
-
 	if (o_stream_flush(proxy->server_output) < 0) {
                 login_proxy_free(proxy);
 		return 1;
@@ -87,10 +83,8 @@
 	return 1;
 }
 
-static int proxy_client_output(void *context)
+static int proxy_client_output(struct login_proxy *proxy)
 {
-	struct login_proxy *proxy = context;
-
 	if (o_stream_flush(proxy->client_output) < 0) {
                 login_proxy_free(proxy);
 		return 1;
@@ -107,17 +101,14 @@
 	return 1;
 }
 
-static void proxy_prelogin_input(void *context)
+static void proxy_prelogin_input(struct login_proxy *proxy)
 {
-	struct login_proxy *proxy = context;
-
 	proxy->callback(proxy->server_input, proxy->server_output,
 			proxy->context);
 }
 
-static void proxy_wait_connect(void *context)
+static void proxy_wait_connect(struct login_proxy *proxy)
 {
-	struct login_proxy *proxy = context;
 	int err;
 
 	err = net_geterror(proxy->server_fd);
--- a/src/login-common/ssl-proxy-gnutls.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/login-common/ssl-proxy-gnutls.c	Fri Dec 15 20:38:08 2006 +0200
@@ -52,8 +52,8 @@
 static gnutls_dh_params dh_params;
 static gnutls_rsa_params rsa_params;
 
-static void ssl_input(void *context);
-static void plain_input(void *context);
+static void ssl_input(struct ssl_proxy *proxy);
+static void plain_input(struct ssl_proxy *proxy);
 static bool ssl_proxy_destroy(struct ssl_proxy *proxy);
 
 static const char *get_alert_text(struct ssl_proxy *proxy)
@@ -158,9 +158,8 @@
 	return FALSE;
 }
 
-static void ssl_output(void *context)
+static void ssl_output(struct ssl_proxy *proxy)
 {
-        struct ssl_proxy *proxy = context;
 	int sent;
 
 	sent = net_transmit(proxy->fd_plain,
@@ -183,9 +182,8 @@
 	proxy->io_ssl = io_add(proxy->fd_ssl, IO_READ, ssl_input, proxy);
 }
 
-static void ssl_input(void *context)
+static void ssl_input(struct ssl_proxy *proxy)
 {
-        struct ssl_proxy *proxy = context;
 	int rcvd, sent;
 
 	rcvd = proxy_recv_ssl(proxy, proxy->outbuf_plain,
@@ -212,9 +210,8 @@
 	proxy->io_ssl = io_add(proxy->fd_ssl, IO_WRITE, ssl_output, proxy);
 }
 
-static void plain_output(void *context)
+static void plain_output(struct ssl_proxy *proxy)
 {
-	struct ssl_proxy *proxy = context;
 	int sent;
 
 	sent = proxy_send_ssl(proxy, NULL, proxy->send_left_ssl);
@@ -230,9 +227,8 @@
 	proxy->io_plain = io_add(proxy->fd_plain, IO_READ, plain_input, proxy);
 }
 
-static void plain_input(void *context)
+static void plain_input(struct ssl_proxy *proxy)
 {
-	struct ssl_proxy *proxy = context;
 	char buf[1024];
 	ssize_t rcvd, sent;
 
@@ -256,9 +252,8 @@
 	proxy->io_plain = io_add(proxy->fd_ssl, IO_WRITE, plain_output, proxy);
 }
 
-static void ssl_handshake(void *context)
+static void ssl_handshake(struct ssl_proxy *proxy)
 {
-	struct ssl_proxy *proxy = context;
 	int ret, dir;
 
         ret = gnutls_handshake(proxy->session);
--- a/src/login-common/ssl-proxy-openssl.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/login-common/ssl-proxy-openssl.c	Fri Dec 15 20:38:08 2006 +0200
@@ -67,10 +67,10 @@
 static struct hash_table *ssl_proxies;
 static struct ssl_parameters ssl_params;
 
-static void plain_read(void *context);
+static void plain_read(struct ssl_proxy *proxy);
 static void ssl_read(struct ssl_proxy *proxy);
 static void ssl_write(struct ssl_proxy *proxy);
-static void ssl_step(void *context);
+static void ssl_step(struct ssl_proxy *proxy);
 static void ssl_proxy_destroy(struct ssl_proxy *proxy);
 static void ssl_proxy_unref(struct ssl_proxy *proxy);
 
@@ -225,9 +225,8 @@
 	}
 }
 
-static void plain_read(void *context)
+static void plain_read(struct ssl_proxy *proxy)
 {
-	struct ssl_proxy *proxy = context;
 	ssize_t ret;
 	bool corked = FALSE;
 
@@ -265,9 +264,8 @@
 	ssl_proxy_unref(proxy);
 }
 
-static void plain_write(void *context)
+static void plain_write(struct ssl_proxy *proxy)
 {
-	struct ssl_proxy *proxy = context;
 	ssize_t ret;
 
 	proxy->refcount++;
@@ -424,10 +422,8 @@
 	}
 }
 
-static void ssl_step(void *context)
+static void ssl_step(struct ssl_proxy *proxy)
 {
-	struct ssl_proxy *proxy = context;
-
 	proxy->refcount++;
 
 	if (!proxy->handshaked)
--- a/src/master/auth-process.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/master/auth-process.c	Fri Dec 15 20:38:08 2006 +0200
@@ -64,7 +64,8 @@
 static void auth_processes_start_missing(void *context);
 
 void auth_process_request(struct auth_process *process, unsigned int login_pid,
-			  unsigned int login_id, void *context)
+			  unsigned int login_id,
+			  struct login_auth_request *request)
 {
 	string_t *str;
 	ssize_t ret;
@@ -88,7 +89,7 @@
 		}
 		auth_process_destroy(process);
 	} else {
-		hash_insert(process->requests, POINTER_CAST(auth_tag), context);
+		hash_insert(process->requests, POINTER_CAST(auth_tag), request);
 	}
 	t_pop();
 }
@@ -96,7 +97,7 @@
 static bool
 auth_process_input_user(struct auth_process *process, const char *args)
 {
-	void *context;
+	struct login_auth_request *request;
 	const char *const *list;
 	unsigned int id;
 
@@ -110,14 +111,14 @@
 	}
 	id = (unsigned int)strtoul(list[0], NULL, 10);
 
-	context = hash_lookup(process->requests, POINTER_CAST(id));
-	if (context == NULL) {
+	request = hash_lookup(process->requests, POINTER_CAST(id));
+	if (request == NULL) {
 		i_error("BUG: Auth process %s sent unrequested reply with ID "
 			"%u", dec2str(process->pid), id);
 		return FALSE;
 	}
 
-	auth_master_callback(list[1], list + 2, context);
+	auth_master_callback(list[1], list + 2, request);
 	hash_remove(process->requests, POINTER_CAST(id));
 	return TRUE;
 }
@@ -125,19 +126,19 @@
 static bool
 auth_process_input_notfound(struct auth_process *process, const char *args)
 {
-	void *context;
+	struct login_auth_request *request;
 	unsigned int id;
 
 	id = (unsigned int)strtoul(args, NULL, 10);
 
-	context = hash_lookup(process->requests, POINTER_CAST(id));
-	if (context == NULL) {
+	request = hash_lookup(process->requests, POINTER_CAST(id));
+	if (request == NULL) {
 		i_error("BUG: Auth process %s sent unrequested reply with ID "
 			"%u", dec2str(process->pid), id);
 		return FALSE;
 	}
 
-	auth_master_callback(NULL, NULL, context);
+	auth_master_callback(NULL, NULL, request);
 	hash_remove(process->requests, POINTER_CAST(id));
 	return TRUE;
 }
@@ -172,7 +173,7 @@
 static bool
 auth_process_input_fail(struct auth_process *process, const char *args)
 {
-	void *context;
+	struct login_auth_request *request;
  	const char *error;
 	unsigned int id;
 
@@ -182,21 +183,20 @@
 
 	id = (unsigned int)strtoul(args, NULL, 10);
 
-	context = hash_lookup(process->requests, POINTER_CAST(id));
-	if (context == NULL) {
+	request = hash_lookup(process->requests, POINTER_CAST(id));
+	if (request == NULL) {
 		i_error("BUG: Auth process %s sent unrequested reply with ID "
 			"%u", dec2str(process->pid), id);
 		return FALSE;
 	}
 
-	auth_master_callback(NULL, NULL, context);
+	auth_master_callback(NULL, NULL, request);
 	hash_remove(process->requests, POINTER_CAST(id));
 	return TRUE;
 }
 
-static void auth_process_input(void *context)
+static void auth_process_input(struct auth_process *process)
 {
-	struct auth_process *process = context;
 	const char *line;
 	bool ret;
 
@@ -255,9 +255,8 @@
 	}
 }
 
-static void auth_worker_input(void *context)
+static void auth_worker_input(struct auth_process *p)
 {
-	struct auth_process *p = context;
 	int fd;
 
 	fd = net_accept(p->worker_listen_fd, NULL, NULL);
--- a/src/master/auth-process.h	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/master/auth-process.h	Fri Dec 15 20:38:08 2006 +0200
@@ -1,15 +1,18 @@
 #ifndef __AUTH_PROCESS_H
 #define __AUTH_PROCESS_H
 
+struct login_auth_request;
+
 void auth_master_callback(const char *user, const char *const *args,
-			  void *context);
+			  struct login_auth_request *request);
 
 /* Find process for given id */
 struct auth_process *auth_process_find(unsigned int pid);
 
 /* Request information about given cookie */
 void auth_process_request(struct auth_process *process, unsigned int login_pid,
-			  unsigned int login_id, void *context);
+			  unsigned int login_id,
+			  struct login_auth_request *request);
 
 /* Close any fds used by auth processes */
 void auth_processes_destroy_all(void);
--- a/src/master/dict-process.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/master/dict-process.c	Fri Dec 15 20:38:08 2006 +0200
@@ -96,10 +96,8 @@
 	return -1;
 }
 
-static void dict_process_listen_input(void *context)
+static void dict_process_listen_input(struct dict_process *process)
 {
-	struct dict_process *process = context;
-
 	i_assert(process->log == NULL);
 	dict_process_start(process);
 }
--- a/src/master/log.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/master/log.c	Fri Dec 15 20:38:08 2006 +0200
@@ -71,10 +71,8 @@
 		to = timeout_add(1000, log_throttle_timeout, NULL);
 }
 
-static void log_read_callback(void *context)
+static void log_read_callback(struct log_io *log_io)
 {
-	struct log_io *log_io = context;
-
 	(void)log_read(log_io);
 }
 
--- a/src/master/login-process.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/master/login-process.c	Fri Dec 15 20:38:08 2006 +0200
@@ -85,9 +85,8 @@
 }
 
 void auth_master_callback(const char *user, const char *const *args,
-			  void *context)
+			  struct login_auth_request *request)
 {
-	struct login_auth_request *request = context;
 	struct master_login_reply master_reply;
 	ssize_t ret;
 
@@ -360,9 +359,8 @@
 	return 1;
 }
 
-static void login_process_input(void *context)
+static void login_process_input(struct login_process *p)
 {
-	struct login_process *p = context;
 	struct auth_process *auth_process;
 	struct login_auth_request *authreq;
 	struct master_login_request req;
--- a/src/master/master-settings.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/master/master-settings.c	Fri Dec 15 20:38:08 2006 +0200
@@ -1032,9 +1032,8 @@
 }
 
 static const char *parse_setting(const char *key, const char *value,
-				 void *context)
+				 struct settings_parse_ctx *ctx)
 {
-	struct settings_parse_ctx *ctx = context;
 	const char *error;
 
 	/* backwards compatibility */
@@ -1170,10 +1169,9 @@
 	return server;
 }
 
-static bool parse_section(const char *type, const char *name, void *context,
-			  const char **errormsg)
+static bool parse_section(const char *type, const char *name,
+			  struct settings_parse_ctx *ctx, const char **errormsg)
 {
-	struct settings_parse_ctx *ctx = context;
 	struct server_settings *server;
 
 	if (type == NULL) {
--- a/src/plugins/expire/auth-client.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/plugins/expire/auth-client.c	Fri Dec 15 20:38:08 2006 +0200
@@ -30,7 +30,7 @@
 	unsigned int handshaked:1;
 };
 
-static void auth_input(void *context);
+static void auth_input(struct auth_connection *conn);
 
 static int auth_connection_connect(struct auth_connection *conn)
 {
@@ -149,9 +149,8 @@
 	conn->return_value = 1;
 }
 
-static void auth_input(void *context)
+static void auth_input(struct auth_connection *conn)
 {
-	struct auth_connection *conn = context;
 	const char *line;
 
 	switch (i_stream_read(conn->input)) {
--- a/src/pop3-login/client-authenticate.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/pop3-login/client-authenticate.c	Fri Dec 15 20:38:08 2006 +0200
@@ -58,9 +58,8 @@
 	return TRUE;
 }
 
-static void client_auth_input(void *context)
+static void client_auth_input(struct pop3_client *client)
 {
-	struct pop3_client *client = context;
 	char *line;
 
 	if (!client_read(client))
--- a/src/pop3-login/client.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/pop3-login/client.c	Fri Dec 15 20:38:08 2006 +0200
@@ -100,9 +100,8 @@
 	client->io = io_add(client->common.fd, IO_READ, client_input, client);
 }
 
-static int client_output_starttls(void *context)
+static int client_output_starttls(struct pop3_client *client)
 {
-	struct pop3_client *client = context;
 	int ret;
 
 	if ((ret = o_stream_flush(client->output)) < 0) {
@@ -198,9 +197,8 @@
 	}
 }
 
-void client_input(void *context)
+void client_input(struct pop3_client *client)
 {
-	struct pop3_client *client = context;
 	char *line, *args;
 
 	client->last_input = ioloop_time;
--- a/src/pop3-login/client.h	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/pop3-login/client.h	Fri Dec 15 20:38:08 2006 +0200
@@ -39,7 +39,7 @@
 void client_send_line(struct pop3_client *client, const char *line);
 
 bool client_read(struct pop3_client *client);
-void client_input(void *context);
+void client_input(struct pop3_client *client);
 
 void client_ref(struct pop3_client *client);
 bool client_unref(struct pop3_client *client);
--- a/src/pop3-login/pop3-proxy.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/pop3-login/pop3-proxy.c	Fri Dec 15 20:38:08 2006 +0200
@@ -11,9 +11,8 @@
 #include "pop3-proxy.h"
 
 static void proxy_input(struct istream *input, struct ostream *output,
-			void *context)
+			struct pop3_client *client)
 {
-	struct pop3_client *client = context;
 	string_t *str;
 	const char *line;
 
--- a/src/pop3/client.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/pop3/client.c	Fri Dec 15 20:38:08 2006 +0200
@@ -36,8 +36,8 @@
 static struct client *my_client; /* we don't need more than one currently */
 static struct timeout *to_idle;
 
-static void client_input(void *context);
-static int client_output(void *context);
+static void client_input(struct client *client);
+static int client_output(struct client *client);
 
 static int sync_mailbox(struct mailbox *box, struct mailbox_status *status)
 {
@@ -329,9 +329,8 @@
 			 "BUG: Unknown error");
 }
 
-static void client_input(void *context)
+static void client_input(struct client *client)
 {
-	struct client *client = context;
 	char *line, *args;
 	int ret;
 
@@ -388,9 +387,8 @@
 		client_destroy(client, NULL);
 }
 
-static int client_output(void *context)
+static int client_output(struct client *client)
 {
-	struct client *client = context;
 	int ret;
 
 	if ((ret = o_stream_flush(client->output)) < 0) {
--- a/src/util/rawlog.c	Fri Dec 15 20:10:51 2006 +0200
+++ b/src/util/rawlog.c	Fri Dec 15 20:38:08 2006 +0200
@@ -111,9 +111,8 @@
 	proxy->last_out_lf = ((const unsigned char *)buf)[size-1] == '\n';
 }
 
-static void server_input(void *context)
+static void server_input(struct rawlog_proxy *proxy)
 {
-	struct rawlog_proxy *proxy = context;
 	unsigned char buf[OUTBUF_THRESHOLD];
 	ssize_t ret;
 
@@ -133,9 +132,8 @@
                 rawlog_proxy_destroy(proxy);
 }
 
-static void client_input(void *context)
+static void client_input(struct rawlog_proxy *proxy)
 {
-	struct rawlog_proxy *proxy = context;
 	unsigned char buf[OUTBUF_THRESHOLD];
 	ssize_t ret;
 
@@ -155,10 +153,8 @@
                 rawlog_proxy_destroy(proxy);
 }
 
-static int server_output(void *context)
+static int server_output(struct rawlog_proxy *proxy)
 {
-	struct rawlog_proxy *proxy = context;
-
 	if (o_stream_flush(proxy->server_output) < 0) {
                 rawlog_proxy_destroy(proxy);
 		return 1;
@@ -175,10 +171,8 @@
 	return 1;
 }
 
-static int client_output(void *context)
+static int client_output(struct rawlog_proxy *proxy)
 {
-	struct rawlog_proxy *proxy = context;
-
 	if (o_stream_flush(proxy->client_output) < 0) {
                 rawlog_proxy_destroy(proxy);
 		return 1;