diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-04-22 05:47:33 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-04-22 05:47:33 +0300 |
commit | eeca7f0151d85d563d1db229e3b7ca936323ffa2 (patch) | |
tree | 32e57172bd786daed9ac4251b3c5edf09c49d242 /src/actionparser.c | |
parent | 3560d8be4b833e888e8386a3dc641fa164b4b808 (diff) | |
download | ck-eeca7f0151d85d563d1db229e3b7ca936323ffa2.tar.gz ck-eeca7f0151d85d563d1db229e3b7ca936323ffa2.tar.bz2 ck-eeca7f0151d85d563d1db229e3b7ca936323ffa2.zip |
First steps towards adding to the db
Diffstat (limited to 'src/actionparser.c')
-rw-r--r-- | src/actionparser.c | 18 |
1 files changed, 9 insertions, 9 deletions
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 <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> #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); |