rust/json: expose json_boolean

pull/2746/head
Victor Julien 8 years ago committed by Jason Ish
parent ba1a67e2cb
commit f47fd2c243

@ -35,6 +35,7 @@ extern {
fn json_string(value: *const c_char) -> *mut JsonT;
fn json_integer(val: u64) -> *mut JsonT;
fn SCJsonBool(val: bool) -> *mut JsonT;
}
pub struct Json {
@ -83,6 +84,14 @@ impl Json {
}
}
pub fn set_boolean(&self, key: &str, val: bool) {
unsafe {
json_object_set_new(self.js,
CString::new(key).unwrap().as_ptr(),
SCJsonBool(val));
}
}
pub fn array_append(&self, val: Json) {
unsafe {
json_array_append_new(self.js, val.js);

@ -92,6 +92,11 @@ void OutputJsonRegister (void)
OutputRegisterModule(MODULE_NAME, "eve-log", OutputJsonInitCtx);
}
json_t *SCJsonBool(int val)
{
return (val ? json_true() : json_false());
}
/* Default Sensor ID value */
static int64_t sensor_id = -1; /* -1 = not defined */

@ -64,6 +64,8 @@ typedef struct AlertJsonThread_ {
LogFileCtx *file_ctx;
} AlertJsonThread;
json_t *SCJsonBool(int val);
#endif /* HAVE_LIBJANSSON */
#endif /* __OUTPUT_JSON_H__ */

@ -229,7 +229,8 @@
#endif
/* Appears not all current distros have jansson that defines this. */
#ifndef json_boolean
#define json_boolean(val) ((val) ? json_true() : json_false())
#define json_boolean(val) SCJsonBool((val))
//#define json_boolean(val) ((val) ? json_true() : json_false())
#endif
#endif

Loading…
Cancel
Save