mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
db config: get config path in init call
This commit is contained in:
parent
26e3f3ef27
commit
8da2fd3564
3 changed files with 10 additions and 2 deletions
|
|
@ -123,6 +123,7 @@ static int dm_ctx_init_custom(struct dmctx *ctx, unsigned int dm_type, unsigned
|
||||||
uci_ctx = uci_alloc_context();
|
uci_ctx = uci_alloc_context();
|
||||||
uci_varstate_ctx = uci_alloc_context();
|
uci_varstate_ctx = uci_alloc_context();
|
||||||
DMUCI_INIT(bbfdm);
|
DMUCI_INIT(bbfdm);
|
||||||
|
get_db_config_path();
|
||||||
}
|
}
|
||||||
INIT_LIST_HEAD(&ctx->list_parameter);
|
INIT_LIST_HEAD(&ctx->list_parameter);
|
||||||
INIT_LIST_HEAD(&ctx->set_list_tmp);
|
INIT_LIST_HEAD(&ctx->set_list_tmp);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
struct uci_context *uci_ctx;
|
struct uci_context *uci_ctx;
|
||||||
struct uci_context *uci_varstate_ctx;
|
struct uci_context *uci_varstate_ctx;
|
||||||
|
static char *db_config = NULL;
|
||||||
|
|
||||||
NEW_UCI_PATH(bbfdm, BBFDM_CONFIG, BBFDM_SAVEDIR)
|
NEW_UCI_PATH(bbfdm, BBFDM_CONFIG, BBFDM_SAVEDIR)
|
||||||
struct uci_section *dmuci_walk_state_section (char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk)
|
struct uci_section *dmuci_walk_state_section (char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk)
|
||||||
|
|
@ -259,11 +260,16 @@ end:
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void get_db_config_path(void)
|
||||||
|
{
|
||||||
|
db_config = (folder_exists(LIB_DB_CONFIG)) ? LIB_DB_CONFIG : ETC_DB_CONFIG;
|
||||||
|
}
|
||||||
|
|
||||||
int db_get_value_string(char *package, char *section, char *option, char **value)
|
int db_get_value_string(char *package, char *section, char *option, char **value)
|
||||||
{
|
{
|
||||||
struct uci_option *o;
|
struct uci_option *o;
|
||||||
|
|
||||||
o = dmuci_get_option_ptr((folder_exists(LIB_DB_CONFIG)) ? LIB_DB_CONFIG : ETC_DB_CONFIG, package, section, option);
|
o = dmuci_get_option_ptr((db_config) ? db_config : LIB_DB_CONFIG, package, section, option);
|
||||||
if (o) {
|
if (o) {
|
||||||
*value = o->v.string ? dmstrdup(o->v.string) : ""; // MEM WILL BE FREED IN DMMEMCLEAN
|
*value = o->v.string ? dmstrdup(o->v.string) : ""; // MEM WILL BE FREED IN DMMEMCLEAN
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -278,7 +284,7 @@ int db_get_value_list(char *package, char *section, char *option, struct uci_lis
|
||||||
struct uci_option *o;
|
struct uci_option *o;
|
||||||
*value = NULL;
|
*value = NULL;
|
||||||
|
|
||||||
o = dmuci_get_option_ptr((folder_exists(LIB_DB_CONFIG)) ? LIB_DB_CONFIG : ETC_DB_CONFIG, package, section, option);
|
o = dmuci_get_option_ptr((db_config) ? db_config : LIB_DB_CONFIG, package, section, option);
|
||||||
if (o) {
|
if (o) {
|
||||||
*value = &o->v.list;
|
*value = &o->v.list;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,7 @@ int dmuci_get_option_value_string(char *package, char *section, char *option, ch
|
||||||
char *dmuci_get_option_value_fallback_def(char *package, char *section, char *option, char *default_value);
|
char *dmuci_get_option_value_fallback_def(char *package, char *section, char *option, char *default_value);
|
||||||
int dmuci_get_option_value_list(char *package, char *section, char *option, struct uci_list **value);
|
int dmuci_get_option_value_list(char *package, char *section, char *option, struct uci_list **value);
|
||||||
struct uci_option *dmuci_get_option_ptr(char *cfg_path, char *package, char *section, char *option);
|
struct uci_option *dmuci_get_option_ptr(char *cfg_path, char *package, char *section, char *option);
|
||||||
|
void get_db_config_path(void);
|
||||||
int db_get_value_string(char *package, char *section, char *option, char **value);
|
int db_get_value_string(char *package, char *section, char *option, char **value);
|
||||||
int db_get_value_list(char *package, char *section, char *option, struct uci_list **value);
|
int db_get_value_list(char *package, char *section, char *option, struct uci_list **value);
|
||||||
int dmuci_get_varstate_string(char *package, char *section, char *option, char **value);
|
int dmuci_get_varstate_string(char *package, char *section, char *option, char **value);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue