Project

General

Profile

Bug #288 ยป 0001-Fix-bug-288-accept-true-in-output-configuration.patch

Jason Ish, 05/27/2011 12:06 AM

View differences:

src/conf.c
ConfGetBool(char *name, int *val)
{
char *strval;
char *trues[] = {"1", "yes", "true", "on"};
size_t u;
*val = 0;
if (ConfGet(name, &strval) != 1)
return 0;
*val = ConfValIsTrue(strval);
return 1;
}
/**
* \brief Check if a value is true.
*
* The value of considered true if it is a string with the value of 1,
* yes, true or on. The test is not case sensitive, any other value
* is false.
*
* \param val The string to test for a true value.
*
* \retval 1 If the value is true, 0 if not.
*/
int
ConfValIsTrue(const char *val)
{
char *trues[] = {"1", "yes", "true", "on"};
size_t u;
for (u = 0; u < sizeof(trues) / sizeof(trues[0]); u++) {
if (strcasecmp(strval, trues[u]) == 0) {
*val = 1;
break;
if (strcasecmp(val, trues[u]) == 0) {
return 1;
}
}
return 1;
return 0;
}
/**
......
const char *val;
val = ConfNodeLookupChildValue(node, key);
if (val != NULL) {
if ((strcasecmp(val, "yes") == 0) || (strcasecmp(val, "true") == 0))
return 1;
}
return 0;
return val != NULL ? ConfValIsTrue(val) : 0;
}
#ifdef UNITTESTS
src/conf.h
void ConfNodeRemove(ConfNode *);
void ConfRegisterTests();
int ConfNodeChildValueIsTrue(ConfNode *node, const char *key);
int ConfValIsTrue(const char *val);
#endif /* ! __CONF_H__ */
src/runmodes.c
}
enabled = ConfNodeLookupChildValue(output_config, "enabled");
if (enabled != NULL && strcasecmp(enabled, "yes") == 0) {
if (enabled != NULL && ConfValIsTrue(enabled)) {
OutputCtx *output_ctx = NULL;
if (module->InitFunc != NULL) {
output_ctx = module->InitFunc(output_config);
    (1-1/1)