]> jfr.im git - irc/quakenet/newserv.git/blobdiff - pqsql/pqsql.h
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / pqsql / pqsql.h
index 8eb2608f6eb042c925178e92e3e1ac1510a880d6..6f885e2eec1d27cd06e74aa1c3213e8f2a7dec1b 100644 (file)
@@ -3,19 +3,39 @@
 
 #include <libpq-fe.h>
 
-#define QH_CREATE 0x01
 #define PQ_ERRORMSG_LENGTH 1024
 
+#define QH_ALREADYFIRED 1
+
+typedef struct PQResult {
+  PGresult *result;
+  int row;
+  int rows;
+} PQResult;
+
+typedef int PQModuleIdentifier;
 typedef void (*PQQueryHandler)(PGconn *, void *);
 
-void pqasyncqueryf(PQQueryHandler handler, void *tag, int flags, char *format, ...);
-void pqloadtable(char *tablename, PQQueryHandler init, PQQueryHandler data, PQQueryHandler fini);
+void pqloadtable(char *tablename, PQQueryHandler init, PQQueryHandler data, PQQueryHandler fini, void *tag);
 
-#define pqasyncquery(handler, tag, format, ...) pqasyncqueryf(handler, tag, 0, format , ##__VA_ARGS__)
-#define pqcreatequery(format, ...) pqasyncqueryf(NULL, NULL, QH_CREATE, format , ##__VA_ARGS__)
-#define pqquery(format, ...) pqasyncqueryf(NULL, NULL, 0, format , ##__VA_ARGS__)
+void pqasyncqueryf(PQModuleIdentifier identifier, PQQueryHandler handler, void *tag, int flags, char *format, ...) __attribute__ ((format (printf, 5, 6)));
+#define pqasyncqueryi(identifier, handler, tag, format, ...) pqasyncqueryf(identifier, handler, tag, 0, format , ##__VA_ARGS__)
+#define pqasyncquery(handler, tag, format, ...) pqasyncqueryf(DB_NULLIDENTIFIER, handler, tag, 0, format , ##__VA_ARGS__)
+#define pqcreatequery(format, ...) pqasyncqueryf(DB_NULLIDENTIFIER, NULL, NULL, DB_CREATE, format , ##__VA_ARGS__)
+#define pqquery(format, ...) pqasyncqueryf(DB_NULLIDENTIFIER, NULL, NULL, 0, format , ##__VA_ARGS__)
 
 int pqconnected(void);
-char* pqlasterror(PGconn * pgconn);
+
+PQModuleIdentifier pqgetid(void);
+void pqfreeid(PQModuleIdentifier identifier);
+
+#define pqquerysuccessful(x) (x && (PQresultStatus(x->result) == PGRES_TUPLES_OK))
+
+PQResult *pqgetresult(PGconn *c);
+int pqfetchrow(PQResult *res);
+char *pqgetvalue(PQResult *res, int column);
+void pqclear(PQResult *res);
+
+#define pqcreateschema(schema) pqcreatequery("CREATE SCHEMA %s;", schema)
 
 #endif