-
Notifications
You must be signed in to change notification settings - Fork 1
/
zzsql.h
46 lines (34 loc) · 870 Bytes
/
zzsql.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef ZZSQL_H
#define ZZSQL_H
#define _XOPEN_SOURCE
#include <stdbool.h>
#include <sqlite3.h>
#include "zz_priv.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DATETIME_FORMAT "%Y-%m-%d %H:%M:%S"
struct zzdb
{
sqlite3 *sqlite;
};
struct zzdbiter
{
sqlite3_stmt *stmt;
int index;
int retval;
};
bool zzdbupdate(struct zzdb *zdb, struct zzfile *zz);
struct zzdb *zzdbopen(struct zzdb *indb);
struct zzdb *zzdbclose(struct zzdb *zdb);
bool zzquery(struct zzdb *zdb, const char *statement, int (*callback)(void*,int,char**,char**), void *cbdata);
// TODO move
time_t zzundatetime(const char *datetime);
const char *zzdatetime(time_t value);
struct zzdbiter zzdbquery(struct zzdb *zdb, char const *fmt, ...);
bool zzdbnext(struct zzdb *zdb, struct zzdbiter *zq, const char *fmt, ...);
void zzdbdone(struct zzdbiter zq);
#ifdef __cplusplus
}
#endif
#endif