aboutsummaryrefslogtreecommitdiffstats
path: root/src/dblayer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dblayer.c')
-rw-r--r--src/dblayer.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/dblayer.c b/src/dblayer.c
index 2e19c5a..f97b70c 100644
--- a/src/dblayer.c
+++ b/src/dblayer.c
@@ -451,3 +451,49 @@ int list_get_programs(DB *db, cklist *ckl) {
return 1;
}
+
+int list_get_path_program_tree(DB *db, cklist *ckl) {
+ sqlite3_stmt *stmt;
+ int rc;
+
+ char sql[STR_M];
+ dbh_form_query_select_programs(sql);
+
+ rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
+ if (rc != SQLITE_OK) {
+ return -2;
+ }
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ char programName[STR_M];
+ strcat(programName, (char *)sqlite3_column_text(stmt, 0));
+ strcat(programName, ":");
+ list_add(ckl, programName);
+ sqlite3_stmt *stmt2;
+ int rc2;
+
+ char sql2[STR_L];
+
+ 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);
+
+ rc2 = sqlite3_prepare_v2(db->ptr, sql2, -1, &stmt2, 0);
+ if (rc2 != SQLITE_OK) {
+ return -2;
+ }
+
+ sqlite3_bind_text(stmt2, 1, (char *)sqlite3_column_text(stmt, 0), -1, 0);
+ while (sqlite3_step(stmt2) == SQLITE_ROW) {
+ char treePath[STR_L] = "|- ";
+ strcat(treePath, (char *)sqlite3_column_text(stmt2, 0));
+ list_add(ckl, treePath);
+ }
+ sqlite3_finalize(stmt2);
+ }
+ sqlite3_finalize(stmt);
+
+ return 1;
+}