Пример #1
0
/**
 * idmef_message_set_data:
 * @message: Pointer to an #idmef_message_t object.
 * @path: Path to be set within @message.
 * @data: Pointer to data to associate @message[@path] with.
 * @size: Size of the data pointed to by @data.
 *
 * This function will set the @path member within @message to the
 * provided @data of size @size.
 *
 * Returns: 0 on success, or a negative value if an error occured.
 */
int idmef_message_set_data(idmef_message_t *message, const char *path, const unsigned char *data, size_t size)
{
        int ret;
        idmef_data_t *id;
        idmef_value_t *iv;

        ret = idmef_data_new_byte_string_dup(&id, data, size);
        if ( ret < 0 )
                return ret;

        ret = idmef_value_new_data(&iv, id);
        if ( ret < 0 ) {
                idmef_data_destroy(id);
                return ret;
        }

        ret = idmef_message_set_value(message, path, iv);
        idmef_value_destroy(iv);

        return ret;
}
static void data_destroy(idmef_value_type_t *type)
{
        idmef_data_destroy(type->data.data_val);
}