Added percentage conversion functions to maxconfig.h
This commit is contained in:
@ -2017,6 +2017,25 @@ config_truth_value(char *str)
|
|||||||
return atoi(str);
|
return atoi(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a string into a floating point representation of a percentage value.
|
||||||
|
* For example 75% is converted to 0.75 and -10% is converted to -0.1.
|
||||||
|
* @param str String to convert
|
||||||
|
* @return String converted to a floating point percentage
|
||||||
|
*/
|
||||||
|
double
|
||||||
|
config_percentage_value(char *str)
|
||||||
|
{
|
||||||
|
double value = 0;
|
||||||
|
|
||||||
|
value = strtod(str,NULL);
|
||||||
|
if(value != 0)
|
||||||
|
value /= 100.0;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
static char *InternalRouters[] = {
|
static char *InternalRouters[] = {
|
||||||
"debugcli",
|
"debugcli",
|
||||||
"cli",
|
"cli",
|
||||||
|
|||||||
@ -115,6 +115,7 @@ CONFIG_PARAMETER* config_get_param(CONFIG_PARAMETER* params, const char* name);
|
|||||||
config_param_type_t config_get_paramtype(CONFIG_PARAMETER* param);
|
config_param_type_t config_get_paramtype(CONFIG_PARAMETER* param);
|
||||||
CONFIG_PARAMETER* config_clone_param(CONFIG_PARAMETER* param);
|
CONFIG_PARAMETER* config_clone_param(CONFIG_PARAMETER* param);
|
||||||
extern int config_truth_value(char *);
|
extern int config_truth_value(char *);
|
||||||
|
extern double config_percentage_value(char *str);
|
||||||
bool config_set_qualified_param(
|
bool config_set_qualified_param(
|
||||||
CONFIG_PARAMETER* param,
|
CONFIG_PARAMETER* param,
|
||||||
void* val,
|
void* val,
|
||||||
|
|||||||
Reference in New Issue
Block a user