diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-04-15 00:43:08 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-04-15 00:43:08 +0300 |
commit | bc25e14b448edb9f41260a23cf6567e6632db267 (patch) | |
tree | 71362a1c8d369f3d0080baee5f98edb3439f3735 /src/main.c | |
parent | 0168c10023f0040ae2fa31a212eb6d2e411eefb3 (diff) | |
download | ck-bc25e14b448edb9f41260a23cf6567e6632db267.tar.gz ck-bc25e14b448edb9f41260a23cf6567e6632db267.tar.bz2 ck-bc25e14b448edb9f41260a23cf6567e6632db267.zip |
dummy init done
action parser
conf parser
db layer
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 6de5b43..0000000 --- a/src/main.c +++ /dev/null @@ -1,85 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sqlite3.h> - -static int callback(void *NotUsed, int argc, char **argv, char **azColName) { - int i; - for(i = 0; i<argc; i++) { - printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL"); - } - printf("\n"); - return 0; -} - -void initDb(sqlite3 *db) { - char *zErrMsg = 0; - char *sql; - int rc; - - /* Create SQL statement */ - sql = "CREATE TABLE PROGRAM(" \ - "id INT PRIMARY KEY NOT NULL," \ - "name TEXT NOT NULL);"; - - /* Execute SQL statement */ - rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg); - - if( rc != SQLITE_OK ){ - fprintf(stderr, "SQL error: %s\n", zErrMsg); - sqlite3_free(zErrMsg); - } else { - fprintf(stdout, "Table created successfully\n"); - } - sql = "CREATE TABLE CONFIG(" \ - "id INT PRIMARY KEY NOT NULL," \ - "path TEXT NOT NULL," \ - "secret INT NOT NULL," \ - "prime INT NOT NULL);"; - - /* Execute SQL statement */ - rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg); - - if( rc != SQLITE_OK ){ - fprintf(stderr, "SQL error: %s\n", zErrMsg); - sqlite3_free(zErrMsg); - } else { - fprintf(stdout, "Table created successfully\n"); - } - sql = "CREATE TABLE REL(" \ - "pId INT NOT NULL," \ - "cId INT NOT NULL);"; - - /* Execute SQL statement */ - rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg); - - if( rc != SQLITE_OK ){ - fprintf(stderr, "SQL error: %s\n", zErrMsg); - sqlite3_free(zErrMsg); - } else { - fprintf(stdout, "Table created successfully\n"); - } -} - - int main(int argc, char* argv[]) { - sqlite3 *db; - int rc; - - /* Open database */ - rc = sqlite3_open("ckdb", &db); - - if (rc) { - fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); - return(0); - } - else { - fprintf(stdout, "Opened database successfully\n"); - } - - if (strcmp("init", argv[1]) == 0) { - initDb(db); - } - - sqlite3_close(db); - return 0; -} |