Beispiel #1
0
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_set_value:
 * @message: Pointer to an #idmef_message_t object.
 * @path: Path to be set within @message.
 * @value: Value to associate @message[@path] with.
 *
 * This function will set the @path member within @message to the
 * provided @value.
 *
 * Returns: 0 on success, or a negative value if an error occured.
 */
int idmef_message_set_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_set(ip, message, value);
        idmef_path_destroy(ip);

        return ret;
}