-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbutil.h
48 lines (42 loc) · 1.08 KB
/
dbutil.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
47
48
#ifndef DBUTIL_H
#define DBUTIL_H
/*
* database access utility functions.
*/
#include <stdio.h>
#include <sqlite3.h>
#include <stdarg.h>
#include "util.h"
#define ERROR_LABEL(db) error: \
d("ERR: %s\n", sqlite3_errmsg(db)); \
sqlite3_finalize(stmt); \
sqlite3_close(db); \
die("failed to dbaccess.");
typedef struct {
char name[DEFAULT_LENGTH];
sqlite3* handle;
} Database;
Database* db_init(char*);
void db_finish(Database*);
void db_begin(Database*);
void db_rollback(Database*);
void db_commit(Database*);
int exec_query(Database*, const char* sql,...);
int exec_query_scalar_int(Database*, const char* sql, ...);
int exec_and_wait_4_done(sqlite3_stmt*);
#define INVALID_INT -99999
enum COLUMN_TYPE {
COLUMN_TYPE_INT,
COLUMN_TYPE_TEXT,
COLUMN_TYPE_BLOB_ELEMENT_FILE,
COLUMN_TYPE_BLOB_SETTING_FILE,
COLUMN_TYPE_END
};
enum SQLITE_RETURN {
SQLITE_RETURN_OK,
SQLITE_RETURN_ERROR
};
List* parse_keywords(List*, char*);
String* create_columns_like_exp(List*, char*, List*, String*);
#endif
/* vim: set ts=4 sw=4 sts=4 expandtab fenc=utf-8: */