Index: ossp-pkg/rc/rc.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.c,v rcsdiff -q -kk '-r1.39' '-r1.40' -u '/v/ossp/cvs/ossp-pkg/rc/rc.c,v' 2>/dev/null --- rc.c 2002/07/10 19:02:24 1.39 +++ rc.c 2002/07/29 16:34:58 1.40 @@ -39,10 +39,11 @@ { ex_t Except; - try { /* Configuration block */ + try { /* Configuration block, config is built here */ configNew(); /* Construct a new config, add default values */ configLoad(argc, (const char **)argv); /* Load cli, env, and conf */ configVerify(); /* Test for usage, help and version options */ + configDefaults(); /* Add default values to empty config members */ } catch(Except) /* Exceptions of the configuration block */ rcError(Except); Index: ossp-pkg/rc/rc.h RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.h,v rcsdiff -q -kk '-r1.35' '-r1.36' -u '/v/ossp/cvs/ossp-pkg/rc/rc.h,v' 2>/dev/null --- rc.h 2002/07/04 16:49:58 1.35 +++ rc.h 2002/07/29 16:34:58 1.36 @@ -73,6 +73,7 @@ rc_return_t configLoad(int, const char **); rc_return_t configInfo(void); rc_return_t configVerify(void); +rc_return_t configDefaults(void); rc_return_t configDelete(void); /* Config accessor prototypes */ Index: ossp-pkg/rc/rc_config.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_config.c,v rcsdiff -q -kk '-r1.22' '-r1.23' -u '/v/ossp/cvs/ossp-pkg/rc/rc_config.c,v' 2>/dev/null --- rc_config.c 2002/07/05 14:10:24 1.22 +++ rc_config.c 2002/07/29 16:34:59 1.23 @@ -252,6 +252,86 @@ return(RC_THROW(RC_OK)); /* No, we should continue processing. */ } +/************************************************ +* configDefaults(void) * +* Write default values to empty config members * +************************************************/ +rc_return_t configDefaults(void) +{ + ex_t Except; + + try { /* Test members for empty attributes */ + if (!configGetval(RC_EVL_VAL) && !configGetval(RC_EXC_VAL) \ + && !configGetval(RC_PRN_VAL)) + clioptSetval(RC_PRN_VAL, "1"); + +/* if (!configGetval(RC_USE_VAL)) + if (!configGetval(RC_HLP_VAL)) + if (!configGetval(RC_INF_VAL)) + if (!configGetval(RC_LBL_VAL)) + if (!configGetval(RC_SIL_VAL)) + if (!configGetval(RC_RAW_VAL)) + if (!configGetval(RC_VRB_VAL))*/ + +/* + if (!configGetval(RC_LOC_VAL)) { + If exists '/etc/rc.d' + clioptSetval(RC_LOC_VAL, "/etc/rc.d/rc."); + FIXME: !This 'rc.' reading logic must still be implemented! + Else + RC_NOP; + } + if (!configGetval(RC_CNF_VAL)) { + If exists '/etc/rcconf' + clioptSetval(RC_CNF_VAL, "/etc/rcconf"); + Else + RC_NOP; + } + if (!configGetval(RC_FNC_VAL)) { + If exists '/etc/rc.func' + clioptSetval(RC_FNC_VAL, "/etc/rc.func"); + Else + RC_NOP; + } +*/ + +/* if (!configGetval(RC_QRY_VAL))*/ + +/* + if (!configGetval(RC_TMP_VAL)) { + If exists '/tmp' + clioptSetval(RC_TMP_VAL, "/tmp"); + Else + RC_NOP; + } +*/ + +/* if (!configGetval(RC_OWN_VAL)) + if (!configGetval(RC_GRP_VAL)) + if (!configGetval(RC_MSK_VAL)) + if (!configGetval(RC_ASS_VAL))*/ + + if (!configGetval(RC_DEF_VAL)) + clioptSetval(RC_DEF_VAL, "^%(\\w+).*?\\n(.*?)^$"); + +/* if (!configGetval(RC_REF_VAL)) + if (!configGetval(RC_PRM_VAL)) + if (!configGetval(RC_TRM_VAL))*/ + + if (!configGetval(RC_NCF_VAL)) + clioptSetval(RC_NCF_VAL, "config"); + +/* if (!configGetval(RC_CMN_VAL)) + if (!configGetval(RC_DFL_VAL)) + if (!configGetval(RC_ERR_VAL))*/ + } + catch(Except) { + rethrow; + } + + return(RC_THROW(RC_OK)); /* Normal response */ +} + /*************************************** * configDelete(void) * * Destruct a configuration *