From 598e0522de924a50ea9c640955daab8512029eb4 Mon Sep 17 00:00:00 2001 From: gramanas Date: Tue, 9 Oct 2018 20:53:30 +0300 Subject: Better list --- src/actions.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src/actions.c') diff --git a/src/actions.c b/src/actions.c index 4ff6816..1b4c9b5 100644 --- a/src/actions.c +++ b/src/actions.c @@ -134,8 +134,11 @@ int run_EDIT(UserOpt *opt, Conf *conf) { /* If the program has many configs */ else { HELP("Ambiguous config. Please type the config name after the program."); - cklist *paths = list_make_new(); - edit_get_avaliable_paths(&db, paths, pName); + char name[STR_M] = ""; + strcat(name, pName); + strcat(name, ":"); + cklist *paths = list_make_and_add(name); + get_program_paths(&db, paths, pName, 1, 0); list_print(paths); list_free(paths); goto error; @@ -147,8 +150,11 @@ int run_EDIT(UserOpt *opt, Conf *conf) { char *cName = list_get(opt->args); if (edit_get_config(&db, pName, confName, cName, &secret)) { ERR("Program %s doesn't have a config named %s", pName, cName); - cklist *paths = list_make_new(); - edit_get_avaliable_paths(&db, paths, pName); + char name[STR_M] = ""; + strcat(name, pName); + strcat(name, ":"); + cklist *paths = list_make_and_add(name); + get_program_paths(&db, paths, pName, 1, 0); list_print(paths); list_free(paths); goto error; @@ -171,7 +177,6 @@ int run_EDIT(UserOpt *opt, Conf *conf) { } int run_LIST(UserOpt *opt, Conf *conf) { - UNUSED(conf); DB db = open_DB(opt); if (db.ptr == NULL) { if (db.error == SQL_ERR_NO_TABLES) { @@ -186,6 +191,7 @@ int run_LIST(UserOpt *opt, Conf *conf) { if (listOpt.err) { goto error; } + char tmp[STR_L] = ""; switch(listOpt._lt) { case LT_PATH: list_get_paths(&db, the_list, listOpt.attr); @@ -197,6 +203,27 @@ int run_LIST(UserOpt *opt, Conf *conf) { list_get_path_program_tree(&db, the_list, listOpt.attr); list_print(the_list); goto close; + case LT_CKCONF: + strcat(tmp, "ck configuration directory path: "); + strcat(tmp, opt->confDir); + list_add(the_list, tmp); +#define X(var, str, name) \ + strcpy(tmp, ""); \ + strcat(tmp, name); \ + strcat(tmp, ": "); \ + strcat(tmp, conf->var); \ + list_add(the_list, tmp); + CONFIG_VARIABLES_TABLE; +#undef X + list_print(the_list); + goto close; + case LT_PROG_CONFS: + if (!program_exists(&db, listOpt.pName)) { + ERR("Program %s doesn't exist in the database.", listOpt.pName); + goto error; + } + get_program_paths(&db, the_list, listOpt.pName, 0, listOpt.attr); + break; case LT_NONE: goto error; } -- cgit v1.2.3