| 1 |
/*- |
| 2 |
* $FreeWRT$ |
| 3 |
*- |
| 4 |
* This file is part of the FreeWRT project. FreeWRT is copyrighted |
| 5 |
* material, please see the LICENCE file in the top-level directory |
| 6 |
* or at http://www.freewrt.org/licence for details. |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef DBIF_H |
| 10 |
#define DBIF_H |
| 11 |
|
| 12 |
#include "sqlite3.h" |
| 13 |
#include "nfohelpr.h" |
| 14 |
|
| 15 |
__BEGIN_DECLS |
| 16 |
EXTERN sqlite3 *db I__(NULL); |
| 17 |
|
| 18 |
/* dbif.c */ |
| 19 |
void dberr(int, const char *, ...) |
| 20 |
__attribute__((format (printf, 2, 3))) |
| 21 |
__attribute__((noreturn)); |
| 22 |
#define dbexecv(cb, cbarg, sqlfmt, ...) dbexecv_(__FILE__, __LINE__, \ |
| 23 |
__func__, (cb), (cbarg), (sqlfmt), __VA_ARGS__) |
| 24 |
int dbexecv_(const char *, unsigned, const char *, sqlite3_callback, |
| 25 |
void *, const char *, ...) |
| 26 |
__attribute__((nonnull (6))) |
| 27 |
__attribute__((format (printf, 6, 7))); |
| 28 |
|
| 29 |
#define xdbexecv(et, cb, cbarg, sqlfmt, ...) do { \ |
| 30 |
if (dbexecv_(__FILE__, __LINE__, __func__, \ |
| 31 |
(cb), (cbarg), (sqlfmt), __VA_ARGS__)) \ |
| 32 |
dberr(1, et ? et : "processing SQL stmt"); \ |
| 33 |
} while (0) |
| 34 |
__END_DECLS |
| 35 |
|
| 36 |
#endif |