Set path for libconfig include directive, so that all config files could be located in the same directory. minor fixes in softmodem-common

This commit is contained in:
frtabu
2021-03-15 23:26:09 +01:00
parent d118e7e60b
commit 98c354fedd
5 changed files with 35 additions and 13 deletions
@@ -260,7 +260,6 @@ NETWORK_CONTROLLER :
FLEXRAN_CACHE = "/mnt/oai_agent_cache";
FLEXRAN_AWAIT_RECONF = "no";
};
log_config :
{
global_log_level ="info";
@@ -279,3 +278,4 @@ NETWORK_CONTROLLER :
rrc_log_verbosity ="medium";
};
@include "channelmod_rfsimu.conf"
+5 -3
View File
@@ -82,10 +82,12 @@ typedef struct configmodule_interface {
#ifdef CONFIG_LOADCONFIG_MAIN
configmodule_interface_t *cfgptr=NULL;
static char config_helpstr [] = "\n lte-softmodem -O [config mode]<:dbgl[debugflags]> \n \
debugflags can also be defined in the config_libconfig section of the config file\n \
static char config_helpstr [] = "\n lte-softmodem -O [config mode]<:dbgl[debugflags]><:incp[path]>\n \
debugflags can also be defined in the config section of the config file\n \
debugflags: mask, 1->print parameters, 2->print memory allocations debug messages\n \
4->print command line processing debug messages\n ";
4->print command line processing debug messages\n \
incp parameter can be used to define the include path used for config files (@include directive)\n \
defaults is set to the path of the main config file.\n";
#define CONFIG_SECTIONNAME "config"
#define CONFIGPARAM_DEBUGFLAGS_IDX 0
+23 -5
View File
@@ -33,8 +33,9 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <libgen.h>
#include <arpa/inet.h>
#include "config_libconfig.h"
#include "config_libconfig_private.h"
@@ -347,17 +348,34 @@ int config_libconfig_init(char *cfgP[], int numP) {
config_get_if()->numptrs=0;
memset(config_get_if()->ptrs,0,sizeof(void *) * CONFIG_MAX_ALLOCATEDPTRS);
memset(config_get_if()->ptrsAllocated, 0, sizeof(config_get_if()->ptrsAllocated));
/* search for include path parameter and set config file include path accordingly */
for (int i=0; i<numP; i++) {
if (strncmp(cfgP[i],"incp",4) == 0) {
config_set_include_dir (&(libconfig_privdata.cfg),cfgP[i]+4);
break;
}
}
/* dirname may modify the input path and returned ptr may points to part of input path */
char *tmppath = strdup(libconfig_privdata.configfile);
if ( config_get_include_dir (&(libconfig_privdata.cfg)) == NULL) {
config_set_include_dir (&(libconfig_privdata.cfg),dirname( tmppath ));
}
const char *incp = config_get_include_dir (&(libconfig_privdata.cfg)) ;
printf("[LIBCONFIG] Path for include directive set to: %s\n", (incp!=NULL)?incp:"libconfig defaults");
/* Read the file. If there is an error, report it and exit. */
if(! config_read_file(&(libconfig_privdata.cfg), libconfig_privdata.configfile)) {
fprintf(stderr,"[LIBCONFIG] %s %d file %s - %d - %s\n",__FILE__, __LINE__,
if( config_read_file(&(libconfig_privdata.cfg), libconfig_privdata.configfile) == CONFIG_FALSE) {
fprintf(stderr,"[LIBCONFIG] %s %d file %s - line %d: %s\n",__FILE__, __LINE__,
libconfig_privdata.configfile, config_error_line(&(libconfig_privdata.cfg)),
config_error_text(&(libconfig_privdata.cfg)));
config_destroy(&(libconfig_privdata.cfg));
printf( "\n");
free(tmppath);
return -1;
}
free(tmppath);
return 0;
}
+5 -4
View File
@@ -95,10 +95,11 @@ void get_common_options(uint32_t execmask) {
checkedparam_t cmdline_log_CheckParams[] = CMDLINE_LOGPARAMS_CHECK_DESC;
check_execmask(execmask);
config_get( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
config_set_checkfunctions(cmdline_logparams, cmdline_log_CheckParams,
sizeof(cmdline_logparams)/sizeof(paramdef_t));
config_get( cmdline_logparams,sizeof(cmdline_logparams)/sizeof(paramdef_t),NULL);
int numparams=sizeof(cmdline_logparams)/sizeof(paramdef_t);
config_set_checkfunctions(cmdline_logparams, cmdline_log_CheckParams,numparams);
config_get( cmdline_logparams,numparams,NULL);
if(config_isparamset(cmdline_logparams,config_paramidx_fromname(cmdline_logparams,numparams, CONFIG_FLOG_OPT))) {
set_glog_onlinelog(online_log_messages);
}
+1
View File
@@ -177,6 +177,7 @@ extern "C"
{ .s5= {NULL} } , \
{ .s5= {NULL} } , \
{ .s5= {NULL} } , \
{ .s5= {NULL} } , \
}
/***************************************************************************************************************************************/