summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c4
-rw-r--r--src/til.c2
-rw-r--r--src/til_settings.c11
-rw-r--r--src/til_settings.h2
4 files changed, 13 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 2e0229e..54abe18 100644
--- a/src/main.c
+++ b/src/main.c
@@ -219,11 +219,11 @@ static int setup_from_args(til_args_t *args, setup_t *res_setup, const til_setti
*/
srand(setup.seed);
- setup.module_settings = til_settings_new(args->module);
+ setup.module_settings = til_settings_new("module", args->module);
if (!setup.module_settings)
goto _err;
- setup.video_settings = til_settings_new(args->video);
+ setup.video_settings = til_settings_new("video", args->video);
if (!setup.video_settings)
goto _err;
diff --git a/src/til.c b/src/til.c
index 489fcf1..58e52bb 100644
--- a/src/til.c
+++ b/src/til.c
@@ -327,7 +327,7 @@ int til_module_randomize_setup(const til_module_t *module, unsigned seed, til_se
if (!module->setup)
return 0;
- settings = til_settings_new(NULL);
+ settings = til_settings_new(module->name, NULL);
if (!settings)
return -ENOMEM;
diff --git a/src/til_settings.c b/src/til_settings.c
index 3e26686..9fce32f 100644
--- a/src/til_settings.c
+++ b/src/til_settings.c
@@ -31,6 +31,7 @@ char * strndup(const char *s, size_t n)
/* Split form of key=value[,key=value...] settings string */
typedef struct til_settings_t {
+ const char *label;
unsigned num;
til_setting_t **settings;
} til_settings_t;
@@ -62,7 +63,7 @@ static int add_value(til_settings_t *settings, const char *key, const char *valu
/* split settings_string into a data structure */
-til_settings_t * til_settings_new(const char *settings_string)
+til_settings_t * til_settings_new(const char *label, const char *settings_string)
{
til_settings_fsm_state_t state = TIL_SETTINGS_FSM_STATE_KEY;
const char *p, *token;
@@ -71,9 +72,15 @@ til_settings_t * til_settings_new(const char *settings_string)
char *value_buf;
size_t value_sz;
+ assert(label);
+
settings = calloc(1, sizeof(til_settings_t));
if (!settings)
- return NULL;
+ goto _err;
+
+ settings->label = strdup(label);
+ if (!settings->label)
+ goto _err;
if (!settings_string)
return settings;
diff --git a/src/til_settings.h b/src/til_settings.h
index df8a307..93c0ed8 100644
--- a/src/til_settings.h
+++ b/src/til_settings.h
@@ -33,7 +33,7 @@ struct til_setting_t {
void *user_data;
};
-til_settings_t * til_settings_new(const char *settings);
+til_settings_t * til_settings_new(const char *label, const char *settings);
til_settings_t * til_settings_free(til_settings_t *settings);
const char * til_settings_get_value(const til_settings_t *settings, const char *key, til_setting_t **res_setting);
const char * til_settings_get_key(const til_settings_t *settings, unsigned pos, til_setting_t **res_setting);
© All Rights Reserved