aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/add.c8
-rw-r--r--src/dblayer.c16
-rw-r--r--src/delete.c10
-rw-r--r--src/edit.c2
-rw-r--r--src/init.c4
-rw-r--r--src/list.c8
-rw-r--r--src/queries.c34
-rw-r--r--src/queries.h36
-rw-r--r--src/restore.c2
9 files changed, 60 insertions, 60 deletions
diff --git a/src/add.c b/src/add.c
index 6292106..d28c82d 100644
--- a/src/add.c
+++ b/src/add.c
@@ -20,7 +20,7 @@ static int get_next_valid_id_from_table(DB *db, const char* tableName) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_select_id_from(sql, tableName);
+ dbh_fq_select_id_from(sql, tableName);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -45,7 +45,7 @@ static int insert_to_program_table(DB *db, const char *name) {
int rc;
char sql[STR_L] = "";
- dbh_form_query_insert_program(sql);
+ dbh_fq_insert_program(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -74,7 +74,7 @@ static int insert_to_config_table(DB *db, const char *path, const int secret, co
int rc;
char sql[STR_L] = "";
- dbh_form_query_insert_config(sql);
+ dbh_fq_insert_config(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
ERR("Error while preparing insert to config sql.");
@@ -150,7 +150,7 @@ static int add_insert_relationship(DB *db, const int pid, const int cid) {
int rc;
char sql[STR_M] = "";
- dhb_form_query_insert_relationship(sql);
+ dhb_fq_insert_relationship(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
db->error = SQL_ERR_SQLITE;
diff --git a/src/dblayer.c b/src/dblayer.c
index 5499cd8..94af089 100644
--- a/src/dblayer.c
+++ b/src/dblayer.c
@@ -36,7 +36,7 @@ int db_exists(const UserOpt *opt) {
/* check if db has the correct tables */
static int check_initialized_DB(sqlite3 *db) {
char sql[STR_M] = "";
- dbh_form_query_select_all_tables(sql);
+ dbh_fq_select_all_tables(sql);
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, sql, (int)strlen(sql), &stmt, NULL);
@@ -100,7 +100,7 @@ int get_program_id(DB *db, const char* name) {
int rc;
char sql[STR_M] = "";
- dhb_form_query_find_program(sql);
+ dhb_fq_find_program(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -129,7 +129,7 @@ int get_config_id(DB *db, const char* path) {
int rc;
char sql[STR_M] = "";
- dhb_form_query_find_config(sql);
+ dhb_fq_find_config(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -162,7 +162,7 @@ int program_has_primary_config(DB *db, const int pid, char *ret, int *sec) {
strcat(selection, ", ");
strcat(selection, COL_CONFIG_SECRET);
- dbh_form_query_select_from_joined_eq(sql, selection, condition);
+ dbh_fq_select_from_joined_eq(sql, selection, condition);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -193,7 +193,7 @@ int get_program_relations(DB *db, int pid) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_count_program_relations(sql);
+ dbh_fq_count_program_relations(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -227,7 +227,7 @@ int get_pid_from_cid(DB *db, int cid) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_get_pid_from_cid(sql);
+ dbh_fq_get_pid_from_cid(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -279,7 +279,7 @@ int get_program_paths(DB *db, cklist *ckl, const char* pName, int bname, int att
strcat(condition, COL_PROGRAM_ID);
char sql[STR_L] = "";
- dbh_form_query_select_from_joined_eq(sql, selection, condition);
+ dbh_fq_select_from_joined_eq(sql, selection, condition);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
sqlite3_bind_int(stmt, 1, pid);
@@ -321,7 +321,7 @@ int secret_enabled(DB *db) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_secret_enabled(sql);
+ dbh_fq_secret_enabled(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
diff --git a/src/delete.c b/src/delete.c
index 1e5a5ed..46bcdc0 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -20,7 +20,7 @@ static int delete_prog(DB *db, int pid) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_delete_x_from_y(sql, COL_PROGRAM_ID, TBL_PROGRAM);
+ dbh_fq_delete_x_from_y(sql, COL_PROGRAM_ID, TBL_PROGRAM);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -41,7 +41,7 @@ static int delete_conf(DB *db, int cid) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_delete_x_from_y(sql, COL_CONFIG_ID, TBL_CONFIG);
+ dbh_fq_delete_x_from_y(sql, COL_CONFIG_ID, TBL_CONFIG);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -67,7 +67,7 @@ static int remove_conf_rel(DB *db, int cid) {
int pid = get_pid_from_cid(db, cid);
char sql[STR_M] = "";
- dbh_form_query_delete_x_from_y(sql, COL_REL_CONFIG_ID, TBL_REL);
+ dbh_fq_delete_x_from_y(sql, COL_REL_CONFIG_ID, TBL_REL);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
return -1;
@@ -88,7 +88,7 @@ static int remove_all_configs(DB *db, int pid) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_select_from_joined_eq(sql, COL_REL_CONFIG_ID, COL_REL_PROGRAM_ID);
+ dbh_fq_select_from_joined_eq(sql, COL_REL_CONFIG_ID, COL_REL_PROGRAM_ID);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
return -2;
@@ -120,7 +120,7 @@ static int get_cid_from_pname_and_basename(DB *db, const char *pName, const char
strcat(condition, ".");
strcat(condition, COL_PROGRAM_NAME);
- dbh_form_query_select_from_joined_eq(sql, selection, condition);
+ dbh_fq_select_from_joined_eq(sql, selection, condition);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
ERR("while preparing get_cid_from_pname_and_basename");
diff --git a/src/edit.c b/src/edit.c
index e1c933a..395c8fb 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -59,7 +59,7 @@ static int edit_get_config(DB *db, const char *pName, char *ret, const char *cNa
strcat(condition, COL_PROGRAM_ID);
char sql[STR_L] = "";
- dbh_form_query_select_from_joined_eq(sql, selection, condition);
+ dbh_fq_select_from_joined_eq(sql, selection, condition);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
sqlite3_bind_int(stmt, 1, pid);
diff --git a/src/init.c b/src/init.c
index 0f7e99e..47ae849 100644
--- a/src/init.c
+++ b/src/init.c
@@ -76,7 +76,7 @@ static int set_secret_enabled(DB *db, int enabled) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_set_secret_enabled(sql);
+ dbh_fq_set_secret_enabled(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -94,7 +94,7 @@ static int set_secret_enabled(DB *db, int enabled) {
static void init_make_tables(DB *db) {
char sql[STR_L] = "";
- dbh_form_query_make_tables(sql);
+ dbh_fq_make_tables(sql);
int rc = sqlite3_exec(db->ptr, sql, 0, 0, 0);
if (rc != SQLITE_OK ) {
diff --git a/src/list.c b/src/list.c
index 1fd0326..b7f5a6e 100644
--- a/src/list.c
+++ b/src/list.c
@@ -90,7 +90,7 @@ int list_get_paths(DB *db, cklist *ckl, int bName, int attr, const char *home) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_select_paths_with_attributes(sql);
+ dbh_fq_select_paths_with_attributes(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -130,7 +130,7 @@ int list_get_programs(DB *db, cklist *ckl) {
int rc;
char sql[STR_M] = "";
- dbh_form_query_select_programs(sql);
+ dbh_fq_select_programs(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -150,7 +150,7 @@ static int list_get_path_program_tree(DB *db, cklist *ckl, int bName, int attr,
int rc;
char sql[STR_M] = "";
- dbh_form_query_select_programs(sql);
+ dbh_fq_select_programs(sql);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {
@@ -177,7 +177,7 @@ static int list_get_path_program_tree(DB *db, cklist *ckl, int bName, int attr,
strcat(condition, ".");
strcat(condition, COL_PROGRAM_NAME);
- dbh_form_query_select_from_joined_eq(sql2, selection, condition);
+ dbh_fq_select_from_joined_eq(sql2, selection, condition);
rc2 = sqlite3_prepare_v2(db->ptr, sql2, -1, &stmt2, 0);
if (rc2 != SQLITE_OK) {
diff --git a/src/queries.c b/src/queries.c
index 8b0a6e8..e4a46fd 100644
--- a/src/queries.c
+++ b/src/queries.c
@@ -11,7 +11,7 @@
#include "queries.h"
#include "ckutil.h"
-void dbh_form_query_make_tables(char *query) {
+void dbh_fq_make_tables(char *query) {
char tmp[STR_L] = "CREATE TABLE ";
strcat(tmp, TBL_PROGRAM);
strcat(tmp, "(");
@@ -51,7 +51,7 @@ void dbh_form_query_make_tables(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_insert_program(char *query) {
+void dbh_fq_insert_program(char *query) {
char tmp[STR_L] = "INSERT INTO ";
strcat(tmp, TBL_PROGRAM);
strcat(tmp, " VALUES(?, ?);");
@@ -59,7 +59,7 @@ void dbh_form_query_insert_program(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_insert_config(char *query) {
+void dbh_fq_insert_config(char *query) {
char tmp[STR_L] = "INSERT INTO ";
strcat(tmp, TBL_CONFIG);
strcat(tmp, " VALUES(?, ?, ?, ?);");
@@ -67,7 +67,7 @@ void dbh_form_query_insert_config(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_select_id_from(char *query, const char* tableName) {
+void dbh_fq_select_id_from(char *query, const char* tableName) {
char tmp[STR_M] = "SELECT ID FROM ";
strcat(tmp, tableName);
strcat(tmp, " ORDER BY ID;");
@@ -75,11 +75,11 @@ void dbh_form_query_select_id_from(char *query, const char* tableName) {
strcpy(query, tmp);
}
-void dbh_form_query_select_all_tables(char *query) {
+void dbh_fq_select_all_tables(char *query) {
strcpy(query, "SELECT * FROM SQLITE_MASTER WHERE type='table';");
}
-void dhb_form_query_insert_relationship(char *query) {
+void dhb_fq_insert_relationship(char *query) {
char tmp[STR_M] = "INSERT INTO ";
strcat(tmp, TBL_REL);
strcat(tmp, " VALUES(?, ?);");
@@ -87,7 +87,7 @@ void dhb_form_query_insert_relationship(char *query) {
strcpy(query, tmp);
}
-void dhb_form_query_find_program(char *query) {
+void dhb_fq_find_program(char *query) {
char tmp[STR_M] = "SELECT ID FROM ";
strcat(tmp, TBL_PROGRAM);
strcat(tmp, " WHERE ");
@@ -97,7 +97,7 @@ void dhb_form_query_find_program(char *query) {
strcpy(query, tmp);
}
-void dhb_form_query_find_config(char *query) {
+void dhb_fq_find_config(char *query) {
char tmp[STR_M] = "SELECT ID FROM ";
strcat(tmp, TBL_CONFIG);
strcat(tmp, " WHERE ");
@@ -107,7 +107,7 @@ void dhb_form_query_find_config(char *query) {
strcpy(query, tmp);
}
-void dhb_form_query_find_relationship(char *query) {
+void dhb_fq_find_relationship(char *query) {
char tmp[STR_M] = "SELECT ";
strcat(tmp, COL_REL_PROGRAM_ID);
strcat(tmp, ", ");
@@ -123,7 +123,7 @@ void dhb_form_query_find_relationship(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_select_from_joined_eq(char *query, const char *selection, const char* condition) {
+void dbh_fq_select_from_joined_eq(char *query, const char *selection, const char* condition) {
char tmp[STR_L] = "SELECT ";
strcat(tmp, selection);
strcat(tmp, " FROM ");
@@ -179,7 +179,7 @@ void dbh_format_query_select_from_joined_like(char *query, const char *selection
strcpy(query, tmp);
}
-void dbh_form_query_select_paths_with_attributes(char *query) {
+void dbh_fq_select_paths_with_attributes(char *query) {
char tmp[STR_L] = "SELECT ";
strcat(tmp, COL_CONFIG_PATH);
strcat(tmp, ",");
@@ -193,7 +193,7 @@ void dbh_form_query_select_paths_with_attributes(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_select_programs(char *query) {
+void dbh_fq_select_programs(char *query) {
char tmp[STR_L] = "SELECT ";
strcat(tmp, COL_PROGRAM_NAME);
strcat(tmp, " FROM ");
@@ -203,7 +203,7 @@ void dbh_form_query_select_programs(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_delete_x_from_y(char *query, const char *x, const char *y) {
+void dbh_fq_delete_x_from_y(char *query, const char *x, const char *y) {
char tmp[STR_M] = "DELETE FROM ";
strcat(tmp, y);
strcat(tmp, " WHERE ");
@@ -213,7 +213,7 @@ void dbh_form_query_delete_x_from_y(char *query, const char *x, const char *y) {
strcpy(query, tmp);
}
-void dbh_form_query_count_program_relations(char *query) {
+void dbh_fq_count_program_relations(char *query) {
char tmp[STR_M] = "SELECT COUNT(*) FROM ";
strcat(tmp, TBL_REL);
strcat(tmp, " WHERE ");
@@ -223,7 +223,7 @@ void dbh_form_query_count_program_relations(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_get_pid_from_cid(char *query) {
+void dbh_fq_get_pid_from_cid(char *query) {
char tmp[STR_M] = "SELECT ";
strcat(tmp, COL_REL_PROGRAM_ID);
strcat(tmp, " FROM ");
@@ -235,7 +235,7 @@ void dbh_form_query_get_pid_from_cid(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_secret_enabled(char *query) {
+void dbh_fq_secret_enabled(char *query) {
char tmp[STR_M] = "SELECT ";
strcat(tmp, COL_CTX_VAL);
strcat(tmp, " FROM ");
@@ -249,7 +249,7 @@ void dbh_form_query_secret_enabled(char *query) {
strcpy(query, tmp);
}
-void dbh_form_query_set_secret_enabled(char *query) {
+void dbh_fq_set_secret_enabled(char *query) {
char tmp[STR_L] = "INSERT INTO ";
strcat(tmp, TBL_CTX);
strcat(tmp, " VALUES(\"");
diff --git a/src/queries.h b/src/queries.h
index ddc8bae..7204df2 100644
--- a/src/queries.h
+++ b/src/queries.h
@@ -49,22 +49,22 @@
/* form queries */
/****************/
-void dbh_form_query_make_tables(char *query);
-void dbh_form_query_insert_program(char *query);
-void dbh_form_query_insert_config(char *query);
-void dbh_form_query_select_id_from(char *query, const char* tableName);
-void dbh_form_query_select_all_tables(char *query);
-void dhb_form_query_insert_relationship(char *query);
-void dhb_form_query_find_program(char *query);
-void dhb_form_query_find_config(char *query);
-void dhb_form_query_find_relationship(char *query);
-void dbh_form_query_select_paths_with_attributes(char *query);
-void dbh_form_query_select_programs(char *query);
-void dbh_form_query_select_from_joined_eq(char *query, const char *selection, const char* condition);
-void dbh_form_query_select_from_joined_like(char *query, const char *selection, const char* condition);
-void dbh_form_query_delete_x_from_y(char *query, const char *x, const char *y);
-void dbh_form_query_count_program_relations(char *query);
-void dbh_form_query_get_pid_from_cid(char *query);
-void dbh_form_query_secret_enabled(char *query);
-void dbh_form_query_set_secret_enabled(char *query);
+void dbh_fq_make_tables(char *query);
+void dbh_fq_insert_program(char *query);
+void dbh_fq_insert_config(char *query);
+void dbh_fq_select_id_from(char *query, const char* tableName);
+void dbh_fq_select_all_tables(char *query);
+void dhb_fq_insert_relationship(char *query);
+void dhb_fq_find_program(char *query);
+void dhb_fq_find_config(char *query);
+void dhb_fq_find_relationship(char *query);
+void dbh_fq_select_paths_with_attributes(char *query);
+void dbh_fq_select_programs(char *query);
+void dbh_fq_select_from_joined_eq(char *query, const char *selection, const char* condition);
+void dbh_fq_select_from_joined_like(char *query, const char *selection, const char* condition);
+void dbh_fq_delete_x_from_y(char *query, const char *x, const char *y);
+void dbh_fq_count_program_relations(char *query);
+void dbh_fq_get_pid_from_cid(char *query);
+void dbh_fq_secret_enabled(char *query);
+void dbh_fq_set_secret_enabled(char *query);
#endif /* DBHELPER_H */
diff --git a/src/restore.c b/src/restore.c
index a4edd94..ce2bebc 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -65,7 +65,7 @@ static int restore_configs_exists(DB *db, Conf *conf, const char *pName, cklist
strcat(condition, ".");
strcat(condition, COL_PROGRAM_NAME);
- dbh_form_query_select_from_joined_eq(sql, selection, condition);
+ dbh_fq_select_from_joined_eq(sql, selection, condition);
rc = sqlite3_prepare_v2(db->ptr, sql, -1, &stmt, 0);
if (rc != SQLITE_OK) {