diff options
Diffstat (limited to 'src/actionhelper.c')
-rw-r--r-- | src/actionhelper.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/actionhelper.c b/src/actionhelper.c index c3b1b81..596a7db 100644 --- a/src/actionhelper.c +++ b/src/actionhelper.c @@ -50,7 +50,7 @@ void move_config(const AddOpt *opt, const Conf *conf, char *ret) { AddOpt add_make_options(cklist *args) { list_rewind(args); - /* since we are here, the first two argumens must exist */ + /* since we are here, the first two arguments must exist */ AddOpt addOpt = { .progName = list_get(args), .secret = 0, @@ -79,6 +79,34 @@ AddOpt add_make_options(cklist *args) { return addOpt; } +DelOpt del_make_options(cklist *args) { + list_rewind(args); + DelOpt delOpt = { + .prog = NULL, + .path = "", + .isConf = 0, + .err = DEL_NO_ERR + }; + + if (strcmp(list_get(args), "-c") == 0) { + delOpt.isConf = 1; + if (!list_next(args)) { + delOpt.err = DEL_ERR_WRONG_ARGS; + return delOpt; + } + realpath(list_get(args), delOpt.path); + if (!util_is_file_rw(delOpt.path)) { + delOpt.err = DEL_ERR_WRONG_PATH; + return delOpt; + } + } else { + delOpt.prog = list_get(args); + } + + list_rewind(args); + return delOpt; +} + void add_print_opts(AddOpt *opt) { printf("Program:\t%s\nConfig:\t\t%s\n", opt->progName, opt->confPath); if (opt->prime && opt->secret) { |