From 65986f9cd9429c7876e5d2f09e4a0cd19d966fa3 Mon Sep 17 00:00:00 2001 From: gramanas Date: Thu, 27 Sep 2018 16:54:43 +0300 Subject: Add dummy delete --- src/actionhelper.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/actionhelper.c') 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) { -- cgit v1.2.3