aboutsummaryrefslogtreecommitdiff
path: root/src/survive_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/survive_config.c')
-rw-r--r--src/survive_config.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/survive_config.c b/src/survive_config.c
index 23433c4..5ee4a84 100644
--- a/src/survive_config.c
+++ b/src/survive_config.c
@@ -77,7 +77,7 @@ int survive_print_help_for_parameter( const char * tomap )
{
char sthelp[160];
snprintf( sthelp, 159, " %s: %s [%c]", sc->name, sc->description, sc->type );
- fprintf( stderr, "\0337\033[1A\033[1000D%s\0338", sthelp, strlen( sthelp ));
+ fprintf( stderr, "\0337\033[1A\033[1000D%s\0338", sthelp );
return 1;
}
}
@@ -776,13 +776,31 @@ const char *survive_configs(SurviveContext *ctx, const char *tag, char flags, co
return def;
}
-SURVIVE_EXPORT void survive_attach_config(SurviveContext *ctx, const char *tag, void * var, char type )
+static void survive_attach_config(SurviveContext *ctx, const char *tag, void * var, char type )
{
config_entry *cv = sc_search(ctx, tag);
if( !cv )
{
- SV_ERROR( "Configuration item %s not initialized.\n", tag );
- return;
+ //Check to see if there is a static config with this value.
+ if( type == 'i' )
+ {
+ *((int*)var) = survive_configi( ctx, tag, SC_SET, 0);
+ }
+ if( type == 'f' )
+ {
+ *((FLT*)var) = survive_configf( ctx, tag, SC_SET, 0);
+ }
+ if( type == 's' )
+ {
+ const char * cv = survive_configs( ctx, tag, SC_SET, 0);
+ memcpy( var, cv, strlen(cv) );
+ }
+ cv = sc_search(ctx, tag);
+ if( !cv )
+ {
+ SV_ERROR( "Configuration item %s not initialized.\n", tag );
+ return;
+ }
}
update_list_t ** ul = &cv->update_list;
while( *ul )
@@ -795,6 +813,21 @@ SURVIVE_EXPORT void survive_attach_config(SurviveContext *ctx, const char *tag,
t->value = var;
}
+SURVIVE_EXPORT void survive_attach_configi(SurviveContext *ctx, const char *tag, int * var )
+{
+ survive_attach_config( ctx, tag, var, 'i' );
+}
+
+SURVIVE_EXPORT void survive_attach_configf(SurviveContext *ctx, const char *tag, FLT * var )
+{
+ survive_attach_config( ctx, tag, var, 'f' );
+}
+
+SURVIVE_EXPORT void survive_attach_configs(SurviveContext *ctx, const char *tag, char * var )
+{
+ survive_attach_config( ctx, tag, var, 's' );
+}
+
SURVIVE_EXPORT void survive_detach_config(SurviveContext *ctx, const char *tag, void * var )
{
config_entry *cv = sc_search(ctx, tag);