aboutsummaryrefslogtreecommitdiff
path: root/src/survive.c
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2018-03-18 22:00:55 -0400
committercnlohr <lohr85@gmail.com>2018-03-18 22:00:55 -0400
commit0996cfcee351bfd665f48a205d2f7fe37dec336c (patch)
tree578b865dc5037d5dbaa074458d7c0b542550e914 /src/survive.c
parentc44cca299fbea4196af125dfedd8e4d60f3ae0cc (diff)
downloadlibsurvive-0996cfcee351bfd665f48a205d2f7fe37dec336c.tar.gz
libsurvive-0996cfcee351bfd665f48a205d2f7fe37dec336c.tar.bz2
Fix configuration system and fix race condition in survive_vive.
Diffstat (limited to 'src/survive.c')
-rwxr-xr-xsrc/survive.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/survive.c b/src/survive.c
index 24bb7d3..05c66d7 100755
--- a/src/survive.c
+++ b/src/survive.c
@@ -164,13 +164,22 @@ SurviveContext * survive_init_internal( int argc, char * const * argv )
if( vartoupdate )
{
- survive_configs( ctx, *av, SC_OVERRIDE, *(av+1) );
- av++;
+ if( av+1 == argvend )
+ {
+ fprintf( stderr, "Error: expected parameter after %s\n", *av );
+ showhelp = 1;
+ }
+ else
+ {
+ survive_configs( ctx, *av+2, SC_OVERRIDE|SC_SET, *(av+1) );
+ av++;
+ }
}
}
}
if( showhelp )
{
+ //Can't use SV_ERROR here since we don't have a context to send to yet.
fprintf( stderr, "libsurvive - usage:\n" );
fprintf( stderr, " --[parameter] [value] - sets parameter\n" );
fprintf( stderr, " -h - shows help.\n" );
@@ -178,8 +187,6 @@ SurviveContext * survive_init_internal( int argc, char * const * argv )
fprintf( stderr, " -l [lighthouse count] - use a specific number of lighthoses.\n" );
fprintf( stderr, " -c [config file] - set config file\n" );
fprintf( stderr, " -p [lighthouse count] - use a specific number of lighthoses.\n" );
-
- //XXX: TODO: Should this just exit(-1)?
return 0;
}
@@ -435,7 +442,7 @@ void survive_close( SurviveContext * ctx )
int survive_poll( struct SurviveContext * ctx )
{
int i, r;
- if( ctx->state = SURVIVE_STOPPED )
+ if( ctx->state == SURVIVE_STOPPED )
{
r = survive_startup( ctx );
if( r )