static int add_idmef_object(idmef_message_t *msg, const char *object, const char *value) { int ret = 0; idmef_value_t *val; idmef_path_t *path; if (value == NULL) { return (0); } ret = idmef_path_new_fast(&path, object); if (ret < 0) { return (-1); } ret = idmef_value_new_from_path(&val, path, value); if (ret < 0) { idmef_path_destroy(path); return (-1); } ret = idmef_path_set(path, msg, val); if (ret < 0) { merror("%s: OSSEC2Prelude: IDMEF: Cannot add object '%s': %s.", ARGV0, object, prelude_strerror(ret)); } idmef_value_destroy(val); idmef_path_destroy(path); return (ret); }
/** * idmef_message_get_value: * @message: Pointer to an #idmef_message_t object. * @path: Path to retrieve the value from within @message. * @value: Pointer where the result should be stored. * * Retrieve the value stored within @path of @message and store it * in the user provided @value. * * Returns: A positive value in case @path was successfully retrieved * 0 if the path is empty, or a negative value if an error occured. */ int idmef_message_get_value(idmef_message_t *message, const char *path, idmef_value_t **value) { int ret; idmef_path_t *ip; ret = idmef_path_new_fast(&ip, path); if ( ret < 0 ) return ret; ret = idmef_path_get(ip, message, value); idmef_path_destroy(ip); return ret; }