diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2026-07-02 10:23:06 +0200 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2026-07-02 10:23:06 +0200 |
| commit | cd7d94ccb19413382b395e88f7384990173f0b18 (patch) | |
| tree | 2f71317e692a6d9222cb99eb9609b08df23a1e34 | |
| parent | 1025fa6dc9b9c5d19f88cd66d6c6222649a177aa (diff) | |
Manage uconfig better in ftag_config
| -rw-r--r-- | src/config.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/config.c b/src/config.c index 083150e..b22588e 100644 --- a/src/config.c +++ b/src/config.c @@ -10,11 +10,10 @@ #define CONFIG_STR_SIZE 128 -static struct uconfig_s *uconfig; static char *ftag_config_keys[FC_COUNT]; static char ftag_config_values[FC_COUNT][CONFIG_STR_SIZE]; -static void ftag_config_read(enum ftag_config_e key) +static void ftag_config_read(struct uconfig_s *uconfig, enum ftag_config_e key) { char *new_value = uconfig_get(uconfig, ftag_config_keys[key]); if (new_value != NULL) { @@ -25,6 +24,8 @@ static void ftag_config_read(enum ftag_config_e key) static int ftag_config_load_file(const char *config_file) { + struct uconfig_s *uconfig; + if (!(config_file && file_exists(config_file))) return 0; @@ -36,8 +37,9 @@ static int ftag_config_load_file(const char *config_file) exit(EXIT_FAILURE); } for (enum ftag_config_e key = FC_FIRST; key < FC_COUNT; key++) { - ftag_config_read(key); + ftag_config_read(uconfig, key); } + uconfig_destroy(uconfig); return 1; } @@ -74,13 +76,6 @@ void ftag_config_init(const char *opt_config_file) strcpy(ftag_config_values[FC_REMOTE_HOST], "localhost"); strcpy(ftag_config_values[FC_REMOTE_ROOT], "ftag"); - uconfig = NULL; - int config_loaded = 0; - - config_loaded = ftag_config_load_file(config_file); - if (config_loaded) - return; - ftag_config_load_file(config_file); } @@ -91,6 +86,4 @@ const char *ftag_config_get(enum ftag_config_e key) void ftag_config_finalize(void) { - if (uconfig) - uconfig_destroy(uconfig); } |
