]> jfr.im git - irc/quakenet/newserv.git/blob - pqsql/pqsql.h
Add a way of doing 'clean' unloads in pqsql.
[irc/quakenet/newserv.git] / pqsql / pqsql.h
1 #ifndef __PQSQL_DB_H
2 #define __PQSQL_DB_H
3
4 #include <libpq-fe.h>
5
6 #define QH_CREATE 0x01
7 #define PQ_ERRORMSG_LENGTH 1024
8
9 #define QH_NULLIDENTIFIER 0
10 #define QH_ALREADYFIRED 1
11
12 typedef int PQModuleIdentifier;
13 typedef void (*PQQueryHandler)(PGconn *, void *);
14
15 void pqloadtable(char *tablename, PQQueryHandler init, PQQueryHandler data, PQQueryHandler fini);
16
17 void pqasyncqueryf(PQModuleIdentifier identifier, PQQueryHandler handler, void *tag, int flags, char *format, ...);
18 #define pqasyncqueryi(identifier, handler, tag, format, ...) pqasyncqueryf(identifier, handler, tag, 0, format , ##__VA_ARGS__)
19 #define pqasyncquery(handler, tag, format, ...) pqasyncqueryf(QH_NULLIDENTIFIER, handler, tag, 0, format , ##__VA_ARGS__)
20 #define pqcreatequery(format, ...) pqasyncqueryf(QH_NULLIDENTIFIER, NULL, NULL, QH_CREATE, format , ##__VA_ARGS__)
21 #define pqquery(format, ...) pqasyncqueryf(QH_NULLIDENTIFIER, NULL, NULL, 0, format , ##__VA_ARGS__)
22
23 int pqconnected(void);
24 char* pqlasterror(PGconn *pgconn);
25
26 PQModuleIdentifier pqgetid(void);
27 void pqfreeid(PQModuleIdentifier identifier);
28
29 #endif