aboutsummaryrefslogtreecommitdiffstats
path: root/src/dblayer.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-10-09 20:53:30 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-10-09 20:53:30 +0300
commit598e0522de924a50ea9c640955daab8512029eb4 (patch)
tree3f3cf027349a414e2f24d1a4c7976916e8b7dc21 /src/dblayer.c
parentfe781e5ae7116733e5b335a0ac016af97266db5f (diff)
downloadck-598e0522de924a50ea9c640955daab8512029eb4.tar.gz
ck-598e0522de924a50ea9c640955daab8512029eb4.tar.bz2
ck-598e0522de924a50ea9c640955daab8512029eb4.zip
Better list
Diffstat (limited to 'src/dblayer.c')
-rw-r--r--src/dblayer.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/dblayer.c b/src/dblayer.c
index 4290a7a..973d561 100644
--- a/src/dblayer.c
+++ b/src/dblayer.c
@@ -478,9 +478,10 @@ int edit_get_config(DB *db, const char *pName, char *ret, const char *cName, int
sqlite3_finalize(stmt);
return flag;
}
+ return -1;
}
-int edit_get_avaliable_paths(DB *db, cklist *ckl, const char* pName) {
+int get_program_paths(DB *db, cklist *ckl, const char* pName, int bname, int attr) {
int pid = get_program_id(db, pName);
/* error */
if (pid == -2) {
@@ -493,6 +494,10 @@ int edit_get_avaliable_paths(DB *db, cklist *ckl, const char* pName) {
int rc;
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_ID);
@@ -506,21 +511,32 @@ int edit_get_avaliable_paths(DB *db, cklist *ckl, const char* pName) {
return -2;
}
- char name[STR_M] = "";
- strcat(name, pName);
- strcat(name, ":");
- list_add(ckl, name);
while (sqlite3_step(stmt) == SQLITE_ROW) {
char *tmp = strdup((char *)sqlite3_column_text(stmt, 0));
char entry[STR_M] = "";
- strcat(entry, "|- ");
- strcat(entry, basename(tmp));
+ if (bname) {
+ strcat(entry, basename(tmp));
+ }
+ else {
+ strcat(entry, tmp);
+ }
+ if (attr) {
+ /* secret */
+ if (sqlite3_column_int(stmt, 1)) {
+ strcat(entry, " [s]");
+ }
+ /* primary */
+ if (sqlite3_column_int(stmt, 2)) {
+ strcat(entry, " [p]");
+ }
+ }
list_add(ckl, entry);
free(tmp);
}
sqlite3_finalize(stmt);
return 0;
}
+ return -1;
}
int list_get_paths(DB *db, cklist *ckl, int attr) {
@@ -732,15 +748,11 @@ int get_program_relations(DB *db, int pid) {
int get_config_number(DB *db, char* pName) {
int pid = get_program_id(db, pName);
- /* error */
- if (pid == -2) {
- return -1;
- }
-
/* program exists */
if (pid > -1) {
return get_program_relations(db, pid);
}
+ return -1;
}
/* Removes the relationship of `cid` with the corresponding program.