From eeca7f0151d85d563d1db229e3b7ca936323ffa2 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 22 Apr 2018 05:47:33 +0300 Subject: First steps towards adding to the db --- src/actionparser.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/actionparser.c') diff --git a/src/actionparser.c b/src/actionparser.c index bfa4f5b..811f0c4 100644 --- a/src/actionparser.c +++ b/src/actionparser.c @@ -17,11 +17,9 @@ #include #include #include -#include -#include -#include #include "actionparser.h" +#include "ckutil.h" /* accepted commands */ /* [0] is the count */ @@ -125,8 +123,9 @@ int parseVals(UserOpt *opt) { return parse_##ACTION(opt); CK_ACTIONS #undef X - } - return 1; + default: + return -1; + } } CkAction determineAction() { @@ -139,7 +138,7 @@ CkAction determineAction() { } CK_ACTIONS #undef X - return -1; + return CK_WRONG_ACTION; } UserOpt make_empty_user_opt() { @@ -178,8 +177,7 @@ void getConfig(UserOpt *opt) { if (strcmp(token, ".") == 0){ printf("Dot\n"); } - struct stat st = {0}; - if (stat(token, &st) == -1) { + if (!util_is_dir(token)) { printf("%s is not a directory\n", token); exit(1); } @@ -218,7 +216,7 @@ ParseResult parseAction(int argc, char* argv[], UserOpt *opt) { // get action nextToken(); opt->action = determineAction(); - if (opt->action == -1) { + if (opt->action == CK_WRONG_ACTION) { opt->err = PERR_UNKONW_ACTION; return OPR_ERR; } @@ -260,6 +258,8 @@ void getPossibleActionNames(char * dest, CkAction ckAction) { break; CK_ACTIONS #undef X + default: + break; } strcpy(dest, buf); -- cgit v1.2.3