#define DBNAME_LEN 100
-#if defined(USE_DBAPI_PGSQL)
-#define DBAPI2_DEFAULT "pgsql"
-#elseif defined(USE_DBAPI_SQLITE)
-#define DBAPI2_DEFAULT "sqlite"
-#else
+#include "../config.h"
+
#define DBAPI2_DEFAULT NULL
-#endif
#include <stdlib.h>
#include <stdarg.h>
struct DBAPIResult;
-typedef DBAPI2_HANDLE *(*DBAPINew)(struct DBAPIConn *);
+typedef DBAPI2_HANDLE *(*DBAPINew)(const struct DBAPIConn *);
typedef void (*DBAPIClose)(struct DBAPIConn *);
-typedef void (*DBAPIQueryCallback)(struct DBAPIResult *, void *);
+typedef void (*DBAPIQueryCallback)(const struct DBAPIResult *, void *);
+
+typedef void (*DBAPIQuery)(const struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, ...) __attribute__ ((format (printf, 4, 5)));
+typedef void (*DBAPISimpleQuery)(const struct DBAPIConn *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
+typedef void (*DBAPIQueryV)(const struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *);
+typedef void (*DBAPICreateTable)(const struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, ...) __attribute__ ((format (printf, 4, 5)));
+typedef void (*DBAPICreateTableV)(const struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *);
+typedef void (*DBAPILoadTable)(const struct DBAPIConn *, DBAPIQueryCallback, DBAPIQueryCallback, DBAPIQueryCallback, DBAPIUserData, const char *);
-typedef void (*DBAPIQuery)(struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, ...);
-typedef void (*DBAPISimpleQuery)(struct DBAPIConn *, const char *, ...);
-typedef void (*DBAPIQueryV)(struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, va_list);
-typedef void (*DBAPICreateTable)(struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, ...);
-typedef void (*DBAPILoadTable)(struct DBAPIConn *, DBAPIQueryCallback, DBAPIQueryCallback, DBAPIQueryCallback, DBAPIUserData, const char *);
+typedef void (*DBAPISafeQuery)(const struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, const char *, ...);
+typedef void (*DBAPISafeSimpleQuery)(const struct DBAPIConn *, const char *, const char *, ...);
+typedef void (*DBAPISafeCreateTable)(const struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, const char *, ...);
-typedef void (*DBAPISafeQuery)(struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, const char *, ...);
-typedef void (*DBAPISafeQueryV)(struct DBAPIConn *, DBAPIQueryCallback, DBAPIUserData, const char *, const char *, va_list);
-typedef void (*DBAPISafeSimpleQuery)(struct DBAPIConn *, const char *, const char *, ...);
-typedef void (*DBAPISafeCreateTable)(struct DBAPIConn *, const char *, ...);
-typedef void (*DBAPISafeLoadTable)(struct DBAPIConn *, const char *, ...);
+typedef void (*DBAPIEscapeString)(const struct DBAPIConn *, char *, const char *, size_t);
+typedef int (*DBAPIQuoteString)(const struct DBAPIConn *, char *, size_t, const char *, size_t);
-typedef void (*DBAPIEscapeString)(struct DBAPIConn *, char *, const char *, size_t);
-typedef int (*DBAPIQuoteString)(struct DBAPIConn *, char *, size_t, const char *, size_t);
+typedef char *(*DBAPITableName)(const struct DBAPIConn *, const char *);
struct DBAPIProviderData;
DBAPIClose close;
DBAPIQueryV query;
- DBAPICreateTable createtable;
+ DBAPICreateTableV createtable;
DBAPILoadTable loadtable;
-/*
- DBAPISafeQuery safequery;
- DBAPISafeSimpleQuery safesimplequery;
- DBAPISafeCreateTable safecreatetable;
- DBAPISafeLoadTable safeloadtable;
-*/
+
+ DBAPITableName tablename;
DBAPIEscapeString escapestring;
DBAPIQuoteString quotestring;
typedef struct DBAPIConn {
DBAPIClose close;
- DBAPIQuery query;
- DBAPISimpleQuery squery;
- DBAPICreateTable createtable;
+ DBAPIQuery unsafequery;
+ DBAPISimpleQuery unsafesquery;
+ DBAPICreateTable unsafecreatetable;
DBAPILoadTable loadtable;
DBAPIEscapeString escapestring; /* deprecated */
+ DBAPITableName tablename;
+
+ DBAPISafeQuery query;
+ DBAPISafeSimpleQuery squery;
+ DBAPISafeCreateTable createtable;
char name[DBNAME_LEN+1];
DBAPIClose __close;
DBAPIQuoteString __quotestring;
DBAPIQueryV __query;
+ DBAPICreateTableV __createtable;
+ DBAPILoadTable __loadtable;
} DBAPIConn;
-typedef char *(*DBAPIResultGet)(struct DBAPIResult *, int);
-typedef int (*DBAPIResultNext)(struct DBAPIResult *);
-typedef void (*DBAPIResultClear)(struct DBAPIResult *);
+typedef char *(*DBAPIResultGet)(const struct DBAPIResult *, unsigned int);
+typedef int (*DBAPIResultNext)(const struct DBAPIResult *);
+typedef void (*DBAPIResultClear)(const struct DBAPIResult *);
typedef struct DBAPIResult {
DBAPI2_RESULT_HANDLE *handle;
int registerdbprovider(const char *, DBAPIProvider *);
void deregisterdbprovider(int);
-DBAPIConn *dbapi2open(const char *, int, const char *);
-
-void dbsnprintf(DBAPIConn *, char *, size_t, const char *, const char *, ...);
+DBAPIConn *dbapi2open(const char *, const char *);
#endif