summaryrefslogtreecommitdiff
path: root/src/biruda.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-12-05 12:31:14 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2014-12-05 12:31:14 +0100
commitb64f784061d7576716d66e6f637d2827b46b2587 (patch)
tree02627e118700c2b1e68dbb016c3652454b2aaf7b /src/biruda.c
parent9d44c565a7e9ded7eea2a8df7665518c622d02d0 (diff)
downloadbiruda-b64f784061d7576716d66e6f637d2827b46b2587.tar.gz
biruda-b64f784061d7576716d66e6f637d2827b46b2587.tar.bz2
better configration testing, added 'data' channel
Diffstat (limited to 'src/biruda.c')
-rw-r--r--src/biruda.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/biruda.c b/src/biruda.c
index 0e0379c..834b72f 100644
--- a/src/biruda.c
+++ b/src/biruda.c
@@ -77,10 +77,49 @@ static int conf_validate_worker_execution( cfg_t *cfg, cfg_opt_t *opt, const cha
return 0;
}
+static int conf_validate_master( cfg_t *cfg, cfg_opt_t *opt )
+{
+ cfg_t *master = cfg_opt_getnsec( opt, cfg_opt_size( opt ) - 1 );
+
+ if( cfg_size( master, "control" ) == 0 ) {
+ cfg_error( cfg, "missing required option 'control' for master" );
+ return -1;
+ }
+
+ if( cfg_size( master, "data" ) == 0 ) {
+ cfg_error( cfg, "missing required option 'data' for master" );
+ return -1;
+ }
+
+ return 0;
+}
+
+static int conf_validate_coordinator( cfg_t *cfg, cfg_opt_t *opt )
+{
+ cfg_t *coordinator = cfg_opt_getnsec( opt, cfg_opt_size( opt ) - 1 );
+
+ if( cfg_size( coordinator, "control" ) == 0 ) {
+ cfg_error( cfg, "missing required option 'control' for coordinator" );
+ return -1;
+ }
+
+ return 0;
+}
+
static int conf_validate_worker( cfg_t *cfg, cfg_opt_t *opt )
{
cfg_t *worker = cfg_opt_getnsec( opt, cfg_opt_size( opt ) - 1 );
+ if( cfg_size( worker, "control" ) == 0 ) {
+ cfg_error( cfg, "missing required option 'control' for worker" );
+ return -1;
+ }
+
+ if( cfg_size( worker, "data" ) == 0 ) {
+ cfg_error( cfg, "missing required option 'data' for worker" );
+ return -1;
+ }
+
worker_execution_mode_t mode = (worker_execution_mode_t)cfg_getint( worker, "execution" );
switch( mode ) {
@@ -103,6 +142,7 @@ static int read_config( const char *filename, cfg_t **cfg )
{
cfg_opt_t opts_master[] = {
CFG_STR( "control", 0, CFGF_NODEFAULT ),
+ CFG_STR( "data", 0, CFGF_NODEFAULT ),
CFG_END( )
};
@@ -113,6 +153,7 @@ static int read_config( const char *filename, cfg_t **cfg )
cfg_opt_t opts_worker[] = {
CFG_STR( "control", 0, CFGF_NODEFAULT ),
+ CFG_STR( "data", 0, CFGF_NODEFAULT ),
CFG_INT_CB( "execution", WORKER_EXECUTION_DISABLED, CFGF_NONE, &conf_validate_worker_execution ),
CFG_STR( "command", NULL, CFGF_NODEFAULT ),
CFG_END( )
@@ -135,6 +176,8 @@ static int read_config( const char *filename, cfg_t **cfg )
*cfg = cfg_init( opts, CFGF_NONE );
+ cfg_set_validate_func( *cfg, "master", &conf_validate_master );
+ cfg_set_validate_func( *cfg, "coordinator", &conf_validate_coordinator );
cfg_set_validate_func( *cfg, "worker", &conf_validate_worker );
switch( cfg_parse( *cfg, filename ) ) {
@@ -171,6 +214,7 @@ static void print_config( struct gengetopt_args_info *args_info, cfg_t *cfg )
if( has_master ) {
puts( "Master:" );
printf( " Control channel: %s\n", cfg_getstr( master_cfg, "control" ) );
+ printf( " Data channel: %s\n", cfg_getstr( master_cfg, "data" ) );
puts( "" );
}
@@ -190,6 +234,7 @@ static void print_config( struct gengetopt_args_info *args_info, cfg_t *cfg )
printf( " Worker %s:\n", cfg_title( worker_cfg ) );
printf( " Control channel: %s\n", cfg_getstr( worker_cfg, "control" ) );
+ printf( " Data channel: %s\n", cfg_getstr( worker_cfg, "data" ) );
printf( " Execution mode: %s\n", worker_exection_mode_str( (worker_execution_mode_t)cfg_getint( worker_cfg, "execution" ) ) );
if( cfg_getint( worker_cfg, "execution" ) == WORKER_EXECUTION_DIRECT ) {
char *command = cfg_getstr( worker_cfg, "command" );