diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-04-15 06:15:06 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-04-15 06:15:06 +0300 |
commit | 6f319efab77e88e06acb689923ad619bf4c78304 (patch) | |
tree | 8d13fc584108627efb5d6b769e64a690b7d9552a /src/actions.c | |
parent | c42092733d664c29d3ac9084859f57ec463f72e3 (diff) | |
download | ck-6f319efab77e88e06acb689923ad619bf4c78304.tar.gz ck-6f319efab77e88e06acb689923ad619bf4c78304.tar.bz2 ck-6f319efab77e88e06acb689923ad619bf4c78304.zip |
variable conf
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 87 |
1 files changed, 61 insertions, 26 deletions
diff --git a/src/actions.c b/src/actions.c index 9840722..881c299 100644 --- a/src/actions.c +++ b/src/actions.c @@ -50,66 +50,101 @@ int run_INIT(UserOpt * opt, Conf *conf) { if (db.error == SQL_NO_ERR) { init_make_tables(&db); } - sqlite3_close(db.get); + sqlite3_close(db.ptr); return 1; } int run_ADD(UserOpt * opt, Conf *conf) { - if (!db_exists()) { - printf("ck is not initialized.\nRun ck init first."); - return 0; - } printf("Running %s\n", "add"); DB db = open_DB(); - if (db.get == NULL) { + if (db.ptr == NULL) { if (db.error == SQL_ERR_NO_TABLES) { printf("no tables\n"); } } + for (int i = 0; i < opt->argc; i++) { + printf("[%d]: %s\n", i, opt->argv[i]); + } return 0; } int run_DEL(UserOpt * opt, Conf *conf) { - if (!db_exists()) { - printf("ck is not initialized.\nRun ck init first."); - return 0; - } printf("Running %s\n", "del"); return 0; } int run_EDIT(UserOpt * opt, Conf *conf) { - if (!db_exists()) { - printf("ck is not initialized.\nRun ck init first."); - return 0; - } printf("Running %s\n", "edit"); return 0; } int run_LIST(UserOpt * opt, Conf *conf) { - if (!db_exists()) { - printf("ck is not initialized.\nRun ck init first."); - return 0; - } printf("Running %s\n", "list"); return 0; } int run_SEARCH(UserOpt * opt, Conf *conf) { - if (!db_exists()) { - printf("ck is not initialized.\nRun ck init first."); - return 0; - } printf("Running %s\n", "search"); return 0; } int run_HELP(UserOpt * opt, Conf *conf) { - if (!db_exists()) { - printf("ck is not initialized.\nRun ck init first."); - return 0; - } printf("Running %s\n", "help"); return 0; } + +void print_INIT_result(int ok) { + if (ok) { + printf("Initialized empty ckdb.\n"); + return; + } +} + +void print_ADD_result(int ok) { + if (ok) { + printf("succes\n"); + return; + } + printf("failure\n"); +} + +void print_DEL_result(int ok) { + if (ok) { + printf("succes\n"); + return; + } + printf("failure\n"); +} + +void print_EDIT_result(int ok) { + if (ok) { + printf("succes\n"); + return; + } + printf("failure\n"); +} + +void print_LIST_result(int ok) { + if (ok) { + printf("succes\n"); + return; + } + printf("failure\n"); +} + +void print_SEARCH_result(int ok) { + if (ok) { + printf("succes\n"); + return; + } + printf("failure\n"); +} + +void print_HELP_result(int ok) { + if (ok) { + printf("succes\n"); + return; + } + printf("failure\n"); +} + |