From: Jason Ish Date: Thu, 17 Nov 2022 05:50:13 +0000 (-0600) Subject: rust/conf: add fn conf_get_node X-Git-Tag: suricata-7.0.0-rc1~310 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=baa7021ee679e27082af614ddc9c72d1837f3f9e;p=thirdparty%2Fsuricata.git rust/conf: add fn conf_get_node A wrapper around ConfGetNode to get a configuration node by name. --- diff --git a/rust/src/conf.rs b/rust/src/conf.rs index 0dae7a013a..6980cd0f29 100644 --- a/rust/src/conf.rs +++ b/rust/src/conf.rs @@ -35,6 +35,22 @@ extern { vptr: *mut *const c_char) -> i8; fn ConfGetChildValueBool(conf: *const c_void, key: *const c_char, vptr: *mut c_int) -> i8; + fn ConfGetNode(key: *const c_char) -> *const c_void; +} + +pub fn conf_get_node(key: &str) -> Option { + let key = if let Ok(key) = CString::new(key) { + key + } else { + return None; + }; + + let node = unsafe { ConfGetNode(key.as_ptr()) }; + if node.is_null() { + None + } else { + Some(ConfNode::wrap(node)) + } } // Return the string value of a configuration value.