use suricata_sys::sys::SCConfGetChildValueBool;
use suricata_sys::sys::SCConfGetNode;
use suricata_sys::sys::SCConfNode;
+use suricata_sys::sys::SCConfNodeLookupChild;
+use suricata_sys::sys::SCConfGetFirstNode;
+use suricata_sys::sys::SCConfGetNextNode;
+use suricata_sys::sys::SCConfGetValueNode;
pub fn conf_get_node(key: &str) -> Option<ConfNode> {
let key = if let Ok(key) = CString::new(key) {
return Self { conf };
}
+ pub fn get_child_node(&self, key: &str) -> Option<ConfNode> {
+ let node = unsafe {
+ let s = CString::new(key).unwrap();
+ SCConfNodeLookupChild(self.conf, s.as_ptr())
+ };
+ if node.is_null() {
+ None
+ } else {
+ Some(ConfNode::wrap(node))
+ }
+ }
+
+ pub fn first(&self) -> Option<ConfNode> {
+ let node = unsafe { SCConfGetFirstNode(self.conf) };
+ if node.is_null() {
+ None
+ } else {
+ Some(ConfNode::wrap(node))
+ }
+ }
+
+ pub fn next(&self) -> Option<ConfNode> {
+ let node = unsafe { SCConfGetNextNode(self.conf) };
+ if node.is_null() {
+ None
+ } else {
+ Some(ConfNode::wrap(node))
+ }
+ }
+
+ pub fn value(&self) -> &str {
+ let vptr = unsafe { SCConfGetValueNode(self.conf) };
+ let value = std::str::from_utf8(unsafe { CStr::from_ptr(vptr).to_bytes() }).unwrap();
+ return value;
+ }
+
pub fn get_child_value(&self, key: &str) -> Option<&str> {
let mut vptr: *const c_char = ptr::null_mut();
parent: *mut SCConfNode, name: *const ::std::os::raw::c_char, final_: ::std::os::raw::c_int,
) -> *mut SCConfNode;
}
+extern "C" {
+ pub fn SCConfGetFirstNode(parent: *const SCConfNode) -> *mut SCConfNode;
+}
+extern "C" {
+ pub fn SCConfGetNextNode(node: *const SCConfNode) -> *mut SCConfNode;
+}
+extern "C" {
+ pub fn SCConfGetValueNode(node: *const SCConfNode) -> *const ::std::os::raw::c_char;
+}
return node;
}
+SCConfNode *SCConfGetFirstNode(const SCConfNode *parent)
+{
+ return TAILQ_FIRST(&parent->head);
+}
+
+SCConfNode *SCConfGetNextNode(const SCConfNode *node)
+{
+ return TAILQ_NEXT(node, next);
+}
+
+const char *SCConfGetValueNode(const SCConfNode *node)
+{
+ return node->val;
+}
+
/**
* \brief Get the root configuration node.
*/
int SCConfSetRootAndDefaultNodes(const char *ifaces_node_name, const char *iface,
SCConfNode **if_root, SCConfNode **if_default);
SCConfNode *SCConfNodeGetNodeOrCreate(SCConfNode *parent, const char *name, int final);
+
+SCConfNode *SCConfGetFirstNode(const SCConfNode *parent);
+SCConfNode *SCConfGetNextNode(const SCConfNode *node);
+const char *SCConfGetValueNode(const SCConfNode *node);
+
#endif /* ! SURICATA_CONF_H */