diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-09-26 12:07:48 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-09-26 12:07:48 +0300 |
commit | 7d0d0e5f1570f06564e07f5e55b9bef9db517f8b (patch) | |
tree | e8007bd87a3cb264346cd0da5544bd1f8f0400ac /src/dblayer.c | |
parent | ba6ff53bebd1ea6c51f12ba5dd218dcce8348df1 (diff) | |
download | ck-7d0d0e5f1570f06564e07f5e55b9bef9db517f8b.tar.gz ck-7d0d0e5f1570f06564e07f5e55b9bef9db517f8b.tar.bz2 ck-7d0d0e5f1570f06564e07f5e55b9bef9db517f8b.zip |
list can now show attributes (secret, primary)
Diffstat (limited to 'src/dblayer.c')
-rw-r--r-- | src/dblayer.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/dblayer.c b/src/dblayer.c index dbd772e..128ad2c 100644 --- a/src/dblayer.c +++ b/src/dblayer.c @@ -412,12 +412,12 @@ int edit_get_prime_config_from_program(DB *db, char *pName, char *ret, int *secr return 0; } -int list_get_paths(DB *db, cklist *ckl) { +int list_get_paths(DB *db, cklist *ckl, int attr) { sqlite3_stmt *stmt; int rc; char sql[STR_M]; - dbh_form_query_select_paths(sql); + dbh_form_query_select_paths_with_attributes(sql); rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { @@ -425,7 +425,19 @@ int list_get_paths(DB *db, cklist *ckl) { } while (sqlite3_step(stmt) == SQLITE_ROW) { - list_add(ckl, (char *)sqlite3_column_text(stmt, 0)); + char path[STR_L] = ""; + strcat(path, (char *)sqlite3_column_text(stmt, 0)); + if (attr) { + /* secret */ + if (sqlite3_column_int(stmt, 1)) { + strcat(path, " [s]"); + } + /* primary */ + if (sqlite3_column_int(stmt, 2)) { + strcat(path, " [p]"); + } + } + list_add(ckl, path); } sqlite3_finalize(stmt); @@ -452,7 +464,7 @@ int list_get_programs(DB *db, cklist *ckl) { return 1; } -int list_get_path_program_tree(DB *db, cklist *ckl) { +int list_get_path_program_tree(DB *db, cklist *ckl, int attr) { sqlite3_stmt *stmt; int rc; @@ -474,11 +486,17 @@ int list_get_path_program_tree(DB *db, cklist *ckl) { char sql2[STR_L]; + char selection[STR_M] = COL_CONFIG_PATH; + strcat(selection, ","); + strcat(selection, COL_CONFIG_SECRET); + strcat(selection, ","); + strcat(selection, COL_CONFIG_PRIMARY); + char condition[STR_M] = TBL_PROGRAM; strcat(condition, "."); strcat(condition, COL_PROGRAM_NAME); - dbh_form_query_select_from_joined_eq(sql2, COL_CONFIG_PATH, condition); + dbh_form_query_select_from_joined_eq(sql2, selection, condition); rc2 = sqlite3_prepare_v2(db->ptr, sql2, -1, &stmt2, 0); if (rc2 != SQLITE_OK) { @@ -489,6 +507,16 @@ int list_get_path_program_tree(DB *db, cklist *ckl) { while (sqlite3_step(stmt2) == SQLITE_ROW) { char treePath[STR_L] = "|- "; strcat(treePath, (char *)sqlite3_column_text(stmt2, 0)); + if (attr) { + /* secret */ + if (sqlite3_column_int(stmt2, 1)) { + strcat(treePath, " [s]"); + } + /* primary */ + if (sqlite3_column_int(stmt2, 2)) { + strcat(treePath, " [p]"); + } + } list_add(ckl, treePath); } sqlite3_finalize(stmt2); |