diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/rtv/rtv.c | 8 | ||||
-rw-r--r-- | src/settings.c | 2 | ||||
-rw-r--r-- | src/settings.h | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index a9d0399..c4c6dd2 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -73,7 +73,13 @@ static char * randomize_module_setup(const rototiller_module_t *module) return NULL; while (module->setup(settings, &desc) > 0) { - if (desc->values) { + if (desc->random) { + char *value; + + value = desc->random(); + settings_add_value(settings, desc->key, value); + free(value); + } else if (desc->values) { int n; for (n = 0; desc->values[n]; n++); diff --git a/src/settings.c b/src/settings.c index e5560b0..02c8e8d 100644 --- a/src/settings.c +++ b/src/settings.c @@ -265,6 +265,8 @@ int setting_desc_clone(const setting_desc_t *desc, setting_desc_t **res_desc) } } + d->random = desc->random; + /* TODO: handle allocation errors above... */ *res_desc = d; diff --git a/src/settings.h b/src/settings.h index 198f8b6..af47326 100644 --- a/src/settings.h +++ b/src/settings.h @@ -11,6 +11,7 @@ typedef struct setting_desc_t { const char *preferred; /* if there's a default, this is it */ const char **values; /* if a set of values is provided, listed here */ const char **annotations; /* if a set of values is provided, annotations for those values may be listed here */ + char * (*random)(void);/* if set, returns a valid random value for this setting */ } setting_desc_t; /* For conveniently representing setting description generators */ |