diff options
Diffstat (limited to 'include/sql.h')
-rw-r--r-- | include/sql.h | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/include/sql.h b/include/sql.h index e14167b..a90fde6 100644 --- a/include/sql.h +++ b/include/sql.h @@ -1,6 +1,48 @@ #ifndef SQL_H #define SQL_H +#include <stdbool.h> +#include <sqlite3.h> -extern const char *INIT_SQL, *INSERT_SQL, *DELETE_SQL; +struct slidid { sqlite3_int64 il, in, res; }; +extern struct sql_state { + sqlite3 *db; +} state; +enum statements_index { + STMTIDX_INIT = 0, + STMTIDX_INSERT, + STMTIDX_DELETE, + STMTIDX_SELECT, + STMTIDX_RESET, + STMTIDX_GETN, + STMTIDX_SIZE, +}; + +enum dberror { + DBERROR_SUCCESS = 0, + DBERROR_ARGS, + DBERROR_INVAL, + DBERROR_OCCUPIED, + DBERROR_SERVER, + DBERROR_TOOBIG, + DBERROR_UNKNOWN, +}; + +extern struct sqlite3_stmt *statements[STMTIDX_SIZE]; + +void sqlite_init(const char *db); +void sqlite_deinit(void); + +enum dberror db_add_url(const char *url, const char *path, char **out); +bool db_del_url(const char *path); +// dong: output parameter +char *db_get_info(const char *path, long *dong); +// server should use this one. Memory must be freed. +char *db_get_url(const char *path); + +static char *itou(register unsigned long i, register char *buf); +static unsigned long utoi(const char *s); + +const char *db_error(enum dberror e); +int db_error_status(enum dberror e); #endif |