2006-02-16 22:50:52 +00:00
|
|
|
/*
|
2007-04-06 12:28:24 +00:00
|
|
|
* xml.h: internal definitions used for XML parsing routines.
|
2006-02-16 22:50:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_XML_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_XML_H__
|
2006-02-16 22:50:52 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
2006-02-16 22:50:52 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/tree.h>
|
|
|
|
# include <libxml/xpath.h>
|
2006-02-16 22:50:52 +00:00
|
|
|
|
2010-02-04 21:52:34 +00:00
|
|
|
int virXPathBoolean(const char *xpath,
|
2008-04-10 16:54:54 +00:00
|
|
|
xmlXPathContextPtr ctxt);
|
2010-02-04 21:52:34 +00:00
|
|
|
char * virXPathString(const char *xpath,
|
2008-04-10 16:54:54 +00:00
|
|
|
xmlXPathContextPtr ctxt);
|
2010-02-04 21:52:34 +00:00
|
|
|
char * virXPathStringLimit(const char *xpath,
|
|
|
|
size_t maxlen,
|
|
|
|
xmlXPathContextPtr ctxt);
|
|
|
|
int virXPathNumber(const char *xpath,
|
2008-04-10 16:54:54 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
double *value);
|
2011-01-13 22:09:18 +00:00
|
|
|
int virXPathInt(const char *xpath,
|
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
int *value);
|
|
|
|
int virXPathUInt(const char *xpath,
|
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
unsigned int *value);
|
2010-02-04 21:52:34 +00:00
|
|
|
int virXPathLong(const char *xpath,
|
2008-04-10 16:54:54 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
long *value);
|
2011-01-13 22:09:18 +00:00
|
|
|
int virXPathULong(const char *xpath,
|
2008-07-11 10:48:34 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
unsigned long *value);
|
2010-02-04 21:52:34 +00:00
|
|
|
int virXPathULongLong(const char *xpath,
|
2009-02-24 14:54:30 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
unsigned long long *value);
|
2011-01-13 22:09:18 +00:00
|
|
|
int virXPathLongLong(const char *xpath,
|
2010-02-02 17:49:09 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
long long *value);
|
2011-01-13 22:09:18 +00:00
|
|
|
int virXPathLongHex(const char *xpath,
|
2009-02-24 14:53:30 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
long *value);
|
2010-02-04 21:52:34 +00:00
|
|
|
int virXPathULongHex(const char *xpath,
|
2009-02-24 14:53:30 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
unsigned long *value);
|
2010-02-04 21:52:34 +00:00
|
|
|
xmlNodePtr virXPathNode(const char *xpath,
|
2008-04-10 16:54:54 +00:00
|
|
|
xmlXPathContextPtr ctxt);
|
2010-02-04 21:52:34 +00:00
|
|
|
int virXPathNodeSet(const char *xpath,
|
2008-04-10 16:54:54 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
xmlNodePtr **list);
|
2008-07-11 16:23:36 +00:00
|
|
|
char * virXMLPropString(xmlNodePtr node,
|
|
|
|
const char *name);
|
|
|
|
|
2011-08-18 21:01:36 +00:00
|
|
|
/* Internal function; prefer the macros below. */
|
2010-02-24 20:44:47 +00:00
|
|
|
xmlDocPtr virXMLParseHelper(int domcode,
|
|
|
|
const char *filename,
|
|
|
|
const char *xmlStr,
|
2011-08-18 21:01:36 +00:00
|
|
|
const char *url,
|
|
|
|
xmlXPathContextPtr *pctxt);
|
2010-02-24 20:44:47 +00:00
|
|
|
|
2011-08-18 21:01:36 +00:00
|
|
|
/**
|
|
|
|
* virXMLParse:
|
|
|
|
* @filename: file to parse, or NULL for string parsing
|
|
|
|
* @xmlStr: if @filename is NULL, a string to parse
|
|
|
|
* @url: if @filename is NULL, an optional filename to attribute the parse to
|
|
|
|
*
|
|
|
|
* Parse xml from either a file or a string.
|
|
|
|
*
|
|
|
|
* Return the parsed document object, or NULL on failure.
|
|
|
|
*/
|
2010-02-24 20:44:47 +00:00
|
|
|
# define virXMLParse(filename, xmlStr, url) \
|
2011-08-18 21:01:36 +00:00
|
|
|
virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, NULL)
|
2010-02-24 20:44:47 +00:00
|
|
|
|
2011-08-18 21:01:36 +00:00
|
|
|
/**
|
|
|
|
* virXMLParseString:
|
|
|
|
* @xmlStr: a string to parse
|
|
|
|
* @url: an optional filename to attribute the parse to
|
|
|
|
*
|
|
|
|
* Parse xml from a string.
|
|
|
|
*
|
|
|
|
* Return the parsed document object, or NULL on failure.
|
|
|
|
*/
|
2010-02-24 20:44:47 +00:00
|
|
|
# define virXMLParseString(xmlStr, url) \
|
2011-08-18 21:01:36 +00:00
|
|
|
virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL)
|
2010-02-24 20:44:47 +00:00
|
|
|
|
2011-08-18 21:01:36 +00:00
|
|
|
/**
|
|
|
|
* virXMLParseFile:
|
|
|
|
* @filename: file to parse
|
|
|
|
*
|
|
|
|
* Parse xml from a file.
|
|
|
|
*
|
|
|
|
* Return the parsed document object, or NULL on failure.
|
|
|
|
*/
|
2010-02-24 20:44:47 +00:00
|
|
|
# define virXMLParseFile(filename) \
|
2011-08-18 21:01:36 +00:00
|
|
|
virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virXMLParseCtxt:
|
|
|
|
* @filename: file to parse, or NULL for string parsing
|
|
|
|
* @xmlStr: if @filename is NULL, a string to parse
|
|
|
|
* @url: if @filename is NULL, an optional filename to attribute the parse to
|
|
|
|
* @pctxt: if non-NULL, populate with a new context object on success,
|
|
|
|
* with (*pctxt)->node pre-set to the root node
|
|
|
|
*
|
|
|
|
* Parse xml from either a file or a string.
|
|
|
|
*
|
|
|
|
* Return the parsed document object, or NULL on failure.
|
|
|
|
*/
|
|
|
|
# define virXMLParseCtxt(filename, xmlStr, url, pctxt) \
|
|
|
|
virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, pctxt)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virXMLParseStringCtxt:
|
|
|
|
* @xmlStr: a string to parse
|
|
|
|
* @url: an optional filename to attribute the parse to
|
|
|
|
* @pctxt: if non-NULL, populate with a new context object on success,
|
|
|
|
* with (*pctxt)->node pre-set to the root node
|
|
|
|
*
|
|
|
|
* Parse xml from a string.
|
|
|
|
*
|
|
|
|
* Return the parsed document object, or NULL on failure.
|
|
|
|
*/
|
|
|
|
# define virXMLParseStringCtxt(xmlStr, url, pctxt) \
|
|
|
|
virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, pctxt)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virXMLParseFileCtxt:
|
|
|
|
* @filename: file to parse
|
|
|
|
* @pctxt: if non-NULL, populate with a new context object on success,
|
|
|
|
* with (*pctxt)->node pre-set to the root node
|
|
|
|
*
|
|
|
|
* Parse xml from a file.
|
|
|
|
*
|
|
|
|
* Return the parsed document object, or NULL on failure.
|
|
|
|
*/
|
|
|
|
# define virXMLParseFileCtxt(filename, pctxt) \
|
|
|
|
virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, pctxt)
|
2010-02-24 20:44:47 +00:00
|
|
|
|
2011-10-06 09:57:06 +00:00
|
|
|
int virXMLSaveFile(const char *path,
|
|
|
|
const char *warnName,
|
|
|
|
const char *warnCommand,
|
|
|
|
const char *xml);
|
|
|
|
|
2006-03-15 12:13:25 +00:00
|
|
|
#endif /* __VIR_XML_H__ */
|