Commit 9bb78c4c authored by Raphael Defosseux's avatar Raphael Defosseux

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/issue-389-fix-missing-option-value-not-reported' into develop_integration_2019_w03
parents 883d7316 c87f4479
...@@ -75,6 +75,7 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -75,6 +75,7 @@ int processoption(paramdef_t *cfgoptions, char *value) {
if ( value == NULL) { if ( value == NULL) {
if( (cfgoptions->paramflags &PARAMFLAG_BOOL) == 0 ) { /* not a boolean, argument required */ if( (cfgoptions->paramflags &PARAMFLAG_BOOL) == 0 ) { /* not a boolean, argument required */
fprintf(stderr,"[CONFIG] command line, option %s requires an argument\n",cfgoptions->optname); fprintf(stderr,"[CONFIG] command line, option %s requires an argument\n",cfgoptions->optname);
exit_fun("[CONFIG] command line parsing fatal error");
return 0; return 0;
} else { /* boolean value option without argument, set value to true*/ } else { /* boolean value option without argument, set value to true*/
tmpval = defbool; tmpval = defbool;
...@@ -143,7 +144,10 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -143,7 +144,10 @@ int processoption(paramdef_t *cfgoptions, char *value) {
return optisset; return optisset;
} }
int config_check_cmdlineopt(char *prefix) { /*--------------------------------------------------------------------*/
/* check unknown options in the command line
*/
int config_check_unknown_cmdlineopt(char *prefix) {
int unknowndetected=0; int unknowndetected=0;
char testprefix[CONFIG_MAXOPTLENGTH]=""; char testprefix[CONFIG_MAXOPTLENGTH]="";
int finalcheck = 0; int finalcheck = 0;
...@@ -161,6 +165,8 @@ int config_check_cmdlineopt(char *prefix) { ...@@ -161,6 +165,8 @@ int config_check_cmdlineopt(char *prefix) {
if ( !finalcheck && testprefix[0]==0 && index(config_get_if()->argv[i],'.') != NULL) continue; if ( !finalcheck && testprefix[0]==0 && index(config_get_if()->argv[i],'.') != NULL) continue;
if ( !finalcheck && isdigit(config_get_if()->argv[i][0])) continue;
if ( !finalcheck && config_get_if()->argv[i][0] == '-' && isdigit(config_get_if()->argv[i][1])) continue; if ( !finalcheck && config_get_if()->argv[i][0] == '-' && isdigit(config_get_if()->argv[i][1])) continue;
if ( (config_get_if()->argv_info[i] & CONFIG_CMDLINEOPT_PROCESSED) == 0 ) { if ( (config_get_if()->argv_info[i] & CONFIG_CMDLINEOPT_PROCESSED) == 0 ) {
...@@ -173,7 +179,7 @@ int config_check_cmdlineopt(char *prefix) { ...@@ -173,7 +179,7 @@ int config_check_cmdlineopt(char *prefix) {
printf_cmdl("[CONFIG] %i unknown option(s) in command line starting with %s (section %s)\n", printf_cmdl("[CONFIG] %i unknown option(s) in command line starting with %s (section %s)\n",
unknowndetected,testprefix,((prefix==NULL)?"":prefix)); unknowndetected,testprefix,((prefix==NULL)?"":prefix));
return unknowndetected; return unknowndetected;
} /* parse_cmdline*/ } /* config_check_unknown_cmdlineopt */
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) { int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) {
int c = config_get_if()->argc; int c = config_get_if()->argc;
...@@ -269,7 +275,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) ...@@ -269,7 +275,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix)
printf_cmdl("[CONFIG] %s %i options set from command line\n",((prefix == NULL) ? "(root)":prefix),j); printf_cmdl("[CONFIG] %s %i options set from command line\n",((prefix == NULL) ? "(root)":prefix),j);
if ( !(CONFIG_ISFLAGSET( CONFIG_NOCHECKUNKOPT )) ) { if ( !(CONFIG_ISFLAGSET( CONFIG_NOCHECKUNKOPT )) ) {
i=config_check_cmdlineopt(prefix); i=config_check_unknown_cmdlineopt(prefix);
if (i > 0) { if (i > 0) {
fprintf(stderr,"[CONFIG] %i unknown options for section %s detected in command line\n", fprintf(stderr,"[CONFIG] %i unknown options for section %s detected in command line\n",
......
...@@ -370,6 +370,12 @@ int config_checkstr_assign_integer(paramdef_t *param) { ...@@ -370,6 +370,12 @@ int config_checkstr_assign_integer(paramdef_t *param) {
return -1; return -1;
} }
void config_set_checkfunctions(paramdef_t *params, checkedparam_t *checkfunctions, int numparams) {
for (int i=0; i< numparams ; i++ ) {
params[i].chkPptr = &(checkfunctions[i]);
}
}
int config_setdefault_string(paramdef_t *cfgoptions, char *prefix) { int config_setdefault_string(paramdef_t *cfgoptions, char *prefix) {
int status = 0; int status = 0;
......
...@@ -57,10 +57,13 @@ extern int config_assign_ipv4addr(paramdef_t *cfgoptions, char *ipv4addr); ...@@ -57,10 +57,13 @@ extern int config_assign_ipv4addr(paramdef_t *cfgoptions, char *ipv4addr);
/* apis to get/check parameters, to be used by oai modules, at configuration time */ /* apis to get/check parameters, to be used by oai modules, at configuration time */
#define CONFIG_CHECKALLSECTIONS "ALLSECTIONS" #define CONFIG_CHECKALLSECTIONS "ALLSECTIONS"
extern int config_check_cmdlineopt(char *prefix); extern int config_check_unknown_cmdlineopt(char *prefix);
extern int config_get(paramdef_t *params,int numparams, char *prefix); extern int config_get(paramdef_t *params,int numparams, char *prefix);
extern int config_getlist(paramlist_def_t *ParamList, paramdef_t *params, int numparams, char *prefix); extern int config_getlist(paramlist_def_t *ParamList, paramdef_t *params, int numparams, char *prefix);
/* apis to set some of the paramdef_t fields before using the get/getlist api's */
extern void config_set_checkfunctions(paramdef_t *params, checkedparam_t *checkfunctions, int numparams);
/* apis to retrieve parameters info after calling get or getlist functions */ /* apis to retrieve parameters info after calling get or getlist functions */
extern int config_isparamset(paramdef_t *params,int paramidx); extern int config_isparamset(paramdef_t *params,int paramidx);
extern int config_get_processedint(paramdef_t *cfgoption); extern int config_get_processedint(paramdef_t *cfgoption);
......
This diff is collapsed.
...@@ -689,7 +689,7 @@ int main( int argc, char **argv ) { ...@@ -689,7 +689,7 @@ int main( int argc, char **argv ) {
#if T_TRACER #if T_TRACER
T_Config_Init(); T_Config_Init();
#endif #endif
ret=config_check_cmdlineopt(NULL); ret=config_check_unknown_cmdlineopt(NULL);
if (ret != 0) { if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line\n",ret); LOG_E(ENB_APP, "%i unknown options in command line\n",ret);
...@@ -938,7 +938,7 @@ int main( int argc, char **argv ) { ...@@ -938,7 +938,7 @@ int main( int argc, char **argv ) {
sync_var=0; sync_var=0;
pthread_cond_broadcast(&sync_cond); pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex); pthread_mutex_unlock(&sync_mutex);
ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS); ret=config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
if (ret != 0) { if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret); LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret);
......
...@@ -1010,7 +1010,7 @@ int main( int argc, char **argv ) { ...@@ -1010,7 +1010,7 @@ int main( int argc, char **argv ) {
} }
#endif #endif
ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS); ret=config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
if (ret != 0) { if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret); LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment