Add MXS_MODULE_PARAM_QUOTEDSTRING configuration value type

A quoted string is a string enclosed in '"':s. This makes it clear
where the string begins and ends, avoiding ambiguity with whitespace.
After the config file has been loaded, the '"':s at the beginning
and at the end of the string are erased. Querying the config value
with config_get_string() will return this de-quoted value.

For example, if the config file reads 'my_string="test""', the actual
string will be 'test"'.
This commit is contained in:
Esa Korhonen
2017-05-24 12:52:44 +03:00
parent f66623c382
commit 88bf361e61
2 changed files with 23 additions and 0 deletions

View File

@ -3601,6 +3601,15 @@ void config_fix_param(const MXS_MODULE_PARAM *params, MXS_CONFIG_PARAMETER *p)
fix_serverlist(p->value);
break;
case MXS_MODULE_PARAM_QUOTEDSTRING:
{ // Remove the '"':s from the ends of the string
char* value = p->value;
size_t len = strlen(value);
value[len - 1] = '\0';
memmove(value, value + 1, len - 1);
}
break;
default:
break;
}
@ -3697,6 +3706,17 @@ bool config_param_is_valid(const MXS_MODULE_PARAM *params, const char *key,
}
break;
case MXS_MODULE_PARAM_QUOTEDSTRING:
valid = false;
{
size_t len = strlen(value);
if ((len >= 2) && (value[0] == '"') && (value[len - 1] == '"'))
{
valid = true;
}
}
break;
case MXS_MODULE_PARAM_ENUM:
if (params[i].accepted_values)
{