diff options
Diffstat (limited to 'src/biruda.c')
-rw-r--r-- | src/biruda.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/biruda.c b/src/biruda.c index 3934d55..1ec8d5a 100644 --- a/src/biruda.c +++ b/src/biruda.c @@ -68,6 +68,19 @@ static int test_config( const struct gengetopt_args_info *args_info ) return 0; } +static int conf_parse_worker_execution( cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result ) +{ + if( strcmp( value, "direct" ) == 0 ) { + *(worker_execution_mode_t *)result = WORKER_EXECUTION_DIRECT; + } else { + cfg_error( cfg, "invalid value for worker execution mode option '%s': %s", + cfg_opt_name( opt ), value ); + return -1; + } + + return 0; +} + static int read_config( const char *filename, cfg_t **cfg ) { cfg_opt_t opts_master[] = { @@ -82,6 +95,8 @@ static int read_config( const char *filename, cfg_t **cfg ) cfg_opt_t opts_worker[] = { CFG_STR( "control", 0, CFGF_NODEFAULT ), + CFG_INT_CB( "execution", WORKER_EXECUTION_DIRECT, CFGF_NONE, conf_parse_worker_execution ), + CFG_STR( "command", NULL, CFGF_NONE ), CFG_END( ) }; @@ -142,12 +157,22 @@ static void print_config( struct gengetopt_args_info *args_info, cfg_t *cfg ) unsigned int nof_workers = cfg_size( cfg, "worker" ); if( nof_workers > 0 ) { - printf( "Workers:\n" ); + puts( "Workers:\n" ); for( unsigned int i = 0; i < nof_workers; i++ ) { cfg_t *worker_cfg = cfg_getnsec( cfg, "worker", i ); printf( " Worker %s:\n", cfg_title( worker_cfg ) ); printf( " Control channel: %s\n", cfg_getstr( worker_cfg, "control" ) ); + printf( " Execution mode: %s\n", worker_exection_mode_str( cfg_getint( worker_cfg, "execution" ) ) ); + if( cfg_getint( worker_cfg, "execution" ) == WORKER_EXECUTION_DIRECT ) { + char *command = cfg_getstr( worker_cfg, "command" ); + if( command != NULL ) { + printf( " Command: %s\n", cfg_getstr( worker_cfg, "command" ) ); + } else { + printf( " No command configured\n" ); + } + } + puts( "" ); } puts( "" ); } |