| 1 |
/* $FreeWRT: src/share/misc/licence.template,v 1.20 2006/12/11 21:04:56 tg Rel $ */ |
| 2 |
|
| 3 |
/*- |
| 4 |
* Copyright (c) 2007 |
| 5 |
* Thorsten Glaser <tg@mirbsd.de> |
| 6 |
* |
| 7 |
* Provided that these terms and disclaimer and all copyright notices |
| 8 |
* are retained or reproduced in an accompanying document, permission |
| 9 |
* is granted to deal in this work without restriction, including un- |
| 10 |
* limited rights to use, publicly perform, distribute, sell, modify, |
| 11 |
* merge, give away, or sublicence. |
| 12 |
* |
| 13 |
* Advertising materials mentioning features or use of this work must |
| 14 |
* display the following acknowledgement: |
| 15 |
* This product includes material provided by Thorsten Glaser. |
| 16 |
* This acknowledgement does not need to be reprinted if this work is |
| 17 |
* linked into a bigger work whose licence does not allow such clause |
| 18 |
* and the author of this work is given due credit in the bigger work |
| 19 |
* or its accompanying documents, where such information is generally |
| 20 |
* kept, provided that said credits are retained. |
| 21 |
* |
| 22 |
* This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to |
| 23 |
* the utmost extent permitted by applicable law, neither express nor |
| 24 |
* implied; without malicious intent or gross negligence. In no event |
| 25 |
* may a licensor, author or contributor be held liable for indirect, |
| 26 |
* direct, other damage, loss, or other issues arising in any way out |
| 27 |
* of dealing in the work, even if advised of the possibility of such |
| 28 |
* damage or existence of a defect, except proven that it results out |
| 29 |
* of said person's immediate fault when using the work as intended. |
| 30 |
*/ |
| 31 |
|
| 32 |
#ifndef DBIF_H |
| 33 |
#define DBIF_H |
| 34 |
|
| 35 |
#include "sqlite3.h" |
| 36 |
|
| 37 |
/* stolen from mksh's sh.h */ |
| 38 |
#ifdef EXTERN |
| 39 |
# define I__(i) = i |
| 40 |
#else |
| 41 |
# define I__(i) |
| 42 |
# define EXTERN extern |
| 43 |
# define EXTERN_DEFINED |
| 44 |
#endif |
| 45 |
|
| 46 |
/* debugging */ |
| 47 |
#define D(level, fmt, ...) do { \ |
| 48 |
if (debug >= (level)) \ |
| 49 |
fprintf(stderr, (fmt), ##__VA_ARGS__); \ |
| 50 |
} while (0) |
| 51 |
|
| 52 |
EXTERN int debug I__(0); |
| 53 |
EXTERN sqlite3 *db I__(NULL); |
| 54 |
|
| 55 |
/* dbif.c */ |
| 56 |
void dberr(int, const char *, ...) |
| 57 |
__attribute__((format (printf, 2, 3))) |
| 58 |
__attribute__((noreturn)); |
| 59 |
#define dbexecv(cb, cbarg, sqlfmt, ...) dbexecv_(__FILE__, __LINE__, \ |
| 60 |
__func__, (cb), (cbarg), (sqlfmt), __VA_ARGS__) |
| 61 |
int dbexecv_(const char *, unsigned, const char *, sqlite3_callback, |
| 62 |
void *, const char *, ...) |
| 63 |
__attribute__((nonnull (6))) |
| 64 |
__attribute__((format (printf, 6, 7))); |
| 65 |
|
| 66 |
#define xdbexecv(et, cb, cbarg, sqlfmt, ...) do { \ |
| 67 |
if (dbexecv_(__FILE__, __LINE__, __func__, \ |
| 68 |
(cb), (cbarg), (sqlfmt), __VA_ARGS__)) \ |
| 69 |
dberr(1, et ? et : "processing SQL stmt"); \ |
| 70 |
} while (0) |
| 71 |
|
| 72 |
#ifdef NFOTISER |
| 73 |
#ifdef __GLIBC__ |
| 74 |
/* fgetln.c */ |
| 75 |
char *fgetln(FILE *, size_t *); |
| 76 |
/* strlfun.c */ |
| 77 |
size_t strlcat(char *, const char *, size_t); |
| 78 |
size_t strlcpy(char *, const char *, size_t); |
| 79 |
#endif |
| 80 |
#endif |
| 81 |
|
| 82 |
#endif |