aboutsummaryrefslogtreecommitdiffstats
path: root/src/dblayer.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-04-17 12:30:44 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-04-17 17:39:29 +0300
commit562bad603ce0fe2a6556f0f1aae4f08c9c300987 (patch)
tree8646982cdcd625dcf7f04262b66d9e78bf53afe4 /src/dblayer.c
parent94bc38df829c4816e629c7dcaed31b1e7c75bc4b (diff)
downloadck-562bad603ce0fe2a6556f0f1aae4f08c9c300987.tar.gz
ck-562bad603ce0fe2a6556f0f1aae4f08c9c300987.tar.bz2
ck-562bad603ce0fe2a6556f0f1aae4f08c9c300987.zip
fix memory leaks, add logo
Diffstat (limited to 'src/dblayer.c')
-rw-r--r--src/dblayer.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/dblayer.c b/src/dblayer.c
index a40fd85..b781f47 100644
--- a/src/dblayer.c
+++ b/src/dblayer.c
@@ -12,7 +12,7 @@
const char * const DB_NAME = "/ckdb";
-char *make_db_name(char * confPath) {
+char *make_db_name(char *confPath) {
char *db_path = strdup(confPath);
db_path = realloc(db_path, strlen(confPath)+strlen(DB_NAME)+1);
@@ -34,7 +34,7 @@ int db_exists(UserOpt *opt) {
// check if db has the correct tables
int check_initialized_DB(sqlite3 *db) {
- char *sql = "SELECT * FROM SQLITE_MASTER;";
+ char *sql = "SELECT * FROM SQLITE_MASTER WHERE type='table';";
sqlite3_stmt *stmt;
int rc = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
@@ -109,17 +109,18 @@ DB open_DB(UserOpt *opt) {
}
void init_make_tables(DB *db) {
- char * sql = "CREATE TABLE REL("
- "pId INT NOT NULL,"
- "cId INT NOT NULL);"
+ char * sql =
+ "CREATE TABLE REL("
+ "pId INT NOT NULL,"
+ "cId INT NOT NULL);"
"CREATE TABLE PROGRAM("
- "id INT PRIMARY KEY NOT NULL,"
- "name TEXT NOT NULL);"
+ "id INT NOT NULL PRIMARY KEY,"
+ "name TEXT NOT NULL);"
"CREATE TABLE CONFIG("
- "id INT PRIMARY KEY NOT NULL,"
- "path TEXT NOT NULL,"
- "secret INT NOT NULL,"
- "prime INT NOT NULL);";
+ "id INT NOT NULL PRIMARY KEY,"
+ "path TEXT NOT NULL,"
+ "secret INT NOT NULL,"
+ "prime INT NOT NULL);";
char *err_msg = NULL;
int rc = sqlite3_exec(db->ptr, sql, 0, 0, &err_msg);
@@ -130,3 +131,7 @@ void init_make_tables(DB *db) {
return;
}
}
+
+int add_insert_program_to_db(DB *db, char* name) {
+ return 0;
+}