]>
Commit | Line | Data |
---|---|---|
ee8cd7d0 CP |
1 | #ifndef __DBAPI_H |
2 | #define __DBAPI_H | |
3 | ||
4 | #include "../config.h" | |
5 | ||
6 | #define DB_NULLIDENTIFIER 0 | |
7 | #define DB_CREATE 1 | |
8 | ||
827cbcd7 CP |
9 | #ifdef DBAPI_OVERRIDE |
10 | #undef USE_DBAPI_PGSQL | |
11 | #undef USE_DBAPI_SQLITE3 | |
12 | #endif | |
13 | ||
14 | #ifndef BUILDING_DBAPI | |
15 | ||
16 | #if defined(USE_DBAPI_PGSQL) || defined(DBAPI_OVERRIDE_PGSQL) | |
ee8cd7d0 CP |
17 | |
18 | #include "../pqsql/pqsql.h" | |
19 | ||
20 | typedef PQModuleIdentifier DBModuleIdentifier; | |
21 | typedef PGconn DBConn; | |
22 | typedef PQQueryHandler DBQueryHandler; | |
23 | typedef PQResult DBResult; | |
24 | ||
25 | #define dbconnected() pqconnected() | |
edd64394 | 26 | #define dbgetid() pqgetid() |
ee8cd7d0 CP |
27 | #define dbfreeid(x) pqfreeid(x) |
28 | ||
aa944539 CP |
29 | #define dbattach(schema) pqcreateschema(schema) |
30 | #define dbdetach(schema) | |
ee8cd7d0 CP |
31 | #define dbescapestring(buf, src, len) PQescapeString(buf, src, len) |
32 | #define dbloadtable(tablename, init, data, fini) pqloadtable(tablename, init, data, fini); | |
33 | ||
34 | #define dbasyncqueryf(id, handler, tag, flags, format, ...) pqasyncqueryf(id, handler, tag, flags, format , ##__VA_ARGS__) | |
35 | #define dbquerysuccessful(x) pqquerysuccessful(x) | |
36 | #define dbgetresult(conn) pqgetresult(conn) | |
37 | #define dbnumfields(x) PQnfields(x->result) | |
38 | ||
39 | #define dbfetchrow(result) pqfetchrow(result) | |
40 | #define dbgetvalue(result, column) pqgetvalue(result, column) | |
41 | ||
42 | #define dbclear(result) pqclear(result) | |
43 | ||
827cbcd7 CP |
44 | #endif /* DBAPI_PGSQL */ |
45 | ||
46 | #if defined(USE_DBAPI_SQLITE3) || defined(DBAPI_OVERRIDE_SQLITE3) | |
ee8cd7d0 CP |
47 | |
48 | #include "../sqlite/sqlite.h" | |
49 | ||
50 | typedef SQLiteModuleIdentifier DBModuleIdentifier; | |
51 | typedef SQLiteConn DBConn; | |
52 | typedef SQLiteQueryHandler DBQueryHandler; | |
53 | typedef SQLiteResult DBResult; | |
54 | ||
55 | #define dbconnected() sqliteconnected() | |
008e57e5 CP |
56 | #define dbgetid() sqlitegetid() |
57 | #define dbfreeid(x) sqlitefreeid(x) | |
ee8cd7d0 | 58 | |
aa944539 CP |
59 | #define dbattach(schema) sqliteattach(schema) |
60 | #define dbdetach(schema) sqlitedetach(schema) | |
ee8cd7d0 CP |
61 | #define dbescapestring(buf, src, len) sqliteescapestring(buf, src, len) |
62 | #define dbloadtable(tablename, init, data, fini) sqliteloadtable(tablename, init, data, fini); | |
63 | ||
64 | #define dbasyncqueryf(id, handler, tag, flags, format, ...) sqliteasyncqueryf(id, handler, tag, flags, format , ##__VA_ARGS__) | |
65 | #define dbquerysuccessful(x) sqlitequerysuccessful(x) | |
66 | #define dbgetresult(conn) sqlitegetresult(conn) | |
67 | #define dbnumfields(x) sqlite3_column_count(x->r) | |
68 | ||
69 | #define dbfetchrow(result) sqlitefetchrow(result) | |
70 | #define dbgetvalue(result, column) sqlitegetvalue(result, column) | |
71 | ||
72 | #define dbclear(result) sqliteclear(result) | |
73 | ||
827cbcd7 CP |
74 | #endif /* DBAPI_SQLITE3 */ |
75 | ||
76 | #endif /* BUILDING_DBAPI */ | |
ee8cd7d0 CP |
77 | |
78 | #define dbasyncqueryi(identifier, handler, tag, format, ...) dbasyncqueryf(identifier, handler, tag, 0, format , ##__VA_ARGS__) | |
79 | #define dbasyncquery(handler, tag, format, ...) dbasyncqueryf(DB_NULLIDENTIFIER, handler, tag, 0, format , ##__VA_ARGS__) | |
80 | #define dbcreatequery(format, ...) dbasyncqueryf(DB_NULLIDENTIFIER, NULL, NULL, DB_CREATE, format , ##__VA_ARGS__) | |
81 | #define dbquery(format, ...) dbasyncqueryf(DB_NULLIDENTIFIER, NULL, NULL, 0, format , ##__VA_ARGS__) | |
82 | ||
827cbcd7 | 83 | #endif /* __DBAPI_H */ |