aboutsummaryrefslogtreecommitdiff
path: root/src/survive_config.c
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2018-03-18 02:45:09 -0400
committercnlohr <lohr85@gmail.com>2018-03-18 22:21:59 -0400
commit179d8a02e231fe853831cdf886c9196929303adb (patch)
tree7de8df2fc9ef4d167398caebffe906985ed0cb54 /src/survive_config.c
parentd21999e85f29edae7de8abdfb293da870e7fad47 (diff)
downloadlibsurvive-179d8a02e231fe853831cdf886c9196929303adb.tar.gz
libsurvive-179d8a02e231fe853831cdf886c9196929303adb.tar.bz2
Moving things over... still todo:
* Make functions for changing temp configs. * Make functions for config_read_str but where it checks the temp one first. * Parse command-line options.
Diffstat (limited to 'src/survive_config.c')
-rw-r--r--src/survive_config.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/survive_config.c b/src/survive_config.c
index d923ba4..4ef2994 100644
--- a/src/survive_config.c
+++ b/src/survive_config.c
@@ -181,6 +181,36 @@ FLT config_read_float(config_group *cg, const char *tag, const FLT def) {
return config_set_float(cg, tag, def);
}
+static config_entry * sc_search(SurviveContext * ctx, const char *tag )
+{
+ config_entry *cv = find_config_entry(ctx->temporary_config_values, tag);
+ if( !cv ) cv = find_config_entry(ctx->global_config_values, tag);
+ return cv;
+}
+
+FLT survive_config_readf( SurviveContext * ctx, const char *tag, FLT def )
+{
+ config_entry * cv = sc_search( ctx, tag );
+ if( !cv ) return def;
+ return cv->numeric.f;
+}
+
+uint32_t survive_config_readi( SurviveContext * ctx, const char *tag, uint32_t def )
+{
+ config_entry * cv = sc_search( ctx, tag );
+ if( !cv ) return def;
+ return cv->numeric.i;
+}
+
+const char * survive_config_reads( SurviveContext * ctx, const char *tag, const char *def )
+{
+ config_entry * cv = sc_search( ctx, tag );
+ if( !cv ) return def;
+ return cv->data;
+}
+
+
+
// TODO: Do something better than this:
#define CFG_MIN(x,y) ((x) < (y)? (x): (y))