aboutsummaryrefslogtreecommitdiffstats
path: root/src/dblayer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dblayer.c')
-rw-r--r--src/dblayer.c38
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);