| 29 |
* of said person's immediate fault when using the work as intended. |
* of said person's immediate fault when using the work as intended. |
| 30 |
*/ |
*/ |
| 31 |
|
|
| 32 |
#ifndef DBIF_H |
#ifndef NFOHELPR_H |
| 33 |
#define DBIF_H |
#define NFOHELPR_H |
|
|
|
|
#include "sqlite3.h" |
|
| 34 |
|
|
| 35 |
/* stolen from mksh's sh.h */ |
/* stolen from mksh's sh.h */ |
| 36 |
#ifdef EXTERN |
#ifdef EXTERN |
| 49 |
|
|
| 50 |
__BEGIN_DECLS |
__BEGIN_DECLS |
| 51 |
EXTERN int debug I__(0); |
EXTERN int debug I__(0); |
|
EXTERN sqlite3 *db I__(NULL); |
|
|
|
|
|
/* dbif.c */ |
|
|
void dberr(int, const char *, ...) |
|
|
__attribute__((format (printf, 2, 3))) |
|
|
__attribute__((noreturn)); |
|
|
#define dbexecv(cb, cbarg, sqlfmt, ...) dbexecv_(__FILE__, __LINE__, \ |
|
|
__func__, (cb), (cbarg), (sqlfmt), __VA_ARGS__) |
|
|
int dbexecv_(const char *, unsigned, const char *, sqlite3_callback, |
|
|
void *, const char *, ...) |
|
|
__attribute__((nonnull (6))) |
|
|
__attribute__((format (printf, 6, 7))); |
|
|
|
|
|
#define xdbexecv(et, cb, cbarg, sqlfmt, ...) do { \ |
|
|
if (dbexecv_(__FILE__, __LINE__, __func__, \ |
|
|
(cb), (cbarg), (sqlfmt), __VA_ARGS__)) \ |
|
|
dberr(1, et ? et : "processing SQL stmt"); \ |
|
|
} while (0) |
|
| 52 |
|
|
| 53 |
#ifdef NFOTISER |
#ifdef NFOTISER |
| 54 |
#ifdef __GLIBC__ |
#ifdef __GLIBC__ |
| 94 |
size_t str_nsave_sz = (n); \ |
size_t str_nsave_sz = (n); \ |
| 95 |
\ |
\ |
| 96 |
str_nsave_ptr = xmalloc(str_nsave_sz + 1); \ |
str_nsave_ptr = xmalloc(str_nsave_sz + 1); \ |
| 97 |
memcpy(str_nsave_sz, (s), str_nsave_sz); \ |
memcpy(str_nsave_ptr, (s), str_nsave_sz); \ |
| 98 |
str_nsave_ptr[str_nsave_sz] = '\0'; \ |
str_nsave_ptr[str_nsave_sz] = '\0'; \ |
| 99 |
(str_nsave_ptr); \ |
(str_nsave_ptr); \ |
| 100 |
}) |
}) |