aboutsummaryrefslogtreecommitdiffstats
path: root/src/dblayer.h
blob: e5c0b73dcfa4244763d44af499cc8b98e7b8cb29 (plain) (blame)
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
/* dblayer.h - Database layer for ck ---------------------------*- C -*-
 *
 * This file is part of ck, the config keeper
 *
 * ---------------------------------------------------------------------
 *
 *
 * ------------------------------------------------------------------ */
#ifndef DBLAYER_H
#define DBLAYER_H

#include <sqlite3.h>

typedef enum SqlErrors SqlError;
enum SqlErrors {
  SQL_NO_ERR = 0,
  SQL_ERR_NO_DB_FILE,
  SQL_ERR_NO_TABLES,
  SQL_ERR_SQLITE
};

typedef struct DBstruct DB;
struct DBstruct {
  sqlite3 *ptr;
  SqlError error;
};

extern int db_exists();
extern DB open_DB();
extern void close_DB(DB *DB);

/* init */
extern void init_make_tables(DB *db);
extern DB init_make_DB();

#endif /* DBLAEYR_H */