Commit 788cc5f7 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/gpd' into integration_2026_w03 (!3849)

Make gpd config utility global

Make gpd a global utility macro for reading config/command line
parameters. Add a corresponding function with full name for clarity,
keep the short name for the macro for backward compatibility and ease of
use.

The main benefit of gpd/config_get_paramdef_from_name macro/function is
that it does not require maintaining a separate parameter index list.
parents 6eeb8d3d 11ae7e79
......@@ -105,13 +105,14 @@ int config_execcheck(configmodule_interface_t *cfg, paramdef_t *params, int nump
return st;
}
int config_paramidx_fromname(paramdef_t *params, int numparams, const char *name) {
for (int i=0; i<numparams ; i++) {
if (strcmp(name,params[i].optname) == 0)
int config_paramidx_fromname(const paramdef_t *params, int numparams, const char *name)
{
for (int i = 0; i < numparams; i++) {
if (strcmp(name, params[i].optname) == 0)
return i;
}
fprintf(stderr,"[CONFIG]config_paramidx_fromname , %s is not a valid parameter name\n",name);
fprintf(stderr, "[CONFIG]config_paramidx_fromname , %s is not a valid parameter name\n", name);
return -1;
}
......@@ -290,3 +291,10 @@ void config_set_checkfunctions(paramdef_t *params, checkedparam_t *checkfunction
params[i].chkPptr = &(checkfunctions[i]);
}
}
const paramdef_t *config_get_paramdef_from_name(const paramdef_t *pd, int num, const char *name)
{
int idx = config_paramidx_fromname(pd, num, (char *)name);
AssertFatal(idx >= 0 && idx < num, "Invalid parameter name %s\n", name);
return &pd[idx];
}
......@@ -49,7 +49,9 @@ extern configmodule_interface_t *uniqCfg;
#define CONFIG_SETRTFLAG(P) if (config_get_if()) { config_get_if()->rtflags |= P; }
#define CONFIG_CLEARRTFLAG(P) if (config_get_if()) { config_get_if()->rtflags &= (~P); }
#define CONFIG_ISPARAMFLAGSET(P,F) ( !!(P.paramflags & F))
int config_paramidx_fromname(paramdef_t *params, int numparams, const char *name);
#define gpd(pd_array, nump, name) config_get_paramdef_from_name(pd_array, nump, name)
int config_paramidx_fromname(const paramdef_t *params, int numparams, const char *name);
/* utility functions, to be used by configuration module and/or configuration libraries */
void config_printhelp(paramdef_t *, int numparams, const char *prefix);
......@@ -75,6 +77,7 @@ int config_check_modify_integer(configmodule_interface_t *cfg, paramdef_t *param
int config_check_intrange(configmodule_interface_t *cfg, paramdef_t *param);
int config_check_strval(configmodule_interface_t *cfg, paramdef_t *param);
int config_checkstr_assign_integer(configmodule_interface_t *cfg, paramdef_t *param);
const paramdef_t *config_get_paramdef_from_name(const paramdef_t *pd, int num, const char *name);
#define CONFIG_GETCONFFILE (config_get_if()->cfgP[0])
......
......@@ -72,14 +72,6 @@ static void ly_print_clb(LY_LOG_LEVEL level, const char *msg, const char *path)
}
}
static const paramdef_t *gpd(const paramdef_t *pd, int num, const char *name)
{
/* the config module does not know const-correctness... */
int idx = config_paramidx_fromname((paramdef_t *)pd, num, (char *)name);
DevAssert(idx >= 0);
return &pd[idx];
}
bool init_mplane(ru_session_list_t *ru_session_list)
{
paramdef_t fhip[] = ORAN_GLOBALPARAMS_DESC;
......
......@@ -440,14 +440,6 @@ void print_fh_config(const struct xran_fh_config *fh_config)
#endif
}
static const paramdef_t *gpd(const paramdef_t *pd, int num, const char *name)
{
/* the config module does not know const-correctness... */
int idx = config_paramidx_fromname((paramdef_t *)pd, num, (char *)name);
DevAssert(idx >= 0);
return &pd[idx];
}
static uint64_t get_u64_mask(const paramdef_t *pd)
{
DevAssert(pd != NULL);
......
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