conf: add SCConfNodeChildValueIsFalse to check for false value

New function to check is a value is actually set to a false value.
pull/14505/head
Jason Ish 8 months ago
parent 6eda4b9f59
commit d89b35db56

@ -758,6 +758,11 @@ extern "C" {
node: *const SCConfNode, key: *const ::std::os::raw::c_char,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn SCConfNodeChildValueIsFalse(
node: *const SCConfNode, key: *const ::std::os::raw::c_char,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn SCConfValIsTrue(val: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}

@ -874,6 +874,26 @@ int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key)
return val != NULL ? SCConfValIsTrue(val) : 0;
}
/**
* \brief Test if a configuration node has a false value.
*
* If the field does not exist, or has anything other than a false
* value, this function will return 0.
*
* \param node The parent configuration node.
* \param name The name of the child node to test.
*
* \retval 1 if the child node has a false value, otherwise 0.
*/
int SCConfNodeChildValueIsFalse(const SCConfNode *node, const char *key)
{
const char *val;
val = SCConfNodeLookupChildValue(node, key);
return val != NULL ? SCConfValIsFalse(val) : 0;
}
/**
* \brief Create the path for an include entry
* \param file The name of the file

@ -82,6 +82,7 @@ const char *SCConfNodeLookupChildValue(const SCConfNode *node, const char *key);
void SCConfNodeRemove(SCConfNode *);
void SCConfRegisterTests(void);
int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key);
int SCConfNodeChildValueIsFalse(const SCConfNode *node, const char *key);
int SCConfValIsTrue(const char *val);
int SCConfValIsFalse(const char *val);
void SCConfNodePrune(SCConfNode *node);

Loading…
Cancel
Save