[dovecot-cvs] dovecot/src/lib-sql driver-pgsql.c, 1.13, 1.14 sql-api.h, 1.12, 1.13

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


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

Modified Files:
	driver-pgsql.c sql-api.h 
Log Message:
Replaced void *context from a lot of callbacks with the actual context
type. Also added/fixed some context type checks.



Index: driver-pgsql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-sql/driver-pgsql.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- driver-pgsql.c	1 Jul 2006 19:15:50 -0000	1.13
+++ driver-pgsql.c	15 Dec 2006 18:38:15 -0000	1.14
@@ -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);

Index: sql-api.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-sql/sql-api.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- sql-api.h	15 Dec 2006 18:11:00 -0000	1.12
+++ sql-api.h	15 Dec 2006 18:38:16 -0000	1.13
@@ -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,



More information about the dovecot-cvs mailing list