From 6f319efab77e88e06acb689923ad619bf4c78304 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 15 Apr 2018 06:15:06 +0300 Subject: variable conf --- src/ck.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/ck.c') diff --git a/src/ck.c b/src/ck.c index 56dec2e..2833176 100644 --- a/src/ck.c +++ b/src/ck.c @@ -7,18 +7,7 @@ #include "confparser.h" #include "dblayer.h" - int main(int argc, char *argv[]) { - sqlite3 *db; - int rc; - - Conf conf; - config_file_parse(&conf); - //return 1; - -#define X(var, str, name) \ - printf("%s: %s\n", name, conf.var); - CONFIG_VARIABLES_TABLE -#undef X +int main(int argc, char *argv[]) { UserOpt opt; switch(parseAction(argc, argv, &opt)) { case OPR_HELP: @@ -27,18 +16,37 @@ printParserError(&opt); case OPR_OK: break; - // } + printf("%s\n", opt.confDir); + Conf conf; + if (opt.action != CKA_INIT) { + if (!db_exists()) { + printf("ck is not initialized.\nRun ck init first.\n"); + return 1; + } + if (!config_file_parse(&conf)) { + return 1; + } + } + + int ok; switch(opt.action) { #define X(ACTION) \ case CKA_##ACTION: \ - run_##ACTION(&opt, &conf); \ + ok = run_##ACTION(&opt, &conf); \ break; CK_ACTIONS #undef X - } + switch(opt.action) { +#define X(ACTION) \ + case CKA_##ACTION: \ + print_##ACTION##_result(ok); \ + break; + CK_ACTIONS +#undef X + } return 0; } -- cgit v1.2.3