Blame src/common/xml_iterate.h

Packit Service 569379
/*
Packit Service 569379
 * Copyright 2013 Red Hat Inc., Durham, North Carolina.
Packit Service 569379
 * All Rights Reserved.
Packit Service 569379
 *
Packit Service 569379
 * This library is free software; you can redistribute it and/or
Packit Service 569379
 * modify it under the terms of the GNU Lesser General Public
Packit Service 569379
 * License as published by the Free Software Foundation; either
Packit Service 569379
 * version 2.1 of the License, or (at your option) any later version.
Packit Service 569379
 *
Packit Service 569379
 * This library is distributed in the hope that it will be useful,
Packit Service 569379
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 569379
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 569379
 * Lesser General Public License for more details.
Packit Service 569379
 *
Packit Service 569379
 * You should have received a copy of the GNU Lesser General Public
Packit Service 569379
 * License along with this library; if not, write to the Free Software
Packit Service 569379
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit Service 569379
 *
Packit Service 569379
 * Authors:
Packit Service 569379
 *   Simon Lukasik <slukasik@redhat.com>
Packit Service 569379
 *
Packit Service 569379
 */
Packit Service 569379
Packit Service 569379
#pragma once
Packit Service 569379
#ifndef _OSCAP_XML_ITERATE_H
Packit Service 569379
#define _OSCAP_XML_ITERATE_H
Packit Service 569379
Packit Service 569379
#include "util.h"
Packit Service 569379
#include <libxml/tree.h>
Packit Service 569379
Packit Service 569379
Packit Service 569379
/**
Packit Service 569379
 * A callback function to be called on each xmlNode. Note that the node
Packit Service 569379
 * can be modified or replaced.
Packit Service 569379
 * @param node the current XML node
Packit Service 569379
 * @param user_data
Packit Service 569379
 * @returns the result of operation
Packit Service 569379
 * @retval 0 indicates success of callback call
Packit Service 569379
 * @retval 1 indicates hard failure of callback call and process is immediately terminated
Packit Service 569379
 * @retval else idicates warn and walking through tree continues
Packit Service 569379
 */
Packit Service 569379
typedef int (*xml_iterate_callback) (xmlNode **node, void *user_data);
Packit Service 569379
Packit Service 569379
/**
Packit Service 569379
 * Parse the input_text as XML and iterate through all nodes in minidom
Packit Service 569379
 * using DFS order. Calls user_fn with user_data on each node. The user_fn
Packit Service 569379
 * is allowed to modify the minidom tree.
Packit Service 569379
 * @param input_text the string which shall be parsed
Packit Service 569379
 * @param output_text the output document after tree walking. This attribute
Packit Service 569379
 * might be NULL to skip the export (which might be useful in case when
Packit Service 569379
 * user_fn does not modify the tree). The caller shall dispose *output_text.
Packit Service 569379
 * @param user_fn Function which is called on each node
Packit Service 569379
 * @param user_data Data supplied to the user_fn
Packit Service 569379
 * @returns 0 on success, 1 on failure.
Packit Service 569379
 */
Packit Service 569379
int xml_iterate_dfs(const char *input_text, char **output_text, xml_iterate_callback user_fn, void *user_data);
Packit Service 569379
Packit Service 569379
Packit Service 569379
#endif