mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-25 10:50:08 +03:00
Revert directory structure changes
This commit is contained in:
parent
64636e7f6e
commit
3473f88a7a
25
ChangeLog
25
ChangeLog
@ -1,28 +1,3 @@
|
||||
Thu Feb 23 02:03:56 CET 2001 Tomasz K³oczko <kloczek@pld.org.pl>
|
||||
|
||||
* *.c *.h libxml files: moved to libxml directory - this allow
|
||||
simplify automake/autoconf. Now isn't neccessary hack on
|
||||
am/ac level for make and remove libxml symlink (modified for this
|
||||
also configure.in and main Makefile.am). Now automake abilities
|
||||
are used in best way (like in many other projects with libraries).
|
||||
* include/win32config.h: moved to libxml directory (now include
|
||||
directory isn't neccessary).
|
||||
* Makefile.am, examples/Makefile.am, libxml/Makefile.am:
|
||||
added empty DEFS and in INCLUDES rest only -I$(top_builddir) -
|
||||
this allow minimize parameters count passed to libtool script
|
||||
(now compilation is also slyghtly more quiet).
|
||||
* configure.in: simplifies libzdetestion - prepare separated
|
||||
variables for keep libz name and path to libz header files isn't
|
||||
realy neccessary (if someone have libz installed in non standard
|
||||
prefix path to header files ald library can be passed as:
|
||||
$ CFALGS="-I</libz.h/path>" LDFLAGS="-L</libz/path>" ./configure
|
||||
* autogen.sh: check now for libxml/entities.h.
|
||||
|
||||
After above building libxml pass correctly and also pass
|
||||
"make install DESTDIR=</install/prefix>" from tar ball generated by
|
||||
"make dist". Seems ac/am reorganization is finished. This changes
|
||||
not touches any other things on *.{c,h} files level.
|
||||
|
||||
Thu Feb 22 07:52:27 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||
|
||||
* xpath.c: finally implemented xmlXPathCompareNodeSets
|
||||
|
4966
HTMLparser.c
Normal file
4966
HTMLparser.c
Normal file
File diff suppressed because it is too large
Load Diff
115
HTMLparser.h
Normal file
115
HTMLparser.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* HTMLparser.h : inf=terface for an HTML 4.0 non-verifying parser
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __HTML_PARSER_H__
|
||||
#define __HTML_PARSER_H__
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Most of the back-end structures from XML and HTML are shared
|
||||
*/
|
||||
typedef xmlParserCtxt htmlParserCtxt;
|
||||
typedef xmlParserCtxtPtr htmlParserCtxtPtr;
|
||||
typedef xmlParserNodeInfo htmlParserNodeInfo;
|
||||
typedef xmlSAXHandler htmlSAXHandler;
|
||||
typedef xmlSAXHandlerPtr htmlSAXHandlerPtr;
|
||||
typedef xmlParserInput htmlParserInput;
|
||||
typedef xmlParserInputPtr htmlParserInputPtr;
|
||||
typedef xmlDocPtr htmlDocPtr;
|
||||
typedef xmlNodePtr htmlNodePtr;
|
||||
|
||||
/*
|
||||
* Internal description of an HTML element
|
||||
*/
|
||||
typedef struct _htmlElemDesc htmlElemDesc;
|
||||
typedef htmlElemDesc *htmlElemDescPtr;
|
||||
struct _htmlElemDesc {
|
||||
const char *name; /* The tag name */
|
||||
char startTag; /* Whether the start tag can be implied */
|
||||
char endTag; /* Whether the end tag can be implied */
|
||||
char saveEndTag; /* Whether the end tag should be saved */
|
||||
char empty; /* Is this an empty element ? */
|
||||
char depr; /* Is this a deprecated element ? */
|
||||
char dtd; /* 1: only in Loose DTD, 2: only Frameset one */
|
||||
const char *desc; /* the description */
|
||||
};
|
||||
|
||||
/*
|
||||
* Internal description of an HTML entity
|
||||
*/
|
||||
typedef struct _htmlEntityDesc htmlEntityDesc;
|
||||
typedef htmlEntityDesc *htmlEntityDescPtr;
|
||||
struct _htmlEntityDesc {
|
||||
int value; /* the UNICODE value for the character */
|
||||
const char *name; /* The entity name */
|
||||
const char *desc; /* the description */
|
||||
};
|
||||
|
||||
/*
|
||||
* There is only few public functions.
|
||||
*/
|
||||
htmlElemDescPtr htmlTagLookup (const xmlChar *tag);
|
||||
htmlEntityDescPtr htmlEntityLookup(const xmlChar *name);
|
||||
htmlEntityDescPtr htmlEntityValueLookup(int value);
|
||||
|
||||
int htmlIsAutoClosed(htmlDocPtr doc,
|
||||
htmlNodePtr elem);
|
||||
int htmlAutoCloseTag(htmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
htmlNodePtr elem);
|
||||
htmlEntityDescPtr htmlParseEntityRef(htmlParserCtxtPtr ctxt,
|
||||
xmlChar **str);
|
||||
int htmlParseCharRef(htmlParserCtxtPtr ctxt);
|
||||
void htmlParseElement(htmlParserCtxtPtr ctxt);
|
||||
|
||||
htmlDocPtr htmlSAXParseDoc (xmlChar *cur,
|
||||
const char *encoding,
|
||||
htmlSAXHandlerPtr sax,
|
||||
void *userData);
|
||||
htmlDocPtr htmlParseDoc (xmlChar *cur,
|
||||
const char *encoding);
|
||||
htmlDocPtr htmlSAXParseFile(const char *filename,
|
||||
const char *encoding,
|
||||
htmlSAXHandlerPtr sax,
|
||||
void *userData);
|
||||
htmlDocPtr htmlParseFile (const char *filename,
|
||||
const char *encoding);
|
||||
int UTF8ToHtml (unsigned char* out,
|
||||
int *outlen,
|
||||
const unsigned char* in,
|
||||
int *inlen);
|
||||
int htmlEncodeEntities(unsigned char* out,
|
||||
int *outlen,
|
||||
const unsigned char* in,
|
||||
int *inlen, int quoteChar);
|
||||
int htmlIsScriptAttribute(const xmlChar *name);
|
||||
int htmlHandleOmittedElem(int val);
|
||||
|
||||
/**
|
||||
* Interfaces for the Push mode
|
||||
*/
|
||||
void htmlFreeParserCtxt (htmlParserCtxtPtr ctxt);
|
||||
htmlParserCtxtPtr htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
const char *chunk,
|
||||
int size,
|
||||
const char *filename,
|
||||
xmlCharEncoding enc);
|
||||
int htmlParseChunk (htmlParserCtxtPtr ctxt,
|
||||
const char *chunk,
|
||||
int size,
|
||||
int terminate);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __HTML_PARSER_H__ */
|
1155
HTMLtree.c
Normal file
1155
HTMLtree.c
Normal file
File diff suppressed because it is too large
Load Diff
61
HTMLtree.h
Normal file
61
HTMLtree.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* tree.h : describes the structures found in an tree resulting
|
||||
* from an XML parsing.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __HTML_TREE_H__
|
||||
#define __HTML_TREE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/HTMLparser.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HTML_TEXT_NODE XML_TEXT_NODE
|
||||
#define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE
|
||||
#define HTML_COMMENT_NODE XML_COMMENT_NODE
|
||||
#define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE
|
||||
|
||||
htmlDocPtr htmlNewDoc (const xmlChar *URI,
|
||||
const xmlChar *ExternalID);
|
||||
htmlDocPtr htmlNewDocNoDtD (const xmlChar *URI,
|
||||
const xmlChar *ExternalID);
|
||||
const xmlChar * htmlGetMetaEncoding (htmlDocPtr doc);
|
||||
int htmlSetMetaEncoding (htmlDocPtr doc,
|
||||
const xmlChar *encoding);
|
||||
void htmlDocDumpMemory (xmlDocPtr cur,
|
||||
xmlChar**mem,
|
||||
int *size);
|
||||
int htmlDocDump (FILE *f,
|
||||
xmlDocPtr cur);
|
||||
int htmlSaveFile (const char *filename,
|
||||
xmlDocPtr cur);
|
||||
void htmlNodeDump (xmlBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
void htmlNodeDumpFile (FILE *out,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
int htmlSaveFileEnc (const char *filename,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
|
||||
/* This one is imported from xmlIO.h
|
||||
void htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __HTML_TREE_H__ */
|
||||
|
103
Makefile.am
103
Makefile.am
@ -1,45 +1,87 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = libxml doc example
|
||||
SUBDIRS = . include doc example
|
||||
|
||||
INCLUDES = $(CORBA_CFLAGS)
|
||||
INCLUDES = -I@srcdir@/include -I./include @Z_CFLAGS@ @CORBA_CFLAGS@
|
||||
|
||||
noinst_PROGRAMS=testSAX testHTML testXPath testURI
|
||||
|
||||
DEPS = $(top_builddir)/libxml/libxml2.la
|
||||
LDADDS = $(top_builddir)/libxml/libxml2.la
|
||||
|
||||
bin_PROGRAMS = xmllint
|
||||
|
||||
xmllint_SOURCES = xmllint.c
|
||||
bin_SCRIPTS=xml2-config
|
||||
|
||||
lib_LTLIBRARIES = libxml2.la
|
||||
libxml2_la_LIBADD = @Z_LIBS@
|
||||
|
||||
libxml2_la_LDFLAGS = -version-info @LIBXML_VERSION_INFO@
|
||||
|
||||
libxml2_la_SOURCES = \
|
||||
SAX.c \
|
||||
entities.c \
|
||||
encoding.c \
|
||||
error.c \
|
||||
parserInternals.c \
|
||||
parser.c \
|
||||
tree.c \
|
||||
hash.c \
|
||||
list.c \
|
||||
xmlIO.c \
|
||||
xmlmemory.c \
|
||||
uri.c \
|
||||
valid.c \
|
||||
xlink.c \
|
||||
HTMLparser.c \
|
||||
HTMLtree.c \
|
||||
debugXML.c \
|
||||
xpath.c \
|
||||
xpointer.c \
|
||||
xinclude.c \
|
||||
nanohttp.c \
|
||||
nanoftp.c
|
||||
|
||||
DEPS = $(top_builddir)/libxml2.la
|
||||
LDADDS = $(top_builddir)/libxml2.la @Z_LIBS@ @M_LIBS@
|
||||
|
||||
man_MANS = xmllint.1 xml2-config.1 libxml.4
|
||||
|
||||
m4datadir = $(datadir)/aclocal
|
||||
m4data_DATA = libxml.m4
|
||||
|
||||
xmllint_SOURCES=xmllint.c
|
||||
xmllint_LDFLAGS =
|
||||
xmllint_DEPENDENCIES = $(DEPS)
|
||||
xmllint_LDADD = $(RDL_LIBS) $(LDADDS)
|
||||
xmllint_LDADD= @RDL_LIBS@ $(LDADDS)
|
||||
|
||||
testSAX_SOURCES = testSAX.c
|
||||
testSAX_SOURCES=testSAX.c
|
||||
testSAX_LDFLAGS =
|
||||
testSAX_DEPENDENCIES = $(DEPS)
|
||||
testSAX_LDADD = $(LDADDS)
|
||||
testSAX_LDADD= $(LDADDS)
|
||||
|
||||
testHTML_SOURCES = testHTML.c
|
||||
testHTML_SOURCES=testHTML.c
|
||||
testHTML_LDFLAGS =
|
||||
testHTML_DEPENDENCIES = $(DEPS)
|
||||
testHTML_LDADD = $(LDADDS)
|
||||
testHTML_LDADD= $(LDADDS)
|
||||
|
||||
testXPath_SOURCES = testXPath.c
|
||||
testXPath_SOURCES=testXPath.c
|
||||
testXPath_LDFLAGS =
|
||||
testXPath_DEPENDENCIES = $(DEPS)
|
||||
testXPath_LDADD = $(LDADDS)
|
||||
testXPath_LDADD= $(LDADDS)
|
||||
|
||||
testURI_SOURCES = testURI.c
|
||||
testURI_SOURCES=testURI.c
|
||||
testURI_LDFLAGS =
|
||||
testURI_DEPENDENCIES = $(DEPS)
|
||||
testURI_LDADD = $(LDADDS)
|
||||
testURI_LDADD= $(LDADDS)
|
||||
|
||||
check-local: tests
|
||||
|
||||
$(srcdir)/libxml:
|
||||
-$(RM) $(srcdir)/libxml
|
||||
ln -s $(srcdir)/. $(srcdir)/libxml
|
||||
|
||||
install-data: $(srcdir)/libxml
|
||||
|
||||
$(libxml2_la_SOURCES): $(srcdir)/libxml
|
||||
|
||||
testall : tests SVGtests SAXtests
|
||||
|
||||
tests: XMLtests XMLenttests HTMLtests Validtests URItests XPathtests XPtrtests XIncludetests
|
||||
@ -363,3 +405,34 @@ cleantar:
|
||||
|
||||
rpm: cleantar distcheck
|
||||
rpm -ta $(distdir).tar.gz
|
||||
|
||||
## We create xml2Conf.sh here and not from configure because we want
|
||||
## to get the paths expanded correctly. Macros like srcdir are given
|
||||
## the value NONE in configure if the user doesn't specify them (this
|
||||
## is an autoconf feature, not a bug).
|
||||
|
||||
confexecdir=$(libdir)
|
||||
confexec_DATA = xml2Conf.sh
|
||||
|
||||
CLEANFILES=xml2Conf.sh
|
||||
|
||||
confexecdir=$(libdir)
|
||||
confexec_DATA = xml2Conf.sh
|
||||
EXTRA_DIST = xml2Conf.sh.in libxml.spec.in libxml.spec libxml.m4 \
|
||||
example/Makefile.am example/gjobread.c example/gjobs.xml \
|
||||
$(man_MANS) libxml-2.0.pc.in xmlversion.h.in \
|
||||
win32/README.MSDev win32/Makefile.mingw \
|
||||
win32/libxml2/libxml2.dsp win32/libxml2/libxml2_so.dsp \
|
||||
win32/libxml2/libxml2_a.dsp vms/build_libxml.com vms/config.vms
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libxml-2.0.pc
|
||||
|
||||
#xml2Conf.sh: xml2Conf.sh.in Makefile
|
||||
### Use sed and then mv to avoid problems if the user interrupts.
|
||||
# sed -e 's?\@XML_LIBDIR\@?$(XML_LIBDIR)?g' \
|
||||
# -e 's?\@XML_INCLUDEDIR\@?$(XML_INCLUDEDIR)?g' \
|
||||
# -e 's?\@XML_LIBS\@?$(XML_LIBS)?g' \
|
||||
# -e 's?\@VERSION\@?$(VERSION)?g' \
|
||||
# < $(srcdir)/xml2Conf.sh.in > xml2Conf.tmp \
|
||||
# && mv xml2Conf.tmp xml2Conf.sh
|
||||
|
120
SAX.h
Normal file
120
SAX.h
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* SAX.h : Default SAX handler interfaces.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_SAX_H__
|
||||
#define __XML_SAX_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
const xmlChar * getPublicId (void *ctx);
|
||||
const xmlChar * getSystemId (void *ctx);
|
||||
void setDocumentLocator (void *ctx,
|
||||
xmlSAXLocatorPtr loc);
|
||||
|
||||
int getLineNumber (void *ctx);
|
||||
int getColumnNumber (void *ctx);
|
||||
|
||||
int isStandalone (void *ctx);
|
||||
int hasInternalSubset (void *ctx);
|
||||
int hasExternalSubset (void *ctx);
|
||||
|
||||
void internalSubset (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
void externalSubset (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlEntityPtr getEntity (void *ctx,
|
||||
const xmlChar *name);
|
||||
xmlEntityPtr getParameterEntity (void *ctx,
|
||||
const xmlChar *name);
|
||||
xmlParserInputPtr resolveEntity (void *ctx,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId);
|
||||
|
||||
void entityDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId,
|
||||
xmlChar *content);
|
||||
void attributeDecl (void *ctx,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
int def,
|
||||
const xmlChar *defaultValue,
|
||||
xmlEnumerationPtr tree);
|
||||
void elementDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
xmlElementContentPtr content);
|
||||
void notationDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId);
|
||||
void unparsedEntityDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId,
|
||||
const xmlChar *notationName);
|
||||
|
||||
void startDocument (void *ctx);
|
||||
void endDocument (void *ctx);
|
||||
void attribute (void *ctx,
|
||||
const xmlChar *fullname,
|
||||
const xmlChar *value);
|
||||
void startElement (void *ctx,
|
||||
const xmlChar *fullname,
|
||||
const xmlChar **atts);
|
||||
void endElement (void *ctx,
|
||||
const xmlChar *name);
|
||||
void reference (void *ctx,
|
||||
const xmlChar *name);
|
||||
void characters (void *ctx,
|
||||
const xmlChar *ch,
|
||||
int len);
|
||||
void ignorableWhitespace (void *ctx,
|
||||
const xmlChar *ch,
|
||||
int len);
|
||||
void processingInstruction (void *ctx,
|
||||
const xmlChar *target,
|
||||
const xmlChar *data);
|
||||
void globalNamespace (void *ctx,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
void setNamespace (void *ctx,
|
||||
const xmlChar *name);
|
||||
xmlNsPtr getNamespace (void *ctx);
|
||||
int checkNamespace (void *ctx,
|
||||
xmlChar *nameSpace);
|
||||
void namespaceDecl (void *ctx,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
void comment (void *ctx,
|
||||
const xmlChar *value);
|
||||
void cdataBlock (void *ctx,
|
||||
const xmlChar *value,
|
||||
int len);
|
||||
|
||||
void xmlDefaultSAXHandlerInit (void);
|
||||
void htmlDefaultSAXHandlerInit (void);
|
||||
void sgmlDefaultSAXHandlerInit (void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_SAX_H__ */
|
@ -36,7 +36,7 @@ if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
test -f libxml/entities.h || {
|
||||
test -f entities.h || {
|
||||
echo "You must run this script in the top-level libxml directory"
|
||||
exit 1
|
||||
}
|
||||
|
74
configure.in
74
configure.in
@ -1,6 +1,6 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.2)
|
||||
AC_INIT(libxml/entities.c)
|
||||
AC_INIT(entities.c)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
@ -42,10 +42,32 @@ AM_PROG_LIBTOOL
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
dnl Checks for zlib library.
|
||||
AC_CHECK_HEADERS(zlib.h,
|
||||
AC_CHECK_LIB(z, gzread, [AC_DEFINE(HAVE_LIBZ) LIBS="$LIBS -lz"])
|
||||
)
|
||||
_cppflags="${CPPFLAGS}"
|
||||
_ldflags="${LDFLAGS}"
|
||||
|
||||
AC_ARG_WITH(zlib,
|
||||
[ --with-zlib[=DIR] use libz in DIR],[
|
||||
if test "$withval" != "no" -a "$withval" != "yes"; then
|
||||
Z_DIR=$withval
|
||||
CPPFLAGS="${CPPFLAGS} -I$withval/include"
|
||||
LDFLAGS="${LDFLAGS} -L$withval/lib"
|
||||
fi
|
||||
])
|
||||
|
||||
AC_CHECK_HEADERS(zlib.h,
|
||||
AC_CHECK_LIB(z, gzread,[
|
||||
AC_DEFINE(HAVE_LIBZ)
|
||||
if test "x${Z_DIR}" != "x"; then
|
||||
Z_CFLAGS="-I${Z_DIR}/include"
|
||||
Z_LIBS="-L${Z_DIR}/lib -lz"
|
||||
else
|
||||
Z_LIBS="-lz"
|
||||
fi]))
|
||||
AC_SUBST(Z_CFLAGS)
|
||||
AC_SUBST(Z_LIBS)
|
||||
|
||||
CPPFLAGS=${_cppflags}
|
||||
LDFLAGS=${_ldflags}
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_DIRENT
|
||||
@ -343,15 +365,37 @@ AC_SUBST(HAVE_ISINF)
|
||||
AC_SUBST(M_LIBS)
|
||||
AC_SUBST(RDL_LIBS)
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
libxml/Makefile
|
||||
libxml/xmlversion.h
|
||||
libxml/xml2-config
|
||||
libxml/libxml-2.0.pc
|
||||
libxml/xml2Conf.sh
|
||||
doc/Makefile
|
||||
example/Makefile
|
||||
libxml.spec
|
||||
])
|
||||
dnl
|
||||
dnl create the libxml and include links needed to get dependencies right
|
||||
dnl
|
||||
if test ! -d $srcdir/include/libxml
|
||||
then
|
||||
if test ! -d $srcdir/include
|
||||
then
|
||||
rm -f $srcdir/include
|
||||
mkdir $srcdir/include
|
||||
fi
|
||||
rm -f $srcdir/libxml
|
||||
(cd $srcdir/include ; ln -s .. libxml)
|
||||
fi
|
||||
if test ! -r $srcdir/libxml
|
||||
then
|
||||
(cd $srcdir ; ln -s include/libxml libxml)
|
||||
fi
|
||||
if test ! -r include/libxml
|
||||
then
|
||||
if test ! -d include
|
||||
then
|
||||
rm -f include
|
||||
mkdir include
|
||||
fi
|
||||
(cd include ; ln -s ../libxml libxml)
|
||||
fi
|
||||
if test ! -r libxml
|
||||
then
|
||||
rm -rf libxml
|
||||
ln -s $srcdir/include/libxml libxml
|
||||
fi
|
||||
|
||||
AC_OUTPUT(libxml.spec Makefile include/Makefile doc/Makefile example/Makefile libxml/xmlversion.h xml2-config libxml-2.0.pc xml2Conf.sh)
|
||||
|
||||
|
1888
debugXML.c
Normal file
1888
debugXML.c
Normal file
File diff suppressed because it is too large
Load Diff
113
debugXML.h
Normal file
113
debugXML.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* debugXML.h : Interfaces to a set of routines used for debugging the tree
|
||||
* produced by the XML parser.
|
||||
*
|
||||
* Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
*/
|
||||
|
||||
#ifndef __DEBUG_XML__
|
||||
#define __DEBUG_XML__
|
||||
#include <stdio.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The standard Dump routines
|
||||
*/
|
||||
void xmlDebugDumpString (FILE *output,
|
||||
const xmlChar *str);
|
||||
void xmlDebugDumpAttr (FILE *output,
|
||||
xmlAttrPtr attr,
|
||||
int depth);
|
||||
void xmlDebugDumpAttrList (FILE *output,
|
||||
xmlAttrPtr attr,
|
||||
int depth);
|
||||
void xmlDebugDumpOneNode (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
void xmlDebugDumpNode (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
void xmlDebugDumpNodeList (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
void xmlDebugDumpDocumentHead(FILE *output,
|
||||
xmlDocPtr doc);
|
||||
void xmlDebugDumpDocument (FILE *output,
|
||||
xmlDocPtr doc);
|
||||
void xmlDebugDumpDTD (FILE *output,
|
||||
xmlDtdPtr doc);
|
||||
void xmlDebugDumpEntities (FILE *output,
|
||||
xmlDocPtr doc);
|
||||
void xmlLsOneNode (FILE *output,
|
||||
xmlNodePtr node);
|
||||
|
||||
/****************************************************************
|
||||
* *
|
||||
* The XML shell related structures and functions *
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
/**
|
||||
* xmlShellReadlineFunc:
|
||||
* @prompt: a string prompt
|
||||
*
|
||||
* This is a generic signature for the XML shell input function
|
||||
*
|
||||
* Returns a string which will be freed by the Shell
|
||||
*/
|
||||
typedef char * (* xmlShellReadlineFunc)(char *prompt);
|
||||
|
||||
/*
|
||||
* The shell context itself
|
||||
* TODO: add the defined function tables.
|
||||
*/
|
||||
typedef struct _xmlShellCtxt xmlShellCtxt;
|
||||
typedef xmlShellCtxt *xmlShellCtxtPtr;
|
||||
struct _xmlShellCtxt {
|
||||
char *filename;
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr node;
|
||||
xmlXPathContextPtr pctxt;
|
||||
int loaded;
|
||||
FILE *output;
|
||||
xmlShellReadlineFunc input;
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlShellCmd:
|
||||
* @ctxt: a shell context
|
||||
* @arg: a string argument
|
||||
* @node: a first node
|
||||
* @node2: a second node
|
||||
*
|
||||
* This is a generic signature for the XML shell functions
|
||||
*
|
||||
* Returns an int, negative returns indicating errors
|
||||
*/
|
||||
typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,
|
||||
char *arg,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
|
||||
/*
|
||||
* The Shell interface.
|
||||
*/
|
||||
void xmlShell (xmlDocPtr doc,
|
||||
char *filename,
|
||||
xmlShellReadlineFunc input,
|
||||
FILE *output);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_DEBUG_ENABLED */
|
||||
#endif /* __DEBUG_XML__ */
|
2078
encoding.c
Normal file
2078
encoding.c
Normal file
File diff suppressed because it is too large
Load Diff
187
encoding.h
Normal file
187
encoding.h
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* encoding.h : interface for the encoding conversion functions needed for
|
||||
* XML
|
||||
*
|
||||
* Related specs:
|
||||
* rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies
|
||||
* [ISO-10646] UTF-8 and UTF-16 in Annexes
|
||||
* [ISO-8859-1] ISO Latin-1 characters codes.
|
||||
* [UNICODE] The Unicode Consortium, "The Unicode Standard --
|
||||
* Worldwide Character Encoding -- Version 1.0", Addison-
|
||||
* Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is
|
||||
* described in Unicode Technical Report #4.
|
||||
* [US-ASCII] Coded Character Set--7-bit American Standard Code for
|
||||
* Information Interchange, ANSI X3.4-1986.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_CHAR_ENCODING_H__
|
||||
#define __XML_CHAR_ENCODING_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#ifdef LIBXML_ICONV_ENABLED
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Predefined values for some standard encodings
|
||||
* Libxml don't do beforehand translation on UTF8, ISOLatinX
|
||||
* It also support UTF16 (LE and BE) by default.
|
||||
*
|
||||
* Anything else would have to be translated to UTF8 before being
|
||||
* given to the parser itself. The BOM for UTF16 and the encoding
|
||||
* declaration are looked at and a converter is looked for at that
|
||||
* point. If not found the parser stops here as asked by the XML REC
|
||||
* Converter can be registered by the user using xmlRegisterCharEncodingHandler
|
||||
* but the currentl form doesn't allow stateful transcoding (a serious
|
||||
* problem agreed !). If iconv has been found it will be used
|
||||
* automatically and allow stateful transcoding, the simplest is then
|
||||
* to be sure to enable icon and to provide iconv libs for the encoding
|
||||
* support needed.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
|
||||
XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
|
||||
XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
|
||||
XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
|
||||
XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
|
||||
XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
|
||||
XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
|
||||
XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
|
||||
XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
|
||||
XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
|
||||
XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
|
||||
XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
|
||||
XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
|
||||
XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
|
||||
XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
|
||||
XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
|
||||
XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
|
||||
XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
|
||||
XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
|
||||
XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
|
||||
XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
|
||||
XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
|
||||
XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
|
||||
XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
|
||||
} xmlCharEncoding;
|
||||
|
||||
/**
|
||||
* xmlCharEncodingInputFunc:
|
||||
* @out: a pointer ot an array of bytes to store the UTF-8 result
|
||||
* @outlen: the lenght of @out
|
||||
* @in: a pointer ot an array of chars in the original encoding
|
||||
* @inlen: the lenght of @in
|
||||
*
|
||||
* Take a block of chars in the original encoding and try to convert
|
||||
* it to an UTF-8 block of chars out.
|
||||
*
|
||||
* Returns the number of byte written, or -1 by lack of space, or -2
|
||||
* if the transcoding failed.
|
||||
* The value of @inlen after return is the number of octets consumed
|
||||
* as the return value is positive, else unpredictiable.
|
||||
* The value of @outlen after return is the number of ocetes consumed.
|
||||
*/
|
||||
typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int *outlen,
|
||||
const unsigned char* in, int *inlen);
|
||||
|
||||
|
||||
/**
|
||||
* xmlCharEncodingOutputFunc:
|
||||
* @out: a pointer ot an array of bytes to store the result
|
||||
* @outlen: the lenght of @out
|
||||
* @in: a pointer ot an array of UTF-8 chars
|
||||
* @inlen: the lenght of @in
|
||||
*
|
||||
* Take a block of UTF-8 chars in and try to convert it to an other
|
||||
* encoding.
|
||||
* Note: a first call designed to produce heading info is called with
|
||||
* in = NULL. If stateful this should also initialize the encoder state
|
||||
*
|
||||
* Returns the number of byte written, or -1 by lack of space, or -2
|
||||
* if the transcoding failed.
|
||||
* The value of @inlen after return is the number of octets consumed
|
||||
* as the return value is positive, else unpredictiable.
|
||||
* The value of @outlen after return is the number of ocetes consumed.
|
||||
*/
|
||||
typedef int (* xmlCharEncodingOutputFunc)(unsigned char* out, int *outlen,
|
||||
const unsigned char* in, int *inlen);
|
||||
|
||||
|
||||
/*
|
||||
* Block defining the handlers for non UTF-8 encodings.
|
||||
* If iconv is supported, there is two extra fields
|
||||
*/
|
||||
|
||||
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
|
||||
typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
|
||||
struct _xmlCharEncodingHandler {
|
||||
char *name;
|
||||
xmlCharEncodingInputFunc input;
|
||||
xmlCharEncodingOutputFunc output;
|
||||
#ifdef LIBXML_ICONV_ENABLED
|
||||
iconv_t iconv_in;
|
||||
iconv_t iconv_out;
|
||||
#endif /* LIBXML_ICONV_ENABLED */
|
||||
};
|
||||
|
||||
/*
|
||||
* Interfaces for encoding handlers
|
||||
*/
|
||||
void xmlInitCharEncodingHandlers (void);
|
||||
void xmlCleanupCharEncodingHandlers (void);
|
||||
void xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
|
||||
xmlCharEncodingHandlerPtr
|
||||
xmlGetCharEncodingHandler (xmlCharEncoding enc);
|
||||
xmlCharEncodingHandlerPtr
|
||||
xmlFindCharEncodingHandler (const char *name);
|
||||
|
||||
|
||||
/*
|
||||
* Interfaces for encoding names and aliases
|
||||
*/
|
||||
int xmlAddEncodingAlias (const char *name,
|
||||
const char *alias);
|
||||
int xmlDelEncodingAlias (const char *alias);
|
||||
const char *
|
||||
xmlGetEncodingAlias (const char *alias);
|
||||
void xmlCleanupEncodingAliases (void);
|
||||
xmlCharEncoding
|
||||
xmlParseCharEncoding (const char* name);
|
||||
const char*
|
||||
xmlGetCharEncodingName (xmlCharEncoding enc);
|
||||
|
||||
/*
|
||||
* Interfaces directly used by the parsers.
|
||||
*/
|
||||
xmlCharEncoding
|
||||
xmlDetectCharEncoding (const unsigned char* in,
|
||||
int len);
|
||||
|
||||
int xmlCheckUTF8 (const unsigned char *utf);
|
||||
|
||||
int xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
|
||||
int xmlCharEncInFunc (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
int xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_CHAR_ENCODING_H__ */
|
1034
entities.c
Normal file
1034
entities.c
Normal file
File diff suppressed because it is too large
Load Diff
114
entities.h
Normal file
114
entities.h
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* entities.h : interface for the XML entities handking
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_ENTITIES_H__
|
||||
#define __XML_ENTITIES_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The different valid entity types
|
||||
*/
|
||||
typedef enum {
|
||||
XML_INTERNAL_GENERAL_ENTITY = 1,
|
||||
XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
|
||||
XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
|
||||
XML_INTERNAL_PARAMETER_ENTITY = 4,
|
||||
XML_EXTERNAL_PARAMETER_ENTITY = 5,
|
||||
XML_INTERNAL_PREDEFINED_ENTITY = 6
|
||||
} xmlEntityType;
|
||||
|
||||
/*
|
||||
* An unit of storage for an entity, contains the string, the value
|
||||
* and the linkind data needed for the linking in the hash table.
|
||||
*/
|
||||
|
||||
typedef struct _xmlEntity xmlEntity;
|
||||
typedef xmlEntity *xmlEntityPtr;
|
||||
struct _xmlEntity {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
|
||||
const xmlChar *name; /* Attribute name */
|
||||
struct _xmlNode *children; /* NULL */
|
||||
struct _xmlNode *last; /* NULL */
|
||||
struct _xmlDtd *parent; /* -> DTD */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
xmlChar *orig; /* content without ref substitution */
|
||||
xmlChar *content; /* content or ndata if unparsed */
|
||||
int length; /* the content length */
|
||||
xmlEntityType etype; /* The entity type */
|
||||
const xmlChar *ExternalID; /* External identifier for PUBLIC */
|
||||
const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
|
||||
|
||||
struct _xmlEntity *nexte; /* unused */
|
||||
const xmlChar *URI; /* the full URI as computed */
|
||||
};
|
||||
|
||||
/*
|
||||
* ALl entities are stored in an hash table
|
||||
* there is 2 separate hash tables for global and parmeter entities
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlEntitiesTable;
|
||||
typedef xmlEntitiesTable *xmlEntitiesTablePtr;
|
||||
|
||||
/*
|
||||
* External functions :
|
||||
*/
|
||||
|
||||
void xmlInitializePredefinedEntities (void);
|
||||
xmlEntityPtr xmlAddDocEntity (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID,
|
||||
const xmlChar *content);
|
||||
xmlEntityPtr xmlAddDtdEntity (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID,
|
||||
const xmlChar *content);
|
||||
xmlEntityPtr xmlGetPredefinedEntity (const xmlChar *name);
|
||||
xmlEntityPtr xmlGetDocEntity (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlEntityPtr xmlGetDtdEntity (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlEntityPtr xmlGetParameterEntity (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
const xmlChar * xmlEncodeEntities (xmlDocPtr doc,
|
||||
const xmlChar *input);
|
||||
xmlChar * xmlEncodeEntitiesReentrant(xmlDocPtr doc,
|
||||
const xmlChar *input);
|
||||
xmlChar * xmlEncodeSpecialChars (xmlDocPtr doc,
|
||||
const xmlChar *input);
|
||||
xmlEntitiesTablePtr xmlCreateEntitiesTable (void);
|
||||
xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
|
||||
void xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
|
||||
void xmlDumpEntitiesTable (xmlBufferPtr buf,
|
||||
xmlEntitiesTablePtr table);
|
||||
void xmlDumpEntityDecl (xmlBufferPtr buf,
|
||||
xmlEntityPtr ent);
|
||||
xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
|
||||
void xmlCleanupPredefinedEntities(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
# endif /* __XML_ENTITIES_H__ */
|
298
error.c
Normal file
298
error.c
Normal file
@ -0,0 +1,298 @@
|
||||
/*
|
||||
* error.c: module displaying/handling XML parser errors
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32config.h"
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Handling of out of context errors *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xmlGenericErrorDefaultFunc:
|
||||
* @ctx: an error context
|
||||
* @msg: the message to display/transmit
|
||||
* @...: extra parameters for the message display
|
||||
*
|
||||
* Default handler for out of context error messages.
|
||||
*/
|
||||
void
|
||||
xmlGenericErrorDefaultFunc(void *ctx, const char *msg, ...) {
|
||||
va_list args;
|
||||
|
||||
if (xmlGenericErrorContext == NULL)
|
||||
xmlGenericErrorContext = (void *) stderr;
|
||||
|
||||
va_start(args, msg);
|
||||
vfprintf((FILE *)xmlGenericErrorContext, msg, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
|
||||
void *xmlGenericErrorContext = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* xmlSetGenericErrorFunc:
|
||||
* @ctx: the new error handling context
|
||||
* @handler: the new handler function
|
||||
*
|
||||
* Function to reset the handler and the error context for out of
|
||||
* context error messages.
|
||||
* This simply means that @handler will be called for subsequent
|
||||
* error messages while not parsing nor validating. And @ctx will
|
||||
* be passed as first argument to @handler
|
||||
* One can simply force messages to be emitted to another FILE * than
|
||||
* stderr by setting @ctx to this file handle and @handler to NULL.
|
||||
*/
|
||||
void
|
||||
xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
|
||||
xmlGenericErrorContext = ctx;
|
||||
if (handler != NULL)
|
||||
xmlGenericError = handler;
|
||||
else
|
||||
xmlGenericError = xmlGenericErrorDefaultFunc;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Handling of parsing errors *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xmlParserPrintFileInfo:
|
||||
* @input: an xmlParserInputPtr input
|
||||
*
|
||||
* Displays the associated file and line informations for the current input
|
||||
*/
|
||||
|
||||
void
|
||||
xmlParserPrintFileInfo(xmlParserInputPtr input) {
|
||||
if (input != NULL) {
|
||||
if (input->filename)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"%s:%d: ", input->filename,
|
||||
input->line);
|
||||
else
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Entity: line %d: ", input->line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlParserPrintFileContext:
|
||||
* @input: an xmlParserInputPtr input
|
||||
*
|
||||
* Displays current context within the input content for error tracking
|
||||
*/
|
||||
|
||||
void
|
||||
xmlParserPrintFileContext(xmlParserInputPtr input) {
|
||||
const xmlChar *cur, *base;
|
||||
int n;
|
||||
|
||||
if (input == NULL) return;
|
||||
cur = input->cur;
|
||||
base = input->base;
|
||||
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
|
||||
cur--;
|
||||
}
|
||||
n = 0;
|
||||
while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
|
||||
cur--;
|
||||
if ((*cur == '\n') || (*cur == '\r')) cur++;
|
||||
base = cur;
|
||||
n = 0;
|
||||
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"%c", (unsigned char) *cur++);
|
||||
n++;
|
||||
}
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
cur = input->cur;
|
||||
while ((*cur == '\n') || (*cur == '\r'))
|
||||
cur--;
|
||||
n = 0;
|
||||
while ((cur != base) && (n++ < 80)) {
|
||||
xmlGenericError(xmlGenericErrorContext, " ");
|
||||
base++;
|
||||
}
|
||||
xmlGenericError(xmlGenericErrorContext,"^\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlParserError:
|
||||
* @ctx: an XML parser context
|
||||
* @msg: the message to display/transmit
|
||||
* @...: extra parameters for the message display
|
||||
*
|
||||
* Display and format an error messages, gives file, line, position and
|
||||
* extra parameters.
|
||||
*/
|
||||
void
|
||||
xmlParserError(void *ctx, const char *msg, ...)
|
||||
{
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlParserInputPtr input = NULL;
|
||||
xmlParserInputPtr cur = NULL;
|
||||
va_list args;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
if ((input != NULL) && (input->filename == NULL) &&
|
||||
(ctxt->inputNr > 1)) {
|
||||
cur = input;
|
||||
input = ctxt->inputTab[ctxt->inputNr - 2];
|
||||
}
|
||||
xmlParserPrintFileInfo(input);
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "error: ");
|
||||
va_start(args, msg);
|
||||
vfprintf(xmlGenericErrorContext, msg, args);
|
||||
va_end(args);
|
||||
|
||||
if (ctxt != NULL) {
|
||||
xmlParserPrintFileContext(input);
|
||||
if (cur != NULL) {
|
||||
xmlParserPrintFileInfo(cur);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
xmlParserPrintFileContext(cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlParserWarning:
|
||||
* @ctx: an XML parser context
|
||||
* @msg: the message to display/transmit
|
||||
* @...: extra parameters for the message display
|
||||
*
|
||||
* Display and format a warning messages, gives file, line, position and
|
||||
* extra parameters.
|
||||
*/
|
||||
void
|
||||
xmlParserWarning(void *ctx, const char *msg, ...)
|
||||
{
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlParserInputPtr input = NULL;
|
||||
xmlParserInputPtr cur = NULL;
|
||||
va_list args;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
if ((input != NULL) && (input->filename == NULL) &&
|
||||
(ctxt->inputNr > 1)) {
|
||||
cur = input;
|
||||
input = ctxt->inputTab[ctxt->inputNr - 2];
|
||||
}
|
||||
xmlParserPrintFileInfo(input);
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "warning: ");
|
||||
va_start(args, msg);
|
||||
vfprintf(xmlGenericErrorContext, msg, args);
|
||||
va_end(args);
|
||||
|
||||
|
||||
if (ctxt != NULL) {
|
||||
xmlParserPrintFileContext(input);
|
||||
if (cur != NULL) {
|
||||
xmlParserPrintFileInfo(cur);
|
||||
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||
xmlParserPrintFileContext(cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Handling of validation errors *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xmlParserValidityError:
|
||||
* @ctx: an XML parser context
|
||||
* @msg: the message to display/transmit
|
||||
* @...: extra parameters for the message display
|
||||
*
|
||||
* Display and format an validity error messages, gives file,
|
||||
* line, position and extra parameters.
|
||||
*/
|
||||
void
|
||||
xmlParserValidityError(void *ctx, const char *msg, ...)
|
||||
{
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlParserInputPtr input = NULL;
|
||||
va_list args;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
if ((input->filename == NULL) && (ctxt->inputNr > 1))
|
||||
input = ctxt->inputTab[ctxt->inputNr - 2];
|
||||
|
||||
xmlParserPrintFileInfo(input);
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
||||
va_start(args, msg);
|
||||
vfprintf(xmlGenericErrorContext, msg, args);
|
||||
va_end(args);
|
||||
|
||||
if (ctxt != NULL) {
|
||||
xmlParserPrintFileContext(input);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlParserValidityWarning:
|
||||
* @ctx: an XML parser context
|
||||
* @msg: the message to display/transmit
|
||||
* @...: extra parameters for the message display
|
||||
*
|
||||
* Display and format a validity warning messages, gives file, line,
|
||||
* position and extra parameters.
|
||||
*/
|
||||
void
|
||||
xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
||||
{
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlParserInputPtr input = NULL;
|
||||
va_list args;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
if ((input->filename == NULL) && (ctxt->inputNr > 1))
|
||||
input = ctxt->inputTab[ctxt->inputNr - 2];
|
||||
|
||||
xmlParserPrintFileInfo(input);
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
|
||||
va_start(args, msg);
|
||||
vfprintf(xmlGenericErrorContext, msg, args);
|
||||
va_end(args);
|
||||
|
||||
if (ctxt != NULL) {
|
||||
xmlParserPrintFileContext(input);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
noinst_PROGRAMS = gjobread
|
||||
|
||||
DEFS =
|
||||
INCLUDES = -I$(top_builddir)
|
||||
INCLUDES = \
|
||||
-I$(top_builddir) -I$(top_srcdir) \
|
||||
-I@srcdir@
|
||||
|
||||
DEPS = $(top_builddir)/libxml/libxml2.la
|
||||
LDADD = $(top_builddir)/libxml/libxml2.la
|
||||
LDADD = $(top_builddir)/libxml2.la @Z_LIBS@
|
||||
|
||||
|
620
hash.c
Normal file
620
hash.c
Normal file
@ -0,0 +1,620 @@
|
||||
/*
|
||||
* hash.c: chained hash tables
|
||||
*
|
||||
* Reference: Your favorite introductory book on algorithms
|
||||
*
|
||||
* Copyright (C) 2000 Bjorn Reese and Daniel Veillard.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
|
||||
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
|
||||
*
|
||||
* Author: bjorn.reese@systematic.dk
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32config.h"
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
/*
|
||||
* A single entry in the hash table
|
||||
*/
|
||||
typedef struct _xmlHashEntry xmlHashEntry;
|
||||
typedef xmlHashEntry *xmlHashEntryPtr;
|
||||
struct _xmlHashEntry {
|
||||
struct _xmlHashEntry *next;
|
||||
xmlChar *name;
|
||||
xmlChar *name2;
|
||||
xmlChar *name3;
|
||||
void *payload;
|
||||
};
|
||||
|
||||
/*
|
||||
* The entire hash table
|
||||
*/
|
||||
struct _xmlHashTable {
|
||||
struct _xmlHashEntry **table;
|
||||
int size;
|
||||
int nbElems;
|
||||
};
|
||||
|
||||
/*
|
||||
* xmlHashComputeKey:
|
||||
* Calculate the hash key
|
||||
*/
|
||||
static unsigned long
|
||||
xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *string) {
|
||||
unsigned long value = 0L;
|
||||
char ch;
|
||||
|
||||
while ((ch = *string++) != 0) {
|
||||
/* value *= 31; */
|
||||
value += (unsigned long)ch;
|
||||
}
|
||||
return (value % table->size);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashCreate:
|
||||
* @size: the size of the hash table
|
||||
*
|
||||
* Create a new xmlHashTablePtr.
|
||||
*
|
||||
* Returns the newly created object, or NULL if an error occured.
|
||||
*/
|
||||
xmlHashTablePtr
|
||||
xmlHashCreate(int size) {
|
||||
xmlHashTablePtr table;
|
||||
|
||||
if (size <= 0)
|
||||
size = 256;
|
||||
|
||||
table = xmlMalloc(sizeof(xmlHashTable));
|
||||
if (table) {
|
||||
table->size = size;
|
||||
table->nbElems = 0;
|
||||
table->table = xmlMalloc(size * sizeof(xmlHashEntry));
|
||||
if (table->table) {
|
||||
memset(table->table, 0, size * sizeof(xmlHashEntry));
|
||||
return(table);
|
||||
}
|
||||
xmlFree(table);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashFree:
|
||||
* @table: the hash table
|
||||
* @f: the deallocator function for items in the hash
|
||||
*
|
||||
* Free the hash table and its contents. The userdata is
|
||||
* deallocated with f if provided.
|
||||
*/
|
||||
void
|
||||
xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) {
|
||||
int i;
|
||||
xmlHashEntryPtr iter;
|
||||
xmlHashEntryPtr next;
|
||||
|
||||
if (table == NULL)
|
||||
return;
|
||||
if (table->table) {
|
||||
for(i = 0; i < table->size; i++) {
|
||||
iter = table->table[i];
|
||||
while (iter) {
|
||||
next = iter->next;
|
||||
if (iter->name)
|
||||
xmlFree(iter->name);
|
||||
if (iter->name2)
|
||||
xmlFree(iter->name2);
|
||||
if (iter->name3)
|
||||
xmlFree(iter->name3);
|
||||
if (f)
|
||||
f(iter->payload, iter->name);
|
||||
iter->payload = NULL;
|
||||
xmlFree(iter);
|
||||
iter = next;
|
||||
}
|
||||
table->table[i] = NULL;
|
||||
}
|
||||
xmlFree(table->table);
|
||||
}
|
||||
xmlFree(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashAddEntry:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @userdata: a pointer to the userdata
|
||||
*
|
||||
* Add the userdata to the hash table. This can later be retrieved
|
||||
* by using the name. Duplicate names generate errors.
|
||||
*
|
||||
* Returns 0 the addition succeeded and -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata) {
|
||||
return(xmlHashAddEntry3(table, name, NULL, NULL, userdata));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashAddEntry2:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @name2: a second name of the userdata
|
||||
* @userdata: a pointer to the userdata
|
||||
*
|
||||
* Add the userdata to the hash table. This can later be retrieved
|
||||
* by using the (name, name2) tuple. Duplicate tuples generate errors.
|
||||
*
|
||||
* Returns 0 the addition succeeded and -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, void *userdata) {
|
||||
return(xmlHashAddEntry3(table, name, name2, NULL, userdata));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashUpdateEntry:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @userdata: a pointer to the userdata
|
||||
* @f: the deallocator function for replaced item (if any)
|
||||
*
|
||||
* Add the userdata to the hash table. This can later be retrieved
|
||||
* by using the name. Existing entry for this name will be removed
|
||||
* and freed with @f if found.
|
||||
*
|
||||
* Returns 0 the addition succeeded and -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name,
|
||||
void *userdata, xmlHashDeallocator f) {
|
||||
return(xmlHashUpdateEntry3(table, name, NULL, NULL, userdata, f));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashUpdateEntry2:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @name2: a second name of the userdata
|
||||
* @userdata: a pointer to the userdata
|
||||
* @f: the deallocator function for replaced item (if any)
|
||||
*
|
||||
* Add the userdata to the hash table. This can later be retrieved
|
||||
* by using the (name, name2) tuple. Existing entry for this tuple will
|
||||
* be removed and freed with @f if found.
|
||||
*
|
||||
* Returns 0 the addition succeeded and -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, void *userdata,
|
||||
xmlHashDeallocator f) {
|
||||
return(xmlHashUpdateEntry3(table, name, name2, NULL, userdata, f));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashLookup:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
*
|
||||
* Find the userdata specified by the name.
|
||||
*
|
||||
* Returns the a pointer to the userdata
|
||||
*/
|
||||
void *
|
||||
xmlHashLookup(xmlHashTablePtr table, const xmlChar *name) {
|
||||
return(xmlHashLookup3(table, name, NULL, NULL));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashLookup2:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @name2: a second name of the userdata
|
||||
*
|
||||
* Find the userdata specified by the (name, name2) tuple.
|
||||
*
|
||||
* Returns the a pointer to the userdata
|
||||
*/
|
||||
void *
|
||||
xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2) {
|
||||
return(xmlHashLookup3(table, name, name2, NULL));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashAddEntry3:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @name2: a second name of the userdata
|
||||
* @name3: a third name of the userdata
|
||||
* @userdata: a pointer to the userdata
|
||||
*
|
||||
* Add the userdata to the hash table. This can later be retrieved
|
||||
* by using the tuple (name, name2, name3). Duplicate entries generate
|
||||
* errors.
|
||||
*
|
||||
* Returns 0 the addition succeeded and -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3,
|
||||
void *userdata) {
|
||||
unsigned long key;
|
||||
xmlHashEntryPtr entry;
|
||||
xmlHashEntryPtr insert;
|
||||
|
||||
if ((table == NULL) || name == NULL)
|
||||
return(-1);
|
||||
|
||||
/*
|
||||
* Check for duplicate and insertion location.
|
||||
*/
|
||||
key = xmlHashComputeKey(table, name);
|
||||
if (table->table[key] == NULL) {
|
||||
insert = NULL;
|
||||
} else {
|
||||
for (insert = table->table[key]; insert->next != NULL;
|
||||
insert = insert->next) {
|
||||
if ((xmlStrEqual(insert->name, name)) &&
|
||||
(xmlStrEqual(insert->name2, name2)) &&
|
||||
(xmlStrEqual(insert->name3, name3)))
|
||||
return(-1);
|
||||
}
|
||||
if ((xmlStrEqual(insert->name, name)) &&
|
||||
(xmlStrEqual(insert->name2, name2)) &&
|
||||
(xmlStrEqual(insert->name3, name3)))
|
||||
return(-1);
|
||||
}
|
||||
|
||||
entry = xmlMalloc(sizeof(xmlHashEntry));
|
||||
if (entry == NULL)
|
||||
return(-1);
|
||||
entry->name = xmlStrdup(name);
|
||||
entry->name2 = xmlStrdup(name2);
|
||||
entry->name3 = xmlStrdup(name3);
|
||||
entry->payload = userdata;
|
||||
entry->next = NULL;
|
||||
|
||||
|
||||
if (insert == NULL) {
|
||||
table->table[key] = entry;
|
||||
} else {
|
||||
insert->next = entry;
|
||||
}
|
||||
table->nbElems++;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashUpdateEntry3:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @name2: a second name of the userdata
|
||||
* @name3: a third name of the userdata
|
||||
* @userdata: a pointer to the userdata
|
||||
* @f: the deallocator function for replaced item (if any)
|
||||
*
|
||||
* Add the userdata to the hash table. This can later be retrieved
|
||||
* by using the tuple (name, name2, name3). Existing entry for this tuple
|
||||
* will be removed and freed with @f if found.
|
||||
*
|
||||
* Returns 0 the addition succeeded and -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xmlHashUpdateEntry3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3,
|
||||
void *userdata, xmlHashDeallocator f) {
|
||||
unsigned long key;
|
||||
xmlHashEntryPtr entry;
|
||||
xmlHashEntryPtr insert;
|
||||
|
||||
if ((table == NULL) || name == NULL)
|
||||
return(-1);
|
||||
|
||||
/*
|
||||
* Check for duplicate and insertion location.
|
||||
*/
|
||||
key = xmlHashComputeKey(table, name);
|
||||
if (table->table[key] == NULL) {
|
||||
insert = NULL;
|
||||
} else {
|
||||
for (insert = table->table[key]; insert->next != NULL;
|
||||
insert = insert->next) {
|
||||
if ((xmlStrEqual(insert->name, name)) &&
|
||||
(xmlStrEqual(insert->name2, name2)) &&
|
||||
(xmlStrEqual(insert->name3, name3))) {
|
||||
if (f)
|
||||
f(insert->payload, insert->name);
|
||||
insert->payload = userdata;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if ((xmlStrEqual(insert->name, name)) &&
|
||||
(xmlStrEqual(insert->name2, name2)) &&
|
||||
(xmlStrEqual(insert->name3, name3))) {
|
||||
if (f)
|
||||
f(insert->payload, insert->name);
|
||||
insert->payload = userdata;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
entry = xmlMalloc(sizeof(xmlHashEntry));
|
||||
if (entry == NULL)
|
||||
return(-1);
|
||||
entry->name = xmlStrdup(name);
|
||||
entry->name2 = xmlStrdup(name2);
|
||||
entry->name3 = xmlStrdup(name3);
|
||||
entry->payload = userdata;
|
||||
entry->next = NULL;
|
||||
table->nbElems++;
|
||||
|
||||
|
||||
if (insert == NULL) {
|
||||
table->table[key] = entry;
|
||||
} else {
|
||||
insert->next = entry;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashLookup:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @name2: a second name of the userdata
|
||||
* @name3: a third name of the userdata
|
||||
*
|
||||
* Find the userdata specified by the (name, name2, name3) tuple.
|
||||
*
|
||||
* Returns the a pointer to the userdata
|
||||
*/
|
||||
void *
|
||||
xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3) {
|
||||
unsigned long key;
|
||||
xmlHashEntryPtr entry;
|
||||
|
||||
if (table == NULL)
|
||||
return(NULL);
|
||||
if (name == NULL)
|
||||
return(NULL);
|
||||
key = xmlHashComputeKey(table, name);
|
||||
for (entry = table->table[key]; entry != NULL; entry = entry->next) {
|
||||
if ((xmlStrEqual(entry->name, name)) &&
|
||||
(xmlStrEqual(entry->name2, name2)) &&
|
||||
(xmlStrEqual(entry->name3, name3)))
|
||||
return(entry->payload);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashScan:
|
||||
* @table: the hash table
|
||||
* @f: the scanner function for items in the hash
|
||||
* @data: extra data passed to f
|
||||
*
|
||||
* Scan the hash table and applied f to each value.
|
||||
*/
|
||||
void
|
||||
xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) {
|
||||
int i;
|
||||
xmlHashEntryPtr iter;
|
||||
xmlHashEntryPtr next;
|
||||
|
||||
if (table == NULL)
|
||||
return;
|
||||
if (f == NULL)
|
||||
return;
|
||||
|
||||
if (table->table) {
|
||||
for(i = 0; i < table->size; i++) {
|
||||
iter = table->table[i];
|
||||
while (iter) {
|
||||
next = iter->next;
|
||||
if (f)
|
||||
f(iter->payload, data, iter->name);
|
||||
iter = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashScan3:
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata or NULL
|
||||
* @name2: a second name of the userdata or NULL
|
||||
* @name3: a third name of the userdata or NULL
|
||||
* @f: the scanner function for items in the hash
|
||||
* @data: extra data passed to f
|
||||
*
|
||||
* Scan the hash table and applied f to each value matching
|
||||
* (name, name2, name3) tuple. If one of the names is null,
|
||||
* the comparison is considered to match.
|
||||
*/
|
||||
void
|
||||
xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3,
|
||||
xmlHashScanner f, void *data) {
|
||||
int i;
|
||||
xmlHashEntryPtr iter;
|
||||
xmlHashEntryPtr next;
|
||||
|
||||
if (table == NULL)
|
||||
return;
|
||||
if (f == NULL)
|
||||
return;
|
||||
|
||||
if (table->table) {
|
||||
for(i = 0; i < table->size; i++) {
|
||||
iter = table->table[i];
|
||||
while (iter) {
|
||||
next = iter->next;
|
||||
if (((name == NULL) || (xmlStrEqual(name, iter->name))) &&
|
||||
((name2 == NULL) || (xmlStrEqual(name2, iter->name2))) &&
|
||||
((name3 == NULL) || (xmlStrEqual(name3, iter->name3)))) {
|
||||
f(iter->payload, data, iter->name);
|
||||
}
|
||||
iter = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashCopy:
|
||||
* @table: the hash table
|
||||
* @f: the copier function for items in the hash
|
||||
*
|
||||
* Scan the hash table and applied f to each value.
|
||||
*
|
||||
* Returns the new table or NULL in case of error.
|
||||
*/
|
||||
xmlHashTablePtr
|
||||
xmlHashCopy(xmlHashTablePtr table, xmlHashCopier f) {
|
||||
int i;
|
||||
xmlHashEntryPtr iter;
|
||||
xmlHashEntryPtr next;
|
||||
xmlHashTablePtr ret;
|
||||
|
||||
if (table == NULL)
|
||||
return(NULL);
|
||||
if (f == NULL)
|
||||
return(NULL);
|
||||
|
||||
ret = xmlHashCreate(table->size);
|
||||
if (table->table) {
|
||||
for(i = 0; i < table->size; i++) {
|
||||
iter = table->table[i];
|
||||
while (iter) {
|
||||
next = iter->next;
|
||||
xmlHashAddEntry3(ret, iter->name, iter->name2,
|
||||
iter->name3, f(iter->payload, iter->name));
|
||||
iter = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret->nbElems = table->nbElems;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlHashSize:
|
||||
* @table: the hash table
|
||||
*
|
||||
* Returns the number of elements in the hash table or
|
||||
* -1 in case of error
|
||||
*/
|
||||
int
|
||||
xmlHashSize(xmlHashTablePtr table) {
|
||||
if (table == NULL)
|
||||
return(-1);
|
||||
return(table->nbElems);
|
||||
}
|
||||
|
||||
/**
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @f: the deallocator function for removed item (if any)
|
||||
*
|
||||
* Find the userdata specified by the (name, name2, name3) tuple and remove
|
||||
* it from the hash table. Existing userdata for this tuple will be removed
|
||||
* and freed with @f.
|
||||
*
|
||||
* Returns 0 if the removal succeeded and -1 in case of error or not found.
|
||||
*/
|
||||
int xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
|
||||
xmlHashDeallocator f) {
|
||||
return(xmlHashRemoveEntry3(table, name, NULL, NULL, f));
|
||||
}
|
||||
|
||||
/**
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @name2: a second name of the userdata
|
||||
* @f: the deallocator function for removed item (if any)
|
||||
*
|
||||
* Find the userdata specified by the (name, name2, name3) tuple and remove
|
||||
* it from the hash table. Existing userdata for this tuple will be removed
|
||||
* and freed with @f.
|
||||
*
|
||||
* Returns 0 if the removal succeeded and -1 in case of error or not found.
|
||||
*/
|
||||
int xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, xmlHashDeallocator f) {
|
||||
return(xmlHashRemoveEntry3(table, name, name2, NULL, f));
|
||||
}
|
||||
|
||||
/**
|
||||
* @table: the hash table
|
||||
* @name: the name of the userdata
|
||||
* @name2: a second name of the userdata
|
||||
* @name3: a third name of the userdata
|
||||
* @f: the deallocator function for removed item (if any)
|
||||
*
|
||||
* Find the userdata specified by the (name, name2, name3) tuple and remove
|
||||
* it from the hash table. Existing userdata for this tuple will be removed
|
||||
* and freed with @f.
|
||||
*
|
||||
* Returns 0 if the removal succeeded and -1 in case of error or not found.
|
||||
*/
|
||||
int xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3,
|
||||
xmlHashDeallocator f) {
|
||||
unsigned long key;
|
||||
xmlHashEntryPtr entry;
|
||||
xmlHashEntryPtr prev = NULL;
|
||||
|
||||
if (table == NULL || name == NULL)
|
||||
return(-1);
|
||||
|
||||
key = xmlHashComputeKey(table, name);
|
||||
if (table->table[key] == NULL) {
|
||||
return(-1);
|
||||
} else {
|
||||
for (entry = table->table[key]; entry != NULL; entry = entry->next) {
|
||||
if (xmlStrEqual(entry->name, name) &&
|
||||
xmlStrEqual(entry->name2, name2) &&
|
||||
xmlStrEqual(entry->name3, name3)) {
|
||||
if(f)
|
||||
f(entry->payload, entry->name);
|
||||
entry->payload = NULL;
|
||||
if(entry->name)
|
||||
xmlFree(entry->name);
|
||||
if(entry->name2)
|
||||
xmlFree(entry->name2);
|
||||
if(entry->name3)
|
||||
xmlFree(entry->name3);
|
||||
if(prev)
|
||||
prev->next = entry->next;
|
||||
else
|
||||
table->table[key] = entry->next;
|
||||
xmlFree(entry);
|
||||
table->nbElems--;
|
||||
return(0);
|
||||
}
|
||||
prev = entry;
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
}
|
129
hash.h
Normal file
129
hash.h
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* hash.c: chained hash tables
|
||||
*
|
||||
* Copyright (C) 2000 Bjorn Reese and Daniel Veillard.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
|
||||
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
|
||||
*
|
||||
* Author: bjorn.reese@systematic.dk
|
||||
*/
|
||||
|
||||
#ifndef __XML_HASH_H__
|
||||
#define __XML_HASH_H__
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The hash table
|
||||
*/
|
||||
typedef struct _xmlHashTable xmlHashTable;
|
||||
typedef xmlHashTable *xmlHashTablePtr;
|
||||
|
||||
/*
|
||||
* function types:
|
||||
*/
|
||||
typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
|
||||
typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
|
||||
typedef void *(*xmlHashScanner)(void *payload, void *data, xmlChar *name);
|
||||
|
||||
/*
|
||||
* Constructor and destructor
|
||||
*/
|
||||
xmlHashTablePtr xmlHashCreate (int size);
|
||||
void xmlHashFree (xmlHashTablePtr table,
|
||||
xmlHashDeallocator f);
|
||||
|
||||
/*
|
||||
* Add a new entry to the hash table
|
||||
*/
|
||||
int xmlHashAddEntry (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
void *userdata);
|
||||
int xmlHashUpdateEntry(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
int xmlHashAddEntry2(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
void *userdata);
|
||||
int xmlHashUpdateEntry2(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
int xmlHashAddEntry3(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
void *userdata);
|
||||
int xmlHashUpdateEntry3(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
|
||||
/*
|
||||
* Remove an entry from the hash table
|
||||
*/
|
||||
int xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
|
||||
xmlHashDeallocator f);
|
||||
int xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, xmlHashDeallocator f);
|
||||
int xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3,
|
||||
xmlHashDeallocator f);
|
||||
|
||||
/*
|
||||
* Retrieve the userdata
|
||||
*/
|
||||
void * xmlHashLookup (xmlHashTablePtr table,
|
||||
const xmlChar *name);
|
||||
void * xmlHashLookup2 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2);
|
||||
void * xmlHashLookup3 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3);
|
||||
|
||||
/*
|
||||
* Helpers
|
||||
*/
|
||||
xmlHashTablePtr xmlHashCopy (xmlHashTablePtr table,
|
||||
xmlHashCopier f);
|
||||
int xmlHashSize (xmlHashTablePtr);
|
||||
void xmlHashScan (xmlHashTablePtr table,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
void xmlHashScan1 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
void xmlHashScan2 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
void xmlHashScan3 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! __XML_HASH_H__ */
|
1
include/.cvsignore
Normal file
1
include/.cvsignore
Normal file
@ -0,0 +1 @@
|
||||
Makefile.in
|
33
include/Makefile.am
Normal file
33
include/Makefile.am
Normal file
@ -0,0 +1,33 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
xmlincdir = $(includedir)
|
||||
|
||||
xmlinc_HEADERS = \
|
||||
libxml/SAX.h \
|
||||
libxml/entities.h \
|
||||
libxml/encoding.h \
|
||||
libxml/parser.h \
|
||||
libxml/parserInternals.h \
|
||||
libxml/xmlerror.h \
|
||||
libxml/HTMLparser.h \
|
||||
libxml/HTMLtree.h \
|
||||
libxml/debugXML.h \
|
||||
libxml/tree.h \
|
||||
libxml/hash.h \
|
||||
libxml/xpath.h \
|
||||
libxml/xpathInternals.h \
|
||||
libxml/xpointer.h \
|
||||
libxml/xinclude.h \
|
||||
libxml/xmlIO.h \
|
||||
libxml/xmlmemory.h \
|
||||
libxml/nanohttp.h \
|
||||
libxml/nanoftp.h \
|
||||
libxml/uri.h \
|
||||
libxml/valid.h \
|
||||
libxml/xlink.h \
|
||||
libxml/xmlversion.h
|
||||
|
||||
install-exec-hook:
|
||||
$(mkinstalldirs) $(DESTDIR)$(xmlincdir) $(DESTDIR)$(xmlincdir)/libxml
|
||||
|
||||
EXTRA_DIST = win32config.h libxml/xmlversion.h.in
|
115
include/libxml/HTMLparser.h
Normal file
115
include/libxml/HTMLparser.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* HTMLparser.h : inf=terface for an HTML 4.0 non-verifying parser
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __HTML_PARSER_H__
|
||||
#define __HTML_PARSER_H__
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Most of the back-end structures from XML and HTML are shared
|
||||
*/
|
||||
typedef xmlParserCtxt htmlParserCtxt;
|
||||
typedef xmlParserCtxtPtr htmlParserCtxtPtr;
|
||||
typedef xmlParserNodeInfo htmlParserNodeInfo;
|
||||
typedef xmlSAXHandler htmlSAXHandler;
|
||||
typedef xmlSAXHandlerPtr htmlSAXHandlerPtr;
|
||||
typedef xmlParserInput htmlParserInput;
|
||||
typedef xmlParserInputPtr htmlParserInputPtr;
|
||||
typedef xmlDocPtr htmlDocPtr;
|
||||
typedef xmlNodePtr htmlNodePtr;
|
||||
|
||||
/*
|
||||
* Internal description of an HTML element
|
||||
*/
|
||||
typedef struct _htmlElemDesc htmlElemDesc;
|
||||
typedef htmlElemDesc *htmlElemDescPtr;
|
||||
struct _htmlElemDesc {
|
||||
const char *name; /* The tag name */
|
||||
char startTag; /* Whether the start tag can be implied */
|
||||
char endTag; /* Whether the end tag can be implied */
|
||||
char saveEndTag; /* Whether the end tag should be saved */
|
||||
char empty; /* Is this an empty element ? */
|
||||
char depr; /* Is this a deprecated element ? */
|
||||
char dtd; /* 1: only in Loose DTD, 2: only Frameset one */
|
||||
const char *desc; /* the description */
|
||||
};
|
||||
|
||||
/*
|
||||
* Internal description of an HTML entity
|
||||
*/
|
||||
typedef struct _htmlEntityDesc htmlEntityDesc;
|
||||
typedef htmlEntityDesc *htmlEntityDescPtr;
|
||||
struct _htmlEntityDesc {
|
||||
int value; /* the UNICODE value for the character */
|
||||
const char *name; /* The entity name */
|
||||
const char *desc; /* the description */
|
||||
};
|
||||
|
||||
/*
|
||||
* There is only few public functions.
|
||||
*/
|
||||
htmlElemDescPtr htmlTagLookup (const xmlChar *tag);
|
||||
htmlEntityDescPtr htmlEntityLookup(const xmlChar *name);
|
||||
htmlEntityDescPtr htmlEntityValueLookup(int value);
|
||||
|
||||
int htmlIsAutoClosed(htmlDocPtr doc,
|
||||
htmlNodePtr elem);
|
||||
int htmlAutoCloseTag(htmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
htmlNodePtr elem);
|
||||
htmlEntityDescPtr htmlParseEntityRef(htmlParserCtxtPtr ctxt,
|
||||
xmlChar **str);
|
||||
int htmlParseCharRef(htmlParserCtxtPtr ctxt);
|
||||
void htmlParseElement(htmlParserCtxtPtr ctxt);
|
||||
|
||||
htmlDocPtr htmlSAXParseDoc (xmlChar *cur,
|
||||
const char *encoding,
|
||||
htmlSAXHandlerPtr sax,
|
||||
void *userData);
|
||||
htmlDocPtr htmlParseDoc (xmlChar *cur,
|
||||
const char *encoding);
|
||||
htmlDocPtr htmlSAXParseFile(const char *filename,
|
||||
const char *encoding,
|
||||
htmlSAXHandlerPtr sax,
|
||||
void *userData);
|
||||
htmlDocPtr htmlParseFile (const char *filename,
|
||||
const char *encoding);
|
||||
int UTF8ToHtml (unsigned char* out,
|
||||
int *outlen,
|
||||
const unsigned char* in,
|
||||
int *inlen);
|
||||
int htmlEncodeEntities(unsigned char* out,
|
||||
int *outlen,
|
||||
const unsigned char* in,
|
||||
int *inlen, int quoteChar);
|
||||
int htmlIsScriptAttribute(const xmlChar *name);
|
||||
int htmlHandleOmittedElem(int val);
|
||||
|
||||
/**
|
||||
* Interfaces for the Push mode
|
||||
*/
|
||||
void htmlFreeParserCtxt (htmlParserCtxtPtr ctxt);
|
||||
htmlParserCtxtPtr htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
const char *chunk,
|
||||
int size,
|
||||
const char *filename,
|
||||
xmlCharEncoding enc);
|
||||
int htmlParseChunk (htmlParserCtxtPtr ctxt,
|
||||
const char *chunk,
|
||||
int size,
|
||||
int terminate);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __HTML_PARSER_H__ */
|
61
include/libxml/HTMLtree.h
Normal file
61
include/libxml/HTMLtree.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* tree.h : describes the structures found in an tree resulting
|
||||
* from an XML parsing.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __HTML_TREE_H__
|
||||
#define __HTML_TREE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/HTMLparser.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HTML_TEXT_NODE XML_TEXT_NODE
|
||||
#define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE
|
||||
#define HTML_COMMENT_NODE XML_COMMENT_NODE
|
||||
#define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE
|
||||
|
||||
htmlDocPtr htmlNewDoc (const xmlChar *URI,
|
||||
const xmlChar *ExternalID);
|
||||
htmlDocPtr htmlNewDocNoDtD (const xmlChar *URI,
|
||||
const xmlChar *ExternalID);
|
||||
const xmlChar * htmlGetMetaEncoding (htmlDocPtr doc);
|
||||
int htmlSetMetaEncoding (htmlDocPtr doc,
|
||||
const xmlChar *encoding);
|
||||
void htmlDocDumpMemory (xmlDocPtr cur,
|
||||
xmlChar**mem,
|
||||
int *size);
|
||||
int htmlDocDump (FILE *f,
|
||||
xmlDocPtr cur);
|
||||
int htmlSaveFile (const char *filename,
|
||||
xmlDocPtr cur);
|
||||
void htmlNodeDump (xmlBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
void htmlNodeDumpFile (FILE *out,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
int htmlSaveFileEnc (const char *filename,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
|
||||
/* This one is imported from xmlIO.h
|
||||
void htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __HTML_TREE_H__ */
|
||||
|
120
include/libxml/SAX.h
Normal file
120
include/libxml/SAX.h
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* SAX.h : Default SAX handler interfaces.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_SAX_H__
|
||||
#define __XML_SAX_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
const xmlChar * getPublicId (void *ctx);
|
||||
const xmlChar * getSystemId (void *ctx);
|
||||
void setDocumentLocator (void *ctx,
|
||||
xmlSAXLocatorPtr loc);
|
||||
|
||||
int getLineNumber (void *ctx);
|
||||
int getColumnNumber (void *ctx);
|
||||
|
||||
int isStandalone (void *ctx);
|
||||
int hasInternalSubset (void *ctx);
|
||||
int hasExternalSubset (void *ctx);
|
||||
|
||||
void internalSubset (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
void externalSubset (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlEntityPtr getEntity (void *ctx,
|
||||
const xmlChar *name);
|
||||
xmlEntityPtr getParameterEntity (void *ctx,
|
||||
const xmlChar *name);
|
||||
xmlParserInputPtr resolveEntity (void *ctx,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId);
|
||||
|
||||
void entityDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId,
|
||||
xmlChar *content);
|
||||
void attributeDecl (void *ctx,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
int def,
|
||||
const xmlChar *defaultValue,
|
||||
xmlEnumerationPtr tree);
|
||||
void elementDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
xmlElementContentPtr content);
|
||||
void notationDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId);
|
||||
void unparsedEntityDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId,
|
||||
const xmlChar *notationName);
|
||||
|
||||
void startDocument (void *ctx);
|
||||
void endDocument (void *ctx);
|
||||
void attribute (void *ctx,
|
||||
const xmlChar *fullname,
|
||||
const xmlChar *value);
|
||||
void startElement (void *ctx,
|
||||
const xmlChar *fullname,
|
||||
const xmlChar **atts);
|
||||
void endElement (void *ctx,
|
||||
const xmlChar *name);
|
||||
void reference (void *ctx,
|
||||
const xmlChar *name);
|
||||
void characters (void *ctx,
|
||||
const xmlChar *ch,
|
||||
int len);
|
||||
void ignorableWhitespace (void *ctx,
|
||||
const xmlChar *ch,
|
||||
int len);
|
||||
void processingInstruction (void *ctx,
|
||||
const xmlChar *target,
|
||||
const xmlChar *data);
|
||||
void globalNamespace (void *ctx,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
void setNamespace (void *ctx,
|
||||
const xmlChar *name);
|
||||
xmlNsPtr getNamespace (void *ctx);
|
||||
int checkNamespace (void *ctx,
|
||||
xmlChar *nameSpace);
|
||||
void namespaceDecl (void *ctx,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
void comment (void *ctx,
|
||||
const xmlChar *value);
|
||||
void cdataBlock (void *ctx,
|
||||
const xmlChar *value,
|
||||
int len);
|
||||
|
||||
void xmlDefaultSAXHandlerInit (void);
|
||||
void htmlDefaultSAXHandlerInit (void);
|
||||
void sgmlDefaultSAXHandlerInit (void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_SAX_H__ */
|
113
include/libxml/debugXML.h
Normal file
113
include/libxml/debugXML.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* debugXML.h : Interfaces to a set of routines used for debugging the tree
|
||||
* produced by the XML parser.
|
||||
*
|
||||
* Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
*/
|
||||
|
||||
#ifndef __DEBUG_XML__
|
||||
#define __DEBUG_XML__
|
||||
#include <stdio.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The standard Dump routines
|
||||
*/
|
||||
void xmlDebugDumpString (FILE *output,
|
||||
const xmlChar *str);
|
||||
void xmlDebugDumpAttr (FILE *output,
|
||||
xmlAttrPtr attr,
|
||||
int depth);
|
||||
void xmlDebugDumpAttrList (FILE *output,
|
||||
xmlAttrPtr attr,
|
||||
int depth);
|
||||
void xmlDebugDumpOneNode (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
void xmlDebugDumpNode (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
void xmlDebugDumpNodeList (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
void xmlDebugDumpDocumentHead(FILE *output,
|
||||
xmlDocPtr doc);
|
||||
void xmlDebugDumpDocument (FILE *output,
|
||||
xmlDocPtr doc);
|
||||
void xmlDebugDumpDTD (FILE *output,
|
||||
xmlDtdPtr doc);
|
||||
void xmlDebugDumpEntities (FILE *output,
|
||||
xmlDocPtr doc);
|
||||
void xmlLsOneNode (FILE *output,
|
||||
xmlNodePtr node);
|
||||
|
||||
/****************************************************************
|
||||
* *
|
||||
* The XML shell related structures and functions *
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
/**
|
||||
* xmlShellReadlineFunc:
|
||||
* @prompt: a string prompt
|
||||
*
|
||||
* This is a generic signature for the XML shell input function
|
||||
*
|
||||
* Returns a string which will be freed by the Shell
|
||||
*/
|
||||
typedef char * (* xmlShellReadlineFunc)(char *prompt);
|
||||
|
||||
/*
|
||||
* The shell context itself
|
||||
* TODO: add the defined function tables.
|
||||
*/
|
||||
typedef struct _xmlShellCtxt xmlShellCtxt;
|
||||
typedef xmlShellCtxt *xmlShellCtxtPtr;
|
||||
struct _xmlShellCtxt {
|
||||
char *filename;
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr node;
|
||||
xmlXPathContextPtr pctxt;
|
||||
int loaded;
|
||||
FILE *output;
|
||||
xmlShellReadlineFunc input;
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlShellCmd:
|
||||
* @ctxt: a shell context
|
||||
* @arg: a string argument
|
||||
* @node: a first node
|
||||
* @node2: a second node
|
||||
*
|
||||
* This is a generic signature for the XML shell functions
|
||||
*
|
||||
* Returns an int, negative returns indicating errors
|
||||
*/
|
||||
typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,
|
||||
char *arg,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
|
||||
/*
|
||||
* The Shell interface.
|
||||
*/
|
||||
void xmlShell (xmlDocPtr doc,
|
||||
char *filename,
|
||||
xmlShellReadlineFunc input,
|
||||
FILE *output);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_DEBUG_ENABLED */
|
||||
#endif /* __DEBUG_XML__ */
|
187
include/libxml/encoding.h
Normal file
187
include/libxml/encoding.h
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* encoding.h : interface for the encoding conversion functions needed for
|
||||
* XML
|
||||
*
|
||||
* Related specs:
|
||||
* rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies
|
||||
* [ISO-10646] UTF-8 and UTF-16 in Annexes
|
||||
* [ISO-8859-1] ISO Latin-1 characters codes.
|
||||
* [UNICODE] The Unicode Consortium, "The Unicode Standard --
|
||||
* Worldwide Character Encoding -- Version 1.0", Addison-
|
||||
* Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is
|
||||
* described in Unicode Technical Report #4.
|
||||
* [US-ASCII] Coded Character Set--7-bit American Standard Code for
|
||||
* Information Interchange, ANSI X3.4-1986.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_CHAR_ENCODING_H__
|
||||
#define __XML_CHAR_ENCODING_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#ifdef LIBXML_ICONV_ENABLED
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Predefined values for some standard encodings
|
||||
* Libxml don't do beforehand translation on UTF8, ISOLatinX
|
||||
* It also support UTF16 (LE and BE) by default.
|
||||
*
|
||||
* Anything else would have to be translated to UTF8 before being
|
||||
* given to the parser itself. The BOM for UTF16 and the encoding
|
||||
* declaration are looked at and a converter is looked for at that
|
||||
* point. If not found the parser stops here as asked by the XML REC
|
||||
* Converter can be registered by the user using xmlRegisterCharEncodingHandler
|
||||
* but the currentl form doesn't allow stateful transcoding (a serious
|
||||
* problem agreed !). If iconv has been found it will be used
|
||||
* automatically and allow stateful transcoding, the simplest is then
|
||||
* to be sure to enable icon and to provide iconv libs for the encoding
|
||||
* support needed.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
|
||||
XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
|
||||
XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
|
||||
XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
|
||||
XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
|
||||
XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
|
||||
XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
|
||||
XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
|
||||
XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
|
||||
XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
|
||||
XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
|
||||
XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
|
||||
XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
|
||||
XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
|
||||
XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
|
||||
XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
|
||||
XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
|
||||
XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
|
||||
XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
|
||||
XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
|
||||
XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
|
||||
XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
|
||||
XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
|
||||
XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
|
||||
} xmlCharEncoding;
|
||||
|
||||
/**
|
||||
* xmlCharEncodingInputFunc:
|
||||
* @out: a pointer ot an array of bytes to store the UTF-8 result
|
||||
* @outlen: the lenght of @out
|
||||
* @in: a pointer ot an array of chars in the original encoding
|
||||
* @inlen: the lenght of @in
|
||||
*
|
||||
* Take a block of chars in the original encoding and try to convert
|
||||
* it to an UTF-8 block of chars out.
|
||||
*
|
||||
* Returns the number of byte written, or -1 by lack of space, or -2
|
||||
* if the transcoding failed.
|
||||
* The value of @inlen after return is the number of octets consumed
|
||||
* as the return value is positive, else unpredictiable.
|
||||
* The value of @outlen after return is the number of ocetes consumed.
|
||||
*/
|
||||
typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int *outlen,
|
||||
const unsigned char* in, int *inlen);
|
||||
|
||||
|
||||
/**
|
||||
* xmlCharEncodingOutputFunc:
|
||||
* @out: a pointer ot an array of bytes to store the result
|
||||
* @outlen: the lenght of @out
|
||||
* @in: a pointer ot an array of UTF-8 chars
|
||||
* @inlen: the lenght of @in
|
||||
*
|
||||
* Take a block of UTF-8 chars in and try to convert it to an other
|
||||
* encoding.
|
||||
* Note: a first call designed to produce heading info is called with
|
||||
* in = NULL. If stateful this should also initialize the encoder state
|
||||
*
|
||||
* Returns the number of byte written, or -1 by lack of space, or -2
|
||||
* if the transcoding failed.
|
||||
* The value of @inlen after return is the number of octets consumed
|
||||
* as the return value is positive, else unpredictiable.
|
||||
* The value of @outlen after return is the number of ocetes consumed.
|
||||
*/
|
||||
typedef int (* xmlCharEncodingOutputFunc)(unsigned char* out, int *outlen,
|
||||
const unsigned char* in, int *inlen);
|
||||
|
||||
|
||||
/*
|
||||
* Block defining the handlers for non UTF-8 encodings.
|
||||
* If iconv is supported, there is two extra fields
|
||||
*/
|
||||
|
||||
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
|
||||
typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
|
||||
struct _xmlCharEncodingHandler {
|
||||
char *name;
|
||||
xmlCharEncodingInputFunc input;
|
||||
xmlCharEncodingOutputFunc output;
|
||||
#ifdef LIBXML_ICONV_ENABLED
|
||||
iconv_t iconv_in;
|
||||
iconv_t iconv_out;
|
||||
#endif /* LIBXML_ICONV_ENABLED */
|
||||
};
|
||||
|
||||
/*
|
||||
* Interfaces for encoding handlers
|
||||
*/
|
||||
void xmlInitCharEncodingHandlers (void);
|
||||
void xmlCleanupCharEncodingHandlers (void);
|
||||
void xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
|
||||
xmlCharEncodingHandlerPtr
|
||||
xmlGetCharEncodingHandler (xmlCharEncoding enc);
|
||||
xmlCharEncodingHandlerPtr
|
||||
xmlFindCharEncodingHandler (const char *name);
|
||||
|
||||
|
||||
/*
|
||||
* Interfaces for encoding names and aliases
|
||||
*/
|
||||
int xmlAddEncodingAlias (const char *name,
|
||||
const char *alias);
|
||||
int xmlDelEncodingAlias (const char *alias);
|
||||
const char *
|
||||
xmlGetEncodingAlias (const char *alias);
|
||||
void xmlCleanupEncodingAliases (void);
|
||||
xmlCharEncoding
|
||||
xmlParseCharEncoding (const char* name);
|
||||
const char*
|
||||
xmlGetCharEncodingName (xmlCharEncoding enc);
|
||||
|
||||
/*
|
||||
* Interfaces directly used by the parsers.
|
||||
*/
|
||||
xmlCharEncoding
|
||||
xmlDetectCharEncoding (const unsigned char* in,
|
||||
int len);
|
||||
|
||||
int xmlCheckUTF8 (const unsigned char *utf);
|
||||
|
||||
int xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
|
||||
int xmlCharEncInFunc (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
int xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_CHAR_ENCODING_H__ */
|
114
include/libxml/entities.h
Normal file
114
include/libxml/entities.h
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* entities.h : interface for the XML entities handking
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_ENTITIES_H__
|
||||
#define __XML_ENTITIES_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The different valid entity types
|
||||
*/
|
||||
typedef enum {
|
||||
XML_INTERNAL_GENERAL_ENTITY = 1,
|
||||
XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
|
||||
XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
|
||||
XML_INTERNAL_PARAMETER_ENTITY = 4,
|
||||
XML_EXTERNAL_PARAMETER_ENTITY = 5,
|
||||
XML_INTERNAL_PREDEFINED_ENTITY = 6
|
||||
} xmlEntityType;
|
||||
|
||||
/*
|
||||
* An unit of storage for an entity, contains the string, the value
|
||||
* and the linkind data needed for the linking in the hash table.
|
||||
*/
|
||||
|
||||
typedef struct _xmlEntity xmlEntity;
|
||||
typedef xmlEntity *xmlEntityPtr;
|
||||
struct _xmlEntity {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
|
||||
const xmlChar *name; /* Attribute name */
|
||||
struct _xmlNode *children; /* NULL */
|
||||
struct _xmlNode *last; /* NULL */
|
||||
struct _xmlDtd *parent; /* -> DTD */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
xmlChar *orig; /* content without ref substitution */
|
||||
xmlChar *content; /* content or ndata if unparsed */
|
||||
int length; /* the content length */
|
||||
xmlEntityType etype; /* The entity type */
|
||||
const xmlChar *ExternalID; /* External identifier for PUBLIC */
|
||||
const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
|
||||
|
||||
struct _xmlEntity *nexte; /* unused */
|
||||
const xmlChar *URI; /* the full URI as computed */
|
||||
};
|
||||
|
||||
/*
|
||||
* ALl entities are stored in an hash table
|
||||
* there is 2 separate hash tables for global and parmeter entities
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlEntitiesTable;
|
||||
typedef xmlEntitiesTable *xmlEntitiesTablePtr;
|
||||
|
||||
/*
|
||||
* External functions :
|
||||
*/
|
||||
|
||||
void xmlInitializePredefinedEntities (void);
|
||||
xmlEntityPtr xmlAddDocEntity (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID,
|
||||
const xmlChar *content);
|
||||
xmlEntityPtr xmlAddDtdEntity (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID,
|
||||
const xmlChar *content);
|
||||
xmlEntityPtr xmlGetPredefinedEntity (const xmlChar *name);
|
||||
xmlEntityPtr xmlGetDocEntity (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlEntityPtr xmlGetDtdEntity (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlEntityPtr xmlGetParameterEntity (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
const xmlChar * xmlEncodeEntities (xmlDocPtr doc,
|
||||
const xmlChar *input);
|
||||
xmlChar * xmlEncodeEntitiesReentrant(xmlDocPtr doc,
|
||||
const xmlChar *input);
|
||||
xmlChar * xmlEncodeSpecialChars (xmlDocPtr doc,
|
||||
const xmlChar *input);
|
||||
xmlEntitiesTablePtr xmlCreateEntitiesTable (void);
|
||||
xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
|
||||
void xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
|
||||
void xmlDumpEntitiesTable (xmlBufferPtr buf,
|
||||
xmlEntitiesTablePtr table);
|
||||
void xmlDumpEntityDecl (xmlBufferPtr buf,
|
||||
xmlEntityPtr ent);
|
||||
xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
|
||||
void xmlCleanupPredefinedEntities(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
# endif /* __XML_ENTITIES_H__ */
|
129
include/libxml/hash.h
Normal file
129
include/libxml/hash.h
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* hash.c: chained hash tables
|
||||
*
|
||||
* Copyright (C) 2000 Bjorn Reese and Daniel Veillard.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
|
||||
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
|
||||
*
|
||||
* Author: bjorn.reese@systematic.dk
|
||||
*/
|
||||
|
||||
#ifndef __XML_HASH_H__
|
||||
#define __XML_HASH_H__
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The hash table
|
||||
*/
|
||||
typedef struct _xmlHashTable xmlHashTable;
|
||||
typedef xmlHashTable *xmlHashTablePtr;
|
||||
|
||||
/*
|
||||
* function types:
|
||||
*/
|
||||
typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
|
||||
typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
|
||||
typedef void *(*xmlHashScanner)(void *payload, void *data, xmlChar *name);
|
||||
|
||||
/*
|
||||
* Constructor and destructor
|
||||
*/
|
||||
xmlHashTablePtr xmlHashCreate (int size);
|
||||
void xmlHashFree (xmlHashTablePtr table,
|
||||
xmlHashDeallocator f);
|
||||
|
||||
/*
|
||||
* Add a new entry to the hash table
|
||||
*/
|
||||
int xmlHashAddEntry (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
void *userdata);
|
||||
int xmlHashUpdateEntry(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
int xmlHashAddEntry2(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
void *userdata);
|
||||
int xmlHashUpdateEntry2(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
int xmlHashAddEntry3(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
void *userdata);
|
||||
int xmlHashUpdateEntry3(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
|
||||
/*
|
||||
* Remove an entry from the hash table
|
||||
*/
|
||||
int xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
|
||||
xmlHashDeallocator f);
|
||||
int xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, xmlHashDeallocator f);
|
||||
int xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3,
|
||||
xmlHashDeallocator f);
|
||||
|
||||
/*
|
||||
* Retrieve the userdata
|
||||
*/
|
||||
void * xmlHashLookup (xmlHashTablePtr table,
|
||||
const xmlChar *name);
|
||||
void * xmlHashLookup2 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2);
|
||||
void * xmlHashLookup3 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3);
|
||||
|
||||
/*
|
||||
* Helpers
|
||||
*/
|
||||
xmlHashTablePtr xmlHashCopy (xmlHashTablePtr table,
|
||||
xmlHashCopier f);
|
||||
int xmlHashSize (xmlHashTablePtr);
|
||||
void xmlHashScan (xmlHashTablePtr table,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
void xmlHashScan1 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
void xmlHashScan2 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
void xmlHashScan3 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! __XML_HASH_H__ */
|
81
include/libxml/list.h
Normal file
81
include/libxml/list.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* list.h: lists interfaces
|
||||
*
|
||||
* Copyright (C) 2000 Gary Pennington and Daniel Veillard.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
|
||||
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
|
||||
*
|
||||
* Author: Gary.Pennington@uk.sun.com
|
||||
*/
|
||||
|
||||
typedef struct _xmlLink xmlLink;
|
||||
typedef xmlLink *xmlLinkPtr;
|
||||
|
||||
typedef struct _xmlList xmlList;
|
||||
typedef xmlList *xmlListPtr;
|
||||
|
||||
typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
|
||||
typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
|
||||
typedef int (*xmlListWalker) (const void *data, const void *user);
|
||||
|
||||
/* Creation/Deletion */
|
||||
xmlListPtr xmlListCreate (xmlListDeallocator deallocator,
|
||||
xmlListDataCompare compare);
|
||||
void xmlListDelete (xmlListPtr l);
|
||||
|
||||
/* Basic Operators */
|
||||
void * xmlListSearch (xmlListPtr l,
|
||||
void *data);
|
||||
void * xmlListReverseSearch (xmlListPtr l,
|
||||
void *data);
|
||||
int xmlListInsert (xmlListPtr l,
|
||||
void *data) ;
|
||||
int xmlListAppend (xmlListPtr l,
|
||||
void *data) ;
|
||||
int xmlListRemoveFirst (xmlListPtr l,
|
||||
void *data);
|
||||
int xmlListRemoveLast (xmlListPtr l,
|
||||
void *data);
|
||||
int xmlListRemoveAll (xmlListPtr l,
|
||||
void *data);
|
||||
void xmlListClear (xmlListPtr l);
|
||||
int xmlListEmpty (xmlListPtr l);
|
||||
xmlLinkPtr xmlListFront (xmlListPtr l);
|
||||
xmlLinkPtr xmlListEnd (xmlListPtr l);
|
||||
int xmlListSize (xmlListPtr l);
|
||||
|
||||
void xmlListPopFront (xmlListPtr l);
|
||||
void xmlListPopBack (xmlListPtr l);
|
||||
int xmlListPushFront (xmlListPtr l,
|
||||
void *data);
|
||||
int xmlListPushBack (xmlListPtr l,
|
||||
void *data);
|
||||
|
||||
/* Advanced Operators */
|
||||
void xmlListReverse (xmlListPtr l);
|
||||
void xmlListSort (xmlListPtr l);
|
||||
void xmlListWalk (xmlListPtr l,
|
||||
xmlListWalker walker,
|
||||
const void *user);
|
||||
void xmlListReverseWalk (xmlListPtr l,
|
||||
xmlListWalker walker,
|
||||
const void *user);
|
||||
void xmlListMerge (xmlListPtr l1,
|
||||
xmlListPtr l2);
|
||||
xmlListPtr xmlListDup (const xmlListPtr old);
|
||||
int xmlListCopy (xmlListPtr cur,
|
||||
const xmlListPtr old);
|
||||
/* Link operators */
|
||||
void * xmlLinkGetData (xmlLinkPtr lk);
|
||||
|
||||
/* xmlListUnique() */
|
||||
/* xmlListSwap */
|
||||
|
||||
|
110
include/libxml/nanoftp.h
Normal file
110
include/libxml/nanoftp.h
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* nanohttp.c: minimalist FTP implementation to fetch external subsets.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __NANO_FTP_H__
|
||||
#define __NANO_FTP_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#ifdef LIBXML_FTP_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ftpListCallback:
|
||||
* @userData: user provided data for the callback
|
||||
* @filename: the file name (including "->" when links are shown)
|
||||
* @attrib: the attribute string
|
||||
* @owner: the owner string
|
||||
* @group: the group string
|
||||
* @size: the file size
|
||||
* @links: the link count
|
||||
* @year: the year
|
||||
* @month: the month
|
||||
* @day: the day
|
||||
* @hour: the hour
|
||||
* @minute: the minute
|
||||
*
|
||||
* A callback for the xmlNanoFTPList command
|
||||
* Note that only one of year and day:minute are specified
|
||||
*/
|
||||
typedef void (*ftpListCallback) (void *userData,
|
||||
const char *filename, const char* attrib,
|
||||
const char *owner, const char *group,
|
||||
unsigned long size, int links, int year,
|
||||
const char *month, int day, int hour,
|
||||
int minute);
|
||||
/**
|
||||
* ftpDataCallback:
|
||||
* A callback for the xmlNanoFTPGet command
|
||||
*/
|
||||
typedef void (*ftpDataCallback) (void *userData, const char *data, int len);
|
||||
|
||||
/*
|
||||
* Init
|
||||
*/
|
||||
void xmlNanoFTPInit (void);
|
||||
void xmlNanoFTPCleanup (void);
|
||||
|
||||
/*
|
||||
* Creating/freeing contexts
|
||||
*/
|
||||
void * xmlNanoFTPNewCtxt (const char *URL);
|
||||
void xmlNanoFTPFreeCtxt (void * ctx);
|
||||
void * xmlNanoFTPConnectTo (const char *server,
|
||||
int port);
|
||||
/*
|
||||
* Opening/closing session connections
|
||||
*/
|
||||
void * xmlNanoFTPOpen (const char *URL);
|
||||
int xmlNanoFTPConnect (void *ctx);
|
||||
int xmlNanoFTPClose (void *ctx);
|
||||
int xmlNanoFTPQuit (void *ctx);
|
||||
void xmlNanoFTPScanProxy (const char *URL);
|
||||
void xmlNanoFTPProxy (const char *host,
|
||||
int port,
|
||||
const char *user,
|
||||
const char *passwd,
|
||||
int type);
|
||||
int xmlNanoFTPUpdateURL (void *ctx,
|
||||
const char *URL);
|
||||
|
||||
/*
|
||||
* Rathern internal commands
|
||||
*/
|
||||
int xmlNanoFTPGetResponse (void *ctx);
|
||||
int xmlNanoFTPCheckResponse (void *ctx);
|
||||
|
||||
/*
|
||||
* CD/DIR/GET handlers
|
||||
*/
|
||||
int xmlNanoFTPCwd (void *ctx,
|
||||
char *directory);
|
||||
|
||||
int xmlNanoFTPGetConnection (void *ctx);
|
||||
int xmlNanoFTPCloseConnection(void *ctx);
|
||||
int xmlNanoFTPList (void *ctx,
|
||||
ftpListCallback callback,
|
||||
void *userData,
|
||||
char *filename);
|
||||
int xmlNanoFTPGetSocket (void *ctx,
|
||||
const char *filename);
|
||||
int xmlNanoFTPGet (void *ctx,
|
||||
ftpDataCallback callback,
|
||||
void *userData,
|
||||
const char *filename);
|
||||
int xmlNanoFTPRead (void *ctx,
|
||||
void *dest,
|
||||
int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* LIBXML_FTP_ENABLED */
|
||||
#endif
|
||||
#endif /* __NANO_FTP_H__ */
|
44
include/libxml/nanohttp.h
Normal file
44
include/libxml/nanohttp.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* nanohttp.c: minimalist HTTP implementation to fetch external subsets.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __NANO_HTTP_H__
|
||||
#define __NANO_HTTP_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#ifdef LIBXML_HTTP_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void xmlNanoHTTPInit (void);
|
||||
void xmlNanoHTTPCleanup (void);
|
||||
void xmlNanoHTTPScanProxy (const char *URL);
|
||||
int xmlNanoHTTPFetch (const char *URL,
|
||||
const char *filename,
|
||||
char **contentType);
|
||||
void * xmlNanoHTTPMethod (const char *URL,
|
||||
const char *method,
|
||||
const char *input,
|
||||
char **contentType,
|
||||
const char *headers);
|
||||
void * xmlNanoHTTPOpen (const char *URL,
|
||||
char **contentType);
|
||||
int xmlNanoHTTPReturnCode (void *ctx);
|
||||
const char * xmlNanoHTTPAuthHeader(void *ctx);
|
||||
int xmlNanoHTTPRead (void *ctx,
|
||||
void *dest,
|
||||
int len);
|
||||
int xmlNanoHTTPSave (void *ctxt,
|
||||
const char *filename);
|
||||
void xmlNanoHTTPClose (void *ctx);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif /* LIBXML_HTTP_ENABLED */
|
||||
#endif
|
||||
#endif /* __NANO_HTTP_H__ */
|
527
include/libxml/parser.h
Normal file
527
include/libxml/parser.h
Normal file
@ -0,0 +1,527 @@
|
||||
/*
|
||||
* parser.h : Interfaces, constants and types related to the XML parser.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_PARSER_H__
|
||||
#define __XML_PARSER_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/entities.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Constants.
|
||||
*/
|
||||
#define XML_DEFAULT_VERSION "1.0"
|
||||
|
||||
/**
|
||||
* an xmlParserInput is an input flow for the XML processor.
|
||||
* Each entity parsed is associated an xmlParserInput (except the
|
||||
* few predefined ones). This is the case both for internal entities
|
||||
* - in which case the flow is already completely in memory - or
|
||||
* external entities - in which case we use the buf structure for
|
||||
* progressive reading and I18N conversions to the internal UTF-8 format.
|
||||
*/
|
||||
|
||||
typedef void (* xmlParserInputDeallocate)(xmlChar *);
|
||||
typedef struct _xmlParserInput xmlParserInput;
|
||||
typedef xmlParserInput *xmlParserInputPtr;
|
||||
struct _xmlParserInput {
|
||||
/* Input buffer */
|
||||
xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
|
||||
|
||||
const char *filename; /* The file analyzed, if any */
|
||||
const char *directory; /* the directory/base of teh file */
|
||||
const xmlChar *base; /* Base of the array to parse */
|
||||
const xmlChar *cur; /* Current char being parsed */
|
||||
int length; /* length if known */
|
||||
int line; /* Current line */
|
||||
int col; /* Current column */
|
||||
int consumed; /* How many xmlChars already consumed */
|
||||
xmlParserInputDeallocate free; /* function to deallocate the base */
|
||||
const xmlChar *encoding; /* the encoding string for entity */
|
||||
const xmlChar *version; /* the version string for entity */
|
||||
int standalone; /* Was that entity marked standalone */
|
||||
};
|
||||
|
||||
/**
|
||||
* the parser can be asked to collect Node informations, i.e. at what
|
||||
* place in the file they were detected.
|
||||
* NOTE: This is off by default and not very well tested.
|
||||
*/
|
||||
typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
|
||||
typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
|
||||
|
||||
struct _xmlParserNodeInfo {
|
||||
const struct _xmlNode* node;
|
||||
/* Position & line # that text that created the node begins & ends on */
|
||||
unsigned long begin_pos;
|
||||
unsigned long begin_line;
|
||||
unsigned long end_pos;
|
||||
unsigned long end_line;
|
||||
};
|
||||
|
||||
typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
|
||||
typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
|
||||
struct _xmlParserNodeInfoSeq {
|
||||
unsigned long maximum;
|
||||
unsigned long length;
|
||||
xmlParserNodeInfo* buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* The parser is now working also as a state based parser
|
||||
* The recursive one use the stagte info for entities processing
|
||||
*/
|
||||
typedef enum {
|
||||
XML_PARSER_EOF = -1, /* nothing is to be parsed */
|
||||
XML_PARSER_START = 0, /* nothing has been parsed */
|
||||
XML_PARSER_MISC, /* Misc* before int subset */
|
||||
XML_PARSER_PI, /* Whithin a processing instruction */
|
||||
XML_PARSER_DTD, /* within some DTD content */
|
||||
XML_PARSER_PROLOG, /* Misc* after internal subset */
|
||||
XML_PARSER_COMMENT, /* within a comment */
|
||||
XML_PARSER_START_TAG, /* within a start tag */
|
||||
XML_PARSER_CONTENT, /* within the content */
|
||||
XML_PARSER_CDATA_SECTION, /* within a CDATA section */
|
||||
XML_PARSER_END_TAG, /* within a closing tag */
|
||||
XML_PARSER_ENTITY_DECL, /* within an entity declaration */
|
||||
XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
|
||||
XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
|
||||
XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
|
||||
XML_PARSER_EPILOG, /* the Misc* after the last end tag */
|
||||
XML_PARSER_IGNORE /* within an IGNORED section */
|
||||
} xmlParserInputState;
|
||||
|
||||
/**
|
||||
* The parser context.
|
||||
* NOTE This doesn't completely defines the parser state, the (current ?)
|
||||
* design of the parser uses recursive function calls since this allow
|
||||
* and easy mapping from the production rules of the specification
|
||||
* to the actual code. The drawback is that the actual function call
|
||||
* also reflect the parser state. However most of the parsing routines
|
||||
* takes as the only argument the parser context pointer, so migrating
|
||||
* to a state based parser for progressive parsing shouldn't be too hard.
|
||||
*/
|
||||
typedef struct _xmlParserCtxt xmlParserCtxt;
|
||||
typedef xmlParserCtxt *xmlParserCtxtPtr;
|
||||
struct _xmlParserCtxt {
|
||||
struct _xmlSAXHandler *sax; /* The SAX handler */
|
||||
void *userData; /* For SAX interface only, used by DOM build */
|
||||
xmlDocPtr myDoc; /* the document being built */
|
||||
int wellFormed; /* is the document well formed */
|
||||
int replaceEntities; /* shall we replace entities ? */
|
||||
const xmlChar *version; /* the XML version string */
|
||||
const xmlChar *encoding; /* the declared encoding, if any */
|
||||
int standalone; /* standalone document */
|
||||
int html; /* an HTML(1)/Docbook(2) document */
|
||||
|
||||
/* Input stream stack */
|
||||
xmlParserInputPtr input; /* Current input stream */
|
||||
int inputNr; /* Number of current input streams */
|
||||
int inputMax; /* Max number of input streams */
|
||||
xmlParserInputPtr *inputTab; /* stack of inputs */
|
||||
|
||||
/* Node analysis stack only used for DOM building */
|
||||
xmlNodePtr node; /* Current parsed Node */
|
||||
int nodeNr; /* Depth of the parsing stack */
|
||||
int nodeMax; /* Max depth of the parsing stack */
|
||||
xmlNodePtr *nodeTab; /* array of nodes */
|
||||
|
||||
int record_info; /* Whether node info should be kept */
|
||||
xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
|
||||
|
||||
int errNo; /* error code */
|
||||
|
||||
int hasExternalSubset; /* reference and external subset */
|
||||
int hasPErefs; /* the internal subset has PE refs */
|
||||
int external; /* are we parsing an external entity */
|
||||
|
||||
int valid; /* is the document valid */
|
||||
int validate; /* shall we try to validate ? */
|
||||
xmlValidCtxt vctxt; /* The validity context */
|
||||
|
||||
xmlParserInputState instate; /* current type of input */
|
||||
int token; /* next char look-ahead */
|
||||
|
||||
char *directory; /* the data directory */
|
||||
|
||||
/* Node name stack */
|
||||
xmlChar *name; /* Current parsed Node */
|
||||
int nameNr; /* Depth of the parsing stack */
|
||||
int nameMax; /* Max depth of the parsing stack */
|
||||
xmlChar * *nameTab; /* array of nodes */
|
||||
|
||||
long nbChars; /* number of xmlChar processed */
|
||||
long checkIndex; /* used by progressive parsing lookup */
|
||||
int keepBlanks; /* ugly but ... */
|
||||
int disableSAX; /* SAX callbacks are disabled */
|
||||
int inSubset; /* Parsing is in int 1/ext 2 subset */
|
||||
xmlChar * intSubName; /* name of subset */
|
||||
xmlChar * extSubURI; /* URI of external subset */
|
||||
xmlChar * extSubSystem; /* SYSTEM ID of external subset */
|
||||
|
||||
/* xml:space values */
|
||||
int * space; /* Should the parser preserve spaces */
|
||||
int spaceNr; /* Depth of the parsing stack */
|
||||
int spaceMax; /* Max depth of the parsing stack */
|
||||
int * spaceTab; /* array of space infos */
|
||||
|
||||
int depth; /* to prevent entity substitution loops */
|
||||
xmlParserInputPtr entity; /* used to check entities boundaries */
|
||||
int charset; /* encoding of the in-memory content
|
||||
actually an xmlCharEncoding */
|
||||
int nodelen; /* Those two fields are there to */
|
||||
int nodemem; /* Speed up large node parsing */
|
||||
int pedantic; /* signal pedantic warnings */
|
||||
void *_private; /* For user data, libxml won't touch it */
|
||||
|
||||
int loadsubset; /* should the external subset be loaded */
|
||||
};
|
||||
|
||||
/**
|
||||
* a SAX Locator.
|
||||
*/
|
||||
typedef struct _xmlSAXLocator xmlSAXLocator;
|
||||
typedef xmlSAXLocator *xmlSAXLocatorPtr;
|
||||
struct _xmlSAXLocator {
|
||||
const xmlChar *(*getPublicId)(void *ctx);
|
||||
const xmlChar *(*getSystemId)(void *ctx);
|
||||
int (*getLineNumber)(void *ctx);
|
||||
int (*getColumnNumber)(void *ctx);
|
||||
};
|
||||
|
||||
/**
|
||||
* a SAX handler is bunch of callbacks called by the parser when processing
|
||||
* of the input generate data or structure informations.
|
||||
*/
|
||||
|
||||
typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
|
||||
const xmlChar *publicId, const xmlChar *systemId);
|
||||
typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
|
||||
const xmlChar *ExternalID, const xmlChar *SystemID);
|
||||
typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
|
||||
const xmlChar *ExternalID, const xmlChar *SystemID);
|
||||
typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
|
||||
const xmlChar *name);
|
||||
typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
|
||||
const xmlChar *name);
|
||||
typedef void (*entityDeclSAXFunc) (void *ctx,
|
||||
const xmlChar *name, int type, const xmlChar *publicId,
|
||||
const xmlChar *systemId, xmlChar *content);
|
||||
typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
|
||||
const xmlChar *publicId, const xmlChar *systemId);
|
||||
typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
|
||||
const xmlChar *name, int type, int def,
|
||||
const xmlChar *defaultValue, xmlEnumerationPtr tree);
|
||||
typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
|
||||
int type, xmlElementContentPtr content);
|
||||
typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
|
||||
const xmlChar *name, const xmlChar *publicId,
|
||||
const xmlChar *systemId, const xmlChar *notationName);
|
||||
typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
|
||||
xmlSAXLocatorPtr loc);
|
||||
typedef void (*startDocumentSAXFunc) (void *ctx);
|
||||
typedef void (*endDocumentSAXFunc) (void *ctx);
|
||||
typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
|
||||
const xmlChar **atts);
|
||||
typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
|
||||
typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
|
||||
typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
|
||||
int len);
|
||||
typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
|
||||
const xmlChar *ch, int len);
|
||||
typedef void (*processingInstructionSAXFunc) (void *ctx,
|
||||
const xmlChar *target, const xmlChar *data);
|
||||
typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
|
||||
typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
|
||||
typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
|
||||
typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
|
||||
typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
|
||||
typedef int (*isStandaloneSAXFunc) (void *ctx);
|
||||
typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
|
||||
typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
|
||||
|
||||
typedef struct _xmlSAXHandler xmlSAXHandler;
|
||||
typedef xmlSAXHandler *xmlSAXHandlerPtr;
|
||||
struct _xmlSAXHandler {
|
||||
internalSubsetSAXFunc internalSubset;
|
||||
isStandaloneSAXFunc isStandalone;
|
||||
hasInternalSubsetSAXFunc hasInternalSubset;
|
||||
hasExternalSubsetSAXFunc hasExternalSubset;
|
||||
resolveEntitySAXFunc resolveEntity;
|
||||
getEntitySAXFunc getEntity;
|
||||
entityDeclSAXFunc entityDecl;
|
||||
notationDeclSAXFunc notationDecl;
|
||||
attributeDeclSAXFunc attributeDecl;
|
||||
elementDeclSAXFunc elementDecl;
|
||||
unparsedEntityDeclSAXFunc unparsedEntityDecl;
|
||||
setDocumentLocatorSAXFunc setDocumentLocator;
|
||||
startDocumentSAXFunc startDocument;
|
||||
endDocumentSAXFunc endDocument;
|
||||
startElementSAXFunc startElement;
|
||||
endElementSAXFunc endElement;
|
||||
referenceSAXFunc reference;
|
||||
charactersSAXFunc characters;
|
||||
ignorableWhitespaceSAXFunc ignorableWhitespace;
|
||||
processingInstructionSAXFunc processingInstruction;
|
||||
commentSAXFunc comment;
|
||||
warningSAXFunc warning;
|
||||
errorSAXFunc error;
|
||||
fatalErrorSAXFunc fatalError;
|
||||
getParameterEntitySAXFunc getParameterEntity;
|
||||
cdataBlockSAXFunc cdataBlock;
|
||||
externalSubsetSAXFunc externalSubset;
|
||||
};
|
||||
|
||||
/**
|
||||
* External entity loaders types
|
||||
*/
|
||||
typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
|
||||
const char *ID,
|
||||
xmlParserCtxtPtr context);
|
||||
|
||||
/**
|
||||
* Global variables: just the default SAX interface tables and XML
|
||||
* version infos.
|
||||
*/
|
||||
LIBXML_DLL_IMPORT extern const char *xmlParserVersion;
|
||||
|
||||
LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator;
|
||||
LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler;
|
||||
LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler;
|
||||
LIBXML_DLL_IMPORT extern xmlSAXHandler sgmlDefaultSAXHandler;
|
||||
|
||||
/**
|
||||
* entity substitution default behaviour.
|
||||
*/
|
||||
|
||||
#ifdef VMS
|
||||
LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultVal;
|
||||
#define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal
|
||||
#else
|
||||
LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
|
||||
#endif
|
||||
LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
|
||||
|
||||
|
||||
/**
|
||||
* Init/Cleanup
|
||||
*/
|
||||
void xmlInitParser (void);
|
||||
void xmlCleanupParser (void);
|
||||
|
||||
/**
|
||||
* Input functions
|
||||
*/
|
||||
int xmlParserInputRead (xmlParserInputPtr in,
|
||||
int len);
|
||||
int xmlParserInputGrow (xmlParserInputPtr in,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* xmlChar handling
|
||||
*/
|
||||
xmlChar * xmlStrdup (const xmlChar *cur);
|
||||
xmlChar * xmlStrndup (const xmlChar *cur,
|
||||
int len);
|
||||
xmlChar * xmlStrsub (const xmlChar *str,
|
||||
int start,
|
||||
int len);
|
||||
const xmlChar * xmlStrchr (const xmlChar *str,
|
||||
xmlChar val);
|
||||
const xmlChar * xmlStrstr (const xmlChar *str,
|
||||
xmlChar *val);
|
||||
const xmlChar * xmlStrcasestr (const xmlChar *str,
|
||||
xmlChar *val);
|
||||
int xmlStrcmp (const xmlChar *str1,
|
||||
const xmlChar *str2);
|
||||
int xmlStrncmp (const xmlChar *str1,
|
||||
const xmlChar *str2,
|
||||
int len);
|
||||
int xmlStrcasecmp (const xmlChar *str1,
|
||||
const xmlChar *str2);
|
||||
int xmlStrncasecmp (const xmlChar *str1,
|
||||
const xmlChar *str2,
|
||||
int len);
|
||||
int xmlStrEqual (const xmlChar *str1,
|
||||
const xmlChar *str2);
|
||||
int xmlStrlen (const xmlChar *str);
|
||||
xmlChar * xmlStrcat (xmlChar *cur,
|
||||
const xmlChar *add);
|
||||
xmlChar * xmlStrncat (xmlChar *cur,
|
||||
const xmlChar *add,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* Basic parsing Interfaces
|
||||
*/
|
||||
xmlDocPtr xmlParseDoc (xmlChar *cur);
|
||||
xmlDocPtr xmlParseMemory (char *buffer,
|
||||
int size);
|
||||
xmlDocPtr xmlParseFile (const char *filename);
|
||||
int xmlSubstituteEntitiesDefault(int val);
|
||||
int xmlKeepBlanksDefault (int val);
|
||||
void xmlStopParser (xmlParserCtxtPtr ctxt);
|
||||
int xmlPedanticParserDefault(int val);
|
||||
|
||||
/**
|
||||
* Recovery mode
|
||||
*/
|
||||
xmlDocPtr xmlRecoverDoc (xmlChar *cur);
|
||||
xmlDocPtr xmlRecoverMemory (char *buffer,
|
||||
int size);
|
||||
xmlDocPtr xmlRecoverFile (const char *filename);
|
||||
|
||||
/**
|
||||
* Less common routines and SAX interfaces
|
||||
*/
|
||||
int xmlParseDocument (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
|
||||
xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
|
||||
xmlChar *cur,
|
||||
int recovery);
|
||||
int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
const char *filename);
|
||||
int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
char *buffer,
|
||||
int size);
|
||||
xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
|
||||
char *buffer,
|
||||
int size,
|
||||
int recovery);
|
||||
xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
|
||||
const char *filename,
|
||||
int recovery);
|
||||
xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
|
||||
const char *filename);
|
||||
xmlDocPtr xmlParseEntity (const char *filename);
|
||||
xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax,
|
||||
xmlParserInputBufferPtr input,
|
||||
xmlCharEncoding enc);
|
||||
int xmlParseBalancedChunkMemory(xmlDocPtr doc,
|
||||
xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
int depth,
|
||||
const xmlChar *string,
|
||||
xmlNodePtr *list);
|
||||
int xmlParseExternalEntity (xmlDocPtr doc,
|
||||
xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
int depth,
|
||||
const xmlChar *URL,
|
||||
const xmlChar *ID,
|
||||
xmlNodePtr *list);
|
||||
int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
|
||||
const xmlChar *URL,
|
||||
const xmlChar *ID,
|
||||
xmlNodePtr *list);
|
||||
|
||||
/**
|
||||
* SAX initialization routines
|
||||
*/
|
||||
void xmlDefaultSAXHandlerInit(void);
|
||||
void htmlDefaultSAXHandlerInit(void);
|
||||
|
||||
/**
|
||||
* Parser contexts handling.
|
||||
*/
|
||||
void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
|
||||
void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
|
||||
void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
|
||||
void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar* buffer,
|
||||
const char* filename);
|
||||
xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
|
||||
|
||||
/**
|
||||
* Reading/setting optional parsing features.
|
||||
*/
|
||||
|
||||
int xmlGetFeaturesList (int *len,
|
||||
const char **result);
|
||||
int xmlGetFeature (xmlParserCtxtPtr ctxt,
|
||||
const char *name,
|
||||
void *result);
|
||||
int xmlSetFeature (xmlParserCtxtPtr ctxt,
|
||||
const char *name,
|
||||
void *value);
|
||||
|
||||
/**
|
||||
* Interfaces for the Push mode
|
||||
*/
|
||||
xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
const char *chunk,
|
||||
int size,
|
||||
const char *filename);
|
||||
int xmlParseChunk (xmlParserCtxtPtr ctxt,
|
||||
const char *chunk,
|
||||
int size,
|
||||
int terminate);
|
||||
|
||||
/**
|
||||
* Special I/O mode
|
||||
*/
|
||||
|
||||
xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputBufferPtr input,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
/**
|
||||
* Node infos
|
||||
*/
|
||||
const xmlParserNodeInfo*
|
||||
xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
|
||||
const xmlNode* node);
|
||||
void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
|
||||
void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
|
||||
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
|
||||
const xmlNode* node);
|
||||
void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
|
||||
const xmlParserNodeInfo* info);
|
||||
|
||||
/*
|
||||
* External entities handling actually implemented in xmlIO
|
||||
*/
|
||||
|
||||
void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
|
||||
xmlExternalEntityLoader
|
||||
xmlGetExternalEntityLoader(void);
|
||||
xmlParserInputPtr
|
||||
xmlLoadExternalEntity (const char *URL,
|
||||
const char *ID,
|
||||
xmlParserCtxtPtr context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_PARSER_H__ */
|
||||
|
314
include/libxml/parserInternals.h
Normal file
314
include/libxml/parserInternals.h
Normal file
@ -0,0 +1,314 @@
|
||||
/*
|
||||
* parserInternals.h : internals routines exported by the parser.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*
|
||||
* 14 Nov 2000 ht - truncated declaration of xmlParseElementChildrenContentDecl
|
||||
* for VMS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __XML_PARSER_INTERNALS_H__
|
||||
#define __XML_PARSER_INTERNALS_H__
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Identifiers can be longer, but this will be more costly
|
||||
* at runtime.
|
||||
*/
|
||||
#define XML_MAX_NAMELEN 100
|
||||
|
||||
/*
|
||||
* The parser tries to always have that amount of input ready
|
||||
* one of the point is providing context when reporting errors
|
||||
*/
|
||||
#define INPUT_CHUNK 250
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* UNICODE version of the macros. *
|
||||
* *
|
||||
************************************************************************/
|
||||
/*
|
||||
* [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
|
||||
* | [#x10000-#x10FFFF]
|
||||
* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
|
||||
*/
|
||||
#define IS_CHAR(c) \
|
||||
((((c) >= 0x20) && ((c) <= 0xD7FF)) || \
|
||||
((c) == 0x09) || ((c) == 0x0A) || ((c) == 0x0D) || \
|
||||
(((c) >= 0xE000) && ((c) <= 0xFFFD)) || \
|
||||
(((c) >= 0x10000) && ((c) <= 0x10FFFF)))
|
||||
|
||||
/*
|
||||
* [3] S ::= (#x20 | #x9 | #xD | #xA)+
|
||||
*/
|
||||
#define IS_BLANK(c) (((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
|
||||
((c) == 0x0D))
|
||||
|
||||
/*
|
||||
* [85] BaseChar ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_BASECHAR(c) xmlIsBaseChar(c)
|
||||
|
||||
/*
|
||||
* [88] Digit ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_DIGIT(c) xmlIsDigit(c)
|
||||
|
||||
/*
|
||||
* [87] CombiningChar ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_COMBINING(c) xmlIsCombining(c)
|
||||
|
||||
/*
|
||||
* [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |
|
||||
* #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] |
|
||||
* [#x309D-#x309E] | [#x30FC-#x30FE]
|
||||
*/
|
||||
#define IS_EXTENDER(c) xmlIsExtender(c)
|
||||
|
||||
/*
|
||||
* [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]
|
||||
*/
|
||||
#define IS_IDEOGRAPHIC(c) xmlIsIdeographic(c)
|
||||
|
||||
/*
|
||||
* [84] Letter ::= BaseChar | Ideographic
|
||||
*/
|
||||
#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
|
||||
|
||||
|
||||
/*
|
||||
* [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
|
||||
*/
|
||||
#define IS_PUBIDCHAR(c) xmlIsPubidChar(c)
|
||||
|
||||
#define SKIP_EOL(p) \
|
||||
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
|
||||
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
|
||||
|
||||
#define MOVETO_ENDTAG(p) \
|
||||
while ((*p) && (*(p) != '>')) (p)++
|
||||
|
||||
#define MOVETO_STARTTAG(p) \
|
||||
while ((*p) && (*(p) != '<')) (p)++
|
||||
|
||||
/**
|
||||
* Global vaiables affecting the default parser behaviour.
|
||||
*/
|
||||
|
||||
LIBXML_DLL_IMPORT extern int xmlParserDebugEntities;
|
||||
LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlParserDebugEntities;
|
||||
LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlLoadExtDtdDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlKeepBlanksDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern xmlChar xmlStringText[];
|
||||
LIBXML_DLL_IMPORT extern xmlChar xmlStringTextNoenc[];
|
||||
LIBXML_DLL_IMPORT extern xmlChar xmlStringComment[];
|
||||
|
||||
/*
|
||||
* Function to finish teh work of the macros where needed
|
||||
*/
|
||||
int xmlIsBaseChar (int c);
|
||||
int xmlIsBlank (int c);
|
||||
int xmlIsPubidChar (int c);
|
||||
int xmlIsLetter (int c);
|
||||
int xmlIsDigit (int c);
|
||||
int xmlIsIdeographic(int c);
|
||||
int xmlIsCombining (int c);
|
||||
int xmlIsExtender (int c);
|
||||
int xmlIsCombining (int c);
|
||||
int xmlIsChar (int c);
|
||||
|
||||
/**
|
||||
* Parser context
|
||||
*/
|
||||
xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
|
||||
xmlParserCtxtPtr xmlCreateFileParserCtxt (const char *filename);
|
||||
xmlParserCtxtPtr xmlCreateMemoryParserCtxt(char *buffer,
|
||||
int size);
|
||||
xmlParserCtxtPtr xmlNewParserCtxt (void);
|
||||
xmlParserCtxtPtr xmlCreateEntityParserCtxt(const xmlChar *URL,
|
||||
const xmlChar *ID,
|
||||
const xmlChar *base);
|
||||
int xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlCharEncoding enc);
|
||||
int xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlCharEncodingHandlerPtr handler);
|
||||
void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/**
|
||||
* Entities
|
||||
*/
|
||||
void xmlHandleEntity (xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr entity);
|
||||
|
||||
/**
|
||||
* Input Streams
|
||||
*/
|
||||
xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr entity);
|
||||
void xmlPushInput (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputPtr input);
|
||||
xmlChar xmlPopInput (xmlParserCtxtPtr ctxt);
|
||||
void xmlFreeInputStream (xmlParserInputPtr input);
|
||||
xmlParserInputPtr xmlNewInputFromFile (xmlParserCtxtPtr ctxt,
|
||||
const char *filename);
|
||||
xmlParserInputPtr xmlNewInputStream (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/**
|
||||
* Namespaces.
|
||||
*/
|
||||
xmlChar * xmlSplitQName (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *name,
|
||||
xmlChar **prefix);
|
||||
xmlChar * xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **prefix);
|
||||
xmlChar * xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseQuotedString (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseNamespace (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/**
|
||||
* Generic production rules
|
||||
*/
|
||||
xmlChar * xmlScanName (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseName (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseNmtoken (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseEntityValue (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **orig);
|
||||
xmlChar * xmlParseAttValue (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseSystemLiteral (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParsePubidLiteral (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseCharData (xmlParserCtxtPtr ctxt,
|
||||
int cdata);
|
||||
xmlChar * xmlParseExternalID (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **publicID,
|
||||
int strict);
|
||||
void xmlParseComment (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParsePITarget (xmlParserCtxtPtr ctxt);
|
||||
void xmlParsePI (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseNotationDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseEntityDecl (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseDefaultDecl (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **value);
|
||||
xmlEnumerationPtr xmlParseNotationType (xmlParserCtxtPtr ctxt);
|
||||
xmlEnumerationPtr xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseEnumeratedType (xmlParserCtxtPtr ctxt,
|
||||
xmlEnumerationPtr *tree);
|
||||
int xmlParseAttributeType (xmlParserCtxtPtr ctxt,
|
||||
xmlEnumerationPtr *tree);
|
||||
void xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
|
||||
xmlElementContentPtr xmlParseElementMixedContentDecl
|
||||
(xmlParserCtxtPtr ctxt);
|
||||
#ifdef VMS
|
||||
xmlElementContentPtr xmlParseElementChildrenContentD
|
||||
(xmlParserCtxtPtr ctxt);
|
||||
#define xmlParseElementChildrenContentDecl xmlParseElementChildrenContentD
|
||||
#else
|
||||
xmlElementContentPtr xmlParseElementChildrenContentDecl
|
||||
(xmlParserCtxtPtr ctxt);
|
||||
#endif
|
||||
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
|
||||
xmlChar *name,
|
||||
xmlElementContentPtr *result);
|
||||
int xmlParseElementDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseMarkupDecl (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseCharRef (xmlParserCtxtPtr ctxt);
|
||||
xmlEntityPtr xmlParseEntityRef (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseReference (xmlParserCtxtPtr ctxt);
|
||||
void xmlParsePEReference (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseAttribute (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **value);
|
||||
xmlChar * xmlParseStartTag (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseEndTag (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseCDSect (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseContent (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseElement (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseVersionNum (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseVersionInfo (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseEncName (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseEncodingDecl (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseSDDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseXMLDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseTextDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseMisc (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseExternalSubset (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
/*
|
||||
* Entities substitution
|
||||
*/
|
||||
#define XML_SUBSTITUTE_NONE 0
|
||||
#define XML_SUBSTITUTE_REF 1
|
||||
#define XML_SUBSTITUTE_PEREF 2
|
||||
#define XML_SUBSTITUTE_BOTH 3
|
||||
|
||||
xmlChar * xmlDecodeEntities (xmlParserCtxtPtr ctxt,
|
||||
int len,
|
||||
int what,
|
||||
xmlChar end,
|
||||
xmlChar end2,
|
||||
xmlChar end3);
|
||||
xmlChar * xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *str,
|
||||
int what,
|
||||
xmlChar end,
|
||||
xmlChar end2,
|
||||
xmlChar end3);
|
||||
|
||||
/*
|
||||
* Generated by MACROS on top of parser.c c.f. PUSH_AND_POP
|
||||
*/
|
||||
int nodePush (xmlParserCtxtPtr ctxt,
|
||||
xmlNodePtr value);
|
||||
xmlNodePtr nodePop (xmlParserCtxtPtr ctxt);
|
||||
int inputPush (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputPtr value);
|
||||
xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/*
|
||||
* other comodities shared between parser.c and parserInternals
|
||||
*/
|
||||
int xmlSkipBlankChars (xmlParserCtxtPtr ctxt);
|
||||
int xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *cur,
|
||||
int *len);
|
||||
void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
|
||||
void xmlParserHandleReference(xmlParserCtxtPtr ctxt);
|
||||
xmlChar *namePop (xmlParserCtxtPtr ctxt);
|
||||
int xmlCheckLanguageID (const xmlChar *lang);
|
||||
|
||||
/*
|
||||
* Really core function shared with HTML parser
|
||||
*/
|
||||
int xmlCurrentChar (xmlParserCtxtPtr ctxt,
|
||||
int *len);
|
||||
int xmlCopyChar (int len,
|
||||
xmlChar *out,
|
||||
int val);
|
||||
void xmlNextChar (xmlParserCtxtPtr ctxt);
|
||||
void xmlParserInputShrink (xmlParserInputPtr in);
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
/*
|
||||
* Actually comes from the HTML parser but launched from the init stuff
|
||||
*/
|
||||
void htmlInitAutoClose (void);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_PARSER_INTERNALS_H__ */
|
701
include/libxml/tree.h
Normal file
701
include/libxml/tree.h
Normal file
@ -0,0 +1,701 @@
|
||||
/*
|
||||
* tree.h : describes the structures found in an tree resulting
|
||||
* from an XML parsing.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*
|
||||
* 14 Nov 2000 ht - added redefinition of xmlBufferWriteChar for VMS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __XML_TREE_H__
|
||||
#define __XML_TREE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XML_XML_NAMESPACE \
|
||||
(const xmlChar *) "http://www.w3.org/XML/1998/namespace"
|
||||
|
||||
/*
|
||||
* The different element types carried by an XML tree
|
||||
*
|
||||
* NOTE: This is synchronized with DOM Level1 values
|
||||
* See http://www.w3.org/TR/REC-DOM-Level-1/
|
||||
*
|
||||
* Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
|
||||
* be deprecated to use an XML_DTD_NODE.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_ELEMENT_NODE= 1,
|
||||
XML_ATTRIBUTE_NODE= 2,
|
||||
XML_TEXT_NODE= 3,
|
||||
XML_CDATA_SECTION_NODE= 4,
|
||||
XML_ENTITY_REF_NODE= 5,
|
||||
XML_ENTITY_NODE= 6,
|
||||
XML_PI_NODE= 7,
|
||||
XML_COMMENT_NODE= 8,
|
||||
XML_DOCUMENT_NODE= 9,
|
||||
XML_DOCUMENT_TYPE_NODE= 10,
|
||||
XML_DOCUMENT_FRAG_NODE= 11,
|
||||
XML_NOTATION_NODE= 12,
|
||||
XML_HTML_DOCUMENT_NODE= 13,
|
||||
XML_DTD_NODE= 14,
|
||||
XML_ELEMENT_DECL= 15,
|
||||
XML_ATTRIBUTE_DECL= 16,
|
||||
XML_ENTITY_DECL= 17,
|
||||
XML_NAMESPACE_DECL= 18,
|
||||
XML_XINCLUDE_START= 19,
|
||||
XML_XINCLUDE_END= 20
|
||||
#ifdef LIBXML_SGML_ENABLED
|
||||
,XML_SGML_DOCUMENT_NODE= 21
|
||||
#endif
|
||||
} xmlElementType;
|
||||
|
||||
/*
|
||||
* Size of an internal character representation.
|
||||
*
|
||||
* We use 8bit chars internal representation for memory efficiency,
|
||||
* Note that with 8 bits wide xmlChars one can still use UTF-8 to handle
|
||||
* correctly non ISO-Latin input.
|
||||
*/
|
||||
|
||||
typedef unsigned char xmlChar;
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef CHAR
|
||||
#define CHAR xmlChar
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BAD_CAST (xmlChar *)
|
||||
|
||||
/*
|
||||
* a DTD Notation definition
|
||||
*/
|
||||
|
||||
typedef struct _xmlNotation xmlNotation;
|
||||
typedef xmlNotation *xmlNotationPtr;
|
||||
struct _xmlNotation {
|
||||
const xmlChar *name; /* Notation name */
|
||||
const xmlChar *PublicID; /* Public identifier, if any */
|
||||
const xmlChar *SystemID; /* System identifier, if any */
|
||||
};
|
||||
|
||||
/*
|
||||
* a DTD Attribute definition
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XML_ATTRIBUTE_CDATA = 1,
|
||||
XML_ATTRIBUTE_ID,
|
||||
XML_ATTRIBUTE_IDREF ,
|
||||
XML_ATTRIBUTE_IDREFS,
|
||||
XML_ATTRIBUTE_ENTITY,
|
||||
XML_ATTRIBUTE_ENTITIES,
|
||||
XML_ATTRIBUTE_NMTOKEN,
|
||||
XML_ATTRIBUTE_NMTOKENS,
|
||||
XML_ATTRIBUTE_ENUMERATION,
|
||||
XML_ATTRIBUTE_NOTATION
|
||||
} xmlAttributeType;
|
||||
|
||||
typedef enum {
|
||||
XML_ATTRIBUTE_NONE = 1,
|
||||
XML_ATTRIBUTE_REQUIRED,
|
||||
XML_ATTRIBUTE_IMPLIED,
|
||||
XML_ATTRIBUTE_FIXED
|
||||
} xmlAttributeDefault;
|
||||
|
||||
typedef struct _xmlEnumeration xmlEnumeration;
|
||||
typedef xmlEnumeration *xmlEnumerationPtr;
|
||||
struct _xmlEnumeration {
|
||||
struct _xmlEnumeration *next; /* next one */
|
||||
const xmlChar *name; /* Enumeration name */
|
||||
};
|
||||
|
||||
typedef struct _xmlAttribute xmlAttribute;
|
||||
typedef xmlAttribute *xmlAttributePtr;
|
||||
struct _xmlAttribute {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
|
||||
const xmlChar *name; /* Attribute name */
|
||||
struct _xmlNode *children; /* NULL */
|
||||
struct _xmlNode *last; /* NULL */
|
||||
struct _xmlDtd *parent; /* -> DTD */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
struct _xmlAttribute *nexth; /* next in hash table */
|
||||
xmlAttributeType atype; /* The attribute type */
|
||||
xmlAttributeDefault def; /* the default */
|
||||
const xmlChar *defaultValue; /* or the default value */
|
||||
xmlEnumerationPtr tree; /* or the enumeration tree if any */
|
||||
const xmlChar *prefix; /* the namespace prefix if any */
|
||||
const xmlChar *elem; /* Element holding the attribute */
|
||||
};
|
||||
|
||||
/*
|
||||
* a DTD Element definition.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_ELEMENT_CONTENT_PCDATA = 1,
|
||||
XML_ELEMENT_CONTENT_ELEMENT,
|
||||
XML_ELEMENT_CONTENT_SEQ,
|
||||
XML_ELEMENT_CONTENT_OR
|
||||
} xmlElementContentType;
|
||||
|
||||
typedef enum {
|
||||
XML_ELEMENT_CONTENT_ONCE = 1,
|
||||
XML_ELEMENT_CONTENT_OPT,
|
||||
XML_ELEMENT_CONTENT_MULT,
|
||||
XML_ELEMENT_CONTENT_PLUS
|
||||
} xmlElementContentOccur;
|
||||
|
||||
typedef struct _xmlElementContent xmlElementContent;
|
||||
typedef xmlElementContent *xmlElementContentPtr;
|
||||
struct _xmlElementContent {
|
||||
xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
|
||||
xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
|
||||
const xmlChar *name; /* Element name */
|
||||
struct _xmlElementContent *c1; /* first child */
|
||||
struct _xmlElementContent *c2; /* second child */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
XML_ELEMENT_TYPE_EMPTY = 1,
|
||||
XML_ELEMENT_TYPE_ANY,
|
||||
XML_ELEMENT_TYPE_MIXED,
|
||||
XML_ELEMENT_TYPE_ELEMENT
|
||||
} xmlElementTypeVal;
|
||||
|
||||
typedef struct _xmlElement xmlElement;
|
||||
typedef xmlElement *xmlElementPtr;
|
||||
struct _xmlElement {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
|
||||
const xmlChar *name; /* Element name */
|
||||
struct _xmlNode *children; /* NULL */
|
||||
struct _xmlNode *last; /* NULL */
|
||||
struct _xmlDtd *parent; /* -> DTD */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
xmlElementTypeVal etype; /* The type */
|
||||
xmlElementContentPtr content; /* the allowed element content */
|
||||
xmlAttributePtr attributes; /* List of the declared attributes */
|
||||
const xmlChar *prefix; /* the namespace prefix if any */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML namespace.
|
||||
* Note that prefix == NULL is valid, it defines the default namespace
|
||||
* within the subtree (until overriden).
|
||||
*
|
||||
* XML_GLOBAL_NAMESPACE is now deprecated for good
|
||||
* xmlNsType is unified with xmlElementType
|
||||
*/
|
||||
|
||||
#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
|
||||
typedef xmlElementType xmlNsType;
|
||||
|
||||
typedef struct _xmlNs xmlNs;
|
||||
typedef xmlNs *xmlNsPtr;
|
||||
struct _xmlNs {
|
||||
struct _xmlNs *next; /* next Ns link for this node */
|
||||
xmlNsType type; /* global or local */
|
||||
const xmlChar *href; /* URL for the namespace */
|
||||
const xmlChar *prefix; /* prefix for the namespace */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML DtD, as defined by <!DOCTYPE.
|
||||
*/
|
||||
typedef struct _xmlDtd xmlDtd;
|
||||
typedef xmlDtd *xmlDtdPtr;
|
||||
struct _xmlDtd {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_DTD_NODE, must be second ! */
|
||||
const xmlChar *name; /* Name of the DTD */
|
||||
struct _xmlNode *children; /* the value of the property link */
|
||||
struct _xmlNode *last; /* last child link */
|
||||
struct _xmlDoc *parent; /* child->parent link */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
/* End of common part */
|
||||
void *notations; /* Hash table for notations if any */
|
||||
void *elements; /* Hash table for elements if any */
|
||||
void *attributes; /* Hash table for attributes if any */
|
||||
void *entities; /* Hash table for entities if any */
|
||||
const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
|
||||
const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
|
||||
void *pentities; /* Hash table for param entities if any */
|
||||
};
|
||||
|
||||
/*
|
||||
* A attribute of an XML node.
|
||||
*/
|
||||
typedef struct _xmlAttr xmlAttr;
|
||||
typedef xmlAttr *xmlAttrPtr;
|
||||
struct _xmlAttr {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
|
||||
const xmlChar *name; /* the name of the property */
|
||||
struct _xmlNode *children; /* the value of the property */
|
||||
struct _xmlNode *last; /* NULL */
|
||||
struct _xmlNode *parent; /* child->parent link */
|
||||
struct _xmlAttr *next; /* next sibling link */
|
||||
struct _xmlAttr *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
xmlNs *ns; /* pointer to the associated namespace */
|
||||
xmlAttributeType atype; /* the attribute type if validating */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML ID instance.
|
||||
*/
|
||||
|
||||
typedef struct _xmlID xmlID;
|
||||
typedef xmlID *xmlIDPtr;
|
||||
struct _xmlID {
|
||||
struct _xmlID *next; /* next ID */
|
||||
const xmlChar *value; /* The ID name */
|
||||
xmlAttrPtr attr; /* The attribut holding it */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML IDREF instance.
|
||||
*/
|
||||
|
||||
typedef struct _xmlRef xmlRef;
|
||||
typedef xmlRef *xmlRefPtr;
|
||||
struct _xmlRef {
|
||||
struct _xmlRef *next; /* next Ref */
|
||||
const xmlChar *value; /* The Ref name */
|
||||
xmlAttrPtr attr; /* The attribut holding it */
|
||||
};
|
||||
|
||||
/*
|
||||
* A buffer structure
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XML_BUFFER_ALLOC_DOUBLEIT,
|
||||
XML_BUFFER_ALLOC_EXACT
|
||||
} xmlBufferAllocationScheme;
|
||||
|
||||
typedef struct _xmlBuffer xmlBuffer;
|
||||
typedef xmlBuffer *xmlBufferPtr;
|
||||
struct _xmlBuffer {
|
||||
xmlChar *content; /* The buffer content UTF8 */
|
||||
unsigned int use; /* The buffer size used */
|
||||
unsigned int size; /* The buffer size */
|
||||
xmlBufferAllocationScheme alloc; /* The realloc method */
|
||||
};
|
||||
|
||||
/*
|
||||
* A node in an XML tree.
|
||||
*/
|
||||
typedef struct _xmlNode xmlNode;
|
||||
typedef xmlNode *xmlNodePtr;
|
||||
struct _xmlNode {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* type number, must be second ! */
|
||||
const xmlChar *name; /* the name of the node, or the entity */
|
||||
struct _xmlNode *children; /* parent->childs link */
|
||||
struct _xmlNode *last; /* last child link */
|
||||
struct _xmlNode *parent; /* child->parent link */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
xmlNs *ns; /* pointer to the associated namespace */
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlChar *content; /* the content */
|
||||
#else
|
||||
xmlBufferPtr content; /* the content in a buffer */
|
||||
#endif
|
||||
|
||||
/* End of common part */
|
||||
struct _xmlAttr *properties;/* properties list */
|
||||
xmlNs *nsDef; /* namespace definitions on this node */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML document.
|
||||
*/
|
||||
typedef struct _xmlDoc xmlDoc;
|
||||
typedef xmlDoc *xmlDocPtr;
|
||||
struct _xmlDoc {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
|
||||
char *name; /* name/filename/URI of the document */
|
||||
struct _xmlNode *children; /* the document tree */
|
||||
struct _xmlNode *last; /* last child link */
|
||||
struct _xmlNode *parent; /* child->parent link */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* autoreference to itself */
|
||||
|
||||
/* End of common part */
|
||||
int compression;/* level of zlib compression */
|
||||
int standalone; /* standalone document (no external refs) */
|
||||
struct _xmlDtd *intSubset; /* the document internal subset */
|
||||
struct _xmlDtd *extSubset; /* the document external subset */
|
||||
struct _xmlNs *oldNs; /* Global namespace, the old way */
|
||||
const xmlChar *version; /* the XML version string */
|
||||
const xmlChar *encoding; /* external initial encoding, if any */
|
||||
void *ids; /* Hash table for ID attributes if any */
|
||||
void *refs; /* Hash table for IDREFs attributes if any */
|
||||
const xmlChar *URL; /* The URI for that document */
|
||||
int charset; /* encoding of the in-memory content
|
||||
actually an xmlCharEncoding */
|
||||
};
|
||||
|
||||
/*
|
||||
* Compatibility naming layer with libxml1
|
||||
*/
|
||||
#ifndef xmlChildrenNode
|
||||
#define xmlChildrenNode children
|
||||
#define xmlRootNode children
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Variables.
|
||||
*/
|
||||
LIBXML_DLL_IMPORT extern xmlNsPtr baseDTD;
|
||||
LIBXML_DLL_IMPORT extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
|
||||
LIBXML_DLL_IMPORT extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
|
||||
LIBXML_DLL_IMPORT extern xmlBufferAllocationScheme xmlBufferAllocScheme; /* alloc scheme to use */
|
||||
LIBXML_DLL_IMPORT extern int xmlSaveNoEmptyTags; /* save empty tags as <empty></empty> */
|
||||
|
||||
/*
|
||||
* Handling Buffers.
|
||||
*/
|
||||
|
||||
xmlBufferPtr xmlBufferCreate (void);
|
||||
xmlBufferPtr xmlBufferCreateSize (size_t size);
|
||||
void xmlBufferFree (xmlBufferPtr buf);
|
||||
int xmlBufferDump (FILE *file,
|
||||
xmlBufferPtr buf);
|
||||
void xmlBufferAdd (xmlBufferPtr buf,
|
||||
const xmlChar *str,
|
||||
int len);
|
||||
void xmlBufferAddHead (xmlBufferPtr buf,
|
||||
const xmlChar *str,
|
||||
int len);
|
||||
void xmlBufferCat (xmlBufferPtr buf,
|
||||
const xmlChar *str);
|
||||
void xmlBufferCCat (xmlBufferPtr buf,
|
||||
const char *str);
|
||||
int xmlBufferShrink (xmlBufferPtr buf,
|
||||
unsigned int len);
|
||||
int xmlBufferGrow (xmlBufferPtr buf,
|
||||
unsigned int len);
|
||||
void xmlBufferEmpty (xmlBufferPtr buf);
|
||||
const xmlChar* xmlBufferContent (const xmlBufferPtr buf);
|
||||
int xmlBufferUse (const xmlBufferPtr buf);
|
||||
void xmlBufferSetAllocationScheme(xmlBufferPtr buf,
|
||||
xmlBufferAllocationScheme scheme);
|
||||
int xmlBufferLength (const xmlBufferPtr buf);
|
||||
|
||||
/*
|
||||
* Creating/freeing new structures
|
||||
*/
|
||||
xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlDtdPtr xmlNewDtd (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc);
|
||||
void xmlFreeDtd (xmlDtdPtr cur);
|
||||
xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
xmlNsPtr xmlNewNs (xmlNodePtr node,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
void xmlFreeNs (xmlNsPtr cur);
|
||||
xmlDocPtr xmlNewDoc (const xmlChar *version);
|
||||
void xmlFreeDoc (xmlDocPtr cur);
|
||||
xmlAttrPtr xmlNewDocProp (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
xmlAttrPtr xmlNewProp (xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
xmlAttrPtr xmlNewNsProp (xmlNodePtr node,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
void xmlFreePropList (xmlAttrPtr cur);
|
||||
void xmlFreeProp (xmlAttrPtr cur);
|
||||
xmlAttrPtr xmlCopyProp (xmlNodePtr target,
|
||||
xmlAttrPtr cur);
|
||||
xmlAttrPtr xmlCopyPropList (xmlNodePtr target,
|
||||
xmlAttrPtr cur);
|
||||
xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd);
|
||||
xmlDocPtr xmlCopyDoc (xmlDocPtr doc,
|
||||
int recursive);
|
||||
|
||||
/*
|
||||
* Creating new nodes
|
||||
*/
|
||||
xmlNodePtr xmlNewDocNode (xmlDocPtr doc,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewNode (xmlNsPtr ns,
|
||||
const xmlChar *name);
|
||||
xmlNodePtr xmlNewChild (xmlNodePtr parent,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewTextChild (xmlNodePtr parent,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewDocText (xmlDocPtr doc,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewText (const xmlChar *content);
|
||||
xmlNodePtr xmlNewPI (const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
xmlNodePtr xmlNewTextLen (const xmlChar *content,
|
||||
int len);
|
||||
xmlNodePtr xmlNewDocComment (xmlDocPtr doc,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewComment (const xmlChar *content);
|
||||
xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
xmlNodePtr xmlNewCharRef (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlNodePtr xmlNewReference (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlNodePtr xmlCopyNode (xmlNodePtr node,
|
||||
int recursive);
|
||||
xmlNodePtr xmlCopyNodeList (xmlNodePtr node);
|
||||
xmlNodePtr xmlNewDocFragment (xmlDocPtr doc);
|
||||
|
||||
/*
|
||||
* Navigating
|
||||
*/
|
||||
xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc);
|
||||
xmlNodePtr xmlGetLastChild (xmlNodePtr parent);
|
||||
int xmlNodeIsText (xmlNodePtr node);
|
||||
int xmlIsBlankNode (xmlNodePtr node);
|
||||
|
||||
/*
|
||||
* Changing the structure
|
||||
*/
|
||||
xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc,
|
||||
xmlNodePtr root);
|
||||
void xmlNodeSetName (xmlNodePtr cur,
|
||||
const xmlChar *name);
|
||||
xmlNodePtr xmlAddChild (xmlNodePtr parent,
|
||||
xmlNodePtr cur);
|
||||
xmlNodePtr xmlAddChildList (xmlNodePtr parent,
|
||||
xmlNodePtr cur);
|
||||
xmlNodePtr xmlReplaceNode (xmlNodePtr old,
|
||||
xmlNodePtr cur);
|
||||
xmlNodePtr xmlAddSibling (xmlNodePtr cur,
|
||||
xmlNodePtr elem);
|
||||
xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur,
|
||||
xmlNodePtr elem);
|
||||
xmlNodePtr xmlAddNextSibling (xmlNodePtr cur,
|
||||
xmlNodePtr elem);
|
||||
void xmlUnlinkNode (xmlNodePtr cur);
|
||||
xmlNodePtr xmlTextMerge (xmlNodePtr first,
|
||||
xmlNodePtr second);
|
||||
void xmlTextConcat (xmlNodePtr node,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
void xmlFreeNodeList (xmlNodePtr cur);
|
||||
void xmlFreeNode (xmlNodePtr cur);
|
||||
void xmlSetTreeDoc (xmlNodePtr tree,
|
||||
xmlDocPtr doc);
|
||||
void xmlSetListDoc (xmlNodePtr list,
|
||||
xmlDocPtr doc);
|
||||
|
||||
/*
|
||||
* Namespaces
|
||||
*/
|
||||
xmlNsPtr xmlSearchNs (xmlDocPtr doc,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *nameSpace);
|
||||
xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *href);
|
||||
xmlNsPtr * xmlGetNsList (xmlDocPtr doc,
|
||||
xmlNodePtr node);
|
||||
void xmlSetNs (xmlNodePtr node,
|
||||
xmlNsPtr ns);
|
||||
xmlNsPtr xmlCopyNamespace (xmlNsPtr cur);
|
||||
xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur);
|
||||
|
||||
/*
|
||||
* Changing the content.
|
||||
*/
|
||||
xmlAttrPtr xmlSetProp (xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
xmlChar * xmlGetProp (xmlNodePtr node,
|
||||
const xmlChar *name);
|
||||
xmlAttrPtr xmlHasProp (xmlNodePtr node,
|
||||
const xmlChar *name);
|
||||
xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
xmlChar * xmlGetNsProp (xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *nameSpace);
|
||||
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
|
||||
const xmlChar *value);
|
||||
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
|
||||
const xmlChar *value,
|
||||
int len);
|
||||
xmlChar * xmlNodeListGetString (xmlDocPtr doc,
|
||||
xmlNodePtr list,
|
||||
int inLine);
|
||||
xmlChar * xmlNodeListGetRawString (xmlDocPtr doc,
|
||||
xmlNodePtr list,
|
||||
int inLine);
|
||||
void xmlNodeSetContent (xmlNodePtr cur,
|
||||
const xmlChar *content);
|
||||
void xmlNodeSetContentLen (xmlNodePtr cur,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
void xmlNodeAddContent (xmlNodePtr cur,
|
||||
const xmlChar *content);
|
||||
void xmlNodeAddContentLen (xmlNodePtr cur,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
xmlChar * xmlNodeGetContent (xmlNodePtr cur);
|
||||
xmlChar * xmlNodeGetLang (xmlNodePtr cur);
|
||||
void xmlNodeSetLang (xmlNodePtr cur,
|
||||
const xmlChar *lang);
|
||||
int xmlNodeGetSpacePreserve (xmlNodePtr cur);
|
||||
void xmlNodeSetSpacePreserve (xmlNodePtr cur, int
|
||||
val);
|
||||
xmlChar * xmlNodeGetBase (xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
void xmlNodeSetBase (xmlNodePtr cur,
|
||||
xmlChar *uri);
|
||||
|
||||
/*
|
||||
* Removing content.
|
||||
*/
|
||||
int xmlRemoveProp (xmlAttrPtr attr);
|
||||
int xmlRemoveNode (xmlNodePtr node); /* TODO */
|
||||
|
||||
/*
|
||||
* Internal, don't use
|
||||
*/
|
||||
#ifdef VMS
|
||||
void xmlBufferWriteXmlCHAR (xmlBufferPtr buf,
|
||||
const xmlChar *string);
|
||||
#define xmlBufferWriteCHAR xmlBufferWriteXmlCHAR
|
||||
#else
|
||||
void xmlBufferWriteCHAR (xmlBufferPtr buf,
|
||||
const xmlChar *string);
|
||||
#endif
|
||||
void xmlBufferWriteChar (xmlBufferPtr buf,
|
||||
const char *string);
|
||||
void xmlBufferWriteQuotedString(xmlBufferPtr buf,
|
||||
const xmlChar *string);
|
||||
|
||||
/*
|
||||
* Namespace handling
|
||||
*/
|
||||
int xmlReconciliateNs (xmlDocPtr doc,
|
||||
xmlNodePtr tree);
|
||||
|
||||
/*
|
||||
* Saving
|
||||
*/
|
||||
void xmlDocDumpFormatMemory (xmlDocPtr cur,
|
||||
xmlChar**mem,
|
||||
int *size,
|
||||
int format);
|
||||
void xmlDocDumpMemory (xmlDocPtr cur,
|
||||
xmlChar**mem,
|
||||
int *size);
|
||||
void xmlDocDumpMemoryEnc (xmlDocPtr out_doc,
|
||||
xmlChar **doc_txt_ptr,
|
||||
int * doc_txt_len,
|
||||
const char *txt_encoding);
|
||||
void xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,
|
||||
xmlChar **doc_txt_ptr,
|
||||
int * doc_txt_len,
|
||||
const char *txt_encoding,
|
||||
int format);
|
||||
int xmlDocDump (FILE *f,
|
||||
xmlDocPtr cur);
|
||||
void xmlElemDump (FILE *f,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
int xmlSaveFile (const char *filename,
|
||||
xmlDocPtr cur);
|
||||
void xmlNodeDump (xmlBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
int level,
|
||||
int format);
|
||||
|
||||
/* This one is exported from xmlIO.h
|
||||
|
||||
int xmlSaveFileTo (xmlOutputBuffer *buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
*/
|
||||
|
||||
int xmlSaveFileEnc (const char *filename,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
|
||||
/*
|
||||
* Compression
|
||||
*/
|
||||
int xmlGetDocCompressMode (xmlDocPtr doc);
|
||||
void xmlSetDocCompressMode (xmlDocPtr doc,
|
||||
int mode);
|
||||
int xmlGetCompressMode (void);
|
||||
void xmlSetCompressMode (int mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_TREE_H__ */
|
||||
|
61
include/libxml/uri.h
Normal file
61
include/libxml/uri.h
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* uri.c: library of generic URI related routines
|
||||
*
|
||||
* Reference: RFC 2396
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_URI_H__
|
||||
#define __XML_URI_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
typedef struct _xmlURI xmlURI;
|
||||
typedef xmlURI *xmlURIPtr;
|
||||
struct _xmlURI {
|
||||
char *scheme;
|
||||
char *opaque;
|
||||
char *authority;
|
||||
char *server;
|
||||
char *user;
|
||||
int port;
|
||||
char *path;
|
||||
char *query;
|
||||
char *fragment;
|
||||
};
|
||||
|
||||
/*
|
||||
* This function is in tree.h:
|
||||
* xmlChar * xmlNodeGetBase (xmlDocPtr doc,
|
||||
* xmlNodePtr cur);
|
||||
*/
|
||||
xmlURIPtr xmlCreateURI (void);
|
||||
xmlChar * xmlBuildURI (const xmlChar *URI,
|
||||
const xmlChar *base);
|
||||
xmlURIPtr xmlParseURI (const char *URI);
|
||||
int xmlParseURIReference (xmlURIPtr uri,
|
||||
const char *str);
|
||||
xmlChar * xmlSaveUri (xmlURIPtr uri);
|
||||
void xmlPrintURI (FILE *stream,
|
||||
xmlURIPtr uri);
|
||||
char * xmlURIUnescapeString (const char *str,
|
||||
int len,
|
||||
char *target);
|
||||
int xmlNormalizeURIPath (char *path);
|
||||
xmlChar * xmlURIEscape (const xmlChar *str);
|
||||
void xmlFreeURI (xmlURIPtr uri);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_URI_H__ */
|
236
include/libxml/valid.h
Normal file
236
include/libxml/valid.h
Normal file
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* valid.h : interface to the DTD handling and the validity checking
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_VALID_H__
|
||||
#define __XML_VALID_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* an xmlValidCtxt is used for error reporting when validating
|
||||
*/
|
||||
|
||||
typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
|
||||
typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
|
||||
|
||||
typedef struct _xmlValidCtxt xmlValidCtxt;
|
||||
typedef xmlValidCtxt *xmlValidCtxtPtr;
|
||||
struct _xmlValidCtxt {
|
||||
void *userData; /* user specific data block */
|
||||
xmlValidityErrorFunc error; /* the callback in case of errors */
|
||||
xmlValidityWarningFunc warning; /* the callback in case of warning */
|
||||
|
||||
/* Node analysis stack used when validating within entities */
|
||||
xmlNodePtr node; /* Current parsed Node */
|
||||
int nodeNr; /* Depth of the parsing stack */
|
||||
int nodeMax; /* Max depth of the parsing stack */
|
||||
xmlNodePtr *nodeTab; /* array of nodes */
|
||||
|
||||
int finishDtd; /* finished validating the Dtd ? */
|
||||
xmlDocPtr doc; /* the document */
|
||||
int valid; /* temporary validity check result */
|
||||
};
|
||||
|
||||
/*
|
||||
* ALl notation declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlNotationTable;
|
||||
typedef xmlNotationTable *xmlNotationTablePtr;
|
||||
|
||||
/*
|
||||
* ALl element declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlElementTable;
|
||||
typedef xmlElementTable *xmlElementTablePtr;
|
||||
|
||||
/*
|
||||
* ALl attribute declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlAttributeTable;
|
||||
typedef xmlAttributeTable *xmlAttributeTablePtr;
|
||||
|
||||
/*
|
||||
* ALl IDs attributes are stored in a table
|
||||
* there is one table per document
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlIDTable;
|
||||
typedef xmlIDTable *xmlIDTablePtr;
|
||||
|
||||
/*
|
||||
* ALl Refs attributes are stored in a table
|
||||
* there is one table per document
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlRefTable;
|
||||
typedef xmlRefTable *xmlRefTablePtr;
|
||||
|
||||
/* helper */
|
||||
xmlChar * xmlSplitQName2 (const xmlChar *name,
|
||||
xmlChar **prefix);
|
||||
|
||||
/* Notation */
|
||||
xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *name,
|
||||
const xmlChar *PublicID,
|
||||
const xmlChar *SystemID);
|
||||
xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
|
||||
void xmlFreeNotationTable(xmlNotationTablePtr table);
|
||||
void xmlDumpNotationDecl (xmlBufferPtr buf,
|
||||
xmlNotationPtr nota);
|
||||
void xmlDumpNotationTable(xmlBufferPtr buf,
|
||||
xmlNotationTablePtr table);
|
||||
|
||||
/* Element Content */
|
||||
xmlElementContentPtr xmlNewElementContent (xmlChar *name,
|
||||
xmlElementContentType type);
|
||||
xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
|
||||
void xmlFreeElementContent(xmlElementContentPtr cur);
|
||||
void xmlSprintfElementContent(char *buf,
|
||||
xmlElementContentPtr content,
|
||||
int glob);
|
||||
|
||||
/* Element */
|
||||
xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *name,
|
||||
xmlElementTypeVal type,
|
||||
xmlElementContentPtr content);
|
||||
xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
|
||||
void xmlFreeElementTable (xmlElementTablePtr table);
|
||||
void xmlDumpElementTable (xmlBufferPtr buf,
|
||||
xmlElementTablePtr table);
|
||||
void xmlDumpElementDecl (xmlBufferPtr buf,
|
||||
xmlElementPtr elem);
|
||||
|
||||
/* Enumeration */
|
||||
xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name);
|
||||
void xmlFreeEnumeration (xmlEnumerationPtr cur);
|
||||
xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
|
||||
|
||||
/* Attribute */
|
||||
xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns,
|
||||
xmlAttributeType type,
|
||||
xmlAttributeDefault def,
|
||||
const xmlChar *defaultValue,
|
||||
xmlEnumerationPtr tree);
|
||||
xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
|
||||
void xmlFreeAttributeTable (xmlAttributeTablePtr table);
|
||||
void xmlDumpAttributeTable (xmlBufferPtr buf,
|
||||
xmlAttributeTablePtr table);
|
||||
void xmlDumpAttributeDecl (xmlBufferPtr buf,
|
||||
xmlAttributePtr attr);
|
||||
|
||||
/* IDs */
|
||||
xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *value,
|
||||
xmlAttrPtr attr);
|
||||
xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table);
|
||||
void xmlFreeIDTable (xmlIDTablePtr table);
|
||||
xmlAttrPtr xmlGetID (xmlDocPtr doc,
|
||||
const xmlChar *ID);
|
||||
int xmlIsID (xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr);
|
||||
int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr);
|
||||
|
||||
/* IDREFs */
|
||||
xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *value,
|
||||
xmlAttrPtr attr);
|
||||
xmlRefTablePtr xmlCopyRefTable (xmlRefTablePtr table);
|
||||
void xmlFreeRefTable (xmlRefTablePtr table);
|
||||
int xmlIsRef (xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr);
|
||||
int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr);
|
||||
|
||||
/**
|
||||
* The public function calls related to validity checking
|
||||
*/
|
||||
|
||||
int xmlValidateRoot (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
int xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlElementPtr elem);
|
||||
xmlChar * xmlValidNormalizeAttributeValue(xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlAttributePtr attr);
|
||||
int xmlValidateAttributeValue(xmlAttributeType type,
|
||||
const xmlChar *value);
|
||||
int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNotationPtr nota);
|
||||
int xmlValidateDtd (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlDtdPtr dtd);
|
||||
int xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
int xmlValidateDocument (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
int xmlValidateElement (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
int xmlValidateOneElement (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr,
|
||||
const xmlChar *value);
|
||||
int xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
int xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *notationName);
|
||||
int xmlIsMixedElement (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name);
|
||||
xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *name);
|
||||
xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *name);
|
||||
|
||||
int xmlValidGetValidElements(xmlNode *prev,
|
||||
xmlNode *next,
|
||||
const xmlChar **list,
|
||||
int max);
|
||||
int xmlValidGetPotentialChildren(xmlElementContent *ctree,
|
||||
const xmlChar **list,
|
||||
int *len,
|
||||
int max);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_VALID_H__ */
|
26
include/libxml/xinclude.h
Normal file
26
include/libxml/xinclude.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* xinclude.c : API to handle XInclude processing
|
||||
*
|
||||
* World Wide Web Consortium Working Draft 26 October 2000
|
||||
* http://www.w3.org/TR/2000/WD-xinclude-20001026
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XINCLUDE_H__
|
||||
#define __XML_XINCLUDE_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int xmlXIncludeProcess (xmlDocPtr doc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_XINCLUDE_H__ */
|
182
include/libxml/xlink.h
Normal file
182
include/libxml/xlink.h
Normal file
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* xlink.h : interfaces to the hyperlinks detection module
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Related specification: http://www.w3.org/TR/xlink
|
||||
* http://www.w3.org/HTML/
|
||||
* and XBase
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XLINK_H__
|
||||
#define __XML_XLINK_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* Various defines for the various Link properties.
|
||||
*
|
||||
* NOTE: the link detection layer will try to resolve QName expansion
|
||||
* of namespaces, if "foo" is the prefix for "http://foo.com/"
|
||||
* then the link detection layer will expand role="foo:myrole"
|
||||
* to "http://foo.com/:myrole"
|
||||
* NOTE: the link detection layer will expand URI-Refences found on
|
||||
* href attributes by using the base mechanism if found.
|
||||
*/
|
||||
typedef xmlChar *xlinkHRef;
|
||||
typedef xmlChar *xlinkRole;
|
||||
typedef xmlChar *xlinkTitle;
|
||||
|
||||
typedef enum {
|
||||
XLINK_TYPE_NONE = 0,
|
||||
XLINK_TYPE_SIMPLE,
|
||||
XLINK_TYPE_EXTENDED,
|
||||
XLINK_TYPE_EXTENDED_SET
|
||||
} xlinkType;
|
||||
|
||||
typedef enum {
|
||||
XLINK_SHOW_NONE = 0,
|
||||
XLINK_SHOW_NEW,
|
||||
XLINK_SHOW_EMBED,
|
||||
XLINK_SHOW_REPLACE
|
||||
} xlinkShow;
|
||||
|
||||
typedef enum {
|
||||
XLINK_ACTUATE_NONE = 0,
|
||||
XLINK_ACTUATE_AUTO,
|
||||
XLINK_ACTUATE_ONREQUEST
|
||||
} xlinkActuate;
|
||||
|
||||
/**
|
||||
* xlinkNodeDetectFunc:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node to check
|
||||
*
|
||||
* This is the prototype for the link detection routine
|
||||
* It calls the default link detection callbacks upon link detection.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkNodeDetectFunc) (void *ctx,
|
||||
xmlNodePtr node);
|
||||
|
||||
/**
|
||||
* The link detection module interract with the upper layers using
|
||||
* a set of callback registered at parsing time.
|
||||
*/
|
||||
|
||||
/**
|
||||
* xlinkSimpleLinkFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @href: the target of the link
|
||||
* @role: the role string
|
||||
* @title: the link title
|
||||
*
|
||||
* This is the prototype for a simple link detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkSimpleLinkFunk) (void *ctx,
|
||||
xmlNodePtr node,
|
||||
const xlinkHRef href,
|
||||
const xlinkRole role,
|
||||
const xlinkTitle title);
|
||||
|
||||
/**
|
||||
* xlinkExtendedLinkFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @nbLocators: the number of locators detected on the link
|
||||
* @hrefs: pointer to the array of locator hrefs
|
||||
* @roles: pointer to the array of locator roles
|
||||
* @nbArcs: the number of arcs detected on the link
|
||||
* @from: pointer to the array of source roles found on the arcs
|
||||
* @to: pointer to the array of target roles found on the arcs
|
||||
* @show: array of values for the show attributes found on the arcs
|
||||
* @actuate: array of values for the actuate attributes found on the arcs
|
||||
* @nbTitles: the number of titles detected on the link
|
||||
* @title: array of titles detected on the link
|
||||
* @langs: array of xml:lang values for the titles
|
||||
*
|
||||
* This is the prototype for a extended link detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkExtendedLinkFunk)(void *ctx,
|
||||
xmlNodePtr node,
|
||||
int nbLocators,
|
||||
const xlinkHRef *hrefs,
|
||||
const xlinkRole *roles,
|
||||
int nbArcs,
|
||||
const xlinkRole *from,
|
||||
const xlinkRole *to,
|
||||
xlinkShow *show,
|
||||
xlinkActuate *actuate,
|
||||
int nbTitles,
|
||||
const xlinkTitle *titles,
|
||||
const xmlChar **langs);
|
||||
|
||||
/**
|
||||
* xlinkExtendedLinkSetFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @nbLocators: the number of locators detected on the link
|
||||
* @hrefs: pointer to the array of locator hrefs
|
||||
* @roles: pointer to the array of locator roles
|
||||
* @nbTitles: the number of titles detected on the link
|
||||
* @title: array of titles detected on the link
|
||||
* @langs: array of xml:lang values for the titles
|
||||
*
|
||||
* This is the prototype for a extended link set detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkExtendedLinkSetFunk) (void *ctx,
|
||||
xmlNodePtr node,
|
||||
int nbLocators,
|
||||
const xlinkHRef *hrefs,
|
||||
const xlinkRole *roles,
|
||||
int nbTitles,
|
||||
const xlinkTitle *titles,
|
||||
const xmlChar **langs);
|
||||
|
||||
/**
|
||||
* This is the structure containing a set of Links detection callbacks
|
||||
*
|
||||
* There is no default xlink callbacks, if one want to get link
|
||||
* recognition activated, those call backs must be provided before parsing.
|
||||
*/
|
||||
typedef struct _xlinkHandler xlinkHandler;
|
||||
typedef xlinkHandler *xlinkHandlerPtr;
|
||||
struct _xlinkHandler {
|
||||
xlinkSimpleLinkFunk simple;
|
||||
xlinkExtendedLinkFunk extended;
|
||||
xlinkExtendedLinkSetFunk set;
|
||||
};
|
||||
|
||||
/**
|
||||
* the default detection routine, can be overriden, they call the default
|
||||
* detection callbacks.
|
||||
*/
|
||||
|
||||
xlinkNodeDetectFunc xlinkGetDefaultDetect (void);
|
||||
void xlinkSetDefaultDetect (xlinkNodeDetectFunc func);
|
||||
|
||||
/**
|
||||
* Routines to set/get the default handlers.
|
||||
*/
|
||||
xlinkHandlerPtr xlinkGetDefaultHandler (void);
|
||||
void xlinkSetDefaultHandler (xlinkHandlerPtr handler);
|
||||
|
||||
/*
|
||||
* Link detection module itself.
|
||||
*/
|
||||
xlinkType xlinkIsLink (xmlDocPtr doc,
|
||||
xmlNodePtr node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_XLINK_H__ */
|
178
include/libxml/xmlIO.h
Normal file
178
include/libxml/xmlIO.h
Normal file
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* xmlIO.h : interface for the I/O interfaces used by the parser
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*
|
||||
* 15 Nov 2000 ht - modified for VMS
|
||||
*/
|
||||
|
||||
#ifndef __XML_IO_H__
|
||||
#define __XML_IO_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/encoding.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Those are the functions and datatypes for the parser input
|
||||
* I/O structures.
|
||||
*/
|
||||
|
||||
typedef int (*xmlInputMatchCallback) (char const *filename);
|
||||
typedef void * (*xmlInputOpenCallback) (char const *filename);
|
||||
typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
|
||||
typedef void (*xmlInputCloseCallback) (void * context);
|
||||
|
||||
typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
|
||||
typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
|
||||
struct _xmlParserInputBuffer {
|
||||
void* context;
|
||||
xmlInputReadCallback readcallback;
|
||||
xmlInputCloseCallback closecallback;
|
||||
|
||||
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
||||
|
||||
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
|
||||
xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Those are the functions and datatypes for the library output
|
||||
* I/O structures.
|
||||
*/
|
||||
|
||||
typedef int (*xmlOutputMatchCallback) (char const *filename);
|
||||
typedef void * (*xmlOutputOpenCallback) (char const *filename);
|
||||
typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
|
||||
int len);
|
||||
typedef void (*xmlOutputCloseCallback) (void * context);
|
||||
|
||||
typedef struct _xmlOutputBuffer xmlOutputBuffer;
|
||||
typedef xmlOutputBuffer *xmlOutputBufferPtr;
|
||||
struct _xmlOutputBuffer {
|
||||
void* context;
|
||||
xmlOutputWriteCallback writecallback;
|
||||
xmlOutputCloseCallback closecallback;
|
||||
|
||||
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
||||
|
||||
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
|
||||
xmlBufferPtr conv; /* if encoder != NULL buffer for output */
|
||||
int written; /* total number of byte written */
|
||||
};
|
||||
|
||||
/*
|
||||
* Interfaces for input
|
||||
*/
|
||||
|
||||
void xmlRegisterDefaultInputCallbacks (void);
|
||||
xmlParserInputBufferPtr
|
||||
xmlAllocParserInputBuffer (xmlCharEncoding enc);
|
||||
|
||||
#ifdef VMS
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFname (const char *URI,
|
||||
xmlCharEncoding enc);
|
||||
#define xmlParserInputBufferCreateFilename xmlParserInputBufferCreateFname
|
||||
#else
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFilename (const char *URI,
|
||||
xmlCharEncoding enc);
|
||||
#endif
|
||||
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFile (FILE *file,
|
||||
xmlCharEncoding enc);
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFd (int fd,
|
||||
xmlCharEncoding enc);
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateMem (const char *mem, int size,
|
||||
xmlCharEncoding enc);
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
|
||||
int len);
|
||||
int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
|
||||
int len);
|
||||
int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
|
||||
int len,
|
||||
const char *buf);
|
||||
void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
|
||||
char * xmlParserGetDirectory (const char *filename);
|
||||
|
||||
int xmlRegisterInputCallbacks (xmlInputMatchCallback match,
|
||||
xmlInputOpenCallback open,
|
||||
xmlInputReadCallback read,
|
||||
xmlInputCloseCallback close);
|
||||
/*
|
||||
* Interfaces for output
|
||||
*/
|
||||
void xmlRegisterDefaultOutputCallbacks(void);
|
||||
xmlOutputBufferPtr
|
||||
xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
xmlOutputBufferCreateFilename (const char *URI,
|
||||
xmlCharEncodingHandlerPtr encoder,
|
||||
int compression);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
xmlOutputBufferCreateFile (FILE *file,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
xmlOutputBufferCreateFd (int fd,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
|
||||
xmlOutputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
int xmlOutputBufferWrite (xmlOutputBufferPtr out,
|
||||
int len,
|
||||
const char *buf);
|
||||
int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
|
||||
const char *str);
|
||||
|
||||
int xmlOutputBufferFlush (xmlOutputBufferPtr out);
|
||||
int xmlOutputBufferClose (xmlOutputBufferPtr out);
|
||||
|
||||
int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match,
|
||||
xmlOutputOpenCallback open,
|
||||
xmlOutputWriteCallback write,
|
||||
xmlOutputCloseCallback close);
|
||||
|
||||
/*
|
||||
* This save function are part of tree.h and HTMLtree.h actually
|
||||
*/
|
||||
int xmlSaveFileTo (xmlOutputBuffer *buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
void xmlNodeDumpOutput (xmlOutputBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
int level,
|
||||
int format,
|
||||
const char *encoding);
|
||||
void htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_IO_H__ */
|
180
include/libxml/xmlerror.h
Normal file
180
include/libxml/xmlerror.h
Normal file
@ -0,0 +1,180 @@
|
||||
#ifndef __XML_ERROR_H__
|
||||
#define __XML_ERROR_H__
|
||||
|
||||
#include <libxml/parser.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
XML_ERR_OK = 0,
|
||||
XML_ERR_INTERNAL_ERROR,
|
||||
XML_ERR_NO_MEMORY,
|
||||
|
||||
XML_ERR_DOCUMENT_START, /* 3 */
|
||||
XML_ERR_DOCUMENT_EMPTY,
|
||||
XML_ERR_DOCUMENT_END,
|
||||
|
||||
XML_ERR_INVALID_HEX_CHARREF, /* 6 */
|
||||
XML_ERR_INVALID_DEC_CHARREF,
|
||||
XML_ERR_INVALID_CHARREF,
|
||||
XML_ERR_INVALID_CHAR,
|
||||
|
||||
XML_ERR_CHARREF_AT_EOF, /* 10 */
|
||||
XML_ERR_CHARREF_IN_PROLOG,
|
||||
XML_ERR_CHARREF_IN_EPILOG,
|
||||
XML_ERR_CHARREF_IN_DTD,
|
||||
XML_ERR_ENTITYREF_AT_EOF,
|
||||
XML_ERR_ENTITYREF_IN_PROLOG,
|
||||
XML_ERR_ENTITYREF_IN_EPILOG,
|
||||
XML_ERR_ENTITYREF_IN_DTD,
|
||||
XML_ERR_PEREF_AT_EOF,
|
||||
XML_ERR_PEREF_IN_PROLOG,
|
||||
XML_ERR_PEREF_IN_EPILOG,
|
||||
XML_ERR_PEREF_IN_INT_SUBSET,
|
||||
|
||||
XML_ERR_ENTITYREF_NO_NAME, /* 22 */
|
||||
XML_ERR_ENTITYREF_SEMICOL_MISSING,
|
||||
|
||||
XML_ERR_PEREF_NO_NAME, /* 24 */
|
||||
XML_ERR_PEREF_SEMICOL_MISSING,
|
||||
|
||||
XML_ERR_UNDECLARED_ENTITY, /* 26 */
|
||||
XML_WAR_UNDECLARED_ENTITY,
|
||||
XML_ERR_UNPARSED_ENTITY,
|
||||
XML_ERR_ENTITY_IS_EXTERNAL,
|
||||
XML_ERR_ENTITY_IS_PARAMETER,
|
||||
|
||||
XML_ERR_UNKNOWN_ENCODING, /* 31 */
|
||||
XML_ERR_UNSUPPORTED_ENCODING,
|
||||
|
||||
XML_ERR_STRING_NOT_STARTED, /* 33 */
|
||||
XML_ERR_STRING_NOT_CLOSED,
|
||||
XML_ERR_NS_DECL_ERROR,
|
||||
|
||||
XML_ERR_ENTITY_NOT_STARTED, /* 36 */
|
||||
XML_ERR_ENTITY_NOT_FINISHED,
|
||||
|
||||
XML_ERR_LT_IN_ATTRIBUTE, /* 38 */
|
||||
XML_ERR_ATTRIBUTE_NOT_STARTED,
|
||||
XML_ERR_ATTRIBUTE_NOT_FINISHED,
|
||||
XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
|
||||
XML_ERR_ATTRIBUTE_REDEFINED,
|
||||
|
||||
XML_ERR_LITERAL_NOT_STARTED, /* 43 */
|
||||
XML_ERR_LITERAL_NOT_FINISHED,
|
||||
|
||||
XML_ERR_COMMENT_NOT_FINISHED, /* 45 */
|
||||
|
||||
XML_ERR_PI_NOT_STARTED, /* 47 */
|
||||
XML_ERR_PI_NOT_FINISHED,
|
||||
|
||||
XML_ERR_NOTATION_NOT_STARTED, /* 49 */
|
||||
XML_ERR_NOTATION_NOT_FINISHED,
|
||||
|
||||
XML_ERR_ATTLIST_NOT_STARTED, /* 51 */
|
||||
XML_ERR_ATTLIST_NOT_FINISHED,
|
||||
|
||||
XML_ERR_MIXED_NOT_STARTED, /* 53 */
|
||||
XML_ERR_MIXED_NOT_FINISHED,
|
||||
|
||||
XML_ERR_ELEMCONTENT_NOT_STARTED, /* 55 */
|
||||
XML_ERR_ELEMCONTENT_NOT_FINISHED,
|
||||
|
||||
XML_ERR_XMLDECL_NOT_STARTED, /* 57 */
|
||||
XML_ERR_XMLDECL_NOT_FINISHED,
|
||||
|
||||
XML_ERR_CONDSEC_NOT_STARTED, /* 59 */
|
||||
XML_ERR_CONDSEC_NOT_FINISHED,
|
||||
|
||||
XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 61 */
|
||||
|
||||
XML_ERR_DOCTYPE_NOT_FINISHED, /* 62 */
|
||||
|
||||
XML_ERR_MISPLACED_CDATA_END, /* 63 */
|
||||
XML_ERR_CDATA_NOT_FINISHED,
|
||||
|
||||
XML_ERR_RESERVED_XML_NAME, /* 65 */
|
||||
|
||||
XML_ERR_SPACE_REQUIRED, /* 66 */
|
||||
XML_ERR_SEPARATOR_REQUIRED,
|
||||
XML_ERR_NMTOKEN_REQUIRED,
|
||||
XML_ERR_NAME_REQUIRED,
|
||||
XML_ERR_PCDATA_REQUIRED,
|
||||
XML_ERR_URI_REQUIRED,
|
||||
XML_ERR_PUBID_REQUIRED,
|
||||
XML_ERR_LT_REQUIRED,
|
||||
XML_ERR_GT_REQUIRED,
|
||||
XML_ERR_LTSLASH_REQUIRED,
|
||||
XML_ERR_EQUAL_REQUIRED,
|
||||
|
||||
XML_ERR_TAG_NAME_MISMATCH, /* 77 */
|
||||
XML_ERR_TAG_NOT_FINISED,
|
||||
|
||||
XML_ERR_STANDALONE_VALUE, /* 79 */
|
||||
|
||||
XML_ERR_ENCODING_NAME, /* 80 */
|
||||
|
||||
XML_ERR_HYPHEN_IN_COMMENT, /* 81 */
|
||||
|
||||
XML_ERR_INVALID_ENCODING, /* 82 */
|
||||
|
||||
XML_ERR_EXT_ENTITY_STANDALONE, /* 83 */
|
||||
|
||||
XML_ERR_CONDSEC_INVALID, /* 84 */
|
||||
|
||||
XML_ERR_VALUE_REQUIRED, /* 85 */
|
||||
|
||||
XML_ERR_NOT_WELL_BALANCED, /* 86 */
|
||||
XML_ERR_EXTRA_CONTENT, /* 87 */
|
||||
XML_ERR_ENTITY_CHAR_ERROR, /* 88 */
|
||||
XML_ERR_ENTITY_PE_INTERNAL, /* 88 */
|
||||
XML_ERR_ENTITY_LOOP, /* 89 */
|
||||
XML_ERR_ENTITY_BOUNDARY, /* 90 */
|
||||
XML_ERR_INVALID_URI, /* 91 */
|
||||
XML_ERR_URI_FRAGMENT /* 92 */
|
||||
}xmlParserErrors;
|
||||
|
||||
/*
|
||||
* Signature of the function to use when there is an error and
|
||||
* no parsing or validity context available
|
||||
*/
|
||||
typedef void (*xmlGenericErrorFunc) (void *ctx, const char *msg, ...);
|
||||
|
||||
/*
|
||||
* Those are the default error function and associated context to use
|
||||
* when when there is an error and no parsing or validity context available
|
||||
*/
|
||||
|
||||
LIBXML_DLL_IMPORT extern xmlGenericErrorFunc xmlGenericError;
|
||||
LIBXML_DLL_IMPORT extern void *xmlGenericErrorContext;
|
||||
|
||||
/*
|
||||
* Use the following function to reset the two previous global variables.
|
||||
*/
|
||||
void xmlSetGenericErrorFunc (void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
|
||||
/*
|
||||
* Default message routines used by SAX and Valid context for error
|
||||
* and warning reporting
|
||||
*/
|
||||
void xmlParserError (void *ctx,
|
||||
const char *msg,
|
||||
...);
|
||||
void xmlParserWarning (void *ctx,
|
||||
const char *msg,
|
||||
...);
|
||||
void xmlParserValidityError (void *ctx,
|
||||
const char *msg,
|
||||
...);
|
||||
void xmlParserValidityWarning(void *ctx,
|
||||
const char *msg,
|
||||
...);
|
||||
void xmlParserPrintFileInfo (xmlParserInputPtr input);
|
||||
void xmlParserPrintFileContext(xmlParserInputPtr input);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_ERROR_H__ */
|
91
include/libxml/xmlmemory.h
Normal file
91
include/libxml/xmlmemory.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* xmlmemory.h: interface for the memory allocation debug.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DEBUG_MEMORY_ALLOC_
|
||||
#define _DEBUG_MEMORY_ALLOC_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
/*
|
||||
* DEBUG_MEMORY_LOCATION should be activated only done when debugging
|
||||
* libxml.
|
||||
*/
|
||||
/* #define DEBUG_MEMORY_LOCATION */
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifndef DEBUG_MEMORY
|
||||
#define DEBUG_MEMORY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MEMORY_LOCATION
|
||||
#define MEM_LIST /* keep a list of all the allocated memory blocks */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The XML memory wrapper support 4 basic overloadable functions
|
||||
*/
|
||||
typedef void (*xmlFreeFunc)(void *);
|
||||
typedef void *(*xmlMallocFunc)(int);
|
||||
typedef void *(*xmlReallocFunc)(void *, int);
|
||||
typedef char *(*xmlStrdupFunc)(const char *);
|
||||
|
||||
/*
|
||||
* The 4 interfaces used for all memory handling within libxml
|
||||
*/
|
||||
LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree;
|
||||
LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
|
||||
LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc;
|
||||
LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
|
||||
|
||||
/*
|
||||
* The way to overload the existing functions
|
||||
*/
|
||||
int xmlMemSetup (xmlFreeFunc freeFunc,
|
||||
xmlMallocFunc mallocFunc,
|
||||
xmlReallocFunc reallocFunc,
|
||||
xmlStrdupFunc strdupFunc);
|
||||
int xmlMemGet (xmlFreeFunc *freeFunc,
|
||||
xmlMallocFunc *mallocFunc,
|
||||
xmlReallocFunc *reallocFunc,
|
||||
xmlStrdupFunc *strdupFunc);
|
||||
|
||||
/*
|
||||
* Initialization of the memory layer
|
||||
*/
|
||||
int xmlInitMemory (void);
|
||||
|
||||
/*
|
||||
* Those are specific to the XML debug memory wrapper
|
||||
*/
|
||||
int xmlMemUsed (void);
|
||||
void xmlMemDisplay (FILE *fp);
|
||||
void xmlMemShow (FILE *fp, int nr);
|
||||
void xmlMemoryDump (void);
|
||||
int xmlInitMemory (void);
|
||||
|
||||
#ifdef DEBUG_MEMORY_LOCATION
|
||||
#define xmlMalloc(x) xmlMallocLoc((x), __FILE__, __LINE__)
|
||||
#define xmlRealloc(p, x) xmlReallocLoc((p), (x), __FILE__, __LINE__)
|
||||
#define xmlMemStrdup(x) xmlMemStrdupLoc((x), __FILE__, __LINE__)
|
||||
|
||||
void * xmlMallocLoc(int size, const char *file, int line);
|
||||
void * xmlReallocLoc(void *ptr,int size, const char *file, int line);
|
||||
char * xmlMemStrdupLoc(const char *str, const char *file, int line);
|
||||
#endif /* DEBUG_MEMORY_LOCATION */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _DEBUG_MEMORY_ALLOC_ */
|
||||
|
129
include/libxml/xmlversion.h.in
Normal file
129
include/libxml/xmlversion.h.in
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* xmlversion.h : compile-time version informations for the XML parser.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_VERSION_H__
|
||||
#define __XML_VERSION_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* use those to be sure nothing nasty will happen if
|
||||
* your library and includes mismatch
|
||||
*/
|
||||
extern void xmlCheckVersion(int version);
|
||||
#define LIBXML_DOTTED_VERSION "@VERSION@"
|
||||
#define LIBXML_VERSION @LIBXML_VERSION_NUMBER@
|
||||
#define LIBXML_VERSION_STRING "@LIBXML_VERSION_NUMBER@"
|
||||
#define LIBXML_TEST_VERSION xmlCheckVersion(@LIBXML_VERSION_NUMBER@);
|
||||
|
||||
/*
|
||||
* Whether the FTP support is configured in
|
||||
*/
|
||||
#if @WITH_FTP@
|
||||
#define LIBXML_FTP_ENABLED
|
||||
#else
|
||||
#define LIBXML_FTP_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the HTTP support is configured in
|
||||
*/
|
||||
#if @WITH_HTTP@
|
||||
#define LIBXML_HTTP_ENABLED
|
||||
#else
|
||||
#define LIBXML_HTTP_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the HTML support is configured in
|
||||
*/
|
||||
#if @WITH_HTML@
|
||||
#define LIBXML_HTML_ENABLED
|
||||
#else
|
||||
#define LIBXML_HTML_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the Docbook support is configured in
|
||||
#if @WITH_SGML@
|
||||
#define LIBXML_SGML_ENABLED
|
||||
#else
|
||||
#define LIBXML_SGML_DISABLED
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*
|
||||
* Whether XPath is configured in
|
||||
*/
|
||||
#if @WITH_XPATH@
|
||||
#define LIBXML_XPATH_ENABLED
|
||||
#else
|
||||
#define LIBXML_XPATH_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether XPointer is configured in
|
||||
*/
|
||||
#if @WITH_XPTR@
|
||||
#define LIBXML_XPTR_ENABLED
|
||||
#else
|
||||
#define LIBXML_XPTR_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether XInclude is configured in
|
||||
*/
|
||||
#if @WITH_XINCLUDE@
|
||||
#define LIBXML_XINCLUDE_ENABLED
|
||||
#else
|
||||
#define LIBXML_XINCLUDE_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether iconv support is available
|
||||
*/
|
||||
#ifndef WIN32
|
||||
#if @WITH_ICONV@
|
||||
#define LIBXML_ICONV_ENABLED
|
||||
#else
|
||||
#define LIBXML_ICONV_DISABLED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether Debugging module is configured in
|
||||
*/
|
||||
#if @WITH_DEBUG@
|
||||
#define LIBXML_DEBUG_ENABLED
|
||||
#else
|
||||
#define LIBXML_DEBUG_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the memory debugging is configured in
|
||||
*/
|
||||
#if @WITH_MEM_DEBUG@
|
||||
#define DEBUG_MEMORY_LOCATION
|
||||
#endif
|
||||
|
||||
#ifndef LIBXML_DLL_IMPORT
|
||||
#if defined(WIN32) && !defined(STATIC)
|
||||
#define LIBXML_DLL_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define LIBXML_DLL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
|
278
include/libxml/xpath.h
Normal file
278
include/libxml/xpath.h
Normal file
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* xpath.c: interface for XML Path Language implementation
|
||||
*
|
||||
* Reference: W3C Working Draft 5 July 1999
|
||||
* http://www.w3.org/Style/XSL/Group/1999/07/xpath-19990705.html
|
||||
*
|
||||
* See COPYRIGHT for the status of this software
|
||||
*
|
||||
* Author: Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XPATH_H__
|
||||
#define __XML_XPATH_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _xmlXPathContext xmlXPathContext;
|
||||
typedef xmlXPathContext *xmlXPathContextPtr;
|
||||
typedef struct _xmlXPathParserContext xmlXPathParserContext;
|
||||
typedef xmlXPathParserContext *xmlXPathParserContextPtr;
|
||||
|
||||
/**
|
||||
* The set of XPath error codes
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XPATH_EXPRESSION_OK = 0,
|
||||
XPATH_NUMBER_ERROR,
|
||||
XPATH_UNFINISHED_LITERAL_ERROR,
|
||||
XPATH_START_LITERAL_ERROR,
|
||||
XPATH_VARIABLE_REF_ERROR,
|
||||
XPATH_UNDEF_VARIABLE_ERROR,
|
||||
XPATH_INVALID_PREDICATE_ERROR,
|
||||
XPATH_EXPR_ERROR,
|
||||
XPATH_UNCLOSED_ERROR,
|
||||
XPATH_UNKNOWN_FUNC_ERROR,
|
||||
XPATH_INVALID_OPERAND,
|
||||
XPATH_INVALID_TYPE,
|
||||
XPATH_INVALID_ARITY,
|
||||
XPATH_INVALID_CTXT_SIZE,
|
||||
XPATH_INVALID_CTXT_POSITION,
|
||||
XPATH_MEMORY_ERROR,
|
||||
XPTR_SYNTAX_ERROR,
|
||||
XPTR_RESOURCE_ERROR,
|
||||
XPTR_SUB_RESOURCE_ERROR,
|
||||
XPATH_UNDEF_PREFIX_ERROR
|
||||
} xmlXPathError;
|
||||
|
||||
/*
|
||||
* A node-set (an unordered collection of nodes without duplicates)
|
||||
*/
|
||||
typedef struct _xmlNodeSet xmlNodeSet;
|
||||
typedef xmlNodeSet *xmlNodeSetPtr;
|
||||
struct _xmlNodeSet {
|
||||
int nodeNr; /* number of nodes in the set */
|
||||
int nodeMax; /* size of the array as allocated */
|
||||
xmlNodePtr *nodeTab; /* array of nodes in no particular order */
|
||||
};
|
||||
|
||||
/*
|
||||
* An expression is evaluated to yield an object, which
|
||||
* has one of the following four basic types:
|
||||
* - node-set
|
||||
* - boolean
|
||||
* - number
|
||||
* - string
|
||||
*
|
||||
* @@ XPointer will add more types !
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XPATH_UNDEFINED = 0,
|
||||
XPATH_NODESET = 1,
|
||||
XPATH_BOOLEAN = 2,
|
||||
XPATH_NUMBER = 3,
|
||||
XPATH_STRING = 4,
|
||||
XPATH_POINT = 5,
|
||||
XPATH_RANGE = 6,
|
||||
XPATH_LOCATIONSET = 7,
|
||||
XPATH_USERS = 8,
|
||||
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
|
||||
} xmlXPathObjectType;
|
||||
|
||||
typedef struct _xmlXPathObject xmlXPathObject;
|
||||
typedef xmlXPathObject *xmlXPathObjectPtr;
|
||||
struct _xmlXPathObject {
|
||||
xmlXPathObjectType type;
|
||||
xmlNodeSetPtr nodesetval;
|
||||
int boolval;
|
||||
double floatval;
|
||||
xmlChar *stringval;
|
||||
void *user;
|
||||
int index;
|
||||
void *user2;
|
||||
int index2;
|
||||
};
|
||||
|
||||
/*
|
||||
* A conversion function is associated to a type and used to cast
|
||||
* the new type to primitive values.
|
||||
*/
|
||||
typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type);
|
||||
|
||||
/*
|
||||
* Extra type: a name and a conversion function.
|
||||
*/
|
||||
|
||||
typedef struct _xmlXPathType xmlXPathType;
|
||||
typedef xmlXPathType *xmlXPathTypePtr;
|
||||
struct _xmlXPathType {
|
||||
const xmlChar *name; /* the type name */
|
||||
xmlXPathConvertFunc func; /* the conversion function */
|
||||
};
|
||||
|
||||
/*
|
||||
* Extra variable: a name and a value.
|
||||
*/
|
||||
|
||||
typedef struct _xmlXPathVariable xmlXPathVariable;
|
||||
typedef xmlXPathVariable *xmlXPathVariablePtr;
|
||||
struct _xmlXPathVariable {
|
||||
const xmlChar *name; /* the variable name */
|
||||
xmlXPathObjectPtr value; /* the value */
|
||||
};
|
||||
|
||||
/*
|
||||
* an evaluation function, the parameters are on the context stack
|
||||
*/
|
||||
|
||||
typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
|
||||
/*
|
||||
* Extra function: a name and a evaluation function.
|
||||
*/
|
||||
|
||||
typedef struct _xmlXPathFunct xmlXPathFunct;
|
||||
typedef xmlXPathFunct *xmlXPathFuncPtr;
|
||||
struct _xmlXPathFunct {
|
||||
const xmlChar *name; /* the function name */
|
||||
xmlXPathEvalFunc func; /* the evaluation function */
|
||||
};
|
||||
|
||||
/*
|
||||
* An axis traversal function. To traverse an axis, the engine calls
|
||||
* the first time with cur == NULL and repeat until the function returns
|
||||
* NULL indicating the end of the axis traversal.
|
||||
*/
|
||||
|
||||
typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr cur);
|
||||
|
||||
/*
|
||||
* Extra axis: a name and an axis function.
|
||||
*/
|
||||
|
||||
typedef struct _xmlXPathAxis xmlXPathAxis;
|
||||
typedef xmlXPathAxis *xmlXPathAxisPtr;
|
||||
struct _xmlXPathAxis {
|
||||
const xmlChar *name; /* the axis name */
|
||||
xmlXPathAxisFunc func; /* the search function */
|
||||
};
|
||||
|
||||
/*
|
||||
* Expression evaluation occurs with respect to a context.
|
||||
* he context consists of:
|
||||
* - a node (the context node)
|
||||
* - a node list (the context node list)
|
||||
* - a set of variable bindings
|
||||
* - a function library
|
||||
* - the set of namespace declarations in scope for the expression
|
||||
* Following the switch to hash tables, this need to be trimmed up at
|
||||
* the next binary incompatible release.
|
||||
*/
|
||||
|
||||
struct _xmlXPathContext {
|
||||
xmlDocPtr doc; /* The current document */
|
||||
xmlNodePtr node; /* The current node */
|
||||
|
||||
int nb_variables_unused; /* unused (hash table) */
|
||||
int max_variables_unused; /* unused (hash table) */
|
||||
xmlHashTablePtr varHash; /* Hash table of defined variables */
|
||||
|
||||
int nb_types; /* number of defined types */
|
||||
int max_types; /* max number of types */
|
||||
xmlXPathTypePtr types; /* Array of defined types */
|
||||
|
||||
int nb_funcs_unused; /* unused (hash table) */
|
||||
int max_funcs_unused; /* unused (hash table) */
|
||||
xmlHashTablePtr funcHash; /* Hash table of defined funcs */
|
||||
|
||||
int nb_axis; /* number of defined axis */
|
||||
int max_axis; /* max number of axis */
|
||||
xmlXPathAxisPtr axis; /* Array of defined axis */
|
||||
|
||||
/* the namespace nodes of the context node */
|
||||
xmlNsPtr *namespaces; /* Array of namespaces */
|
||||
int nsNr; /* number of namespace in scope */
|
||||
void *user; /* function to free */
|
||||
|
||||
/* extra variables */
|
||||
int contextSize; /* the context size */
|
||||
int proximityPosition; /* the proximity position */
|
||||
|
||||
/* extra stuff for XPointer */
|
||||
int xptr; /* it this an XPointer context */
|
||||
xmlNodePtr here; /* for here() */
|
||||
xmlNodePtr origin; /* for origin() */
|
||||
|
||||
/* the set of namespace declarations in scope for the expression */
|
||||
xmlHashTablePtr nsHash; /* The namespaces hash table */
|
||||
void *varLookupFunc; /* variable lookup func */
|
||||
void *varLookupData; /* variable lookup data */
|
||||
|
||||
/* Possibility to link in an extra item */
|
||||
void *extra; /* needed for XSLT */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XPath parser context, it contains pure parsing informations,
|
||||
* an xmlXPathContext, and the stack of objects.
|
||||
*/
|
||||
struct _xmlXPathParserContext {
|
||||
const xmlChar *cur; /* the current char being parsed */
|
||||
const xmlChar *base; /* the full expression */
|
||||
|
||||
int error; /* error code */
|
||||
|
||||
xmlXPathContextPtr context; /* the evaluation context */
|
||||
xmlXPathObjectPtr value; /* the current value */
|
||||
int valueNr; /* number of values stacked */
|
||||
int valueMax; /* max number of values stacked */
|
||||
xmlXPathObjectPtr *valueTab; /* stack of values */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XPath function
|
||||
* The arguments (if any) are popped out of the context stack
|
||||
* and the result is pushed on the stack.
|
||||
*/
|
||||
|
||||
typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs);
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Public API *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* Evaluation functions.
|
||||
*/
|
||||
void xmlXPathInit (void);
|
||||
xmlXPathContextPtr xmlXPathNewContext (xmlDocPtr doc);
|
||||
void xmlXPathFreeContext (xmlXPathContextPtr ctxt);
|
||||
xmlXPathObjectPtr xmlXPathEval (const xmlChar *str,
|
||||
xmlXPathContextPtr ctxt);
|
||||
xmlXPathObjectPtr xmlXPathEvalXPtrExpr (const xmlChar *str,
|
||||
xmlXPathContextPtr ctxt);
|
||||
void xmlXPathFreeObject (xmlXPathObjectPtr obj);
|
||||
xmlXPathObjectPtr xmlXPathEvalExpression (const xmlChar *str,
|
||||
xmlXPathContextPtr ctxt);
|
||||
xmlNodeSetPtr xmlXPathNodeSetCreate (xmlNodePtr val);
|
||||
void xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj);
|
||||
void xmlXPathFreeNodeSet (xmlNodeSetPtr obj);
|
||||
xmlXPathObjectPtr xmlXPathObjectCopy (xmlXPathObjectPtr val);
|
||||
int xmlXPathCmpNodes (xmlNodePtr node1,
|
||||
xmlNodePtr node2);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! __XML_XPATH_H__ */
|
236
include/libxml/xpathInternals.h
Normal file
236
include/libxml/xpathInternals.h
Normal file
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* xpath.c: internal interfaces for XML Path Language implementation
|
||||
* used to build new modules on top of XPath
|
||||
*
|
||||
* See COPYRIGHT for the status of this software
|
||||
*
|
||||
* Author: Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XPATH_INTERNALS_H__
|
||||
#define __XML_XPATH_INTERNALS_H__
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Helpers *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
#define CHECK_ERROR \
|
||||
if (ctxt->error != XPATH_EXPRESSION_OK) return
|
||||
|
||||
#define CHECK_ERROR0 \
|
||||
if (ctxt->error != XPATH_EXPRESSION_OK) return(0)
|
||||
|
||||
#define XP_ERROR(X) \
|
||||
{ xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
|
||||
ctxt->error = (X); return; }
|
||||
|
||||
#define XP_ERROR0(X) \
|
||||
{ xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
|
||||
ctxt->error = (X); return(0); }
|
||||
|
||||
#define CHECK_TYPE(typeval) \
|
||||
if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
|
||||
XP_ERROR(XPATH_INVALID_TYPE)
|
||||
|
||||
#define CHECK_ARITY(x) \
|
||||
if (nargs != (x)) \
|
||||
XP_ERROR(XPATH_INVALID_ARITY);
|
||||
|
||||
#define CAST_TO_STRING \
|
||||
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \
|
||||
xmlXPathStringFunction(ctxt, 1);
|
||||
|
||||
#define CAST_TO_NUMBER \
|
||||
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \
|
||||
xmlXPathNumberFunction(ctxt, 1);
|
||||
|
||||
#define CAST_TO_BOOLEAN \
|
||||
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
|
||||
xmlXPathBooleanFunction(ctxt, 1);
|
||||
|
||||
/*
|
||||
* Varibale Lookup forwarding
|
||||
*/
|
||||
typedef xmlXPathObjectPtr
|
||||
(*xmlXPathVariableLookupFunc) (void *ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri);
|
||||
|
||||
void xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
|
||||
xmlXPathVariableLookupFunc f,
|
||||
void *varCtxt);
|
||||
|
||||
/*
|
||||
* Error reporting
|
||||
*/
|
||||
void xmlXPatherror (xmlXPathParserContextPtr ctxt,
|
||||
const char *file,
|
||||
int line,
|
||||
int no);
|
||||
|
||||
void xmlXPathDebugDumpObject (FILE *output,
|
||||
xmlXPathObjectPtr cur,
|
||||
int depth);
|
||||
|
||||
/**
|
||||
* Extending a context
|
||||
*/
|
||||
|
||||
int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *ns_uri);
|
||||
const xmlChar * xmlXPathNsLookup (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *ns_uri);
|
||||
void xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt);
|
||||
|
||||
int xmlXPathRegisterFunc (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
xmlXPathFunction f);
|
||||
int xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri,
|
||||
xmlXPathFunction f);
|
||||
int xmlXPathRegisterVariable (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
xmlXPathObjectPtr value);
|
||||
int xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri,
|
||||
xmlXPathObjectPtr value);
|
||||
xmlXPathFunction xmlXPathFunctionLookup (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name);
|
||||
xmlXPathFunction xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri);
|
||||
void xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt);
|
||||
xmlXPathObjectPtr xmlXPathVariableLookup (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name);
|
||||
xmlXPathObjectPtr xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri);
|
||||
void xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
|
||||
|
||||
/**
|
||||
* Utilities to extend XPath
|
||||
*/
|
||||
xmlXPathParserContextPtr
|
||||
xmlXPathNewParserContext (const xmlChar *str,
|
||||
xmlXPathContextPtr ctxt);
|
||||
void xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
|
||||
|
||||
/* TODO: remap to xmlXPathValuePop and Push */
|
||||
xmlXPathObjectPtr valuePop (xmlXPathParserContextPtr ctxt);
|
||||
int valuePush (xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr value);
|
||||
|
||||
xmlXPathObjectPtr xmlXPathNewString (const xmlChar *val);
|
||||
xmlXPathObjectPtr xmlXPathNewCString (const char *val);
|
||||
xmlXPathObjectPtr xmlXPathNewFloat (double val);
|
||||
xmlXPathObjectPtr xmlXPathNewBoolean (int val);
|
||||
xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
|
||||
xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val);
|
||||
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
|
||||
xmlNodePtr val);
|
||||
|
||||
|
||||
void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt,
|
||||
int nargs);
|
||||
void xmlXPathRoot (xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt);
|
||||
xmlChar * xmlXPathParseName (xmlXPathParserContextPtr ctxt);
|
||||
xmlChar * xmlXPathParseNCName (xmlXPathParserContextPtr ctxt);
|
||||
|
||||
/*
|
||||
* Debug
|
||||
*/
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
double xmlXPathStringEvalNumber(const xmlChar *str);
|
||||
void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth);
|
||||
#endif
|
||||
/*
|
||||
* Existing functions
|
||||
*/
|
||||
|
||||
int xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr res);
|
||||
void xmlXPathInit(void);
|
||||
void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt);
|
||||
xmlNodeSetPtr xmlXPathNodeSetCreate(xmlNodePtr val);
|
||||
void xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val);
|
||||
xmlNodeSetPtr xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2);
|
||||
void xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val);
|
||||
void xmlXPathNodeSetRemove(xmlNodeSetPtr cur, int val);
|
||||
void xmlXPathFreeNodeSet(xmlNodeSetPtr obj);
|
||||
xmlXPathObjectPtr xmlXPathNewNodeSet(xmlNodePtr val);
|
||||
xmlXPathObjectPtr xmlXPathNewNodeSetList(xmlNodeSetPtr val);
|
||||
xmlXPathObjectPtr xmlXPathWrapNodeSet(xmlNodeSetPtr val);
|
||||
void xmlXPathFreeNodeSetList(xmlXPathObjectPtr obj);
|
||||
|
||||
|
||||
xmlXPathObjectPtr xmlXPathNewFloat(double val);
|
||||
xmlXPathObjectPtr xmlXPathNewBoolean(int val);
|
||||
xmlXPathObjectPtr xmlXPathNewString(const xmlChar *val);
|
||||
xmlXPathObjectPtr xmlXPathNewCString(const char *val);
|
||||
void xmlXPathFreeObject(xmlXPathObjectPtr obj);
|
||||
xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc);
|
||||
void xmlXPathFreeContext(xmlXPathContextPtr ctxt);
|
||||
|
||||
int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
|
||||
int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
|
||||
void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
|
||||
|
||||
|
||||
/*
|
||||
* Some of the axis navigation routines
|
||||
*/
|
||||
xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
|
||||
xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
|
||||
xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
|
||||
/*
|
||||
* The official core of XPath functions
|
||||
*/
|
||||
void xmlXPathRoot(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! __XML_XPATH_INTERNALS_H__ */
|
57
include/libxml/xpointer.h
Normal file
57
include/libxml/xpointer.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* xpointer.h : API to handle XML Pointers
|
||||
*
|
||||
* World Wide Web Consortium Working Draft 03-March-1998
|
||||
* http://www.w3.org/TR/1998/WD-xptr-19980303
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XPTR_H__
|
||||
#define __XML_XPTR_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A Location Set
|
||||
*/
|
||||
typedef struct _xmlLocationSet xmlLocationSet;
|
||||
typedef xmlLocationSet *xmlLocationSetPtr;
|
||||
struct _xmlLocationSet {
|
||||
int locNr; /* number of locations in the set */
|
||||
int locMax; /* size of the array as allocated */
|
||||
xmlXPathObjectPtr *locTab;/* array of locations */
|
||||
};
|
||||
|
||||
/*
|
||||
* Handling of location sets
|
||||
*/
|
||||
|
||||
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
|
||||
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
|
||||
xmlLocationSetPtr val2);
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
xmlXPathContextPtr xmlXPtrNewContext (xmlDocPtr doc,
|
||||
xmlNodePtr here,
|
||||
xmlNodePtr origin);
|
||||
xmlXPathObjectPtr xmlXPtrEval (const xmlChar *str,
|
||||
xmlXPathContextPtr ctx);
|
||||
void xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
|
||||
int nargs);
|
||||
xmlNodePtr xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
|
||||
void xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_XPTR_H__ */
|
92
include/win32config.h
Normal file
92
include/win32config.h
Normal file
@ -0,0 +1,92 @@
|
||||
#define HAVE_CTYPE_H
|
||||
#define HAVE_STDLIB_H
|
||||
#define HAVE_MALLOC_H
|
||||
#define HAVE_TIME_H
|
||||
#define HAVE_FCNTL_H
|
||||
|
||||
#include <io.h>
|
||||
|
||||
#define LIBXML_DLL_IMPORT
|
||||
#define SOCKLEN_T int
|
||||
|
||||
#ifdef INCLUDE_WINSOCK
|
||||
#include <winsock2.h>
|
||||
|
||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define EALREADY WSAEALREADY
|
||||
#define ENOTSOCK WSAENOTSOCK
|
||||
#define EDESTADDRREQ WSAEDESTADDRREQ
|
||||
#define EMSGSIZE WSAEMSGSIZE
|
||||
#define EPROTOTYPE WSAEPROTOTYPE
|
||||
#define ENOPROTOOPT WSAENOPROTOOPT
|
||||
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
|
||||
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
|
||||
#define EOPNOTSUPP WSAEOPNOTSUPP
|
||||
#define EPFNOSUPPORT WSAEPFNOSUPPORT
|
||||
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||
#define EADDRINUSE WSAEADDRINUSE
|
||||
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
|
||||
#define ENETDOWN WSAENETDOWN
|
||||
#define ENETUNREACH WSAENETUNREACH
|
||||
#define ENETRESET WSAENETRESET
|
||||
#define ECONNABORTED WSAECONNABORTED
|
||||
#define ECONNRESET WSAECONNRESET
|
||||
#define ENOBUFS WSAENOBUFS
|
||||
#define EISCONN WSAEISCONN
|
||||
#define ENOTCONN WSAENOTCONN
|
||||
#define ESHUTDOWN WSAESHUTDOWN
|
||||
#define ETOOMANYREFS WSAETOOMANYREFS
|
||||
#define ETIMEDOUT WSAETIMEDOUT
|
||||
#define ECONNREFUSED WSAECONNREFUSED
|
||||
#define ELOOP WSAELOOP
|
||||
#define ENAMETOOLONG WSAENAMETOOLONG
|
||||
#define EHOSTDOWN WSAEHOSTDOWN
|
||||
#define EHOSTUNREACH WSAEHOSTUNREACH
|
||||
#define ENOTEMPTY WSAENOTEMPTY
|
||||
#define EPROCLIM WSAEPROCLIM
|
||||
#define EUSERS WSAEUSERS
|
||||
#define EDQUOT WSAEDQUOT
|
||||
#define ESTALE WSAESTALE
|
||||
#define EREMOTE WSAEREMOTE
|
||||
#endif /* INCLUDE_WINSOCK */
|
||||
|
||||
#define HAVE_ISINF
|
||||
#define HAVE_ISNAN
|
||||
|
||||
#include <math.h>
|
||||
static int isinf (double d) {
|
||||
int expon = 0;
|
||||
double val = frexp (d, &expon);
|
||||
if (expon == 1025) {
|
||||
if (val == 0.5) {
|
||||
return 1;
|
||||
} else if (val == -0.5) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
static int isnan (double d) {
|
||||
int expon = 0;
|
||||
double val = frexp (d, &expon);
|
||||
if (expon == 1025) {
|
||||
if (val == 0.5) {
|
||||
return 0;
|
||||
} else if (val == -0.5) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#include <direct.h>
|
||||
|
||||
#define HAVE_SYS_STAT_H #define HAVE__STAT
|
||||
|
12
libxml-2.0.pc.in
Normal file
12
libxml-2.0.pc.in
Normal file
@ -0,0 +1,12 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
|
||||
Name: libXML
|
||||
Version: @VERSION@
|
||||
Description: libXML library.
|
||||
Requires:
|
||||
Libs: -L${libdir} -lxml2 @Z_LIBS@ @M_LIBS@ @LIBS@
|
||||
Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
|
66
libxml.4
Normal file
66
libxml.4
Normal file
@ -0,0 +1,66 @@
|
||||
.TH libxml 4 "12 April 2000"
|
||||
.SH NAME
|
||||
libxml \- library used to parse XML files
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I libxml
|
||||
library is used to parse XML files.
|
||||
Its internal document repesentation is as close as possible to the
|
||||
.I DOM
|
||||
(Document Object Model) interface,
|
||||
an API for accessing XML or HTML structured documents.
|
||||
.LP
|
||||
The
|
||||
.I libxml
|
||||
library also has a
|
||||
.IR SAX -like
|
||||
interface,
|
||||
which is designed to be compatible with
|
||||
.IR expat (1).
|
||||
NOTE:
|
||||
.IR SAX ,
|
||||
the Simple API for XML,
|
||||
is a standard interface for event-based XML parsing,
|
||||
developed collaboratively by the members of the XML-DEV mailing list,
|
||||
currently hosted by OASIS.
|
||||
The
|
||||
.I expat
|
||||
library is a XML 1.0 parser written in C,
|
||||
which aims to be fully conforming.
|
||||
It is currently not a validating XML processor.
|
||||
.LP
|
||||
The
|
||||
.I libxml
|
||||
library now includes a nearly complete
|
||||
.I XPath
|
||||
implementation.
|
||||
The
|
||||
.I XPath
|
||||
(XML Path Language) is a language for addressing parts of an
|
||||
XML document,
|
||||
designed to be used by both
|
||||
.I XSLT
|
||||
and
|
||||
.IR XPointer .
|
||||
.LP
|
||||
The
|
||||
.I libxml
|
||||
library exports Push and Pull type parser interfaces for both XML and
|
||||
.IR html .
|
||||
.SH FILES
|
||||
.TP 2.2i
|
||||
.B /depot/lib/libxml_2.0.0/libxml.a
|
||||
static library
|
||||
.TP
|
||||
.B /depot/lib/libxml_2.0.0/libxml.so
|
||||
shareable library
|
||||
.TP
|
||||
.B /depot/package/libxml_2.0.0/bin/xmllint
|
||||
binary application for parsing XML files
|
||||
.SH AUTHORS
|
||||
Daniel Veillard (Daniel.Veillard@w3.org).
|
||||
If you download and install this package please send the author email.
|
||||
Manual page by Ziying Sherwin (sherwin@nlm.nih.gov),
|
||||
Lister Hill National Center for Biomedical Communications,
|
||||
U.S. National Library of Medicine.
|
||||
.\" end of manual page
|
148
libxml.m4
Normal file
148
libxml.m4
Normal file
@ -0,0 +1,148 @@
|
||||
dnl Code shamelessly stolen from glib-config by Sebastian Rittau
|
||||
dnl AM_PATH_XML([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
AC_DEFUN(AM_PATH_XML,[
|
||||
AC_ARG_WITH(xml-prefix,
|
||||
[ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
|
||||
xml_config_prefix="$withval", xml_config_prefix="")
|
||||
AC_ARG_ENABLE(xmltest,
|
||||
[ --disable-xmltest Do not try to compile and run a test XML program],,
|
||||
enable_xmltest=yes)
|
||||
|
||||
if test x$xml_config_prefix != x ; then
|
||||
xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
|
||||
if test x${XML_CONFIG+set} != xset ; then
|
||||
XML_CONFIG=$xml_config_prefix/bin/xml-config
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(XML_CONFIG, xml-config, no)
|
||||
min_xml_version=ifelse([$1], ,2.0.0, [$1])
|
||||
AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
|
||||
no_xml=""
|
||||
if test "$XML_CONFIG" = "no" ; then
|
||||
no_xml=yes
|
||||
else
|
||||
XML_CFLAGS=`$XML_CONFIG $xml_config_args --cflags`
|
||||
XML_LIBS=`$XML_CONFIG $xml_config_args --libs`
|
||||
xml_config_major_version=`$XML_CONFIG $xml_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
xml_config_minor_version=`$XML_CONFIG $xml_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
xml_config_micro_version=`$XML_CONFIG $xml_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
if test "x$enable_xmltest" = "xyes" ; then
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $XML_CFLAGS"
|
||||
LIBS="$XML_LIBS $LIBS"
|
||||
dnl
|
||||
dnl Now check if the installed libxml is sufficiently new.
|
||||
dnl
|
||||
rm -f conf.xmltest
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <xmlversion.h>
|
||||
#include <parser.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int xml_major_version, xml_minor_version, xml_micro_version;
|
||||
int major, minor, micro;
|
||||
char *tmp_version;
|
||||
|
||||
system("touch conf.xmltest");
|
||||
|
||||
tmp_version = xmlStrdup("$min_xml_version");
|
||||
if(sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
||||
printf("%s, bad version string\n", "$min_xml_version");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
tmp_version = xmlStrdup(LIBXML_DOTTED_VERSION);
|
||||
if(sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
|
||||
printf("%s, bad version string\n", "$min_xml_version");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if((xml_major_version != $xml_config_major_version) ||
|
||||
(xml_minor_version != $xml_config_minor_version) ||
|
||||
(xml_micro_version != $xml_config_micro_version))
|
||||
{
|
||||
printf("\n*** 'xml-config --version' returned %d.%d.%d, but libxml (%d.%d.%d)\n",
|
||||
$xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version,
|
||||
xml_major_version, xml_minor_version, xml_micro_version);
|
||||
printf("*** was found! If xml-config was correct, then it is best\n");
|
||||
printf("*** to remove the old version of libxml. You may also be able to fix the error\n");
|
||||
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
|
||||
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
|
||||
printf("*** required on your system.\n");
|
||||
printf("*** If xml-config was wrong, set the environment variable XML_CONFIG\n");
|
||||
printf("*** to point to the correct copy of xml-config, and remove the file config.cache\n");
|
||||
printf("*** before re-running configure\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((xml_major_version > major) ||
|
||||
((xml_major_version == major) && (xml_minor_version > minor)) ||
|
||||
((xml_major_version == major) && (xml_minor_version == minor) &&
|
||||
(xml_micro_version >= micro)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
|
||||
xml_major_version, xml_minor_version, xml_micro_version);
|
||||
printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
|
||||
major, minor, micro);
|
||||
printf("*** libxml is always available from ftp://ftp.gnome.org.\n");
|
||||
printf("***\n");
|
||||
printf("*** If you have already installed a sufficiently new version, this error\n");
|
||||
printf("*** probably means that the wrong copy of the xml-config shell script is\n");
|
||||
printf("*** being found. The easiest way to fix this is to remove the old version\n");
|
||||
printf("*** of libxml, but you can also set the XML_CONFIG environment to point to the\n");
|
||||
printf("*** correct copy of xml-config. (In this case, you will have to\n");
|
||||
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
|
||||
printf("*** so that the correct libraries are found at run-time))\n");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$no_xml" = x ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
if test "$XML_CONFIG" = "no" ; then
|
||||
echo "*** The xml-config script installed by libxml could not be found"
|
||||
echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
|
||||
echo "*** your path, or set the XML_CONFIG environment variable to the"
|
||||
echo "*** full path to xml-config."
|
||||
else
|
||||
if test -f conf.xmltest ; then
|
||||
:
|
||||
else
|
||||
echo "*** Could not run libxml test program, checking why..."
|
||||
CFLAGS="$CFLAGS $XML_CFLAGS"
|
||||
LIBS="$LIBS $XML_LIBS"
|
||||
dnl FIXME: AC_TRY_LINK
|
||||
fi
|
||||
fi
|
||||
|
||||
XML_CFLAGS=""
|
||||
XML_LIBS=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
AC_SUBST(XML_CFLAGS)
|
||||
AC_SUBST(XML_LIBS)
|
||||
rm -f conf.xmltest
|
||||
])
|
706
list.c
Normal file
706
list.c
Normal file
@ -0,0 +1,706 @@
|
||||
/*
|
||||
* list.c: lists handling implementation
|
||||
*
|
||||
* Copyright (C) 2000 Gary Pennington and Daniel Veillard.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
|
||||
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
|
||||
*
|
||||
* Author: Gary.Pennington@uk.sun.com
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32config.h"
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/list.h>
|
||||
|
||||
/*
|
||||
* Type definition are kept internal
|
||||
*/
|
||||
|
||||
struct _xmlLink
|
||||
{
|
||||
struct _xmlLink *next;
|
||||
struct _xmlLink *prev;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct _xmlList
|
||||
{
|
||||
xmlLinkPtr sentinel;
|
||||
void (*linkDeallocator)(xmlLinkPtr );
|
||||
int (*linkCompare)(const void *, const void*);
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Interfaces *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xmlLinkDeallocator:
|
||||
* @l: a list
|
||||
* @lk: a link
|
||||
*
|
||||
* Unlink and deallocate @lk from list @l
|
||||
*/
|
||||
static void
|
||||
xmlLinkDeallocator(xmlListPtr l, xmlLinkPtr lk)
|
||||
{
|
||||
(lk->prev)->next = lk->next;
|
||||
(lk->next)->prev = lk->prev;
|
||||
if(l->linkDeallocator)
|
||||
l->linkDeallocator(lk);
|
||||
xmlFree(lk);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlLinkCompare:
|
||||
* @data0: first data
|
||||
* @data1: second data
|
||||
*
|
||||
* Compares two arbitrary data
|
||||
*
|
||||
* Returns -1, 0 or 1 depending on whether data1 is greater equal or smaller
|
||||
* than data0
|
||||
*/
|
||||
static int
|
||||
xmlLinkCompare(const void *data0, const void *data1)
|
||||
{
|
||||
if (data0 < data1)
|
||||
return (-1);
|
||||
else if (data0 == data1)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListLowerSearch:
|
||||
* @l: a list
|
||||
* @data: a data
|
||||
*
|
||||
* Search data in the ordered list walking from the beginning
|
||||
*
|
||||
* Returns the link containing the data or NULL
|
||||
*/
|
||||
static xmlLinkPtr
|
||||
xmlListLowerSearch(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
|
||||
for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next);
|
||||
return lk;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListHigherSearch:
|
||||
* @l: a list
|
||||
* @data: a data
|
||||
*
|
||||
* Search data in the ordered list walking backward from the end
|
||||
*
|
||||
* Returns the link containing the data or NULL
|
||||
*/
|
||||
static xmlLinkPtr
|
||||
xmlListHigherSearch(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
|
||||
for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev);
|
||||
return lk;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListSearch:
|
||||
* @l: a list
|
||||
* @data: a data
|
||||
*
|
||||
* Search data in the list
|
||||
*
|
||||
* Returns the link containing the data or NULL
|
||||
*/
|
||||
static xmlLinkPtr
|
||||
xmlListLinkSearch(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
lk = xmlListLowerSearch(l, data);
|
||||
if (lk == l->sentinel)
|
||||
return NULL;
|
||||
else {
|
||||
if (l->linkCompare(lk->data, data) ==0)
|
||||
return lk;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListLinkReverseSearch:
|
||||
* @l: a list
|
||||
* @data: a data
|
||||
*
|
||||
* Search data in the list processing backward
|
||||
*
|
||||
* Returns the link containing the data or NULL
|
||||
*/
|
||||
xmlLinkPtr
|
||||
xmlListLinkReverseSearch(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
lk = xmlListHigherSearch(l, data);
|
||||
if (lk == l->sentinel)
|
||||
return NULL;
|
||||
else {
|
||||
if (l->linkCompare(lk->data, data) ==0)
|
||||
return lk;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListCreate:
|
||||
* @deallocator: an optional deallocator function
|
||||
* @compare: an optional comparison function
|
||||
*
|
||||
* Create a new list
|
||||
*
|
||||
* Returns the new list or NULL in case of error
|
||||
*/
|
||||
xmlListPtr
|
||||
xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
|
||||
{
|
||||
xmlListPtr l;
|
||||
if (NULL == (l = (xmlListPtr )xmlMalloc( sizeof(xmlList)))) {
|
||||
perror("Cannot initialize memory for list");
|
||||
return (NULL);
|
||||
}
|
||||
/* Initialize the list to NULL */
|
||||
memset(l, 0, sizeof(xmlList));
|
||||
|
||||
/* Add the sentinel */
|
||||
if (NULL ==(l->sentinel = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) {
|
||||
perror("Cannot initialize memory for sentinel");
|
||||
xmlFree(l);
|
||||
return (NULL);
|
||||
}
|
||||
l->sentinel->next = l->sentinel;
|
||||
l->sentinel->prev = l->sentinel;
|
||||
l->sentinel->data = NULL;
|
||||
|
||||
/* If there is a link deallocator, use it */
|
||||
if (deallocator != NULL)
|
||||
l->linkDeallocator = deallocator;
|
||||
/* If there is a link comparator, use it */
|
||||
if (compare != NULL)
|
||||
l->linkCompare = compare;
|
||||
else /* Use our own */
|
||||
l->linkCompare = xmlLinkCompare;
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListSearch:
|
||||
* @l: a list
|
||||
* @data: a search value
|
||||
*
|
||||
* Search the list for an existing value of @data
|
||||
*
|
||||
* Returns the value associated to @data or NULL in case of error
|
||||
*/
|
||||
void *
|
||||
xmlListSearch(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
lk = xmlListLinkSearch(l, data);
|
||||
if (lk)
|
||||
return (lk->data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListLinkReverseSearch:
|
||||
* @l: a list
|
||||
* @data: a search value
|
||||
*
|
||||
* Search the list in reverse order for an existing value of @data
|
||||
*
|
||||
* Returns the value associated to @data or NULL in case of error
|
||||
*/
|
||||
void *
|
||||
xmlListReverseSearch(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
lk = xmlListLinkReverseSearch(l, data);
|
||||
if (lk)
|
||||
return (lk->data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListInsert:
|
||||
* @l: a list
|
||||
* @data: the data
|
||||
*
|
||||
* Insert data in the ordered list at the beginning for this value
|
||||
*
|
||||
* Returns 0 in case of success, 1 in case of failure
|
||||
*/
|
||||
int
|
||||
xmlListInsert(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lkPlace, lkNew;
|
||||
|
||||
lkPlace = xmlListLowerSearch(l, data);
|
||||
/* Add the new link */
|
||||
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
|
||||
if (lkNew == NULL) {
|
||||
perror("Cannot initialize memory for new link");
|
||||
return (1);
|
||||
}
|
||||
lkNew->data = data;
|
||||
lkPlace = lkPlace->prev;
|
||||
lkNew->next = lkPlace->next;
|
||||
(lkPlace->next)->prev = lkNew;
|
||||
lkPlace->next = lkNew;
|
||||
lkNew->prev = lkPlace;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListAppend:
|
||||
* @l: a list
|
||||
* @data: the data
|
||||
*
|
||||
* Insert data in the ordered list at the end for this value
|
||||
*
|
||||
* Returns 0 in case of success, 1 in case of failure
|
||||
*/
|
||||
int xmlListAppend(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lkPlace, lkNew;
|
||||
|
||||
lkPlace = xmlListHigherSearch(l, data);
|
||||
/* Add the new link */
|
||||
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
|
||||
if (lkNew == NULL) {
|
||||
perror("Cannot initialize memory for new link");
|
||||
return (0);
|
||||
}
|
||||
lkNew->data = data;
|
||||
lkNew->next = lkPlace->next;
|
||||
(lkPlace->next)->prev = lkNew;
|
||||
lkPlace->next = lkNew;
|
||||
lkNew->prev = lkPlace;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListDelete:
|
||||
* @l: a list
|
||||
*
|
||||
* Deletes the list and its associated data
|
||||
*/
|
||||
void xmlListDelete(xmlListPtr l)
|
||||
{
|
||||
xmlListClear(l);
|
||||
xmlFree(l->sentinel);
|
||||
xmlFree(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListRemoveFirst:
|
||||
* @l: a list
|
||||
* @data: list data
|
||||
*
|
||||
* Remove the first instance associated to data in the list
|
||||
*
|
||||
* Returns 1 if a deallocation occured, or 0 if not found
|
||||
*/
|
||||
int
|
||||
xmlListRemoveFirst(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
|
||||
/*Find the first instance of this data */
|
||||
lk = xmlListLinkSearch(l, data);
|
||||
if (lk != NULL) {
|
||||
xmlLinkDeallocator(l, lk);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListRemoveLast:
|
||||
* @l: a list
|
||||
* @data: list data
|
||||
*
|
||||
* Remove the last instance associated to data in the list
|
||||
*
|
||||
* Returns 1 if a deallocation occured, or 0 if not found
|
||||
*/
|
||||
int
|
||||
xmlListRemoveLast(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
|
||||
/*Find the last instance of this data */
|
||||
lk = xmlListLinkReverseSearch(l, data);
|
||||
if (lk != NULL) {
|
||||
xmlLinkDeallocator(l, lk);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListRemoveAll:
|
||||
* @l: a list
|
||||
* @data: list data
|
||||
*
|
||||
* Remove the all instance associated to data in the list
|
||||
*
|
||||
* Returns the number of deallocation, or 0 if not found
|
||||
*/
|
||||
int
|
||||
xmlListRemoveAll(xmlListPtr l, void *data)
|
||||
{
|
||||
int count=0;
|
||||
|
||||
|
||||
while(xmlListRemoveFirst(l, data))
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListClear:
|
||||
* @l: a list
|
||||
*
|
||||
* Remove the all data in the list
|
||||
*/
|
||||
void
|
||||
xmlListClear(xmlListPtr l)
|
||||
{
|
||||
xmlLinkPtr lk = l->sentinel->next;
|
||||
|
||||
while(lk != l->sentinel) {
|
||||
xmlLinkPtr next = lk->next;
|
||||
|
||||
xmlLinkDeallocator(l, lk);
|
||||
lk = next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListEmpty:
|
||||
* @l: a list
|
||||
*
|
||||
* Returns 1 if the list is empty, 0 otherwise
|
||||
*/
|
||||
int
|
||||
xmlListEmpty(xmlListPtr l)
|
||||
{
|
||||
return (l->sentinel->next == l->sentinel);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListFront:
|
||||
* @l: a list
|
||||
*
|
||||
* Returns the first element in the list, or NULL
|
||||
*/
|
||||
xmlLinkPtr
|
||||
xmlListFront(xmlListPtr l)
|
||||
{
|
||||
return (l->sentinel->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListFront:
|
||||
* @l: a list
|
||||
*
|
||||
* Returns the last element in the list, or NULL
|
||||
*/
|
||||
xmlLinkPtr
|
||||
xmlListEnd(xmlListPtr l)
|
||||
{
|
||||
return (l->sentinel->prev);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListSize:
|
||||
* @l: a list
|
||||
*
|
||||
* Returns the number of elements in the list
|
||||
*/
|
||||
int
|
||||
xmlListSize(xmlListPtr l)
|
||||
{
|
||||
xmlLinkPtr lk;
|
||||
int count=0;
|
||||
|
||||
/* TODO: keep a counter in xmlList instead */
|
||||
for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next, count++);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListPopFront:
|
||||
* @l: a list
|
||||
*
|
||||
* Removes the first element in the list
|
||||
*/
|
||||
void
|
||||
xmlListPopFront(xmlListPtr l)
|
||||
{
|
||||
if(!xmlListEmpty(l))
|
||||
xmlLinkDeallocator(l, l->sentinel->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListPopBack:
|
||||
* @l: a list
|
||||
*
|
||||
* Removes the last element in the list
|
||||
*/
|
||||
void
|
||||
xmlListPopBack(xmlListPtr l)
|
||||
{
|
||||
if(!xmlListEmpty(l))
|
||||
xmlLinkDeallocator(l, l->sentinel->prev);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListPushFront:
|
||||
* @l: a list
|
||||
* @data: new data
|
||||
*
|
||||
* add the new data at the beginning of the list
|
||||
*
|
||||
* Returns 1 if successful, 0 otherwise
|
||||
*/
|
||||
int
|
||||
xmlListPushFront(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lkPlace, lkNew;
|
||||
|
||||
lkPlace = l->sentinel;
|
||||
/* Add the new link */
|
||||
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
|
||||
if (lkNew == NULL) {
|
||||
perror("Cannot initialize memory for new link");
|
||||
return (0);
|
||||
}
|
||||
lkNew->data = data;
|
||||
lkNew->next = lkPlace->next;
|
||||
(lkPlace->next)->prev = lkNew;
|
||||
lkPlace->next = lkNew;
|
||||
lkNew->prev = lkPlace;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListPushBack:
|
||||
* @l: a list
|
||||
* @data: new data
|
||||
*
|
||||
* add the new data at the end of the list
|
||||
*
|
||||
* Returns 1 if successful, 0 otherwise
|
||||
*/
|
||||
int
|
||||
xmlListPushBack(xmlListPtr l, void *data)
|
||||
{
|
||||
xmlLinkPtr lkPlace, lkNew;
|
||||
|
||||
lkPlace = l->sentinel->prev;
|
||||
/* Add the new link */
|
||||
if (NULL ==(lkNew = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) {
|
||||
perror("Cannot initialize memory for new link");
|
||||
return (0);
|
||||
}
|
||||
lkNew->data = data;
|
||||
lkNew->next = lkPlace->next;
|
||||
(lkPlace->next)->prev = lkNew;
|
||||
lkPlace->next = lkNew;
|
||||
lkNew->prev = lkPlace;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlLinkGetData:
|
||||
* @lk: a link
|
||||
*
|
||||
* See Returns.
|
||||
*
|
||||
* Returns a pointer to the data referenced from this link
|
||||
*/
|
||||
void *
|
||||
xmlLinkGetData(xmlLinkPtr lk)
|
||||
{
|
||||
return lk->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListReverse:
|
||||
* @l: a list
|
||||
*
|
||||
* Reverse the order of the elements in the list
|
||||
*/
|
||||
void
|
||||
xmlListReverse(xmlListPtr l) {
|
||||
xmlLinkPtr lk;
|
||||
xmlLinkPtr lkPrev = l->sentinel;
|
||||
|
||||
for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) {
|
||||
lkPrev->next = lkPrev->prev;
|
||||
lkPrev->prev = lk;
|
||||
lkPrev = lk;
|
||||
}
|
||||
/* Fix up the last node */
|
||||
lkPrev->next = lkPrev->prev;
|
||||
lkPrev->prev = lk;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListSort:
|
||||
* @l: a list
|
||||
*
|
||||
* Sort all the elements in the list
|
||||
*/
|
||||
void
|
||||
xmlListSort(xmlListPtr l)
|
||||
{
|
||||
xmlListPtr lTemp;
|
||||
|
||||
if(xmlListEmpty(l))
|
||||
return;
|
||||
|
||||
/* I think that the real answer is to implement quicksort, the
|
||||
* alternative is to implement some list copying procedure which
|
||||
* would be based on a list copy followed by a clear followed by
|
||||
* an insert. This is slow...
|
||||
*/
|
||||
|
||||
if (NULL ==(lTemp = xmlListDup(l)))
|
||||
return;
|
||||
xmlListClear(l);
|
||||
xmlListMerge(l, lTemp);
|
||||
xmlListDelete(lTemp);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListWalk:
|
||||
* @l: a list
|
||||
* @walker: a processing function
|
||||
*
|
||||
* Walk all the element of the first from first to last and
|
||||
* apply the walker function to it
|
||||
*/
|
||||
void
|
||||
xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
|
||||
xmlLinkPtr lk;
|
||||
|
||||
for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) {
|
||||
if((walker(lk->data, user)) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListReverseWalk:
|
||||
* @l: a list
|
||||
* @walker: a processing function
|
||||
*
|
||||
* Walk all the element of the list in reverse order and
|
||||
* apply the walker function to it
|
||||
*/
|
||||
void
|
||||
xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
|
||||
xmlLinkPtr lk;
|
||||
|
||||
for(lk = l->sentinel->prev; lk != l->sentinel; lk = lk->prev) {
|
||||
if((walker(lk->data, user)) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListMerge:
|
||||
* @l1: the original list
|
||||
* @l2: the new list
|
||||
*
|
||||
* include all the elements of the second list in the first one and
|
||||
* clear the second list
|
||||
*/
|
||||
void
|
||||
xmlListMerge(xmlListPtr l1, xmlListPtr l2)
|
||||
{
|
||||
xmlListCopy(l1, l2);
|
||||
xmlListClear(l2);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListDup:
|
||||
* @old: the list
|
||||
*
|
||||
* Duplicate the list
|
||||
*
|
||||
* Returns a new copy of the list or NULL in case of error
|
||||
*/
|
||||
xmlListPtr
|
||||
xmlListDup(const xmlListPtr old)
|
||||
{
|
||||
xmlListPtr cur;
|
||||
/* Hmmm, how to best deal with allocation issues when copying
|
||||
* lists. If there is a de-allocator, should responsibility lie with
|
||||
* the new list or the old list. Surely not both. I'll arbitrarily
|
||||
* set it to be the old list for the time being whilst I work out
|
||||
* the answer
|
||||
*/
|
||||
if (NULL ==(cur = xmlListCreate(NULL, old->linkCompare)))
|
||||
return (NULL);
|
||||
if (0 != xmlListCopy(cur, old))
|
||||
return NULL;
|
||||
return cur;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlListCopy:
|
||||
* @cur: the new list
|
||||
* @old: the old list
|
||||
*
|
||||
* Move all the element from the old list in the new list
|
||||
*
|
||||
* Returns 0 in case of success 1 in case of error
|
||||
*/
|
||||
int
|
||||
xmlListCopy(xmlListPtr cur, const xmlListPtr old)
|
||||
{
|
||||
/* Walk the old tree and insert the data into the new one */
|
||||
xmlLinkPtr lk;
|
||||
|
||||
for(lk = old->sentinel->next; lk != old->sentinel; lk = lk->next) {
|
||||
if (0 !=xmlListInsert(cur, lk->data)) {
|
||||
xmlListDelete(cur);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
/* xmlListUnique() */
|
||||
/* xmlListSwap */
|
81
list.h
Normal file
81
list.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* list.h: lists interfaces
|
||||
*
|
||||
* Copyright (C) 2000 Gary Pennington and Daniel Veillard.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
|
||||
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
|
||||
*
|
||||
* Author: Gary.Pennington@uk.sun.com
|
||||
*/
|
||||
|
||||
typedef struct _xmlLink xmlLink;
|
||||
typedef xmlLink *xmlLinkPtr;
|
||||
|
||||
typedef struct _xmlList xmlList;
|
||||
typedef xmlList *xmlListPtr;
|
||||
|
||||
typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
|
||||
typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
|
||||
typedef int (*xmlListWalker) (const void *data, const void *user);
|
||||
|
||||
/* Creation/Deletion */
|
||||
xmlListPtr xmlListCreate (xmlListDeallocator deallocator,
|
||||
xmlListDataCompare compare);
|
||||
void xmlListDelete (xmlListPtr l);
|
||||
|
||||
/* Basic Operators */
|
||||
void * xmlListSearch (xmlListPtr l,
|
||||
void *data);
|
||||
void * xmlListReverseSearch (xmlListPtr l,
|
||||
void *data);
|
||||
int xmlListInsert (xmlListPtr l,
|
||||
void *data) ;
|
||||
int xmlListAppend (xmlListPtr l,
|
||||
void *data) ;
|
||||
int xmlListRemoveFirst (xmlListPtr l,
|
||||
void *data);
|
||||
int xmlListRemoveLast (xmlListPtr l,
|
||||
void *data);
|
||||
int xmlListRemoveAll (xmlListPtr l,
|
||||
void *data);
|
||||
void xmlListClear (xmlListPtr l);
|
||||
int xmlListEmpty (xmlListPtr l);
|
||||
xmlLinkPtr xmlListFront (xmlListPtr l);
|
||||
xmlLinkPtr xmlListEnd (xmlListPtr l);
|
||||
int xmlListSize (xmlListPtr l);
|
||||
|
||||
void xmlListPopFront (xmlListPtr l);
|
||||
void xmlListPopBack (xmlListPtr l);
|
||||
int xmlListPushFront (xmlListPtr l,
|
||||
void *data);
|
||||
int xmlListPushBack (xmlListPtr l,
|
||||
void *data);
|
||||
|
||||
/* Advanced Operators */
|
||||
void xmlListReverse (xmlListPtr l);
|
||||
void xmlListSort (xmlListPtr l);
|
||||
void xmlListWalk (xmlListPtr l,
|
||||
xmlListWalker walker,
|
||||
const void *user);
|
||||
void xmlListReverseWalk (xmlListPtr l,
|
||||
xmlListWalker walker,
|
||||
const void *user);
|
||||
void xmlListMerge (xmlListPtr l1,
|
||||
xmlListPtr l2);
|
||||
xmlListPtr xmlListDup (const xmlListPtr old);
|
||||
int xmlListCopy (xmlListPtr cur,
|
||||
const xmlListPtr old);
|
||||
/* Link operators */
|
||||
void * xmlLinkGetData (xmlLinkPtr lk);
|
||||
|
||||
/* xmlListUnique() */
|
||||
/* xmlListSwap */
|
||||
|
||||
|
110
nanoftp.h
Normal file
110
nanoftp.h
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* nanohttp.c: minimalist FTP implementation to fetch external subsets.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __NANO_FTP_H__
|
||||
#define __NANO_FTP_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#ifdef LIBXML_FTP_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ftpListCallback:
|
||||
* @userData: user provided data for the callback
|
||||
* @filename: the file name (including "->" when links are shown)
|
||||
* @attrib: the attribute string
|
||||
* @owner: the owner string
|
||||
* @group: the group string
|
||||
* @size: the file size
|
||||
* @links: the link count
|
||||
* @year: the year
|
||||
* @month: the month
|
||||
* @day: the day
|
||||
* @hour: the hour
|
||||
* @minute: the minute
|
||||
*
|
||||
* A callback for the xmlNanoFTPList command
|
||||
* Note that only one of year and day:minute are specified
|
||||
*/
|
||||
typedef void (*ftpListCallback) (void *userData,
|
||||
const char *filename, const char* attrib,
|
||||
const char *owner, const char *group,
|
||||
unsigned long size, int links, int year,
|
||||
const char *month, int day, int hour,
|
||||
int minute);
|
||||
/**
|
||||
* ftpDataCallback:
|
||||
* A callback for the xmlNanoFTPGet command
|
||||
*/
|
||||
typedef void (*ftpDataCallback) (void *userData, const char *data, int len);
|
||||
|
||||
/*
|
||||
* Init
|
||||
*/
|
||||
void xmlNanoFTPInit (void);
|
||||
void xmlNanoFTPCleanup (void);
|
||||
|
||||
/*
|
||||
* Creating/freeing contexts
|
||||
*/
|
||||
void * xmlNanoFTPNewCtxt (const char *URL);
|
||||
void xmlNanoFTPFreeCtxt (void * ctx);
|
||||
void * xmlNanoFTPConnectTo (const char *server,
|
||||
int port);
|
||||
/*
|
||||
* Opening/closing session connections
|
||||
*/
|
||||
void * xmlNanoFTPOpen (const char *URL);
|
||||
int xmlNanoFTPConnect (void *ctx);
|
||||
int xmlNanoFTPClose (void *ctx);
|
||||
int xmlNanoFTPQuit (void *ctx);
|
||||
void xmlNanoFTPScanProxy (const char *URL);
|
||||
void xmlNanoFTPProxy (const char *host,
|
||||
int port,
|
||||
const char *user,
|
||||
const char *passwd,
|
||||
int type);
|
||||
int xmlNanoFTPUpdateURL (void *ctx,
|
||||
const char *URL);
|
||||
|
||||
/*
|
||||
* Rathern internal commands
|
||||
*/
|
||||
int xmlNanoFTPGetResponse (void *ctx);
|
||||
int xmlNanoFTPCheckResponse (void *ctx);
|
||||
|
||||
/*
|
||||
* CD/DIR/GET handlers
|
||||
*/
|
||||
int xmlNanoFTPCwd (void *ctx,
|
||||
char *directory);
|
||||
|
||||
int xmlNanoFTPGetConnection (void *ctx);
|
||||
int xmlNanoFTPCloseConnection(void *ctx);
|
||||
int xmlNanoFTPList (void *ctx,
|
||||
ftpListCallback callback,
|
||||
void *userData,
|
||||
char *filename);
|
||||
int xmlNanoFTPGetSocket (void *ctx,
|
||||
const char *filename);
|
||||
int xmlNanoFTPGet (void *ctx,
|
||||
ftpDataCallback callback,
|
||||
void *userData,
|
||||
const char *filename);
|
||||
int xmlNanoFTPRead (void *ctx,
|
||||
void *dest,
|
||||
int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* LIBXML_FTP_ENABLED */
|
||||
#endif
|
||||
#endif /* __NANO_FTP_H__ */
|
1202
nanohttp.c
Normal file
1202
nanohttp.c
Normal file
File diff suppressed because it is too large
Load Diff
44
nanohttp.h
Normal file
44
nanohttp.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* nanohttp.c: minimalist HTTP implementation to fetch external subsets.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __NANO_HTTP_H__
|
||||
#define __NANO_HTTP_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#ifdef LIBXML_HTTP_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void xmlNanoHTTPInit (void);
|
||||
void xmlNanoHTTPCleanup (void);
|
||||
void xmlNanoHTTPScanProxy (const char *URL);
|
||||
int xmlNanoHTTPFetch (const char *URL,
|
||||
const char *filename,
|
||||
char **contentType);
|
||||
void * xmlNanoHTTPMethod (const char *URL,
|
||||
const char *method,
|
||||
const char *input,
|
||||
char **contentType,
|
||||
const char *headers);
|
||||
void * xmlNanoHTTPOpen (const char *URL,
|
||||
char **contentType);
|
||||
int xmlNanoHTTPReturnCode (void *ctx);
|
||||
const char * xmlNanoHTTPAuthHeader(void *ctx);
|
||||
int xmlNanoHTTPRead (void *ctx,
|
||||
void *dest,
|
||||
int len);
|
||||
int xmlNanoHTTPSave (void *ctxt,
|
||||
const char *filename);
|
||||
void xmlNanoHTTPClose (void *ctx);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif /* LIBXML_HTTP_ENABLED */
|
||||
#endif
|
||||
#endif /* __NANO_HTTP_H__ */
|
527
parser.h
Normal file
527
parser.h
Normal file
@ -0,0 +1,527 @@
|
||||
/*
|
||||
* parser.h : Interfaces, constants and types related to the XML parser.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_PARSER_H__
|
||||
#define __XML_PARSER_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/entities.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Constants.
|
||||
*/
|
||||
#define XML_DEFAULT_VERSION "1.0"
|
||||
|
||||
/**
|
||||
* an xmlParserInput is an input flow for the XML processor.
|
||||
* Each entity parsed is associated an xmlParserInput (except the
|
||||
* few predefined ones). This is the case both for internal entities
|
||||
* - in which case the flow is already completely in memory - or
|
||||
* external entities - in which case we use the buf structure for
|
||||
* progressive reading and I18N conversions to the internal UTF-8 format.
|
||||
*/
|
||||
|
||||
typedef void (* xmlParserInputDeallocate)(xmlChar *);
|
||||
typedef struct _xmlParserInput xmlParserInput;
|
||||
typedef xmlParserInput *xmlParserInputPtr;
|
||||
struct _xmlParserInput {
|
||||
/* Input buffer */
|
||||
xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
|
||||
|
||||
const char *filename; /* The file analyzed, if any */
|
||||
const char *directory; /* the directory/base of teh file */
|
||||
const xmlChar *base; /* Base of the array to parse */
|
||||
const xmlChar *cur; /* Current char being parsed */
|
||||
int length; /* length if known */
|
||||
int line; /* Current line */
|
||||
int col; /* Current column */
|
||||
int consumed; /* How many xmlChars already consumed */
|
||||
xmlParserInputDeallocate free; /* function to deallocate the base */
|
||||
const xmlChar *encoding; /* the encoding string for entity */
|
||||
const xmlChar *version; /* the version string for entity */
|
||||
int standalone; /* Was that entity marked standalone */
|
||||
};
|
||||
|
||||
/**
|
||||
* the parser can be asked to collect Node informations, i.e. at what
|
||||
* place in the file they were detected.
|
||||
* NOTE: This is off by default and not very well tested.
|
||||
*/
|
||||
typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
|
||||
typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
|
||||
|
||||
struct _xmlParserNodeInfo {
|
||||
const struct _xmlNode* node;
|
||||
/* Position & line # that text that created the node begins & ends on */
|
||||
unsigned long begin_pos;
|
||||
unsigned long begin_line;
|
||||
unsigned long end_pos;
|
||||
unsigned long end_line;
|
||||
};
|
||||
|
||||
typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
|
||||
typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
|
||||
struct _xmlParserNodeInfoSeq {
|
||||
unsigned long maximum;
|
||||
unsigned long length;
|
||||
xmlParserNodeInfo* buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* The parser is now working also as a state based parser
|
||||
* The recursive one use the stagte info for entities processing
|
||||
*/
|
||||
typedef enum {
|
||||
XML_PARSER_EOF = -1, /* nothing is to be parsed */
|
||||
XML_PARSER_START = 0, /* nothing has been parsed */
|
||||
XML_PARSER_MISC, /* Misc* before int subset */
|
||||
XML_PARSER_PI, /* Whithin a processing instruction */
|
||||
XML_PARSER_DTD, /* within some DTD content */
|
||||
XML_PARSER_PROLOG, /* Misc* after internal subset */
|
||||
XML_PARSER_COMMENT, /* within a comment */
|
||||
XML_PARSER_START_TAG, /* within a start tag */
|
||||
XML_PARSER_CONTENT, /* within the content */
|
||||
XML_PARSER_CDATA_SECTION, /* within a CDATA section */
|
||||
XML_PARSER_END_TAG, /* within a closing tag */
|
||||
XML_PARSER_ENTITY_DECL, /* within an entity declaration */
|
||||
XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
|
||||
XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
|
||||
XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
|
||||
XML_PARSER_EPILOG, /* the Misc* after the last end tag */
|
||||
XML_PARSER_IGNORE /* within an IGNORED section */
|
||||
} xmlParserInputState;
|
||||
|
||||
/**
|
||||
* The parser context.
|
||||
* NOTE This doesn't completely defines the parser state, the (current ?)
|
||||
* design of the parser uses recursive function calls since this allow
|
||||
* and easy mapping from the production rules of the specification
|
||||
* to the actual code. The drawback is that the actual function call
|
||||
* also reflect the parser state. However most of the parsing routines
|
||||
* takes as the only argument the parser context pointer, so migrating
|
||||
* to a state based parser for progressive parsing shouldn't be too hard.
|
||||
*/
|
||||
typedef struct _xmlParserCtxt xmlParserCtxt;
|
||||
typedef xmlParserCtxt *xmlParserCtxtPtr;
|
||||
struct _xmlParserCtxt {
|
||||
struct _xmlSAXHandler *sax; /* The SAX handler */
|
||||
void *userData; /* For SAX interface only, used by DOM build */
|
||||
xmlDocPtr myDoc; /* the document being built */
|
||||
int wellFormed; /* is the document well formed */
|
||||
int replaceEntities; /* shall we replace entities ? */
|
||||
const xmlChar *version; /* the XML version string */
|
||||
const xmlChar *encoding; /* the declared encoding, if any */
|
||||
int standalone; /* standalone document */
|
||||
int html; /* an HTML(1)/Docbook(2) document */
|
||||
|
||||
/* Input stream stack */
|
||||
xmlParserInputPtr input; /* Current input stream */
|
||||
int inputNr; /* Number of current input streams */
|
||||
int inputMax; /* Max number of input streams */
|
||||
xmlParserInputPtr *inputTab; /* stack of inputs */
|
||||
|
||||
/* Node analysis stack only used for DOM building */
|
||||
xmlNodePtr node; /* Current parsed Node */
|
||||
int nodeNr; /* Depth of the parsing stack */
|
||||
int nodeMax; /* Max depth of the parsing stack */
|
||||
xmlNodePtr *nodeTab; /* array of nodes */
|
||||
|
||||
int record_info; /* Whether node info should be kept */
|
||||
xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
|
||||
|
||||
int errNo; /* error code */
|
||||
|
||||
int hasExternalSubset; /* reference and external subset */
|
||||
int hasPErefs; /* the internal subset has PE refs */
|
||||
int external; /* are we parsing an external entity */
|
||||
|
||||
int valid; /* is the document valid */
|
||||
int validate; /* shall we try to validate ? */
|
||||
xmlValidCtxt vctxt; /* The validity context */
|
||||
|
||||
xmlParserInputState instate; /* current type of input */
|
||||
int token; /* next char look-ahead */
|
||||
|
||||
char *directory; /* the data directory */
|
||||
|
||||
/* Node name stack */
|
||||
xmlChar *name; /* Current parsed Node */
|
||||
int nameNr; /* Depth of the parsing stack */
|
||||
int nameMax; /* Max depth of the parsing stack */
|
||||
xmlChar * *nameTab; /* array of nodes */
|
||||
|
||||
long nbChars; /* number of xmlChar processed */
|
||||
long checkIndex; /* used by progressive parsing lookup */
|
||||
int keepBlanks; /* ugly but ... */
|
||||
int disableSAX; /* SAX callbacks are disabled */
|
||||
int inSubset; /* Parsing is in int 1/ext 2 subset */
|
||||
xmlChar * intSubName; /* name of subset */
|
||||
xmlChar * extSubURI; /* URI of external subset */
|
||||
xmlChar * extSubSystem; /* SYSTEM ID of external subset */
|
||||
|
||||
/* xml:space values */
|
||||
int * space; /* Should the parser preserve spaces */
|
||||
int spaceNr; /* Depth of the parsing stack */
|
||||
int spaceMax; /* Max depth of the parsing stack */
|
||||
int * spaceTab; /* array of space infos */
|
||||
|
||||
int depth; /* to prevent entity substitution loops */
|
||||
xmlParserInputPtr entity; /* used to check entities boundaries */
|
||||
int charset; /* encoding of the in-memory content
|
||||
actually an xmlCharEncoding */
|
||||
int nodelen; /* Those two fields are there to */
|
||||
int nodemem; /* Speed up large node parsing */
|
||||
int pedantic; /* signal pedantic warnings */
|
||||
void *_private; /* For user data, libxml won't touch it */
|
||||
|
||||
int loadsubset; /* should the external subset be loaded */
|
||||
};
|
||||
|
||||
/**
|
||||
* a SAX Locator.
|
||||
*/
|
||||
typedef struct _xmlSAXLocator xmlSAXLocator;
|
||||
typedef xmlSAXLocator *xmlSAXLocatorPtr;
|
||||
struct _xmlSAXLocator {
|
||||
const xmlChar *(*getPublicId)(void *ctx);
|
||||
const xmlChar *(*getSystemId)(void *ctx);
|
||||
int (*getLineNumber)(void *ctx);
|
||||
int (*getColumnNumber)(void *ctx);
|
||||
};
|
||||
|
||||
/**
|
||||
* a SAX handler is bunch of callbacks called by the parser when processing
|
||||
* of the input generate data or structure informations.
|
||||
*/
|
||||
|
||||
typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
|
||||
const xmlChar *publicId, const xmlChar *systemId);
|
||||
typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
|
||||
const xmlChar *ExternalID, const xmlChar *SystemID);
|
||||
typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
|
||||
const xmlChar *ExternalID, const xmlChar *SystemID);
|
||||
typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
|
||||
const xmlChar *name);
|
||||
typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
|
||||
const xmlChar *name);
|
||||
typedef void (*entityDeclSAXFunc) (void *ctx,
|
||||
const xmlChar *name, int type, const xmlChar *publicId,
|
||||
const xmlChar *systemId, xmlChar *content);
|
||||
typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
|
||||
const xmlChar *publicId, const xmlChar *systemId);
|
||||
typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
|
||||
const xmlChar *name, int type, int def,
|
||||
const xmlChar *defaultValue, xmlEnumerationPtr tree);
|
||||
typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
|
||||
int type, xmlElementContentPtr content);
|
||||
typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
|
||||
const xmlChar *name, const xmlChar *publicId,
|
||||
const xmlChar *systemId, const xmlChar *notationName);
|
||||
typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
|
||||
xmlSAXLocatorPtr loc);
|
||||
typedef void (*startDocumentSAXFunc) (void *ctx);
|
||||
typedef void (*endDocumentSAXFunc) (void *ctx);
|
||||
typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
|
||||
const xmlChar **atts);
|
||||
typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
|
||||
typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
|
||||
typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
|
||||
int len);
|
||||
typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
|
||||
const xmlChar *ch, int len);
|
||||
typedef void (*processingInstructionSAXFunc) (void *ctx,
|
||||
const xmlChar *target, const xmlChar *data);
|
||||
typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
|
||||
typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
|
||||
typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
|
||||
typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
|
||||
typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
|
||||
typedef int (*isStandaloneSAXFunc) (void *ctx);
|
||||
typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
|
||||
typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
|
||||
|
||||
typedef struct _xmlSAXHandler xmlSAXHandler;
|
||||
typedef xmlSAXHandler *xmlSAXHandlerPtr;
|
||||
struct _xmlSAXHandler {
|
||||
internalSubsetSAXFunc internalSubset;
|
||||
isStandaloneSAXFunc isStandalone;
|
||||
hasInternalSubsetSAXFunc hasInternalSubset;
|
||||
hasExternalSubsetSAXFunc hasExternalSubset;
|
||||
resolveEntitySAXFunc resolveEntity;
|
||||
getEntitySAXFunc getEntity;
|
||||
entityDeclSAXFunc entityDecl;
|
||||
notationDeclSAXFunc notationDecl;
|
||||
attributeDeclSAXFunc attributeDecl;
|
||||
elementDeclSAXFunc elementDecl;
|
||||
unparsedEntityDeclSAXFunc unparsedEntityDecl;
|
||||
setDocumentLocatorSAXFunc setDocumentLocator;
|
||||
startDocumentSAXFunc startDocument;
|
||||
endDocumentSAXFunc endDocument;
|
||||
startElementSAXFunc startElement;
|
||||
endElementSAXFunc endElement;
|
||||
referenceSAXFunc reference;
|
||||
charactersSAXFunc characters;
|
||||
ignorableWhitespaceSAXFunc ignorableWhitespace;
|
||||
processingInstructionSAXFunc processingInstruction;
|
||||
commentSAXFunc comment;
|
||||
warningSAXFunc warning;
|
||||
errorSAXFunc error;
|
||||
fatalErrorSAXFunc fatalError;
|
||||
getParameterEntitySAXFunc getParameterEntity;
|
||||
cdataBlockSAXFunc cdataBlock;
|
||||
externalSubsetSAXFunc externalSubset;
|
||||
};
|
||||
|
||||
/**
|
||||
* External entity loaders types
|
||||
*/
|
||||
typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
|
||||
const char *ID,
|
||||
xmlParserCtxtPtr context);
|
||||
|
||||
/**
|
||||
* Global variables: just the default SAX interface tables and XML
|
||||
* version infos.
|
||||
*/
|
||||
LIBXML_DLL_IMPORT extern const char *xmlParserVersion;
|
||||
|
||||
LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator;
|
||||
LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler;
|
||||
LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler;
|
||||
LIBXML_DLL_IMPORT extern xmlSAXHandler sgmlDefaultSAXHandler;
|
||||
|
||||
/**
|
||||
* entity substitution default behaviour.
|
||||
*/
|
||||
|
||||
#ifdef VMS
|
||||
LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultVal;
|
||||
#define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal
|
||||
#else
|
||||
LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
|
||||
#endif
|
||||
LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
|
||||
|
||||
|
||||
/**
|
||||
* Init/Cleanup
|
||||
*/
|
||||
void xmlInitParser (void);
|
||||
void xmlCleanupParser (void);
|
||||
|
||||
/**
|
||||
* Input functions
|
||||
*/
|
||||
int xmlParserInputRead (xmlParserInputPtr in,
|
||||
int len);
|
||||
int xmlParserInputGrow (xmlParserInputPtr in,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* xmlChar handling
|
||||
*/
|
||||
xmlChar * xmlStrdup (const xmlChar *cur);
|
||||
xmlChar * xmlStrndup (const xmlChar *cur,
|
||||
int len);
|
||||
xmlChar * xmlStrsub (const xmlChar *str,
|
||||
int start,
|
||||
int len);
|
||||
const xmlChar * xmlStrchr (const xmlChar *str,
|
||||
xmlChar val);
|
||||
const xmlChar * xmlStrstr (const xmlChar *str,
|
||||
xmlChar *val);
|
||||
const xmlChar * xmlStrcasestr (const xmlChar *str,
|
||||
xmlChar *val);
|
||||
int xmlStrcmp (const xmlChar *str1,
|
||||
const xmlChar *str2);
|
||||
int xmlStrncmp (const xmlChar *str1,
|
||||
const xmlChar *str2,
|
||||
int len);
|
||||
int xmlStrcasecmp (const xmlChar *str1,
|
||||
const xmlChar *str2);
|
||||
int xmlStrncasecmp (const xmlChar *str1,
|
||||
const xmlChar *str2,
|
||||
int len);
|
||||
int xmlStrEqual (const xmlChar *str1,
|
||||
const xmlChar *str2);
|
||||
int xmlStrlen (const xmlChar *str);
|
||||
xmlChar * xmlStrcat (xmlChar *cur,
|
||||
const xmlChar *add);
|
||||
xmlChar * xmlStrncat (xmlChar *cur,
|
||||
const xmlChar *add,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* Basic parsing Interfaces
|
||||
*/
|
||||
xmlDocPtr xmlParseDoc (xmlChar *cur);
|
||||
xmlDocPtr xmlParseMemory (char *buffer,
|
||||
int size);
|
||||
xmlDocPtr xmlParseFile (const char *filename);
|
||||
int xmlSubstituteEntitiesDefault(int val);
|
||||
int xmlKeepBlanksDefault (int val);
|
||||
void xmlStopParser (xmlParserCtxtPtr ctxt);
|
||||
int xmlPedanticParserDefault(int val);
|
||||
|
||||
/**
|
||||
* Recovery mode
|
||||
*/
|
||||
xmlDocPtr xmlRecoverDoc (xmlChar *cur);
|
||||
xmlDocPtr xmlRecoverMemory (char *buffer,
|
||||
int size);
|
||||
xmlDocPtr xmlRecoverFile (const char *filename);
|
||||
|
||||
/**
|
||||
* Less common routines and SAX interfaces
|
||||
*/
|
||||
int xmlParseDocument (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
|
||||
xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
|
||||
xmlChar *cur,
|
||||
int recovery);
|
||||
int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
const char *filename);
|
||||
int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
char *buffer,
|
||||
int size);
|
||||
xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
|
||||
char *buffer,
|
||||
int size,
|
||||
int recovery);
|
||||
xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
|
||||
const char *filename,
|
||||
int recovery);
|
||||
xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
|
||||
const char *filename);
|
||||
xmlDocPtr xmlParseEntity (const char *filename);
|
||||
xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax,
|
||||
xmlParserInputBufferPtr input,
|
||||
xmlCharEncoding enc);
|
||||
int xmlParseBalancedChunkMemory(xmlDocPtr doc,
|
||||
xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
int depth,
|
||||
const xmlChar *string,
|
||||
xmlNodePtr *list);
|
||||
int xmlParseExternalEntity (xmlDocPtr doc,
|
||||
xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
int depth,
|
||||
const xmlChar *URL,
|
||||
const xmlChar *ID,
|
||||
xmlNodePtr *list);
|
||||
int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
|
||||
const xmlChar *URL,
|
||||
const xmlChar *ID,
|
||||
xmlNodePtr *list);
|
||||
|
||||
/**
|
||||
* SAX initialization routines
|
||||
*/
|
||||
void xmlDefaultSAXHandlerInit(void);
|
||||
void htmlDefaultSAXHandlerInit(void);
|
||||
|
||||
/**
|
||||
* Parser contexts handling.
|
||||
*/
|
||||
void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
|
||||
void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
|
||||
void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
|
||||
void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar* buffer,
|
||||
const char* filename);
|
||||
xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
|
||||
|
||||
/**
|
||||
* Reading/setting optional parsing features.
|
||||
*/
|
||||
|
||||
int xmlGetFeaturesList (int *len,
|
||||
const char **result);
|
||||
int xmlGetFeature (xmlParserCtxtPtr ctxt,
|
||||
const char *name,
|
||||
void *result);
|
||||
int xmlSetFeature (xmlParserCtxtPtr ctxt,
|
||||
const char *name,
|
||||
void *value);
|
||||
|
||||
/**
|
||||
* Interfaces for the Push mode
|
||||
*/
|
||||
xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
const char *chunk,
|
||||
int size,
|
||||
const char *filename);
|
||||
int xmlParseChunk (xmlParserCtxtPtr ctxt,
|
||||
const char *chunk,
|
||||
int size,
|
||||
int terminate);
|
||||
|
||||
/**
|
||||
* Special I/O mode
|
||||
*/
|
||||
|
||||
xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputBufferPtr input,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
/**
|
||||
* Node infos
|
||||
*/
|
||||
const xmlParserNodeInfo*
|
||||
xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
|
||||
const xmlNode* node);
|
||||
void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
|
||||
void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
|
||||
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
|
||||
const xmlNode* node);
|
||||
void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
|
||||
const xmlParserNodeInfo* info);
|
||||
|
||||
/*
|
||||
* External entities handling actually implemented in xmlIO
|
||||
*/
|
||||
|
||||
void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
|
||||
xmlExternalEntityLoader
|
||||
xmlGetExternalEntityLoader(void);
|
||||
xmlParserInputPtr
|
||||
xmlLoadExternalEntity (const char *URL,
|
||||
const char *ID,
|
||||
xmlParserCtxtPtr context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_PARSER_H__ */
|
||||
|
3537
parserInternals.c
Normal file
3537
parserInternals.c
Normal file
File diff suppressed because it is too large
Load Diff
314
parserInternals.h
Normal file
314
parserInternals.h
Normal file
@ -0,0 +1,314 @@
|
||||
/*
|
||||
* parserInternals.h : internals routines exported by the parser.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*
|
||||
* 14 Nov 2000 ht - truncated declaration of xmlParseElementChildrenContentDecl
|
||||
* for VMS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __XML_PARSER_INTERNALS_H__
|
||||
#define __XML_PARSER_INTERNALS_H__
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Identifiers can be longer, but this will be more costly
|
||||
* at runtime.
|
||||
*/
|
||||
#define XML_MAX_NAMELEN 100
|
||||
|
||||
/*
|
||||
* The parser tries to always have that amount of input ready
|
||||
* one of the point is providing context when reporting errors
|
||||
*/
|
||||
#define INPUT_CHUNK 250
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* UNICODE version of the macros. *
|
||||
* *
|
||||
************************************************************************/
|
||||
/*
|
||||
* [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
|
||||
* | [#x10000-#x10FFFF]
|
||||
* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
|
||||
*/
|
||||
#define IS_CHAR(c) \
|
||||
((((c) >= 0x20) && ((c) <= 0xD7FF)) || \
|
||||
((c) == 0x09) || ((c) == 0x0A) || ((c) == 0x0D) || \
|
||||
(((c) >= 0xE000) && ((c) <= 0xFFFD)) || \
|
||||
(((c) >= 0x10000) && ((c) <= 0x10FFFF)))
|
||||
|
||||
/*
|
||||
* [3] S ::= (#x20 | #x9 | #xD | #xA)+
|
||||
*/
|
||||
#define IS_BLANK(c) (((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
|
||||
((c) == 0x0D))
|
||||
|
||||
/*
|
||||
* [85] BaseChar ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_BASECHAR(c) xmlIsBaseChar(c)
|
||||
|
||||
/*
|
||||
* [88] Digit ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_DIGIT(c) xmlIsDigit(c)
|
||||
|
||||
/*
|
||||
* [87] CombiningChar ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_COMBINING(c) xmlIsCombining(c)
|
||||
|
||||
/*
|
||||
* [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |
|
||||
* #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] |
|
||||
* [#x309D-#x309E] | [#x30FC-#x30FE]
|
||||
*/
|
||||
#define IS_EXTENDER(c) xmlIsExtender(c)
|
||||
|
||||
/*
|
||||
* [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]
|
||||
*/
|
||||
#define IS_IDEOGRAPHIC(c) xmlIsIdeographic(c)
|
||||
|
||||
/*
|
||||
* [84] Letter ::= BaseChar | Ideographic
|
||||
*/
|
||||
#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
|
||||
|
||||
|
||||
/*
|
||||
* [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
|
||||
*/
|
||||
#define IS_PUBIDCHAR(c) xmlIsPubidChar(c)
|
||||
|
||||
#define SKIP_EOL(p) \
|
||||
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
|
||||
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
|
||||
|
||||
#define MOVETO_ENDTAG(p) \
|
||||
while ((*p) && (*(p) != '>')) (p)++
|
||||
|
||||
#define MOVETO_STARTTAG(p) \
|
||||
while ((*p) && (*(p) != '<')) (p)++
|
||||
|
||||
/**
|
||||
* Global vaiables affecting the default parser behaviour.
|
||||
*/
|
||||
|
||||
LIBXML_DLL_IMPORT extern int xmlParserDebugEntities;
|
||||
LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlParserDebugEntities;
|
||||
LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlLoadExtDtdDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern int xmlKeepBlanksDefaultValue;
|
||||
LIBXML_DLL_IMPORT extern xmlChar xmlStringText[];
|
||||
LIBXML_DLL_IMPORT extern xmlChar xmlStringTextNoenc[];
|
||||
LIBXML_DLL_IMPORT extern xmlChar xmlStringComment[];
|
||||
|
||||
/*
|
||||
* Function to finish teh work of the macros where needed
|
||||
*/
|
||||
int xmlIsBaseChar (int c);
|
||||
int xmlIsBlank (int c);
|
||||
int xmlIsPubidChar (int c);
|
||||
int xmlIsLetter (int c);
|
||||
int xmlIsDigit (int c);
|
||||
int xmlIsIdeographic(int c);
|
||||
int xmlIsCombining (int c);
|
||||
int xmlIsExtender (int c);
|
||||
int xmlIsCombining (int c);
|
||||
int xmlIsChar (int c);
|
||||
|
||||
/**
|
||||
* Parser context
|
||||
*/
|
||||
xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
|
||||
xmlParserCtxtPtr xmlCreateFileParserCtxt (const char *filename);
|
||||
xmlParserCtxtPtr xmlCreateMemoryParserCtxt(char *buffer,
|
||||
int size);
|
||||
xmlParserCtxtPtr xmlNewParserCtxt (void);
|
||||
xmlParserCtxtPtr xmlCreateEntityParserCtxt(const xmlChar *URL,
|
||||
const xmlChar *ID,
|
||||
const xmlChar *base);
|
||||
int xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlCharEncoding enc);
|
||||
int xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlCharEncodingHandlerPtr handler);
|
||||
void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/**
|
||||
* Entities
|
||||
*/
|
||||
void xmlHandleEntity (xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr entity);
|
||||
|
||||
/**
|
||||
* Input Streams
|
||||
*/
|
||||
xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr entity);
|
||||
void xmlPushInput (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputPtr input);
|
||||
xmlChar xmlPopInput (xmlParserCtxtPtr ctxt);
|
||||
void xmlFreeInputStream (xmlParserInputPtr input);
|
||||
xmlParserInputPtr xmlNewInputFromFile (xmlParserCtxtPtr ctxt,
|
||||
const char *filename);
|
||||
xmlParserInputPtr xmlNewInputStream (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/**
|
||||
* Namespaces.
|
||||
*/
|
||||
xmlChar * xmlSplitQName (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *name,
|
||||
xmlChar **prefix);
|
||||
xmlChar * xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **prefix);
|
||||
xmlChar * xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseQuotedString (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseNamespace (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/**
|
||||
* Generic production rules
|
||||
*/
|
||||
xmlChar * xmlScanName (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseName (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseNmtoken (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseEntityValue (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **orig);
|
||||
xmlChar * xmlParseAttValue (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseSystemLiteral (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParsePubidLiteral (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseCharData (xmlParserCtxtPtr ctxt,
|
||||
int cdata);
|
||||
xmlChar * xmlParseExternalID (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **publicID,
|
||||
int strict);
|
||||
void xmlParseComment (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParsePITarget (xmlParserCtxtPtr ctxt);
|
||||
void xmlParsePI (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseNotationDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseEntityDecl (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseDefaultDecl (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **value);
|
||||
xmlEnumerationPtr xmlParseNotationType (xmlParserCtxtPtr ctxt);
|
||||
xmlEnumerationPtr xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseEnumeratedType (xmlParserCtxtPtr ctxt,
|
||||
xmlEnumerationPtr *tree);
|
||||
int xmlParseAttributeType (xmlParserCtxtPtr ctxt,
|
||||
xmlEnumerationPtr *tree);
|
||||
void xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
|
||||
xmlElementContentPtr xmlParseElementMixedContentDecl
|
||||
(xmlParserCtxtPtr ctxt);
|
||||
#ifdef VMS
|
||||
xmlElementContentPtr xmlParseElementChildrenContentD
|
||||
(xmlParserCtxtPtr ctxt);
|
||||
#define xmlParseElementChildrenContentDecl xmlParseElementChildrenContentD
|
||||
#else
|
||||
xmlElementContentPtr xmlParseElementChildrenContentDecl
|
||||
(xmlParserCtxtPtr ctxt);
|
||||
#endif
|
||||
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
|
||||
xmlChar *name,
|
||||
xmlElementContentPtr *result);
|
||||
int xmlParseElementDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseMarkupDecl (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseCharRef (xmlParserCtxtPtr ctxt);
|
||||
xmlEntityPtr xmlParseEntityRef (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseReference (xmlParserCtxtPtr ctxt);
|
||||
void xmlParsePEReference (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseAttribute (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **value);
|
||||
xmlChar * xmlParseStartTag (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseEndTag (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseCDSect (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseContent (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseElement (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseVersionNum (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseVersionInfo (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseEncName (xmlParserCtxtPtr ctxt);
|
||||
xmlChar * xmlParseEncodingDecl (xmlParserCtxtPtr ctxt);
|
||||
int xmlParseSDDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseXMLDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseTextDecl (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseMisc (xmlParserCtxtPtr ctxt);
|
||||
void xmlParseExternalSubset (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
/*
|
||||
* Entities substitution
|
||||
*/
|
||||
#define XML_SUBSTITUTE_NONE 0
|
||||
#define XML_SUBSTITUTE_REF 1
|
||||
#define XML_SUBSTITUTE_PEREF 2
|
||||
#define XML_SUBSTITUTE_BOTH 3
|
||||
|
||||
xmlChar * xmlDecodeEntities (xmlParserCtxtPtr ctxt,
|
||||
int len,
|
||||
int what,
|
||||
xmlChar end,
|
||||
xmlChar end2,
|
||||
xmlChar end3);
|
||||
xmlChar * xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *str,
|
||||
int what,
|
||||
xmlChar end,
|
||||
xmlChar end2,
|
||||
xmlChar end3);
|
||||
|
||||
/*
|
||||
* Generated by MACROS on top of parser.c c.f. PUSH_AND_POP
|
||||
*/
|
||||
int nodePush (xmlParserCtxtPtr ctxt,
|
||||
xmlNodePtr value);
|
||||
xmlNodePtr nodePop (xmlParserCtxtPtr ctxt);
|
||||
int inputPush (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputPtr value);
|
||||
xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/*
|
||||
* other comodities shared between parser.c and parserInternals
|
||||
*/
|
||||
int xmlSkipBlankChars (xmlParserCtxtPtr ctxt);
|
||||
int xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *cur,
|
||||
int *len);
|
||||
void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
|
||||
void xmlParserHandleReference(xmlParserCtxtPtr ctxt);
|
||||
xmlChar *namePop (xmlParserCtxtPtr ctxt);
|
||||
int xmlCheckLanguageID (const xmlChar *lang);
|
||||
|
||||
/*
|
||||
* Really core function shared with HTML parser
|
||||
*/
|
||||
int xmlCurrentChar (xmlParserCtxtPtr ctxt,
|
||||
int *len);
|
||||
int xmlCopyChar (int len,
|
||||
xmlChar *out,
|
||||
int val);
|
||||
void xmlNextChar (xmlParserCtxtPtr ctxt);
|
||||
void xmlParserInputShrink (xmlParserInputPtr in);
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
/*
|
||||
* Actually comes from the HTML parser but launched from the init stuff
|
||||
*/
|
||||
void htmlInitAutoClose (void);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_PARSER_INTERNALS_H__ */
|
701
tree.h
Normal file
701
tree.h
Normal file
@ -0,0 +1,701 @@
|
||||
/*
|
||||
* tree.h : describes the structures found in an tree resulting
|
||||
* from an XML parsing.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*
|
||||
* 14 Nov 2000 ht - added redefinition of xmlBufferWriteChar for VMS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __XML_TREE_H__
|
||||
#define __XML_TREE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XML_XML_NAMESPACE \
|
||||
(const xmlChar *) "http://www.w3.org/XML/1998/namespace"
|
||||
|
||||
/*
|
||||
* The different element types carried by an XML tree
|
||||
*
|
||||
* NOTE: This is synchronized with DOM Level1 values
|
||||
* See http://www.w3.org/TR/REC-DOM-Level-1/
|
||||
*
|
||||
* Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
|
||||
* be deprecated to use an XML_DTD_NODE.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_ELEMENT_NODE= 1,
|
||||
XML_ATTRIBUTE_NODE= 2,
|
||||
XML_TEXT_NODE= 3,
|
||||
XML_CDATA_SECTION_NODE= 4,
|
||||
XML_ENTITY_REF_NODE= 5,
|
||||
XML_ENTITY_NODE= 6,
|
||||
XML_PI_NODE= 7,
|
||||
XML_COMMENT_NODE= 8,
|
||||
XML_DOCUMENT_NODE= 9,
|
||||
XML_DOCUMENT_TYPE_NODE= 10,
|
||||
XML_DOCUMENT_FRAG_NODE= 11,
|
||||
XML_NOTATION_NODE= 12,
|
||||
XML_HTML_DOCUMENT_NODE= 13,
|
||||
XML_DTD_NODE= 14,
|
||||
XML_ELEMENT_DECL= 15,
|
||||
XML_ATTRIBUTE_DECL= 16,
|
||||
XML_ENTITY_DECL= 17,
|
||||
XML_NAMESPACE_DECL= 18,
|
||||
XML_XINCLUDE_START= 19,
|
||||
XML_XINCLUDE_END= 20
|
||||
#ifdef LIBXML_SGML_ENABLED
|
||||
,XML_SGML_DOCUMENT_NODE= 21
|
||||
#endif
|
||||
} xmlElementType;
|
||||
|
||||
/*
|
||||
* Size of an internal character representation.
|
||||
*
|
||||
* We use 8bit chars internal representation for memory efficiency,
|
||||
* Note that with 8 bits wide xmlChars one can still use UTF-8 to handle
|
||||
* correctly non ISO-Latin input.
|
||||
*/
|
||||
|
||||
typedef unsigned char xmlChar;
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef CHAR
|
||||
#define CHAR xmlChar
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BAD_CAST (xmlChar *)
|
||||
|
||||
/*
|
||||
* a DTD Notation definition
|
||||
*/
|
||||
|
||||
typedef struct _xmlNotation xmlNotation;
|
||||
typedef xmlNotation *xmlNotationPtr;
|
||||
struct _xmlNotation {
|
||||
const xmlChar *name; /* Notation name */
|
||||
const xmlChar *PublicID; /* Public identifier, if any */
|
||||
const xmlChar *SystemID; /* System identifier, if any */
|
||||
};
|
||||
|
||||
/*
|
||||
* a DTD Attribute definition
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XML_ATTRIBUTE_CDATA = 1,
|
||||
XML_ATTRIBUTE_ID,
|
||||
XML_ATTRIBUTE_IDREF ,
|
||||
XML_ATTRIBUTE_IDREFS,
|
||||
XML_ATTRIBUTE_ENTITY,
|
||||
XML_ATTRIBUTE_ENTITIES,
|
||||
XML_ATTRIBUTE_NMTOKEN,
|
||||
XML_ATTRIBUTE_NMTOKENS,
|
||||
XML_ATTRIBUTE_ENUMERATION,
|
||||
XML_ATTRIBUTE_NOTATION
|
||||
} xmlAttributeType;
|
||||
|
||||
typedef enum {
|
||||
XML_ATTRIBUTE_NONE = 1,
|
||||
XML_ATTRIBUTE_REQUIRED,
|
||||
XML_ATTRIBUTE_IMPLIED,
|
||||
XML_ATTRIBUTE_FIXED
|
||||
} xmlAttributeDefault;
|
||||
|
||||
typedef struct _xmlEnumeration xmlEnumeration;
|
||||
typedef xmlEnumeration *xmlEnumerationPtr;
|
||||
struct _xmlEnumeration {
|
||||
struct _xmlEnumeration *next; /* next one */
|
||||
const xmlChar *name; /* Enumeration name */
|
||||
};
|
||||
|
||||
typedef struct _xmlAttribute xmlAttribute;
|
||||
typedef xmlAttribute *xmlAttributePtr;
|
||||
struct _xmlAttribute {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
|
||||
const xmlChar *name; /* Attribute name */
|
||||
struct _xmlNode *children; /* NULL */
|
||||
struct _xmlNode *last; /* NULL */
|
||||
struct _xmlDtd *parent; /* -> DTD */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
struct _xmlAttribute *nexth; /* next in hash table */
|
||||
xmlAttributeType atype; /* The attribute type */
|
||||
xmlAttributeDefault def; /* the default */
|
||||
const xmlChar *defaultValue; /* or the default value */
|
||||
xmlEnumerationPtr tree; /* or the enumeration tree if any */
|
||||
const xmlChar *prefix; /* the namespace prefix if any */
|
||||
const xmlChar *elem; /* Element holding the attribute */
|
||||
};
|
||||
|
||||
/*
|
||||
* a DTD Element definition.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_ELEMENT_CONTENT_PCDATA = 1,
|
||||
XML_ELEMENT_CONTENT_ELEMENT,
|
||||
XML_ELEMENT_CONTENT_SEQ,
|
||||
XML_ELEMENT_CONTENT_OR
|
||||
} xmlElementContentType;
|
||||
|
||||
typedef enum {
|
||||
XML_ELEMENT_CONTENT_ONCE = 1,
|
||||
XML_ELEMENT_CONTENT_OPT,
|
||||
XML_ELEMENT_CONTENT_MULT,
|
||||
XML_ELEMENT_CONTENT_PLUS
|
||||
} xmlElementContentOccur;
|
||||
|
||||
typedef struct _xmlElementContent xmlElementContent;
|
||||
typedef xmlElementContent *xmlElementContentPtr;
|
||||
struct _xmlElementContent {
|
||||
xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
|
||||
xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
|
||||
const xmlChar *name; /* Element name */
|
||||
struct _xmlElementContent *c1; /* first child */
|
||||
struct _xmlElementContent *c2; /* second child */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
XML_ELEMENT_TYPE_EMPTY = 1,
|
||||
XML_ELEMENT_TYPE_ANY,
|
||||
XML_ELEMENT_TYPE_MIXED,
|
||||
XML_ELEMENT_TYPE_ELEMENT
|
||||
} xmlElementTypeVal;
|
||||
|
||||
typedef struct _xmlElement xmlElement;
|
||||
typedef xmlElement *xmlElementPtr;
|
||||
struct _xmlElement {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
|
||||
const xmlChar *name; /* Element name */
|
||||
struct _xmlNode *children; /* NULL */
|
||||
struct _xmlNode *last; /* NULL */
|
||||
struct _xmlDtd *parent; /* -> DTD */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
xmlElementTypeVal etype; /* The type */
|
||||
xmlElementContentPtr content; /* the allowed element content */
|
||||
xmlAttributePtr attributes; /* List of the declared attributes */
|
||||
const xmlChar *prefix; /* the namespace prefix if any */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML namespace.
|
||||
* Note that prefix == NULL is valid, it defines the default namespace
|
||||
* within the subtree (until overriden).
|
||||
*
|
||||
* XML_GLOBAL_NAMESPACE is now deprecated for good
|
||||
* xmlNsType is unified with xmlElementType
|
||||
*/
|
||||
|
||||
#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
|
||||
typedef xmlElementType xmlNsType;
|
||||
|
||||
typedef struct _xmlNs xmlNs;
|
||||
typedef xmlNs *xmlNsPtr;
|
||||
struct _xmlNs {
|
||||
struct _xmlNs *next; /* next Ns link for this node */
|
||||
xmlNsType type; /* global or local */
|
||||
const xmlChar *href; /* URL for the namespace */
|
||||
const xmlChar *prefix; /* prefix for the namespace */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML DtD, as defined by <!DOCTYPE.
|
||||
*/
|
||||
typedef struct _xmlDtd xmlDtd;
|
||||
typedef xmlDtd *xmlDtdPtr;
|
||||
struct _xmlDtd {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_DTD_NODE, must be second ! */
|
||||
const xmlChar *name; /* Name of the DTD */
|
||||
struct _xmlNode *children; /* the value of the property link */
|
||||
struct _xmlNode *last; /* last child link */
|
||||
struct _xmlDoc *parent; /* child->parent link */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
/* End of common part */
|
||||
void *notations; /* Hash table for notations if any */
|
||||
void *elements; /* Hash table for elements if any */
|
||||
void *attributes; /* Hash table for attributes if any */
|
||||
void *entities; /* Hash table for entities if any */
|
||||
const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
|
||||
const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
|
||||
void *pentities; /* Hash table for param entities if any */
|
||||
};
|
||||
|
||||
/*
|
||||
* A attribute of an XML node.
|
||||
*/
|
||||
typedef struct _xmlAttr xmlAttr;
|
||||
typedef xmlAttr *xmlAttrPtr;
|
||||
struct _xmlAttr {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
|
||||
const xmlChar *name; /* the name of the property */
|
||||
struct _xmlNode *children; /* the value of the property */
|
||||
struct _xmlNode *last; /* NULL */
|
||||
struct _xmlNode *parent; /* child->parent link */
|
||||
struct _xmlAttr *next; /* next sibling link */
|
||||
struct _xmlAttr *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
xmlNs *ns; /* pointer to the associated namespace */
|
||||
xmlAttributeType atype; /* the attribute type if validating */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML ID instance.
|
||||
*/
|
||||
|
||||
typedef struct _xmlID xmlID;
|
||||
typedef xmlID *xmlIDPtr;
|
||||
struct _xmlID {
|
||||
struct _xmlID *next; /* next ID */
|
||||
const xmlChar *value; /* The ID name */
|
||||
xmlAttrPtr attr; /* The attribut holding it */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML IDREF instance.
|
||||
*/
|
||||
|
||||
typedef struct _xmlRef xmlRef;
|
||||
typedef xmlRef *xmlRefPtr;
|
||||
struct _xmlRef {
|
||||
struct _xmlRef *next; /* next Ref */
|
||||
const xmlChar *value; /* The Ref name */
|
||||
xmlAttrPtr attr; /* The attribut holding it */
|
||||
};
|
||||
|
||||
/*
|
||||
* A buffer structure
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XML_BUFFER_ALLOC_DOUBLEIT,
|
||||
XML_BUFFER_ALLOC_EXACT
|
||||
} xmlBufferAllocationScheme;
|
||||
|
||||
typedef struct _xmlBuffer xmlBuffer;
|
||||
typedef xmlBuffer *xmlBufferPtr;
|
||||
struct _xmlBuffer {
|
||||
xmlChar *content; /* The buffer content UTF8 */
|
||||
unsigned int use; /* The buffer size used */
|
||||
unsigned int size; /* The buffer size */
|
||||
xmlBufferAllocationScheme alloc; /* The realloc method */
|
||||
};
|
||||
|
||||
/*
|
||||
* A node in an XML tree.
|
||||
*/
|
||||
typedef struct _xmlNode xmlNode;
|
||||
typedef xmlNode *xmlNodePtr;
|
||||
struct _xmlNode {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* type number, must be second ! */
|
||||
const xmlChar *name; /* the name of the node, or the entity */
|
||||
struct _xmlNode *children; /* parent->childs link */
|
||||
struct _xmlNode *last; /* last child link */
|
||||
struct _xmlNode *parent; /* child->parent link */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
xmlNs *ns; /* pointer to the associated namespace */
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlChar *content; /* the content */
|
||||
#else
|
||||
xmlBufferPtr content; /* the content in a buffer */
|
||||
#endif
|
||||
|
||||
/* End of common part */
|
||||
struct _xmlAttr *properties;/* properties list */
|
||||
xmlNs *nsDef; /* namespace definitions on this node */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XML document.
|
||||
*/
|
||||
typedef struct _xmlDoc xmlDoc;
|
||||
typedef xmlDoc *xmlDocPtr;
|
||||
struct _xmlDoc {
|
||||
#ifndef XML_WITHOUT_CORBA
|
||||
void *_private; /* for Corba, must be first ! */
|
||||
#endif
|
||||
xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
|
||||
char *name; /* name/filename/URI of the document */
|
||||
struct _xmlNode *children; /* the document tree */
|
||||
struct _xmlNode *last; /* last child link */
|
||||
struct _xmlNode *parent; /* child->parent link */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* autoreference to itself */
|
||||
|
||||
/* End of common part */
|
||||
int compression;/* level of zlib compression */
|
||||
int standalone; /* standalone document (no external refs) */
|
||||
struct _xmlDtd *intSubset; /* the document internal subset */
|
||||
struct _xmlDtd *extSubset; /* the document external subset */
|
||||
struct _xmlNs *oldNs; /* Global namespace, the old way */
|
||||
const xmlChar *version; /* the XML version string */
|
||||
const xmlChar *encoding; /* external initial encoding, if any */
|
||||
void *ids; /* Hash table for ID attributes if any */
|
||||
void *refs; /* Hash table for IDREFs attributes if any */
|
||||
const xmlChar *URL; /* The URI for that document */
|
||||
int charset; /* encoding of the in-memory content
|
||||
actually an xmlCharEncoding */
|
||||
};
|
||||
|
||||
/*
|
||||
* Compatibility naming layer with libxml1
|
||||
*/
|
||||
#ifndef xmlChildrenNode
|
||||
#define xmlChildrenNode children
|
||||
#define xmlRootNode children
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Variables.
|
||||
*/
|
||||
LIBXML_DLL_IMPORT extern xmlNsPtr baseDTD;
|
||||
LIBXML_DLL_IMPORT extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
|
||||
LIBXML_DLL_IMPORT extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
|
||||
LIBXML_DLL_IMPORT extern xmlBufferAllocationScheme xmlBufferAllocScheme; /* alloc scheme to use */
|
||||
LIBXML_DLL_IMPORT extern int xmlSaveNoEmptyTags; /* save empty tags as <empty></empty> */
|
||||
|
||||
/*
|
||||
* Handling Buffers.
|
||||
*/
|
||||
|
||||
xmlBufferPtr xmlBufferCreate (void);
|
||||
xmlBufferPtr xmlBufferCreateSize (size_t size);
|
||||
void xmlBufferFree (xmlBufferPtr buf);
|
||||
int xmlBufferDump (FILE *file,
|
||||
xmlBufferPtr buf);
|
||||
void xmlBufferAdd (xmlBufferPtr buf,
|
||||
const xmlChar *str,
|
||||
int len);
|
||||
void xmlBufferAddHead (xmlBufferPtr buf,
|
||||
const xmlChar *str,
|
||||
int len);
|
||||
void xmlBufferCat (xmlBufferPtr buf,
|
||||
const xmlChar *str);
|
||||
void xmlBufferCCat (xmlBufferPtr buf,
|
||||
const char *str);
|
||||
int xmlBufferShrink (xmlBufferPtr buf,
|
||||
unsigned int len);
|
||||
int xmlBufferGrow (xmlBufferPtr buf,
|
||||
unsigned int len);
|
||||
void xmlBufferEmpty (xmlBufferPtr buf);
|
||||
const xmlChar* xmlBufferContent (const xmlBufferPtr buf);
|
||||
int xmlBufferUse (const xmlBufferPtr buf);
|
||||
void xmlBufferSetAllocationScheme(xmlBufferPtr buf,
|
||||
xmlBufferAllocationScheme scheme);
|
||||
int xmlBufferLength (const xmlBufferPtr buf);
|
||||
|
||||
/*
|
||||
* Creating/freeing new structures
|
||||
*/
|
||||
xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlDtdPtr xmlNewDtd (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc);
|
||||
void xmlFreeDtd (xmlDtdPtr cur);
|
||||
xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
xmlNsPtr xmlNewNs (xmlNodePtr node,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
void xmlFreeNs (xmlNsPtr cur);
|
||||
xmlDocPtr xmlNewDoc (const xmlChar *version);
|
||||
void xmlFreeDoc (xmlDocPtr cur);
|
||||
xmlAttrPtr xmlNewDocProp (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
xmlAttrPtr xmlNewProp (xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
xmlAttrPtr xmlNewNsProp (xmlNodePtr node,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
void xmlFreePropList (xmlAttrPtr cur);
|
||||
void xmlFreeProp (xmlAttrPtr cur);
|
||||
xmlAttrPtr xmlCopyProp (xmlNodePtr target,
|
||||
xmlAttrPtr cur);
|
||||
xmlAttrPtr xmlCopyPropList (xmlNodePtr target,
|
||||
xmlAttrPtr cur);
|
||||
xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd);
|
||||
xmlDocPtr xmlCopyDoc (xmlDocPtr doc,
|
||||
int recursive);
|
||||
|
||||
/*
|
||||
* Creating new nodes
|
||||
*/
|
||||
xmlNodePtr xmlNewDocNode (xmlDocPtr doc,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewNode (xmlNsPtr ns,
|
||||
const xmlChar *name);
|
||||
xmlNodePtr xmlNewChild (xmlNodePtr parent,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewTextChild (xmlNodePtr parent,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewDocText (xmlDocPtr doc,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewText (const xmlChar *content);
|
||||
xmlNodePtr xmlNewPI (const xmlChar *name,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
xmlNodePtr xmlNewTextLen (const xmlChar *content,
|
||||
int len);
|
||||
xmlNodePtr xmlNewDocComment (xmlDocPtr doc,
|
||||
const xmlChar *content);
|
||||
xmlNodePtr xmlNewComment (const xmlChar *content);
|
||||
xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
xmlNodePtr xmlNewCharRef (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlNodePtr xmlNewReference (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlNodePtr xmlCopyNode (xmlNodePtr node,
|
||||
int recursive);
|
||||
xmlNodePtr xmlCopyNodeList (xmlNodePtr node);
|
||||
xmlNodePtr xmlNewDocFragment (xmlDocPtr doc);
|
||||
|
||||
/*
|
||||
* Navigating
|
||||
*/
|
||||
xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc);
|
||||
xmlNodePtr xmlGetLastChild (xmlNodePtr parent);
|
||||
int xmlNodeIsText (xmlNodePtr node);
|
||||
int xmlIsBlankNode (xmlNodePtr node);
|
||||
|
||||
/*
|
||||
* Changing the structure
|
||||
*/
|
||||
xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc,
|
||||
xmlNodePtr root);
|
||||
void xmlNodeSetName (xmlNodePtr cur,
|
||||
const xmlChar *name);
|
||||
xmlNodePtr xmlAddChild (xmlNodePtr parent,
|
||||
xmlNodePtr cur);
|
||||
xmlNodePtr xmlAddChildList (xmlNodePtr parent,
|
||||
xmlNodePtr cur);
|
||||
xmlNodePtr xmlReplaceNode (xmlNodePtr old,
|
||||
xmlNodePtr cur);
|
||||
xmlNodePtr xmlAddSibling (xmlNodePtr cur,
|
||||
xmlNodePtr elem);
|
||||
xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur,
|
||||
xmlNodePtr elem);
|
||||
xmlNodePtr xmlAddNextSibling (xmlNodePtr cur,
|
||||
xmlNodePtr elem);
|
||||
void xmlUnlinkNode (xmlNodePtr cur);
|
||||
xmlNodePtr xmlTextMerge (xmlNodePtr first,
|
||||
xmlNodePtr second);
|
||||
void xmlTextConcat (xmlNodePtr node,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
void xmlFreeNodeList (xmlNodePtr cur);
|
||||
void xmlFreeNode (xmlNodePtr cur);
|
||||
void xmlSetTreeDoc (xmlNodePtr tree,
|
||||
xmlDocPtr doc);
|
||||
void xmlSetListDoc (xmlNodePtr list,
|
||||
xmlDocPtr doc);
|
||||
|
||||
/*
|
||||
* Namespaces
|
||||
*/
|
||||
xmlNsPtr xmlSearchNs (xmlDocPtr doc,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *nameSpace);
|
||||
xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *href);
|
||||
xmlNsPtr * xmlGetNsList (xmlDocPtr doc,
|
||||
xmlNodePtr node);
|
||||
void xmlSetNs (xmlNodePtr node,
|
||||
xmlNsPtr ns);
|
||||
xmlNsPtr xmlCopyNamespace (xmlNsPtr cur);
|
||||
xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur);
|
||||
|
||||
/*
|
||||
* Changing the content.
|
||||
*/
|
||||
xmlAttrPtr xmlSetProp (xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
xmlChar * xmlGetProp (xmlNodePtr node,
|
||||
const xmlChar *name);
|
||||
xmlAttrPtr xmlHasProp (xmlNodePtr node,
|
||||
const xmlChar *name);
|
||||
xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
xmlChar * xmlGetNsProp (xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *nameSpace);
|
||||
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
|
||||
const xmlChar *value);
|
||||
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
|
||||
const xmlChar *value,
|
||||
int len);
|
||||
xmlChar * xmlNodeListGetString (xmlDocPtr doc,
|
||||
xmlNodePtr list,
|
||||
int inLine);
|
||||
xmlChar * xmlNodeListGetRawString (xmlDocPtr doc,
|
||||
xmlNodePtr list,
|
||||
int inLine);
|
||||
void xmlNodeSetContent (xmlNodePtr cur,
|
||||
const xmlChar *content);
|
||||
void xmlNodeSetContentLen (xmlNodePtr cur,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
void xmlNodeAddContent (xmlNodePtr cur,
|
||||
const xmlChar *content);
|
||||
void xmlNodeAddContentLen (xmlNodePtr cur,
|
||||
const xmlChar *content,
|
||||
int len);
|
||||
xmlChar * xmlNodeGetContent (xmlNodePtr cur);
|
||||
xmlChar * xmlNodeGetLang (xmlNodePtr cur);
|
||||
void xmlNodeSetLang (xmlNodePtr cur,
|
||||
const xmlChar *lang);
|
||||
int xmlNodeGetSpacePreserve (xmlNodePtr cur);
|
||||
void xmlNodeSetSpacePreserve (xmlNodePtr cur, int
|
||||
val);
|
||||
xmlChar * xmlNodeGetBase (xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
void xmlNodeSetBase (xmlNodePtr cur,
|
||||
xmlChar *uri);
|
||||
|
||||
/*
|
||||
* Removing content.
|
||||
*/
|
||||
int xmlRemoveProp (xmlAttrPtr attr);
|
||||
int xmlRemoveNode (xmlNodePtr node); /* TODO */
|
||||
|
||||
/*
|
||||
* Internal, don't use
|
||||
*/
|
||||
#ifdef VMS
|
||||
void xmlBufferWriteXmlCHAR (xmlBufferPtr buf,
|
||||
const xmlChar *string);
|
||||
#define xmlBufferWriteCHAR xmlBufferWriteXmlCHAR
|
||||
#else
|
||||
void xmlBufferWriteCHAR (xmlBufferPtr buf,
|
||||
const xmlChar *string);
|
||||
#endif
|
||||
void xmlBufferWriteChar (xmlBufferPtr buf,
|
||||
const char *string);
|
||||
void xmlBufferWriteQuotedString(xmlBufferPtr buf,
|
||||
const xmlChar *string);
|
||||
|
||||
/*
|
||||
* Namespace handling
|
||||
*/
|
||||
int xmlReconciliateNs (xmlDocPtr doc,
|
||||
xmlNodePtr tree);
|
||||
|
||||
/*
|
||||
* Saving
|
||||
*/
|
||||
void xmlDocDumpFormatMemory (xmlDocPtr cur,
|
||||
xmlChar**mem,
|
||||
int *size,
|
||||
int format);
|
||||
void xmlDocDumpMemory (xmlDocPtr cur,
|
||||
xmlChar**mem,
|
||||
int *size);
|
||||
void xmlDocDumpMemoryEnc (xmlDocPtr out_doc,
|
||||
xmlChar **doc_txt_ptr,
|
||||
int * doc_txt_len,
|
||||
const char *txt_encoding);
|
||||
void xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,
|
||||
xmlChar **doc_txt_ptr,
|
||||
int * doc_txt_len,
|
||||
const char *txt_encoding,
|
||||
int format);
|
||||
int xmlDocDump (FILE *f,
|
||||
xmlDocPtr cur);
|
||||
void xmlElemDump (FILE *f,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
int xmlSaveFile (const char *filename,
|
||||
xmlDocPtr cur);
|
||||
void xmlNodeDump (xmlBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
int level,
|
||||
int format);
|
||||
|
||||
/* This one is exported from xmlIO.h
|
||||
|
||||
int xmlSaveFileTo (xmlOutputBuffer *buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
*/
|
||||
|
||||
int xmlSaveFileEnc (const char *filename,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
|
||||
/*
|
||||
* Compression
|
||||
*/
|
||||
int xmlGetDocCompressMode (xmlDocPtr doc);
|
||||
void xmlSetDocCompressMode (xmlDocPtr doc,
|
||||
int mode);
|
||||
int xmlGetCompressMode (void);
|
||||
void xmlSetCompressMode (int mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_TREE_H__ */
|
||||
|
61
uri.h
Normal file
61
uri.h
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* uri.c: library of generic URI related routines
|
||||
*
|
||||
* Reference: RFC 2396
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_URI_H__
|
||||
#define __XML_URI_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
typedef struct _xmlURI xmlURI;
|
||||
typedef xmlURI *xmlURIPtr;
|
||||
struct _xmlURI {
|
||||
char *scheme;
|
||||
char *opaque;
|
||||
char *authority;
|
||||
char *server;
|
||||
char *user;
|
||||
int port;
|
||||
char *path;
|
||||
char *query;
|
||||
char *fragment;
|
||||
};
|
||||
|
||||
/*
|
||||
* This function is in tree.h:
|
||||
* xmlChar * xmlNodeGetBase (xmlDocPtr doc,
|
||||
* xmlNodePtr cur);
|
||||
*/
|
||||
xmlURIPtr xmlCreateURI (void);
|
||||
xmlChar * xmlBuildURI (const xmlChar *URI,
|
||||
const xmlChar *base);
|
||||
xmlURIPtr xmlParseURI (const char *URI);
|
||||
int xmlParseURIReference (xmlURIPtr uri,
|
||||
const char *str);
|
||||
xmlChar * xmlSaveUri (xmlURIPtr uri);
|
||||
void xmlPrintURI (FILE *stream,
|
||||
xmlURIPtr uri);
|
||||
char * xmlURIUnescapeString (const char *str,
|
||||
int len,
|
||||
char *target);
|
||||
int xmlNormalizeURIPath (char *path);
|
||||
xmlChar * xmlURIEscape (const xmlChar *str);
|
||||
void xmlFreeURI (xmlURIPtr uri);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_URI_H__ */
|
236
valid.h
Normal file
236
valid.h
Normal file
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* valid.h : interface to the DTD handling and the validity checking
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_VALID_H__
|
||||
#define __XML_VALID_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* an xmlValidCtxt is used for error reporting when validating
|
||||
*/
|
||||
|
||||
typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
|
||||
typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
|
||||
|
||||
typedef struct _xmlValidCtxt xmlValidCtxt;
|
||||
typedef xmlValidCtxt *xmlValidCtxtPtr;
|
||||
struct _xmlValidCtxt {
|
||||
void *userData; /* user specific data block */
|
||||
xmlValidityErrorFunc error; /* the callback in case of errors */
|
||||
xmlValidityWarningFunc warning; /* the callback in case of warning */
|
||||
|
||||
/* Node analysis stack used when validating within entities */
|
||||
xmlNodePtr node; /* Current parsed Node */
|
||||
int nodeNr; /* Depth of the parsing stack */
|
||||
int nodeMax; /* Max depth of the parsing stack */
|
||||
xmlNodePtr *nodeTab; /* array of nodes */
|
||||
|
||||
int finishDtd; /* finished validating the Dtd ? */
|
||||
xmlDocPtr doc; /* the document */
|
||||
int valid; /* temporary validity check result */
|
||||
};
|
||||
|
||||
/*
|
||||
* ALl notation declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlNotationTable;
|
||||
typedef xmlNotationTable *xmlNotationTablePtr;
|
||||
|
||||
/*
|
||||
* ALl element declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlElementTable;
|
||||
typedef xmlElementTable *xmlElementTablePtr;
|
||||
|
||||
/*
|
||||
* ALl attribute declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlAttributeTable;
|
||||
typedef xmlAttributeTable *xmlAttributeTablePtr;
|
||||
|
||||
/*
|
||||
* ALl IDs attributes are stored in a table
|
||||
* there is one table per document
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlIDTable;
|
||||
typedef xmlIDTable *xmlIDTablePtr;
|
||||
|
||||
/*
|
||||
* ALl Refs attributes are stored in a table
|
||||
* there is one table per document
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlRefTable;
|
||||
typedef xmlRefTable *xmlRefTablePtr;
|
||||
|
||||
/* helper */
|
||||
xmlChar * xmlSplitQName2 (const xmlChar *name,
|
||||
xmlChar **prefix);
|
||||
|
||||
/* Notation */
|
||||
xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *name,
|
||||
const xmlChar *PublicID,
|
||||
const xmlChar *SystemID);
|
||||
xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
|
||||
void xmlFreeNotationTable(xmlNotationTablePtr table);
|
||||
void xmlDumpNotationDecl (xmlBufferPtr buf,
|
||||
xmlNotationPtr nota);
|
||||
void xmlDumpNotationTable(xmlBufferPtr buf,
|
||||
xmlNotationTablePtr table);
|
||||
|
||||
/* Element Content */
|
||||
xmlElementContentPtr xmlNewElementContent (xmlChar *name,
|
||||
xmlElementContentType type);
|
||||
xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
|
||||
void xmlFreeElementContent(xmlElementContentPtr cur);
|
||||
void xmlSprintfElementContent(char *buf,
|
||||
xmlElementContentPtr content,
|
||||
int glob);
|
||||
|
||||
/* Element */
|
||||
xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *name,
|
||||
xmlElementTypeVal type,
|
||||
xmlElementContentPtr content);
|
||||
xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
|
||||
void xmlFreeElementTable (xmlElementTablePtr table);
|
||||
void xmlDumpElementTable (xmlBufferPtr buf,
|
||||
xmlElementTablePtr table);
|
||||
void xmlDumpElementDecl (xmlBufferPtr buf,
|
||||
xmlElementPtr elem);
|
||||
|
||||
/* Enumeration */
|
||||
xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name);
|
||||
void xmlFreeEnumeration (xmlEnumerationPtr cur);
|
||||
xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
|
||||
|
||||
/* Attribute */
|
||||
xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns,
|
||||
xmlAttributeType type,
|
||||
xmlAttributeDefault def,
|
||||
const xmlChar *defaultValue,
|
||||
xmlEnumerationPtr tree);
|
||||
xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
|
||||
void xmlFreeAttributeTable (xmlAttributeTablePtr table);
|
||||
void xmlDumpAttributeTable (xmlBufferPtr buf,
|
||||
xmlAttributeTablePtr table);
|
||||
void xmlDumpAttributeDecl (xmlBufferPtr buf,
|
||||
xmlAttributePtr attr);
|
||||
|
||||
/* IDs */
|
||||
xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *value,
|
||||
xmlAttrPtr attr);
|
||||
xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table);
|
||||
void xmlFreeIDTable (xmlIDTablePtr table);
|
||||
xmlAttrPtr xmlGetID (xmlDocPtr doc,
|
||||
const xmlChar *ID);
|
||||
int xmlIsID (xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr);
|
||||
int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr);
|
||||
|
||||
/* IDREFs */
|
||||
xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *value,
|
||||
xmlAttrPtr attr);
|
||||
xmlRefTablePtr xmlCopyRefTable (xmlRefTablePtr table);
|
||||
void xmlFreeRefTable (xmlRefTablePtr table);
|
||||
int xmlIsRef (xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr);
|
||||
int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr);
|
||||
|
||||
/**
|
||||
* The public function calls related to validity checking
|
||||
*/
|
||||
|
||||
int xmlValidateRoot (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
int xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlElementPtr elem);
|
||||
xmlChar * xmlValidNormalizeAttributeValue(xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlAttributePtr attr);
|
||||
int xmlValidateAttributeValue(xmlAttributeType type,
|
||||
const xmlChar *value);
|
||||
int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNotationPtr nota);
|
||||
int xmlValidateDtd (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlDtdPtr dtd);
|
||||
int xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
int xmlValidateDocument (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
int xmlValidateElement (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
int xmlValidateOneElement (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr,
|
||||
const xmlChar *value);
|
||||
int xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
int xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *notationName);
|
||||
int xmlIsMixedElement (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name);
|
||||
xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *name);
|
||||
xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *name);
|
||||
|
||||
int xmlValidGetValidElements(xmlNode *prev,
|
||||
xmlNode *next,
|
||||
const xmlChar **list,
|
||||
int max);
|
||||
int xmlValidGetPotentialChildren(xmlElementContent *ctree,
|
||||
const xmlChar **list,
|
||||
int *len,
|
||||
int max);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_VALID_H__ */
|
806
xinclude.c
Normal file
806
xinclude.c
Normal file
@ -0,0 +1,806 @@
|
||||
/*
|
||||
* xinclude.c : Code to implement XInclude processing
|
||||
*
|
||||
* World Wide Web Consortium Working Draft 26 October 2000
|
||||
* http://www.w3.org/TR/2000/WD-xinclude-20001026
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO: compute XPointers nodesets
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32config.h"
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/xpointer.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
#include <libxml/debugXML.h>
|
||||
#endif
|
||||
#include <libxml/xmlerror.h>
|
||||
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#include <libxml/xinclude.h>
|
||||
|
||||
#define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/1999/XML/xinclude"
|
||||
#define XINCLUDE_NODE (const xmlChar *) "include"
|
||||
#define XINCLUDE_HREF (const xmlChar *) "href"
|
||||
#define XINCLUDE_PARSE (const xmlChar *) "parse"
|
||||
#define XINCLUDE_PARSE_XML (const xmlChar *) "xml"
|
||||
#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text"
|
||||
|
||||
/* #define DEBUG_XINCLUDE */
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* XInclude contexts handling *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/*
|
||||
* An XInclude context
|
||||
*/
|
||||
typedef xmlChar *URL;
|
||||
typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt;
|
||||
typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;
|
||||
struct _xmlXIncludeCtxt {
|
||||
xmlDocPtr doc; /* the source document */
|
||||
int incNr; /* number of includes */
|
||||
int incMax; /* size of includes tab */
|
||||
xmlNodePtr *incTab; /* array of include nodes */
|
||||
xmlNodePtr *repTab; /* array of replacement node lists */
|
||||
int docNr; /* number of parsed documents */
|
||||
int docMax; /* size of parsed documents tab */
|
||||
xmlDocPtr *docTab; /* array of parsed documents */
|
||||
URL *urlTab; /* array of parsed documents URLs */
|
||||
int txtNr; /* number of unparsed documents */
|
||||
int txtMax; /* size of unparsed documents tab */
|
||||
xmlNodePtr *txtTab; /* array of unparsed text nodes */
|
||||
URL *txturlTab; /* array of unparsed txtuments URLs */
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlXIncludeAddNode:
|
||||
* @ctxt: the XInclude context
|
||||
* @node: the new node
|
||||
*
|
||||
* Add a new node to process to an XInclude context
|
||||
*/
|
||||
void
|
||||
xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
|
||||
if (ctxt->incMax == 0) {
|
||||
ctxt->incMax = 4;
|
||||
ctxt->incTab = (xmlNodePtr *) xmlMalloc(ctxt->incMax *
|
||||
sizeof(ctxt->incTab[0]));
|
||||
if (ctxt->incTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"malloc failed !\n");
|
||||
return;
|
||||
}
|
||||
ctxt->repTab = (xmlNodePtr *) xmlMalloc(ctxt->incMax *
|
||||
sizeof(ctxt->repTab[0]));
|
||||
if (ctxt->repTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"malloc failed !\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ctxt->incNr >= ctxt->incMax) {
|
||||
ctxt->incMax *= 2;
|
||||
ctxt->incTab = (xmlNodePtr *) xmlRealloc(ctxt->incTab,
|
||||
ctxt->incMax * sizeof(ctxt->incTab[0]));
|
||||
if (ctxt->incTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"realloc failed !\n");
|
||||
return;
|
||||
}
|
||||
ctxt->repTab = (xmlNodePtr *) xmlRealloc(ctxt->repTab,
|
||||
ctxt->incMax * sizeof(ctxt->repTab[0]));
|
||||
if (ctxt->repTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"realloc failed !\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
ctxt->incTab[ctxt->incNr] = node;
|
||||
ctxt->repTab[ctxt->incNr] = NULL;
|
||||
ctxt->incNr++;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeAddDoc:
|
||||
* @ctxt: the XInclude context
|
||||
* @doc: the new document
|
||||
* @url: the associated URL
|
||||
*
|
||||
* Add a new document to the list
|
||||
*/
|
||||
void
|
||||
xmlXIncludeAddDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, const URL url) {
|
||||
if (ctxt->docMax == 0) {
|
||||
ctxt->docMax = 4;
|
||||
ctxt->docTab = (xmlDocPtr *) xmlMalloc(ctxt->docMax *
|
||||
sizeof(ctxt->docTab[0]));
|
||||
if (ctxt->docTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"malloc failed !\n");
|
||||
return;
|
||||
}
|
||||
ctxt->urlTab = (URL *) xmlMalloc(ctxt->docMax *
|
||||
sizeof(ctxt->urlTab[0]));
|
||||
if (ctxt->urlTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"malloc failed !\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ctxt->docNr >= ctxt->docMax) {
|
||||
ctxt->docMax *= 2;
|
||||
ctxt->docTab = (xmlDocPtr *) xmlRealloc(ctxt->docTab,
|
||||
ctxt->docMax * sizeof(ctxt->docTab[0]));
|
||||
if (ctxt->docTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"realloc failed !\n");
|
||||
return;
|
||||
}
|
||||
ctxt->urlTab = (URL *) xmlRealloc(ctxt->urlTab,
|
||||
ctxt->docMax * sizeof(ctxt->urlTab[0]));
|
||||
if (ctxt->urlTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"realloc failed !\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
ctxt->docTab[ctxt->docNr] = doc;
|
||||
ctxt->urlTab[ctxt->docNr] = xmlStrdup(url);
|
||||
ctxt->docNr++;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeAddTxt:
|
||||
* @ctxt: the XInclude context
|
||||
* @txt: the new text node
|
||||
* @url: the associated URL
|
||||
*
|
||||
* Add a new txtument to the list
|
||||
*/
|
||||
void
|
||||
xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const URL url) {
|
||||
if (ctxt->txtMax == 0) {
|
||||
ctxt->txtMax = 4;
|
||||
ctxt->txtTab = (xmlNodePtr *) xmlMalloc(ctxt->txtMax *
|
||||
sizeof(ctxt->txtTab[0]));
|
||||
if (ctxt->txtTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"malloc failed !\n");
|
||||
return;
|
||||
}
|
||||
ctxt->txturlTab = (URL *) xmlMalloc(ctxt->txtMax *
|
||||
sizeof(ctxt->txturlTab[0]));
|
||||
if (ctxt->txturlTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"malloc failed !\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ctxt->txtNr >= ctxt->txtMax) {
|
||||
ctxt->txtMax *= 2;
|
||||
ctxt->txtTab = (xmlNodePtr *) xmlRealloc(ctxt->txtTab,
|
||||
ctxt->txtMax * sizeof(ctxt->txtTab[0]));
|
||||
if (ctxt->txtTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"realloc failed !\n");
|
||||
return;
|
||||
}
|
||||
ctxt->txturlTab = (URL *) xmlRealloc(ctxt->txturlTab,
|
||||
ctxt->txtMax * sizeof(ctxt->urlTab[0]));
|
||||
if (ctxt->txturlTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"realloc failed !\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
ctxt->txtTab[ctxt->txtNr] = txt;
|
||||
ctxt->txturlTab[ctxt->txtNr] = xmlStrdup(url);
|
||||
ctxt->txtNr++;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeNewContext:
|
||||
* @doc: an XML Document
|
||||
*
|
||||
* Creates a new XInclude context
|
||||
*
|
||||
* Returns the new set
|
||||
*/
|
||||
xmlXIncludeCtxtPtr
|
||||
xmlXIncludeNewContext(xmlDocPtr doc) {
|
||||
xmlXIncludeCtxtPtr ret;
|
||||
|
||||
if (doc == NULL)
|
||||
return(NULL);
|
||||
ret = (xmlXIncludeCtxtPtr) xmlMalloc(sizeof(xmlXIncludeCtxt));
|
||||
if (ret == NULL)
|
||||
return(NULL);
|
||||
memset(ret, 0, sizeof(xmlXIncludeCtxt));
|
||||
ret->doc = doc;
|
||||
ret->incNr = 0;
|
||||
ret->incMax = 0;
|
||||
ret->incTab = NULL;
|
||||
ret->repTab = NULL;
|
||||
ret->docNr = 0;
|
||||
ret->docMax = 0;
|
||||
ret->docTab = NULL;
|
||||
ret->urlTab = NULL;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeFreeContext:
|
||||
* @ctxt: the XInclude context
|
||||
*
|
||||
* Free an XInclude context
|
||||
*/
|
||||
void
|
||||
xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
|
||||
int i;
|
||||
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
for (i = 0;i < ctxt->docNr;i++) {
|
||||
xmlFreeDoc(ctxt->docTab[i]);
|
||||
if (ctxt->urlTab[i] != NULL)
|
||||
xmlFree(ctxt->urlTab[i]);
|
||||
}
|
||||
for (i = 0;i < ctxt->txtNr;i++) {
|
||||
if (ctxt->txturlTab[i] != NULL)
|
||||
xmlFree(ctxt->txturlTab[i]);
|
||||
}
|
||||
if (ctxt->incTab != NULL)
|
||||
xmlFree(ctxt->incTab);
|
||||
if (ctxt->repTab != NULL)
|
||||
xmlFree(ctxt->repTab);
|
||||
if (ctxt->urlTab != NULL)
|
||||
xmlFree(ctxt->urlTab);
|
||||
if (ctxt->docTab != NULL)
|
||||
xmlFree(ctxt->docTab);
|
||||
if (ctxt->txtTab != NULL)
|
||||
xmlFree(ctxt->txtTab);
|
||||
if (ctxt->txturlTab != NULL)
|
||||
xmlFree(ctxt->txturlTab);
|
||||
memset(ctxt, 0xeb, sizeof(xmlXIncludeCtxt));
|
||||
xmlFree(ctxt);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* XInclude I/O handling *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xmlXIncludeLoadDoc:
|
||||
* @ctxt: the XInclude context
|
||||
* @url: the associated URL
|
||||
* @nr: the xinclude node number
|
||||
*
|
||||
* Load the document, and store the result in the XInclude context
|
||||
*/
|
||||
void
|
||||
xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
|
||||
xmlDocPtr doc;
|
||||
xmlURIPtr uri;
|
||||
xmlChar *URL;
|
||||
xmlChar *fragment = NULL;
|
||||
int i;
|
||||
/*
|
||||
* Check the URL and remove any fragment identifier
|
||||
*/
|
||||
uri = xmlParseURI((const char *)url);
|
||||
if (uri == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: invalid value URI %s\n", url);
|
||||
return;
|
||||
}
|
||||
if (uri->fragment != NULL) {
|
||||
fragment = (xmlChar *) uri->fragment;
|
||||
uri->fragment = NULL;
|
||||
}
|
||||
URL = xmlSaveUri(uri);
|
||||
xmlFreeURI(uri);
|
||||
if (URL == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: invalid value URI %s\n", url);
|
||||
if (fragment != NULL)
|
||||
xmlFree(fragment);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handling of references to the local document are done
|
||||
* directly through ctxt->doc.
|
||||
*/
|
||||
if ((URL[0] == 0) || (URL[0] == '#')) {
|
||||
doc = NULL;
|
||||
goto loaded;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent reloading twice the document.
|
||||
*/
|
||||
for (i = 0; i < ctxt->docNr; i++) {
|
||||
if (xmlStrEqual(URL, ctxt->urlTab[i])) {
|
||||
doc = ctxt->docTab[i];
|
||||
goto loaded;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Load it.
|
||||
*/
|
||||
doc = xmlParseFile((const char *)URL);
|
||||
if (doc == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: could not load %s\n", URL);
|
||||
xmlFree(URL);
|
||||
if (fragment != NULL)
|
||||
xmlFree(fragment);
|
||||
return;
|
||||
}
|
||||
xmlXIncludeAddDoc(ctxt, doc, URL);
|
||||
|
||||
loaded:
|
||||
if (fragment == NULL) {
|
||||
/*
|
||||
* Add the top children list as the replacement copy.
|
||||
* ISSUE: seems we should scrap DTD info from the copied list.
|
||||
*/
|
||||
if (doc == NULL)
|
||||
ctxt->repTab[nr] = xmlCopyNodeList(ctxt->doc->children);
|
||||
else
|
||||
ctxt->repTab[nr] = xmlCopyNodeList(doc->children);
|
||||
} else {
|
||||
/*
|
||||
* Computes the XPointer expression and make a copy used
|
||||
* as the replacement copy.
|
||||
*/
|
||||
xmlXPathObjectPtr xptr;
|
||||
xmlXPathContextPtr xptrctxt;
|
||||
|
||||
if (doc == NULL) {
|
||||
xptrctxt = xmlXPtrNewContext(ctxt->doc, ctxt->incTab[nr], NULL);
|
||||
} else {
|
||||
xptrctxt = xmlXPtrNewContext(doc, NULL, NULL);
|
||||
}
|
||||
if (xptrctxt == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: could create XPointer context\n");
|
||||
xmlFree(URL);
|
||||
xmlFree(fragment);
|
||||
return;
|
||||
}
|
||||
xptr = xmlXPtrEval(fragment, xptrctxt);
|
||||
if (xptr == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: XPointer evaluation failed: #%s\n",
|
||||
fragment);
|
||||
xmlXPathFreeContext(xptrctxt);
|
||||
xmlFree(URL);
|
||||
xmlFree(fragment);
|
||||
return;
|
||||
}
|
||||
ctxt->repTab[nr] = xmlXPtrBuildNodeList(xptr);
|
||||
xmlXPathFreeObject(xptr);
|
||||
xmlXPathFreeContext(xptrctxt);
|
||||
xmlFree(fragment);
|
||||
}
|
||||
xmlFree(URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeLoadTxt:
|
||||
* @ctxt: the XInclude context
|
||||
* @url: the associated URL
|
||||
* @nr: the xinclude node number
|
||||
*
|
||||
* Load the content, and store the result in the XInclude context
|
||||
*/
|
||||
void
|
||||
xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
|
||||
xmlParserInputBufferPtr buf;
|
||||
xmlNodePtr node;
|
||||
xmlURIPtr uri;
|
||||
xmlChar *URL;
|
||||
int i;
|
||||
/*
|
||||
* Check the URL and remove any fragment identifier
|
||||
*/
|
||||
uri = xmlParseURI((const char *)url);
|
||||
if (uri == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: invalid value URI %s\n", url);
|
||||
return;
|
||||
}
|
||||
if (uri->fragment != NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: fragment identifier forbidden for text: %s\n",
|
||||
uri->fragment);
|
||||
xmlFreeURI(uri);
|
||||
return;
|
||||
}
|
||||
URL = xmlSaveUri(uri);
|
||||
xmlFreeURI(uri);
|
||||
if (URL == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: invalid value URI %s\n", url);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handling of references to the local document are done
|
||||
* directly through ctxt->doc.
|
||||
*/
|
||||
if (URL[0] == 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: text serialization of document not available\n");
|
||||
xmlFree(URL);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent reloading twice the document.
|
||||
*/
|
||||
for (i = 0; i < ctxt->txtNr; i++) {
|
||||
if (xmlStrEqual(URL, ctxt->txturlTab[i])) {
|
||||
node = xmlCopyNode(ctxt->txtTab[i], 1);
|
||||
goto loaded;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Load it.
|
||||
* Issue 62: how to detect the encoding
|
||||
*/
|
||||
buf = xmlParserInputBufferCreateFilename((const char *)URL, 0);
|
||||
if (buf == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: could not load %s\n", URL);
|
||||
xmlFree(URL);
|
||||
return;
|
||||
}
|
||||
node = xmlNewText(NULL);
|
||||
|
||||
/*
|
||||
* Scan all chars from the resource and add the to the node
|
||||
*/
|
||||
while (xmlParserInputBufferRead(buf, 128) > 0) {
|
||||
int len;
|
||||
const xmlChar *content;
|
||||
|
||||
content = xmlBufferContent(buf->buffer);
|
||||
len = xmlBufferLength(buf->buffer);
|
||||
for (i = 0;i < len; i++) {
|
||||
/*
|
||||
* TODO: if the encoding issue is solved, scan UTF8 chars instead
|
||||
*/
|
||||
if (!IS_CHAR(content[i])) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: %s contains invalid char %d\n", URL, content[i]);
|
||||
} else {
|
||||
xmlNodeAddContentLen(node, &content[i], 1);
|
||||
}
|
||||
}
|
||||
xmlBufferShrink(buf->buffer, len);
|
||||
}
|
||||
xmlFreeParserInputBuffer(buf);
|
||||
xmlXIncludeAddTxt(ctxt, node, URL);
|
||||
|
||||
loaded:
|
||||
/*
|
||||
* Add the element as the replacement copy.
|
||||
*/
|
||||
ctxt->repTab[nr] = node;
|
||||
xmlFree(URL);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* XInclude Processing *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xmlXIncludePreProcessNode:
|
||||
* @ctxt: an XInclude context
|
||||
* @node: an XInclude node
|
||||
*
|
||||
* Implement the infoset replacement lookup on the XML element @node
|
||||
*
|
||||
* Returns the result list or NULL in case of error
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
|
||||
xmlXIncludeAddNode(ctxt, node);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeLoadNode:
|
||||
* @ctxt: an XInclude context
|
||||
* @nr: the node number
|
||||
*
|
||||
* Find and load the infoset replacement for the given node.
|
||||
*
|
||||
* Returns 0 if substition succeeded, -1 if some processing failed
|
||||
*/
|
||||
int
|
||||
xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
||||
xmlNodePtr cur;
|
||||
xmlChar *href;
|
||||
xmlChar *parse;
|
||||
xmlChar *base;
|
||||
xmlChar *URI;
|
||||
int xml = 1; /* default Issue 64 */
|
||||
|
||||
if (ctxt == NULL)
|
||||
return(-1);
|
||||
if ((nr < 0) || (nr >= ctxt->incNr))
|
||||
return(-1);
|
||||
cur = ctxt->incTab[nr];
|
||||
if (cur == NULL)
|
||||
return(-1);
|
||||
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlDebugDumpNode(stdout, cur, 0);
|
||||
#endif
|
||||
/*
|
||||
* read the attributes
|
||||
*/
|
||||
href = xmlGetNsProp(cur, XINCLUDE_NS, XINCLUDE_HREF);
|
||||
if (href == NULL) {
|
||||
href = xmlGetProp(cur, XINCLUDE_HREF);
|
||||
if (href == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "XInclude: no href\n");
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
parse = xmlGetNsProp(cur, XINCLUDE_NS, XINCLUDE_PARSE);
|
||||
if (parse == NULL) {
|
||||
parse = xmlGetProp(cur, XINCLUDE_PARSE);
|
||||
}
|
||||
if (parse != NULL) {
|
||||
if (xmlStrEqual(parse, XINCLUDE_PARSE_XML))
|
||||
xml = 1;
|
||||
else if (xmlStrEqual(parse, XINCLUDE_PARSE_TEXT))
|
||||
xml = 0;
|
||||
else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: invalid value %s for %s\n",
|
||||
parse, XINCLUDE_PARSE);
|
||||
if (href != NULL)
|
||||
xmlFree(href);
|
||||
if (parse != NULL)
|
||||
xmlFree(parse);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* compute the URI
|
||||
*/
|
||||
base = xmlNodeGetBase(ctxt->doc, cur);
|
||||
if (base == NULL) {
|
||||
URI = xmlBuildURI(href, ctxt->doc->URL);
|
||||
} else {
|
||||
URI = xmlBuildURI(href, base);
|
||||
}
|
||||
if (URI == NULL) {
|
||||
xmlChar *escbase;
|
||||
xmlChar *eschref;
|
||||
/*
|
||||
* Some escapeing may be needed
|
||||
*/
|
||||
escbase = xmlURIEscape(base);
|
||||
eschref = xmlURIEscape(href);
|
||||
URI = xmlBuildURI(eschref, escbase);
|
||||
if (escbase != NULL)
|
||||
xmlFree(escbase);
|
||||
if (eschref != NULL)
|
||||
xmlFree(eschref);
|
||||
}
|
||||
if (URI == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "XInclude: failed build URL\n");
|
||||
if (parse != NULL)
|
||||
xmlFree(parse);
|
||||
if (href != NULL)
|
||||
xmlFree(href);
|
||||
if (base != NULL)
|
||||
xmlFree(base);
|
||||
return(-1);
|
||||
}
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
xmlGenericError(xmlGenericErrorContext, "parse: %s\n",
|
||||
xml ? "xml": "text");
|
||||
xmlGenericError(xmlGenericErrorContext, "URI: %s\n", URI);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
*/
|
||||
if (xml) {
|
||||
xmlXIncludeLoadDoc(ctxt, URI, nr);
|
||||
/* xmlXIncludeGetFragment(ctxt, cur, URI); */
|
||||
} else {
|
||||
xmlXIncludeLoadTxt(ctxt, URI, nr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
*/
|
||||
if (URI != NULL)
|
||||
xmlFree(URI);
|
||||
if (parse != NULL)
|
||||
xmlFree(parse);
|
||||
if (href != NULL)
|
||||
xmlFree(href);
|
||||
if (base != NULL)
|
||||
xmlFree(base);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeIncludeNode:
|
||||
* @ctxt: an XInclude context
|
||||
* @nr: the node number
|
||||
*
|
||||
* Inplement the infoset replacement for the given node
|
||||
*
|
||||
* Returns 0 if substition succeeded, -1 if some processing failed
|
||||
*/
|
||||
int
|
||||
xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
||||
xmlNodePtr cur, end, list;
|
||||
|
||||
if (ctxt == NULL)
|
||||
return(-1);
|
||||
if ((nr < 0) || (nr >= ctxt->incNr))
|
||||
return(-1);
|
||||
cur = ctxt->incTab[nr];
|
||||
if (cur == NULL)
|
||||
return(-1);
|
||||
|
||||
/*
|
||||
* Change the current node as an XInclude start one, and add an
|
||||
* entity end one
|
||||
*/
|
||||
cur->type = XML_XINCLUDE_START;
|
||||
end = xmlNewNode(cur->ns, cur->name);
|
||||
if (end == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: failed to build node\n");
|
||||
return(-1);
|
||||
}
|
||||
end->type = XML_XINCLUDE_END;
|
||||
xmlAddNextSibling(cur, end);
|
||||
|
||||
/*
|
||||
* Add the list of nodes
|
||||
*/
|
||||
list = ctxt->repTab[nr];
|
||||
ctxt->repTab[nr] = NULL;
|
||||
while (list != NULL) {
|
||||
cur = list;
|
||||
list = list->next;
|
||||
|
||||
xmlAddPrevSibling(end, cur);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeTestNode:
|
||||
* @doc: an XML document
|
||||
* @node: an XInclude node
|
||||
*
|
||||
* test if the node is an XInclude node
|
||||
*
|
||||
* Returns 1 true, 0 otherwise
|
||||
*/
|
||||
int
|
||||
xmlXIncludeTestNode(xmlDocPtr doc, xmlNodePtr node) {
|
||||
if (node == NULL)
|
||||
return(0);
|
||||
if (node->ns == NULL)
|
||||
return(0);
|
||||
if ((xmlStrEqual(node->name, XINCLUDE_NODE)) &&
|
||||
(xmlStrEqual(node->ns->href, XINCLUDE_NS))) return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXIncludeProcess:
|
||||
* @doc: an XML document
|
||||
*
|
||||
* Implement the XInclude substitution on the XML document @doc
|
||||
*
|
||||
* Returns 0 if no substition were done, -1 if some processing failed
|
||||
* or the number of substitutions done.
|
||||
*/
|
||||
int
|
||||
xmlXIncludeProcess(xmlDocPtr doc) {
|
||||
xmlXIncludeCtxtPtr ctxt;
|
||||
xmlNodePtr cur;
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
if (doc == NULL)
|
||||
return(-1);
|
||||
ctxt = xmlXIncludeNewContext(doc);
|
||||
if (ctxt == NULL)
|
||||
return(-1);
|
||||
|
||||
/*
|
||||
* First phase: lookup the elements in the document
|
||||
*/
|
||||
cur = xmlDocGetRootElement(doc);
|
||||
if (xmlXIncludeTestNode(doc, cur))
|
||||
xmlXIncludePreProcessNode(ctxt, cur);
|
||||
while (cur != NULL) {
|
||||
/* TODO: need to work on entities -> stack */
|
||||
if ((cur->children != NULL) &&
|
||||
(cur->children->type != XML_ENTITY_DECL)) {
|
||||
cur = cur->children;
|
||||
if (xmlXIncludeTestNode(doc, cur))
|
||||
xmlXIncludePreProcessNode(ctxt, cur);
|
||||
} else if (cur->next != NULL) {
|
||||
cur = cur->next;
|
||||
if (xmlXIncludeTestNode(doc, cur))
|
||||
xmlXIncludePreProcessNode(ctxt, cur);
|
||||
} else {
|
||||
do {
|
||||
cur = cur->parent;
|
||||
if (cur == NULL) break; /* do */
|
||||
if (cur->next != NULL) {
|
||||
cur = cur->next;
|
||||
if (xmlXIncludeTestNode(doc, cur))
|
||||
xmlXIncludePreProcessNode(ctxt, cur);
|
||||
break; /* do */
|
||||
}
|
||||
} while (cur != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Second Phase : collect the infosets fragments
|
||||
*/
|
||||
for (i = 0;i < ctxt->incNr; i++) {
|
||||
xmlXIncludeLoadNode(ctxt, i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Third phase: extend the original document infoset.
|
||||
*/
|
||||
for (i = 0;i < ctxt->incNr; i++) {
|
||||
xmlXIncludeIncludeNode(ctxt, i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup
|
||||
*/
|
||||
xmlXIncludeFreeContext(ctxt);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#else /* !LIBXML_XINCLUDE_ENABLED */
|
||||
#endif
|
26
xinclude.h
Normal file
26
xinclude.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* xinclude.c : API to handle XInclude processing
|
||||
*
|
||||
* World Wide Web Consortium Working Draft 26 October 2000
|
||||
* http://www.w3.org/TR/2000/WD-xinclude-20001026
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XINCLUDE_H__
|
||||
#define __XML_XINCLUDE_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int xmlXIncludeProcess (xmlDocPtr doc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_XINCLUDE_H__ */
|
187
xlink.c
Normal file
187
xlink.c
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* xlink.c : implementation of the hyperlinks detection module
|
||||
* This version supports both XML XLinks and HTML simple links
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32config.h"
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h> /* for memset() only */
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/xlink.h>
|
||||
|
||||
#define XLINK_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xlink/namespace/")
|
||||
#define XHTML_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xhtml/")
|
||||
|
||||
/****************************************************************
|
||||
* *
|
||||
* Default setting and related functions *
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
xlinkHandlerPtr xlinkDefaultHandler = NULL;
|
||||
xlinkNodeDetectFunc xlinkDefaultDetect = NULL;
|
||||
|
||||
/**
|
||||
* xlinkGetDefaultHandler:
|
||||
*
|
||||
* Get the default xlink handler.
|
||||
*
|
||||
* Returns the current xlinkHandlerPtr value.
|
||||
*/
|
||||
xlinkHandlerPtr
|
||||
xlinkGetDefaultHandler(void) {
|
||||
return(xlinkDefaultHandler);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xlinkSetDefaultHandler:
|
||||
* @handler: the new value for the xlink handler block
|
||||
*
|
||||
* Set the default xlink handlers
|
||||
*/
|
||||
void
|
||||
xlinkSetDefaultHandler(xlinkHandlerPtr handler) {
|
||||
xlinkDefaultHandler = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* xlinkGetDefaultDetect:
|
||||
*
|
||||
* Get the default xlink detection routine
|
||||
*
|
||||
* Returns the current function or NULL;
|
||||
*/
|
||||
xlinkNodeDetectFunc
|
||||
xlinkGetDefaultDetect (void) {
|
||||
return(xlinkDefaultDetect);
|
||||
}
|
||||
|
||||
/**
|
||||
* xlinkSetDefaultDetect:
|
||||
* @func: pointer to the new detction routine.
|
||||
*
|
||||
* Set the default xlink detection routine
|
||||
*/
|
||||
void
|
||||
xlinkSetDefaultDetect (xlinkNodeDetectFunc func) {
|
||||
xlinkDefaultDetect = func;
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* *
|
||||
* The detection routines *
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* xlinkIsLink:
|
||||
* @doc: the document containing the node
|
||||
* @node: the node pointer itself
|
||||
*
|
||||
* Check whether the given node carries the attributes needed
|
||||
* to be a link element (or is one of the linking elements issued
|
||||
* from the (X)HTML DtDs).
|
||||
* This routine don't try to do full checking of the link validity
|
||||
* but tries to detect and return the appropriate link type.
|
||||
*
|
||||
* Returns the xlinkType of the node (XLINK_TYPE_NONE if there is no
|
||||
* link detected.
|
||||
*/
|
||||
xlinkType
|
||||
xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) {
|
||||
xmlChar *type = NULL, *role = NULL;
|
||||
xlinkType ret = XLINK_TYPE_NONE;
|
||||
|
||||
if (node == NULL) return(XLINK_TYPE_NONE);
|
||||
if (doc == NULL) doc = node->doc;
|
||||
if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {
|
||||
/*
|
||||
* This is an HTML document.
|
||||
*/
|
||||
} else if ((node->ns != NULL) &&
|
||||
(xmlStrEqual(node->ns->href, XHTML_NAMESPACE))) {
|
||||
/*
|
||||
* !!!! We really need an IS_XHTML_ELEMENT function from HTMLtree.h @@@
|
||||
*/
|
||||
/*
|
||||
* This is an XHTML element within an XML document
|
||||
* Check whether it's one of the element able to carry links
|
||||
* and in that case if it holds the attributes.
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't prevent a-priori having XML Linking constructs on
|
||||
* XHTML elements
|
||||
*/
|
||||
type = xmlGetNsProp(node, BAD_CAST"type", XLINK_NAMESPACE);
|
||||
if (type != NULL) {
|
||||
if (!xmlStrEqual(type, BAD_CAST "simple")) {
|
||||
ret = XLINK_TYPE_SIMPLE;
|
||||
} if (!xmlStrEqual(type, BAD_CAST "extended")) {
|
||||
role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE);
|
||||
if (role != NULL) {
|
||||
xmlNsPtr xlink;
|
||||
xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE);
|
||||
if (xlink == NULL) {
|
||||
/* Humm, fallback method */
|
||||
if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset"))
|
||||
ret = XLINK_TYPE_EXTENDED_SET;
|
||||
} else {
|
||||
xmlChar buf[200];
|
||||
#ifdef HAVE_SNPRINTF
|
||||
snprintf((char *) buf, sizeof(buf), "%s:external-linkset",
|
||||
(char *) xlink->prefix);
|
||||
#else
|
||||
sprintf((char *) buf, "%s:external-linkset",
|
||||
(char *) xlink->prefix);
|
||||
#endif
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
if (xmlStrEqual(role, buf))
|
||||
ret = XLINK_TYPE_EXTENDED_SET;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
ret = XLINK_TYPE_EXTENDED;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != NULL) xmlFree(type);
|
||||
if (role != NULL) xmlFree(role);
|
||||
return(ret);
|
||||
}
|
182
xlink.h
Normal file
182
xlink.h
Normal file
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* xlink.h : interfaces to the hyperlinks detection module
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Related specification: http://www.w3.org/TR/xlink
|
||||
* http://www.w3.org/HTML/
|
||||
* and XBase
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XLINK_H__
|
||||
#define __XML_XLINK_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* Various defines for the various Link properties.
|
||||
*
|
||||
* NOTE: the link detection layer will try to resolve QName expansion
|
||||
* of namespaces, if "foo" is the prefix for "http://foo.com/"
|
||||
* then the link detection layer will expand role="foo:myrole"
|
||||
* to "http://foo.com/:myrole"
|
||||
* NOTE: the link detection layer will expand URI-Refences found on
|
||||
* href attributes by using the base mechanism if found.
|
||||
*/
|
||||
typedef xmlChar *xlinkHRef;
|
||||
typedef xmlChar *xlinkRole;
|
||||
typedef xmlChar *xlinkTitle;
|
||||
|
||||
typedef enum {
|
||||
XLINK_TYPE_NONE = 0,
|
||||
XLINK_TYPE_SIMPLE,
|
||||
XLINK_TYPE_EXTENDED,
|
||||
XLINK_TYPE_EXTENDED_SET
|
||||
} xlinkType;
|
||||
|
||||
typedef enum {
|
||||
XLINK_SHOW_NONE = 0,
|
||||
XLINK_SHOW_NEW,
|
||||
XLINK_SHOW_EMBED,
|
||||
XLINK_SHOW_REPLACE
|
||||
} xlinkShow;
|
||||
|
||||
typedef enum {
|
||||
XLINK_ACTUATE_NONE = 0,
|
||||
XLINK_ACTUATE_AUTO,
|
||||
XLINK_ACTUATE_ONREQUEST
|
||||
} xlinkActuate;
|
||||
|
||||
/**
|
||||
* xlinkNodeDetectFunc:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node to check
|
||||
*
|
||||
* This is the prototype for the link detection routine
|
||||
* It calls the default link detection callbacks upon link detection.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkNodeDetectFunc) (void *ctx,
|
||||
xmlNodePtr node);
|
||||
|
||||
/**
|
||||
* The link detection module interract with the upper layers using
|
||||
* a set of callback registered at parsing time.
|
||||
*/
|
||||
|
||||
/**
|
||||
* xlinkSimpleLinkFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @href: the target of the link
|
||||
* @role: the role string
|
||||
* @title: the link title
|
||||
*
|
||||
* This is the prototype for a simple link detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkSimpleLinkFunk) (void *ctx,
|
||||
xmlNodePtr node,
|
||||
const xlinkHRef href,
|
||||
const xlinkRole role,
|
||||
const xlinkTitle title);
|
||||
|
||||
/**
|
||||
* xlinkExtendedLinkFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @nbLocators: the number of locators detected on the link
|
||||
* @hrefs: pointer to the array of locator hrefs
|
||||
* @roles: pointer to the array of locator roles
|
||||
* @nbArcs: the number of arcs detected on the link
|
||||
* @from: pointer to the array of source roles found on the arcs
|
||||
* @to: pointer to the array of target roles found on the arcs
|
||||
* @show: array of values for the show attributes found on the arcs
|
||||
* @actuate: array of values for the actuate attributes found on the arcs
|
||||
* @nbTitles: the number of titles detected on the link
|
||||
* @title: array of titles detected on the link
|
||||
* @langs: array of xml:lang values for the titles
|
||||
*
|
||||
* This is the prototype for a extended link detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkExtendedLinkFunk)(void *ctx,
|
||||
xmlNodePtr node,
|
||||
int nbLocators,
|
||||
const xlinkHRef *hrefs,
|
||||
const xlinkRole *roles,
|
||||
int nbArcs,
|
||||
const xlinkRole *from,
|
||||
const xlinkRole *to,
|
||||
xlinkShow *show,
|
||||
xlinkActuate *actuate,
|
||||
int nbTitles,
|
||||
const xlinkTitle *titles,
|
||||
const xmlChar **langs);
|
||||
|
||||
/**
|
||||
* xlinkExtendedLinkSetFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @nbLocators: the number of locators detected on the link
|
||||
* @hrefs: pointer to the array of locator hrefs
|
||||
* @roles: pointer to the array of locator roles
|
||||
* @nbTitles: the number of titles detected on the link
|
||||
* @title: array of titles detected on the link
|
||||
* @langs: array of xml:lang values for the titles
|
||||
*
|
||||
* This is the prototype for a extended link set detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkExtendedLinkSetFunk) (void *ctx,
|
||||
xmlNodePtr node,
|
||||
int nbLocators,
|
||||
const xlinkHRef *hrefs,
|
||||
const xlinkRole *roles,
|
||||
int nbTitles,
|
||||
const xlinkTitle *titles,
|
||||
const xmlChar **langs);
|
||||
|
||||
/**
|
||||
* This is the structure containing a set of Links detection callbacks
|
||||
*
|
||||
* There is no default xlink callbacks, if one want to get link
|
||||
* recognition activated, those call backs must be provided before parsing.
|
||||
*/
|
||||
typedef struct _xlinkHandler xlinkHandler;
|
||||
typedef xlinkHandler *xlinkHandlerPtr;
|
||||
struct _xlinkHandler {
|
||||
xlinkSimpleLinkFunk simple;
|
||||
xlinkExtendedLinkFunk extended;
|
||||
xlinkExtendedLinkSetFunk set;
|
||||
};
|
||||
|
||||
/**
|
||||
* the default detection routine, can be overriden, they call the default
|
||||
* detection callbacks.
|
||||
*/
|
||||
|
||||
xlinkNodeDetectFunc xlinkGetDefaultDetect (void);
|
||||
void xlinkSetDefaultDetect (xlinkNodeDetectFunc func);
|
||||
|
||||
/**
|
||||
* Routines to set/get the default handlers.
|
||||
*/
|
||||
xlinkHandlerPtr xlinkGetDefaultHandler (void);
|
||||
void xlinkSetDefaultHandler (xlinkHandlerPtr handler);
|
||||
|
||||
/*
|
||||
* Link detection module itself.
|
||||
*/
|
||||
xlinkType xlinkIsLink (xmlDocPtr doc,
|
||||
xmlNodePtr node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_XLINK_H__ */
|
31
xml2-config.1
Normal file
31
xml2-config.1
Normal file
@ -0,0 +1,31 @@
|
||||
.TH GNOME-XML 1 "3 July 1999" Version 1.1.0
|
||||
.SH NAME
|
||||
xml-config - script to get information about the installed version of GNOME-XML
|
||||
.SH SYNOPSIS
|
||||
.B xml-config
|
||||
[\-\-prefix\fI[=DIR]\fP] [\-\-libs] [\-\-cflags] [\-\-version] [\-\-help]
|
||||
.SH DESCRIPTION
|
||||
\fIxml-config\fP is a tool that is used to determine the compile and
|
||||
linker flags that should be used to compile and link programs that use
|
||||
\fIGNOME-XML\fP.
|
||||
.SH OPTIONS
|
||||
.l
|
||||
\fIxml-config\fP accepts the following options:
|
||||
.TP 8
|
||||
.B \-\-version
|
||||
Print the currently installed version of \fIGNOME-XML\fP on the standard output.
|
||||
.TP 8
|
||||
.B \-\-libs
|
||||
Print the linker flags that are necessary to link a \fIGNOME-XML\fP program.
|
||||
.TP 8
|
||||
.B \-\-cflags
|
||||
Print the compiler flags that are necessary to compile a \fIGNOME-XML\fP program.
|
||||
.TP 8
|
||||
.B \-\-prefix=PREFIX
|
||||
If specified, use PREFIX instead of the installation prefix that
|
||||
\fIGNOME-XML\fP was built with when computing the output for the
|
||||
\-\-cflags and \-\-libs options. This option must be specified before
|
||||
any \-\-libs or \-\-cflags options.
|
||||
.SH AUTHOR
|
||||
This manual page was written by Fredrik Hallenberg <hallon@lysator.liu.se>,
|
||||
for the Debian GNU/linux system (but may be used by others).
|
72
xml2-config.in
Normal file
72
xml2-config.in
Normal file
@ -0,0 +1,72 @@
|
||||
#! /bin/sh
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
includedir=@includedir@
|
||||
libdir=@libdir@
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: xml-config [OPTION]
|
||||
|
||||
Known values for OPTION are:
|
||||
|
||||
--prefix=DIR change libxml prefix [default $prefix]
|
||||
--libs print library linking information
|
||||
--cflags print pre-processor and compiler flags
|
||||
--help display this help and exit
|
||||
--version output version information
|
||||
EOF
|
||||
|
||||
exit $1
|
||||
}
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage 1
|
||||
fi
|
||||
|
||||
cflags=false
|
||||
libs=false
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
*) optarg= ;;
|
||||
esac
|
||||
|
||||
case "$1" in
|
||||
--prefix=*)
|
||||
prefix=$optarg
|
||||
;;
|
||||
|
||||
--prefix)
|
||||
echo $prefix
|
||||
;;
|
||||
|
||||
--version)
|
||||
echo @VERSION@
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--help)
|
||||
usage 0
|
||||
;;
|
||||
|
||||
--cflags)
|
||||
echo @XML_INCLUDEDIR@ @XML_CFLAGS@
|
||||
;;
|
||||
|
||||
--libs)
|
||||
echo @XML_LIBDIR@ @XML_LIBS@
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exit 0
|
8
xml2Conf.sh.in
Normal file
8
xml2Conf.sh.in
Normal file
@ -0,0 +1,8 @@
|
||||
#
|
||||
# Configuration file for using the XML library in GNOME applications
|
||||
#
|
||||
XML_LIBDIR="@XML_LIBDIR@"
|
||||
XML_LIBS="@XML_LIBS@"
|
||||
XML_INCLUDEDIR="@XML_INCLUDEDIR@"
|
||||
MODULE_VERSION="xml-@VERSION@"
|
||||
|
178
xmlIO.h
Normal file
178
xmlIO.h
Normal file
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* xmlIO.h : interface for the I/O interfaces used by the parser
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*
|
||||
* 15 Nov 2000 ht - modified for VMS
|
||||
*/
|
||||
|
||||
#ifndef __XML_IO_H__
|
||||
#define __XML_IO_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/encoding.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Those are the functions and datatypes for the parser input
|
||||
* I/O structures.
|
||||
*/
|
||||
|
||||
typedef int (*xmlInputMatchCallback) (char const *filename);
|
||||
typedef void * (*xmlInputOpenCallback) (char const *filename);
|
||||
typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
|
||||
typedef void (*xmlInputCloseCallback) (void * context);
|
||||
|
||||
typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
|
||||
typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
|
||||
struct _xmlParserInputBuffer {
|
||||
void* context;
|
||||
xmlInputReadCallback readcallback;
|
||||
xmlInputCloseCallback closecallback;
|
||||
|
||||
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
||||
|
||||
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
|
||||
xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Those are the functions and datatypes for the library output
|
||||
* I/O structures.
|
||||
*/
|
||||
|
||||
typedef int (*xmlOutputMatchCallback) (char const *filename);
|
||||
typedef void * (*xmlOutputOpenCallback) (char const *filename);
|
||||
typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
|
||||
int len);
|
||||
typedef void (*xmlOutputCloseCallback) (void * context);
|
||||
|
||||
typedef struct _xmlOutputBuffer xmlOutputBuffer;
|
||||
typedef xmlOutputBuffer *xmlOutputBufferPtr;
|
||||
struct _xmlOutputBuffer {
|
||||
void* context;
|
||||
xmlOutputWriteCallback writecallback;
|
||||
xmlOutputCloseCallback closecallback;
|
||||
|
||||
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
||||
|
||||
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
|
||||
xmlBufferPtr conv; /* if encoder != NULL buffer for output */
|
||||
int written; /* total number of byte written */
|
||||
};
|
||||
|
||||
/*
|
||||
* Interfaces for input
|
||||
*/
|
||||
|
||||
void xmlRegisterDefaultInputCallbacks (void);
|
||||
xmlParserInputBufferPtr
|
||||
xmlAllocParserInputBuffer (xmlCharEncoding enc);
|
||||
|
||||
#ifdef VMS
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFname (const char *URI,
|
||||
xmlCharEncoding enc);
|
||||
#define xmlParserInputBufferCreateFilename xmlParserInputBufferCreateFname
|
||||
#else
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFilename (const char *URI,
|
||||
xmlCharEncoding enc);
|
||||
#endif
|
||||
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFile (FILE *file,
|
||||
xmlCharEncoding enc);
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFd (int fd,
|
||||
xmlCharEncoding enc);
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateMem (const char *mem, int size,
|
||||
xmlCharEncoding enc);
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
|
||||
int len);
|
||||
int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
|
||||
int len);
|
||||
int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
|
||||
int len,
|
||||
const char *buf);
|
||||
void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
|
||||
char * xmlParserGetDirectory (const char *filename);
|
||||
|
||||
int xmlRegisterInputCallbacks (xmlInputMatchCallback match,
|
||||
xmlInputOpenCallback open,
|
||||
xmlInputReadCallback read,
|
||||
xmlInputCloseCallback close);
|
||||
/*
|
||||
* Interfaces for output
|
||||
*/
|
||||
void xmlRegisterDefaultOutputCallbacks(void);
|
||||
xmlOutputBufferPtr
|
||||
xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
xmlOutputBufferCreateFilename (const char *URI,
|
||||
xmlCharEncodingHandlerPtr encoder,
|
||||
int compression);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
xmlOutputBufferCreateFile (FILE *file,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
xmlOutputBufferCreateFd (int fd,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
|
||||
xmlOutputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
int xmlOutputBufferWrite (xmlOutputBufferPtr out,
|
||||
int len,
|
||||
const char *buf);
|
||||
int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
|
||||
const char *str);
|
||||
|
||||
int xmlOutputBufferFlush (xmlOutputBufferPtr out);
|
||||
int xmlOutputBufferClose (xmlOutputBufferPtr out);
|
||||
|
||||
int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match,
|
||||
xmlOutputOpenCallback open,
|
||||
xmlOutputWriteCallback write,
|
||||
xmlOutputCloseCallback close);
|
||||
|
||||
/*
|
||||
* This save function are part of tree.h and HTMLtree.h actually
|
||||
*/
|
||||
int xmlSaveFileTo (xmlOutputBuffer *buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
void xmlNodeDumpOutput (xmlOutputBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
int level,
|
||||
int format,
|
||||
const char *encoding);
|
||||
void htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_IO_H__ */
|
180
xmlerror.h
Normal file
180
xmlerror.h
Normal file
@ -0,0 +1,180 @@
|
||||
#ifndef __XML_ERROR_H__
|
||||
#define __XML_ERROR_H__
|
||||
|
||||
#include <libxml/parser.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
XML_ERR_OK = 0,
|
||||
XML_ERR_INTERNAL_ERROR,
|
||||
XML_ERR_NO_MEMORY,
|
||||
|
||||
XML_ERR_DOCUMENT_START, /* 3 */
|
||||
XML_ERR_DOCUMENT_EMPTY,
|
||||
XML_ERR_DOCUMENT_END,
|
||||
|
||||
XML_ERR_INVALID_HEX_CHARREF, /* 6 */
|
||||
XML_ERR_INVALID_DEC_CHARREF,
|
||||
XML_ERR_INVALID_CHARREF,
|
||||
XML_ERR_INVALID_CHAR,
|
||||
|
||||
XML_ERR_CHARREF_AT_EOF, /* 10 */
|
||||
XML_ERR_CHARREF_IN_PROLOG,
|
||||
XML_ERR_CHARREF_IN_EPILOG,
|
||||
XML_ERR_CHARREF_IN_DTD,
|
||||
XML_ERR_ENTITYREF_AT_EOF,
|
||||
XML_ERR_ENTITYREF_IN_PROLOG,
|
||||
XML_ERR_ENTITYREF_IN_EPILOG,
|
||||
XML_ERR_ENTITYREF_IN_DTD,
|
||||
XML_ERR_PEREF_AT_EOF,
|
||||
XML_ERR_PEREF_IN_PROLOG,
|
||||
XML_ERR_PEREF_IN_EPILOG,
|
||||
XML_ERR_PEREF_IN_INT_SUBSET,
|
||||
|
||||
XML_ERR_ENTITYREF_NO_NAME, /* 22 */
|
||||
XML_ERR_ENTITYREF_SEMICOL_MISSING,
|
||||
|
||||
XML_ERR_PEREF_NO_NAME, /* 24 */
|
||||
XML_ERR_PEREF_SEMICOL_MISSING,
|
||||
|
||||
XML_ERR_UNDECLARED_ENTITY, /* 26 */
|
||||
XML_WAR_UNDECLARED_ENTITY,
|
||||
XML_ERR_UNPARSED_ENTITY,
|
||||
XML_ERR_ENTITY_IS_EXTERNAL,
|
||||
XML_ERR_ENTITY_IS_PARAMETER,
|
||||
|
||||
XML_ERR_UNKNOWN_ENCODING, /* 31 */
|
||||
XML_ERR_UNSUPPORTED_ENCODING,
|
||||
|
||||
XML_ERR_STRING_NOT_STARTED, /* 33 */
|
||||
XML_ERR_STRING_NOT_CLOSED,
|
||||
XML_ERR_NS_DECL_ERROR,
|
||||
|
||||
XML_ERR_ENTITY_NOT_STARTED, /* 36 */
|
||||
XML_ERR_ENTITY_NOT_FINISHED,
|
||||
|
||||
XML_ERR_LT_IN_ATTRIBUTE, /* 38 */
|
||||
XML_ERR_ATTRIBUTE_NOT_STARTED,
|
||||
XML_ERR_ATTRIBUTE_NOT_FINISHED,
|
||||
XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
|
||||
XML_ERR_ATTRIBUTE_REDEFINED,
|
||||
|
||||
XML_ERR_LITERAL_NOT_STARTED, /* 43 */
|
||||
XML_ERR_LITERAL_NOT_FINISHED,
|
||||
|
||||
XML_ERR_COMMENT_NOT_FINISHED, /* 45 */
|
||||
|
||||
XML_ERR_PI_NOT_STARTED, /* 47 */
|
||||
XML_ERR_PI_NOT_FINISHED,
|
||||
|
||||
XML_ERR_NOTATION_NOT_STARTED, /* 49 */
|
||||
XML_ERR_NOTATION_NOT_FINISHED,
|
||||
|
||||
XML_ERR_ATTLIST_NOT_STARTED, /* 51 */
|
||||
XML_ERR_ATTLIST_NOT_FINISHED,
|
||||
|
||||
XML_ERR_MIXED_NOT_STARTED, /* 53 */
|
||||
XML_ERR_MIXED_NOT_FINISHED,
|
||||
|
||||
XML_ERR_ELEMCONTENT_NOT_STARTED, /* 55 */
|
||||
XML_ERR_ELEMCONTENT_NOT_FINISHED,
|
||||
|
||||
XML_ERR_XMLDECL_NOT_STARTED, /* 57 */
|
||||
XML_ERR_XMLDECL_NOT_FINISHED,
|
||||
|
||||
XML_ERR_CONDSEC_NOT_STARTED, /* 59 */
|
||||
XML_ERR_CONDSEC_NOT_FINISHED,
|
||||
|
||||
XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 61 */
|
||||
|
||||
XML_ERR_DOCTYPE_NOT_FINISHED, /* 62 */
|
||||
|
||||
XML_ERR_MISPLACED_CDATA_END, /* 63 */
|
||||
XML_ERR_CDATA_NOT_FINISHED,
|
||||
|
||||
XML_ERR_RESERVED_XML_NAME, /* 65 */
|
||||
|
||||
XML_ERR_SPACE_REQUIRED, /* 66 */
|
||||
XML_ERR_SEPARATOR_REQUIRED,
|
||||
XML_ERR_NMTOKEN_REQUIRED,
|
||||
XML_ERR_NAME_REQUIRED,
|
||||
XML_ERR_PCDATA_REQUIRED,
|
||||
XML_ERR_URI_REQUIRED,
|
||||
XML_ERR_PUBID_REQUIRED,
|
||||
XML_ERR_LT_REQUIRED,
|
||||
XML_ERR_GT_REQUIRED,
|
||||
XML_ERR_LTSLASH_REQUIRED,
|
||||
XML_ERR_EQUAL_REQUIRED,
|
||||
|
||||
XML_ERR_TAG_NAME_MISMATCH, /* 77 */
|
||||
XML_ERR_TAG_NOT_FINISED,
|
||||
|
||||
XML_ERR_STANDALONE_VALUE, /* 79 */
|
||||
|
||||
XML_ERR_ENCODING_NAME, /* 80 */
|
||||
|
||||
XML_ERR_HYPHEN_IN_COMMENT, /* 81 */
|
||||
|
||||
XML_ERR_INVALID_ENCODING, /* 82 */
|
||||
|
||||
XML_ERR_EXT_ENTITY_STANDALONE, /* 83 */
|
||||
|
||||
XML_ERR_CONDSEC_INVALID, /* 84 */
|
||||
|
||||
XML_ERR_VALUE_REQUIRED, /* 85 */
|
||||
|
||||
XML_ERR_NOT_WELL_BALANCED, /* 86 */
|
||||
XML_ERR_EXTRA_CONTENT, /* 87 */
|
||||
XML_ERR_ENTITY_CHAR_ERROR, /* 88 */
|
||||
XML_ERR_ENTITY_PE_INTERNAL, /* 88 */
|
||||
XML_ERR_ENTITY_LOOP, /* 89 */
|
||||
XML_ERR_ENTITY_BOUNDARY, /* 90 */
|
||||
XML_ERR_INVALID_URI, /* 91 */
|
||||
XML_ERR_URI_FRAGMENT /* 92 */
|
||||
}xmlParserErrors;
|
||||
|
||||
/*
|
||||
* Signature of the function to use when there is an error and
|
||||
* no parsing or validity context available
|
||||
*/
|
||||
typedef void (*xmlGenericErrorFunc) (void *ctx, const char *msg, ...);
|
||||
|
||||
/*
|
||||
* Those are the default error function and associated context to use
|
||||
* when when there is an error and no parsing or validity context available
|
||||
*/
|
||||
|
||||
LIBXML_DLL_IMPORT extern xmlGenericErrorFunc xmlGenericError;
|
||||
LIBXML_DLL_IMPORT extern void *xmlGenericErrorContext;
|
||||
|
||||
/*
|
||||
* Use the following function to reset the two previous global variables.
|
||||
*/
|
||||
void xmlSetGenericErrorFunc (void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
|
||||
/*
|
||||
* Default message routines used by SAX and Valid context for error
|
||||
* and warning reporting
|
||||
*/
|
||||
void xmlParserError (void *ctx,
|
||||
const char *msg,
|
||||
...);
|
||||
void xmlParserWarning (void *ctx,
|
||||
const char *msg,
|
||||
...);
|
||||
void xmlParserValidityError (void *ctx,
|
||||
const char *msg,
|
||||
...);
|
||||
void xmlParserValidityWarning(void *ctx,
|
||||
const char *msg,
|
||||
...);
|
||||
void xmlParserPrintFileInfo (xmlParserInputPtr input);
|
||||
void xmlParserPrintFileContext(xmlParserInputPtr input);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_ERROR_H__ */
|
707
xmlmemory.c
Normal file
707
xmlmemory.c
Normal file
@ -0,0 +1,707 @@
|
||||
/*
|
||||
* memory.c: libxml memory allocator wrapper.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32config.h"
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
|
||||
#ifdef xmlMalloc
|
||||
#undef xmlMalloc
|
||||
#endif
|
||||
#ifdef xmlRealloc
|
||||
#undef xmlRealloc
|
||||
#endif
|
||||
#ifdef xmlMemStrdup
|
||||
#undef xmlMemStrdup
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Each of the blocks allocated begin with a header containing informations
|
||||
*/
|
||||
|
||||
#define MEMTAG 0x5aa5
|
||||
|
||||
#define MALLOC_TYPE 1
|
||||
#define REALLOC_TYPE 2
|
||||
#define STRDUP_TYPE 3
|
||||
|
||||
typedef struct memnod {
|
||||
unsigned int mh_tag;
|
||||
unsigned int mh_type;
|
||||
unsigned long mh_number;
|
||||
size_t mh_size;
|
||||
#ifdef MEM_LIST
|
||||
struct memnod *mh_next;
|
||||
struct memnod *mh_prev;
|
||||
#endif
|
||||
const char *mh_file;
|
||||
unsigned int mh_line;
|
||||
} MEMHDR;
|
||||
|
||||
|
||||
#ifdef SUN4
|
||||
#define ALIGN_SIZE 16
|
||||
#else
|
||||
#define ALIGN_SIZE sizeof(double)
|
||||
#endif
|
||||
#define HDR_SIZE sizeof(MEMHDR)
|
||||
#define RESERVE_SIZE (((HDR_SIZE + (ALIGN_SIZE-1)) \
|
||||
/ ALIGN_SIZE ) * ALIGN_SIZE)
|
||||
|
||||
|
||||
#define CLIENT_2_HDR(a) ((MEMHDR *) (((char *) (a)) - RESERVE_SIZE))
|
||||
#define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE))
|
||||
|
||||
|
||||
static unsigned long debugMemSize = 0;
|
||||
static unsigned long debugMaxMemSize = 0;
|
||||
static int block=0;
|
||||
int xmlMemStopAtBlock = 0;
|
||||
int xmlMemInitialized = 0;
|
||||
#ifdef MEM_LIST
|
||||
static MEMHDR *memlist = NULL;
|
||||
#endif
|
||||
|
||||
void debugmem_tag_error(void *addr);
|
||||
#ifdef MEM_LIST
|
||||
void debugmem_list_add(MEMHDR *);
|
||||
void debugmem_list_delete(MEMHDR *);
|
||||
#endif
|
||||
#define Mem_Tag_Err(a) debugmem_tag_error(a);
|
||||
|
||||
#ifndef TEST_POINT
|
||||
#define TEST_POINT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlMallocBreakpoint:
|
||||
*
|
||||
* Breakpoint to use in conjunction with xmlMemStopAtBlock. When the block
|
||||
* number reaches the specified value this function is called. One need to add a breakpoint
|
||||
* to it to get the context in which the given block is allocated.
|
||||
*/
|
||||
|
||||
void
|
||||
xmlMallocBreakpoint(void) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMallocBreakpoint reached on block %d\n", xmlMemStopAtBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMallocLoc:
|
||||
* @size: an int specifying the size in byte to allocate.
|
||||
* @file: the file name or NULL
|
||||
* @line: the line number
|
||||
*
|
||||
* a malloc() equivalent, with logging of the allocation info.
|
||||
*
|
||||
* Returns a pointer to the allocated area or NULL in case of lack of memory.
|
||||
*/
|
||||
|
||||
void *
|
||||
xmlMallocLoc(int size, const char * file, int line)
|
||||
{
|
||||
MEMHDR *p;
|
||||
|
||||
if (!xmlMemInitialized) xmlInitMemory();
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Malloc(%d)\n",size);
|
||||
#endif
|
||||
|
||||
TEST_POINT
|
||||
|
||||
p = (MEMHDR *) malloc(RESERVE_SIZE+size);
|
||||
|
||||
if (!p) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlMalloc : Out of free space\n");
|
||||
xmlMemoryDump();
|
||||
return(NULL);
|
||||
}
|
||||
p->mh_tag = MEMTAG;
|
||||
p->mh_number = ++block;
|
||||
p->mh_size = size;
|
||||
p->mh_type = MALLOC_TYPE;
|
||||
p->mh_file = file;
|
||||
p->mh_line = line;
|
||||
debugMemSize += size;
|
||||
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
||||
#ifdef MEM_LIST
|
||||
debugmem_list_add(p);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Malloc(%d) Ok\n",size);
|
||||
#endif
|
||||
|
||||
if (xmlMemStopAtBlock == block) xmlMallocBreakpoint();
|
||||
|
||||
TEST_POINT
|
||||
|
||||
return(HDR_2_CLIENT(p));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemMalloc:
|
||||
* @size: an int specifying the size in byte to allocate.
|
||||
*
|
||||
* a malloc() equivalent, with logging of the allocation info.
|
||||
*
|
||||
* Returns a pointer to the allocated area or NULL in case of lack of memory.
|
||||
*/
|
||||
|
||||
void *
|
||||
xmlMemMalloc(int size)
|
||||
{
|
||||
return(xmlMallocLoc(size, "none", 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlReallocLoc:
|
||||
* @ptr: the initial memory block pointer
|
||||
* @size: an int specifying the size in byte to allocate.
|
||||
* @file: the file name or NULL
|
||||
* @line: the line number
|
||||
*
|
||||
* a realloc() equivalent, with logging of the allocation info.
|
||||
*
|
||||
* Returns a pointer to the allocated area or NULL in case of lack of memory.
|
||||
*/
|
||||
|
||||
void *
|
||||
xmlReallocLoc(void *ptr,int size, const char * file, int line)
|
||||
{
|
||||
MEMHDR *p;
|
||||
unsigned long number;
|
||||
|
||||
if (!xmlMemInitialized) xmlInitMemory();
|
||||
TEST_POINT
|
||||
|
||||
p = CLIENT_2_HDR(ptr);
|
||||
number = p->mh_number;
|
||||
if (p->mh_tag != MEMTAG) {
|
||||
Mem_Tag_Err(p);
|
||||
goto error;
|
||||
}
|
||||
p->mh_tag = ~MEMTAG;
|
||||
debugMemSize -= p->mh_size;
|
||||
#ifdef MEM_LIST
|
||||
debugmem_list_delete(p);
|
||||
#endif
|
||||
|
||||
p = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
|
||||
if (!p) {
|
||||
goto error;
|
||||
}
|
||||
p->mh_tag = MEMTAG;
|
||||
p->mh_number = number;
|
||||
p->mh_type = REALLOC_TYPE;
|
||||
p->mh_size = size;
|
||||
p->mh_file = file;
|
||||
p->mh_line = line;
|
||||
debugMemSize += size;
|
||||
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
||||
#ifdef MEM_LIST
|
||||
debugmem_list_add(p);
|
||||
#endif
|
||||
|
||||
TEST_POINT
|
||||
|
||||
return(HDR_2_CLIENT(p));
|
||||
|
||||
error:
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemRealloc:
|
||||
* @ptr: the initial memory block pointer
|
||||
* @size: an int specifying the size in byte to allocate.
|
||||
*
|
||||
* a realloc() equivalent, with logging of the allocation info.
|
||||
*
|
||||
* Returns a pointer to the allocated area or NULL in case of lack of memory.
|
||||
*/
|
||||
|
||||
void *
|
||||
xmlMemRealloc(void *ptr,int size) {
|
||||
return(xmlReallocLoc(ptr, size, "none", 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemFree:
|
||||
* @ptr: the memory block pointer
|
||||
*
|
||||
* a free() equivalent, with error checking.
|
||||
*/
|
||||
void
|
||||
xmlMemFree(void *ptr)
|
||||
{
|
||||
MEMHDR *p;
|
||||
|
||||
TEST_POINT
|
||||
|
||||
p = CLIENT_2_HDR(ptr);
|
||||
if (p->mh_tag != MEMTAG) {
|
||||
Mem_Tag_Err(p);
|
||||
goto error;
|
||||
}
|
||||
p->mh_tag = ~MEMTAG;
|
||||
debugMemSize -= p->mh_size;
|
||||
|
||||
#ifdef MEM_LIST
|
||||
debugmem_list_delete(p);
|
||||
#endif
|
||||
free(p);
|
||||
|
||||
TEST_POINT
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlFree(%X) error\n", (unsigned int) ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemStrdupLoc:
|
||||
* @ptr: the initial string pointer
|
||||
* @file: the file name or NULL
|
||||
* @line: the line number
|
||||
*
|
||||
* a strdup() equivalent, with logging of the allocation info.
|
||||
*
|
||||
* Returns a pointer to the new string or NULL if allocation error occured.
|
||||
*/
|
||||
|
||||
char *
|
||||
xmlMemStrdupLoc(const char *str, const char *file, int line)
|
||||
{
|
||||
char *s;
|
||||
size_t size = strlen(str) + 1;
|
||||
MEMHDR *p;
|
||||
|
||||
if (!xmlMemInitialized) xmlInitMemory();
|
||||
TEST_POINT
|
||||
|
||||
p = (MEMHDR *) malloc(RESERVE_SIZE+size);
|
||||
if (!p) {
|
||||
goto error;
|
||||
}
|
||||
p->mh_tag = MEMTAG;
|
||||
p->mh_number = ++block;
|
||||
p->mh_size = size;
|
||||
p->mh_type = STRDUP_TYPE;
|
||||
p->mh_file = file;
|
||||
p->mh_line = line;
|
||||
debugMemSize += size;
|
||||
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
||||
#ifdef MEM_LIST
|
||||
debugmem_list_add(p);
|
||||
#endif
|
||||
s = (char *) HDR_2_CLIENT(p);
|
||||
|
||||
if (xmlMemStopAtBlock == block) xmlMallocBreakpoint();
|
||||
|
||||
if (s != NULL)
|
||||
strcpy(s,str);
|
||||
else
|
||||
goto error;
|
||||
|
||||
TEST_POINT
|
||||
|
||||
return(s);
|
||||
|
||||
error:
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemoryStrdup:
|
||||
* @ptr: the initial string pointer
|
||||
*
|
||||
* a strdup() equivalent, with logging of the allocation info.
|
||||
*
|
||||
* Returns a pointer to the new string or NULL if allocation error occured.
|
||||
*/
|
||||
|
||||
char *
|
||||
xmlMemoryStrdup(const char *str) {
|
||||
return(xmlMemStrdupLoc(str, "none", 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemUsed:
|
||||
*
|
||||
* returns the amount of memory currenly allocated
|
||||
*
|
||||
* Returns an int representing the amount of memory allocated.
|
||||
*/
|
||||
|
||||
int
|
||||
xmlMemUsed(void) {
|
||||
return(debugMemSize);
|
||||
}
|
||||
|
||||
#ifdef MEM_LIST
|
||||
/**
|
||||
* xmlMemContentShow:
|
||||
* @fp: a FILE descriptor used as the output file
|
||||
* @p: a memory block header
|
||||
*
|
||||
* tries to show some content from the memory block
|
||||
*/
|
||||
|
||||
void
|
||||
xmlMemContentShow(FILE *fp, MEMHDR *p)
|
||||
{
|
||||
int i,j,len = p->mh_size;
|
||||
const char *buf = (const char *) HDR_2_CLIENT(p);
|
||||
|
||||
if (p == NULL) {
|
||||
fprintf(fp, " NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0;i < len;i++) {
|
||||
if (buf[i] == 0) break;
|
||||
if (!isprint(buf[i])) break;
|
||||
}
|
||||
if ((i < 4) && ((buf[i] != 0) || (i == 0))) {
|
||||
if (len >= 4) {
|
||||
MEMHDR *q;
|
||||
void *cur;
|
||||
|
||||
for (j = 0;j < len -3;j += 4) {
|
||||
cur = *((void **) &buf[j]);
|
||||
q = CLIENT_2_HDR(cur);
|
||||
p = memlist;
|
||||
while (p != NULL) {
|
||||
if (p == q) break;
|
||||
p = p->mh_next;
|
||||
}
|
||||
if ((p != NULL) && (p == q)) {
|
||||
fprintf(fp, " pointer to #%lu at index %d",
|
||||
p->mh_number, j);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ((i == 0) && (buf[i] == 0)) {
|
||||
fprintf(fp," null");
|
||||
} else {
|
||||
if (buf[i] == 0) fprintf(fp," \"%.25s\"", buf);
|
||||
else {
|
||||
fprintf(fp," [");
|
||||
for (j = 0;j < i;j++)
|
||||
fprintf(fp,"%c", buf[j]);
|
||||
fprintf(fp,"]");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlMemShow:
|
||||
* @fp: a FILE descriptor used as the output file
|
||||
* @nr: number of entries to dump
|
||||
*
|
||||
* show a show display of the memory allocated, and dump
|
||||
* the @nr last allocated areas which were not freed
|
||||
*/
|
||||
|
||||
void
|
||||
xmlMemShow(FILE *fp, int nr)
|
||||
{
|
||||
#ifdef MEM_LIST
|
||||
MEMHDR *p;
|
||||
#endif
|
||||
|
||||
if (fp != NULL)
|
||||
fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n",
|
||||
debugMemSize, debugMaxMemSize);
|
||||
#ifdef MEM_LIST
|
||||
if (nr > 0) {
|
||||
fprintf(fp,"NUMBER SIZE TYPE WHERE\n");
|
||||
p = memlist;
|
||||
while ((p) && nr > 0) {
|
||||
fprintf(fp,"%6lu %6u ",p->mh_number,p->mh_size);
|
||||
switch (p->mh_type) {
|
||||
case STRDUP_TYPE:fprintf(fp,"strdup() in ");break;
|
||||
case MALLOC_TYPE:fprintf(fp,"malloc() in ");break;
|
||||
case REALLOC_TYPE:fprintf(fp,"realloc() in ");break;
|
||||
default:fprintf(fp," ??? in ");break;
|
||||
}
|
||||
if (p->mh_file != NULL)
|
||||
fprintf(fp,"%s(%d)", p->mh_file, p->mh_line);
|
||||
if (p->mh_tag != MEMTAG)
|
||||
fprintf(fp," INVALID");
|
||||
xmlMemContentShow(fp, p);
|
||||
fprintf(fp,"\n");
|
||||
nr--;
|
||||
p = p->mh_next;
|
||||
}
|
||||
}
|
||||
#endif /* MEM_LIST */
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemDisplay:
|
||||
* @fp: a FILE descriptor used as the output file, if NULL, the result is
|
||||
* written to the file .memorylist
|
||||
*
|
||||
* show in-extenso the memory blocks allocated
|
||||
*/
|
||||
|
||||
void
|
||||
xmlMemDisplay(FILE *fp)
|
||||
{
|
||||
#ifdef MEM_LIST
|
||||
MEMHDR *p;
|
||||
int idx;
|
||||
#if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME)
|
||||
time_t currentTime;
|
||||
char buf[500];
|
||||
struct tm * tstruct;
|
||||
|
||||
currentTime = time(NULL);
|
||||
tstruct = localtime(¤tTime);
|
||||
strftime(buf, sizeof(buf) - 1, "%c", tstruct);
|
||||
fprintf(fp," %s\n\n", buf);
|
||||
#endif
|
||||
|
||||
|
||||
fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n",
|
||||
debugMemSize, debugMaxMemSize);
|
||||
fprintf(fp,"BLOCK NUMBER SIZE TYPE\n");
|
||||
idx = 0;
|
||||
p = memlist;
|
||||
while (p) {
|
||||
fprintf(fp,"%-5u %6lu %6u ",idx++,p->mh_number,p->mh_size);
|
||||
switch (p->mh_type) {
|
||||
case STRDUP_TYPE:fprintf(fp,"strdup() in ");break;
|
||||
case MALLOC_TYPE:fprintf(fp,"malloc() in ");break;
|
||||
case REALLOC_TYPE:fprintf(fp,"realloc() in ");break;
|
||||
default:fprintf(fp," ??? in ");break;
|
||||
}
|
||||
if (p->mh_file != NULL) fprintf(fp,"%s(%d)", p->mh_file, p->mh_line);
|
||||
if (p->mh_tag != MEMTAG)
|
||||
fprintf(fp," INVALID");
|
||||
xmlMemContentShow(fp, p);
|
||||
fprintf(fp,"\n");
|
||||
p = p->mh_next;
|
||||
}
|
||||
#else
|
||||
fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MEM_LIST
|
||||
|
||||
void debugmem_list_add(MEMHDR *p)
|
||||
{
|
||||
p->mh_next = memlist;
|
||||
p->mh_prev = NULL;
|
||||
if (memlist) memlist->mh_prev = p;
|
||||
memlist = p;
|
||||
#ifdef MEM_LIST_DEBUG
|
||||
if (stderr)
|
||||
Mem_Display(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void debugmem_list_delete(MEMHDR *p)
|
||||
{
|
||||
if (p->mh_next)
|
||||
p->mh_next->mh_prev = p->mh_prev;
|
||||
if (p->mh_prev)
|
||||
p->mh_prev->mh_next = p->mh_next;
|
||||
else memlist = p->mh_next;
|
||||
#ifdef MEM_LIST_DEBUG
|
||||
if (stderr)
|
||||
Mem_Display(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* debugmem_tag_error : internal error function.
|
||||
*/
|
||||
|
||||
void debugmem_tag_error(void *p)
|
||||
{
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Memory tag error occurs :%p \n\t bye\n", p);
|
||||
#ifdef MEM_LIST
|
||||
if (stderr)
|
||||
xmlMemDisplay(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
FILE *xmlMemoryDumpFile = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* xmlMemoryDump:
|
||||
*
|
||||
* Dump in-extenso the memory blocks allocated to the file .memorylist
|
||||
*/
|
||||
|
||||
void
|
||||
xmlMemoryDump(void)
|
||||
{
|
||||
#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
|
||||
FILE *dump;
|
||||
|
||||
dump = fopen(".memdump", "w");
|
||||
if (dump == NULL) xmlMemoryDumpFile = stdout;
|
||||
else xmlMemoryDumpFile = dump;
|
||||
|
||||
xmlMemDisplay(xmlMemoryDumpFile);
|
||||
|
||||
if (dump != NULL) fclose(dump);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* *
|
||||
* Initialization Routines *
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
|
||||
xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
|
||||
xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
|
||||
xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
|
||||
xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
|
||||
#else
|
||||
xmlFreeFunc xmlFree = (xmlFreeFunc) free;
|
||||
xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
|
||||
xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
|
||||
xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) strdup;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlInitMemory:
|
||||
*
|
||||
* Initialize the memory layer.
|
||||
*
|
||||
* Returns 0 on success
|
||||
*/
|
||||
|
||||
static int xmlInitMemoryDone = 0;
|
||||
|
||||
int
|
||||
xmlInitMemory(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
char *breakpoint;
|
||||
#endif
|
||||
|
||||
if (xmlInitMemoryDone) return(-1);
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
breakpoint = getenv("XML_MEM_BREAKPOINT");
|
||||
if (breakpoint != NULL) {
|
||||
sscanf(breakpoint, "%d", &xmlMemStopAtBlock);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlInitMemory() Ok\n");
|
||||
#endif
|
||||
ret = 0;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemSetup:
|
||||
* @freeFunc: the free() function to use
|
||||
* @mallocFunc: the malloc() function to use
|
||||
* @reallocFunc: the realloc() function to use
|
||||
* @strdupFunc: the strdup() function to use
|
||||
*
|
||||
* Override the default memory access functions with a new set
|
||||
* This has to be called before any other libxml routines !
|
||||
*
|
||||
* Should this be blocked if there was already some allocations
|
||||
* done ?
|
||||
*
|
||||
* Returns 0 on success
|
||||
*/
|
||||
int
|
||||
xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
|
||||
xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc) {
|
||||
if (freeFunc == NULL)
|
||||
return(-1);
|
||||
if (mallocFunc == NULL)
|
||||
return(-1);
|
||||
if (reallocFunc == NULL)
|
||||
return(-1);
|
||||
if (strdupFunc == NULL)
|
||||
return(-1);
|
||||
xmlFree = freeFunc;
|
||||
xmlMalloc = mallocFunc;
|
||||
xmlRealloc = reallocFunc;
|
||||
xmlMemStrdup = strdupFunc;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlMemGet:
|
||||
* @freeFunc: the free() function in use
|
||||
* @mallocFunc: the malloc() function in use
|
||||
* @reallocFunc: the realloc() function in use
|
||||
* @strdupFunc: the strdup() function in use
|
||||
*
|
||||
* Return the memory access functions set currently in use
|
||||
*
|
||||
* Returns 0 on success
|
||||
*/
|
||||
int
|
||||
xmlMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc,
|
||||
xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc) {
|
||||
if (freeFunc != NULL) *freeFunc = xmlFree;
|
||||
if (mallocFunc != NULL) *mallocFunc = xmlMalloc;
|
||||
if (reallocFunc != NULL) *reallocFunc = xmlRealloc;
|
||||
if (strdupFunc != NULL) *strdupFunc = xmlMemStrdup;
|
||||
return(0);
|
||||
}
|
||||
|
91
xmlmemory.h
Normal file
91
xmlmemory.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* xmlmemory.h: interface for the memory allocation debug.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DEBUG_MEMORY_ALLOC_
|
||||
#define _DEBUG_MEMORY_ALLOC_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
/*
|
||||
* DEBUG_MEMORY_LOCATION should be activated only done when debugging
|
||||
* libxml.
|
||||
*/
|
||||
/* #define DEBUG_MEMORY_LOCATION */
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifndef DEBUG_MEMORY
|
||||
#define DEBUG_MEMORY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MEMORY_LOCATION
|
||||
#define MEM_LIST /* keep a list of all the allocated memory blocks */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The XML memory wrapper support 4 basic overloadable functions
|
||||
*/
|
||||
typedef void (*xmlFreeFunc)(void *);
|
||||
typedef void *(*xmlMallocFunc)(int);
|
||||
typedef void *(*xmlReallocFunc)(void *, int);
|
||||
typedef char *(*xmlStrdupFunc)(const char *);
|
||||
|
||||
/*
|
||||
* The 4 interfaces used for all memory handling within libxml
|
||||
*/
|
||||
LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree;
|
||||
LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
|
||||
LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc;
|
||||
LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
|
||||
|
||||
/*
|
||||
* The way to overload the existing functions
|
||||
*/
|
||||
int xmlMemSetup (xmlFreeFunc freeFunc,
|
||||
xmlMallocFunc mallocFunc,
|
||||
xmlReallocFunc reallocFunc,
|
||||
xmlStrdupFunc strdupFunc);
|
||||
int xmlMemGet (xmlFreeFunc *freeFunc,
|
||||
xmlMallocFunc *mallocFunc,
|
||||
xmlReallocFunc *reallocFunc,
|
||||
xmlStrdupFunc *strdupFunc);
|
||||
|
||||
/*
|
||||
* Initialization of the memory layer
|
||||
*/
|
||||
int xmlInitMemory (void);
|
||||
|
||||
/*
|
||||
* Those are specific to the XML debug memory wrapper
|
||||
*/
|
||||
int xmlMemUsed (void);
|
||||
void xmlMemDisplay (FILE *fp);
|
||||
void xmlMemShow (FILE *fp, int nr);
|
||||
void xmlMemoryDump (void);
|
||||
int xmlInitMemory (void);
|
||||
|
||||
#ifdef DEBUG_MEMORY_LOCATION
|
||||
#define xmlMalloc(x) xmlMallocLoc((x), __FILE__, __LINE__)
|
||||
#define xmlRealloc(p, x) xmlReallocLoc((p), (x), __FILE__, __LINE__)
|
||||
#define xmlMemStrdup(x) xmlMemStrdupLoc((x), __FILE__, __LINE__)
|
||||
|
||||
void * xmlMallocLoc(int size, const char *file, int line);
|
||||
void * xmlReallocLoc(void *ptr,int size, const char *file, int line);
|
||||
char * xmlMemStrdupLoc(const char *str, const char *file, int line);
|
||||
#endif /* DEBUG_MEMORY_LOCATION */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _DEBUG_MEMORY_ALLOC_ */
|
||||
|
129
xmlversion.h.in
Normal file
129
xmlversion.h.in
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* xmlversion.h : compile-time version informations for the XML parser.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_VERSION_H__
|
||||
#define __XML_VERSION_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* use those to be sure nothing nasty will happen if
|
||||
* your library and includes mismatch
|
||||
*/
|
||||
extern void xmlCheckVersion(int version);
|
||||
#define LIBXML_DOTTED_VERSION "@VERSION@"
|
||||
#define LIBXML_VERSION @LIBXML_VERSION_NUMBER@
|
||||
#define LIBXML_VERSION_STRING "@LIBXML_VERSION_NUMBER@"
|
||||
#define LIBXML_TEST_VERSION xmlCheckVersion(@LIBXML_VERSION_NUMBER@);
|
||||
|
||||
/*
|
||||
* Whether the FTP support is configured in
|
||||
*/
|
||||
#if @WITH_FTP@
|
||||
#define LIBXML_FTP_ENABLED
|
||||
#else
|
||||
#define LIBXML_FTP_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the HTTP support is configured in
|
||||
*/
|
||||
#if @WITH_HTTP@
|
||||
#define LIBXML_HTTP_ENABLED
|
||||
#else
|
||||
#define LIBXML_HTTP_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the HTML support is configured in
|
||||
*/
|
||||
#if @WITH_HTML@
|
||||
#define LIBXML_HTML_ENABLED
|
||||
#else
|
||||
#define LIBXML_HTML_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the Docbook support is configured in
|
||||
#if @WITH_SGML@
|
||||
#define LIBXML_SGML_ENABLED
|
||||
#else
|
||||
#define LIBXML_SGML_DISABLED
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*
|
||||
* Whether XPath is configured in
|
||||
*/
|
||||
#if @WITH_XPATH@
|
||||
#define LIBXML_XPATH_ENABLED
|
||||
#else
|
||||
#define LIBXML_XPATH_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether XPointer is configured in
|
||||
*/
|
||||
#if @WITH_XPTR@
|
||||
#define LIBXML_XPTR_ENABLED
|
||||
#else
|
||||
#define LIBXML_XPTR_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether XInclude is configured in
|
||||
*/
|
||||
#if @WITH_XINCLUDE@
|
||||
#define LIBXML_XINCLUDE_ENABLED
|
||||
#else
|
||||
#define LIBXML_XINCLUDE_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether iconv support is available
|
||||
*/
|
||||
#ifndef WIN32
|
||||
#if @WITH_ICONV@
|
||||
#define LIBXML_ICONV_ENABLED
|
||||
#else
|
||||
#define LIBXML_ICONV_DISABLED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether Debugging module is configured in
|
||||
*/
|
||||
#if @WITH_DEBUG@
|
||||
#define LIBXML_DEBUG_ENABLED
|
||||
#else
|
||||
#define LIBXML_DEBUG_DISABLED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the memory debugging is configured in
|
||||
*/
|
||||
#if @WITH_MEM_DEBUG@
|
||||
#define DEBUG_MEMORY_LOCATION
|
||||
#endif
|
||||
|
||||
#ifndef LIBXML_DLL_IMPORT
|
||||
#if defined(WIN32) && !defined(STATIC)
|
||||
#define LIBXML_DLL_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define LIBXML_DLL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
|
278
xpath.h
Normal file
278
xpath.h
Normal file
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* xpath.c: interface for XML Path Language implementation
|
||||
*
|
||||
* Reference: W3C Working Draft 5 July 1999
|
||||
* http://www.w3.org/Style/XSL/Group/1999/07/xpath-19990705.html
|
||||
*
|
||||
* See COPYRIGHT for the status of this software
|
||||
*
|
||||
* Author: Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XPATH_H__
|
||||
#define __XML_XPATH_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _xmlXPathContext xmlXPathContext;
|
||||
typedef xmlXPathContext *xmlXPathContextPtr;
|
||||
typedef struct _xmlXPathParserContext xmlXPathParserContext;
|
||||
typedef xmlXPathParserContext *xmlXPathParserContextPtr;
|
||||
|
||||
/**
|
||||
* The set of XPath error codes
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XPATH_EXPRESSION_OK = 0,
|
||||
XPATH_NUMBER_ERROR,
|
||||
XPATH_UNFINISHED_LITERAL_ERROR,
|
||||
XPATH_START_LITERAL_ERROR,
|
||||
XPATH_VARIABLE_REF_ERROR,
|
||||
XPATH_UNDEF_VARIABLE_ERROR,
|
||||
XPATH_INVALID_PREDICATE_ERROR,
|
||||
XPATH_EXPR_ERROR,
|
||||
XPATH_UNCLOSED_ERROR,
|
||||
XPATH_UNKNOWN_FUNC_ERROR,
|
||||
XPATH_INVALID_OPERAND,
|
||||
XPATH_INVALID_TYPE,
|
||||
XPATH_INVALID_ARITY,
|
||||
XPATH_INVALID_CTXT_SIZE,
|
||||
XPATH_INVALID_CTXT_POSITION,
|
||||
XPATH_MEMORY_ERROR,
|
||||
XPTR_SYNTAX_ERROR,
|
||||
XPTR_RESOURCE_ERROR,
|
||||
XPTR_SUB_RESOURCE_ERROR,
|
||||
XPATH_UNDEF_PREFIX_ERROR
|
||||
} xmlXPathError;
|
||||
|
||||
/*
|
||||
* A node-set (an unordered collection of nodes without duplicates)
|
||||
*/
|
||||
typedef struct _xmlNodeSet xmlNodeSet;
|
||||
typedef xmlNodeSet *xmlNodeSetPtr;
|
||||
struct _xmlNodeSet {
|
||||
int nodeNr; /* number of nodes in the set */
|
||||
int nodeMax; /* size of the array as allocated */
|
||||
xmlNodePtr *nodeTab; /* array of nodes in no particular order */
|
||||
};
|
||||
|
||||
/*
|
||||
* An expression is evaluated to yield an object, which
|
||||
* has one of the following four basic types:
|
||||
* - node-set
|
||||
* - boolean
|
||||
* - number
|
||||
* - string
|
||||
*
|
||||
* @@ XPointer will add more types !
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XPATH_UNDEFINED = 0,
|
||||
XPATH_NODESET = 1,
|
||||
XPATH_BOOLEAN = 2,
|
||||
XPATH_NUMBER = 3,
|
||||
XPATH_STRING = 4,
|
||||
XPATH_POINT = 5,
|
||||
XPATH_RANGE = 6,
|
||||
XPATH_LOCATIONSET = 7,
|
||||
XPATH_USERS = 8,
|
||||
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
|
||||
} xmlXPathObjectType;
|
||||
|
||||
typedef struct _xmlXPathObject xmlXPathObject;
|
||||
typedef xmlXPathObject *xmlXPathObjectPtr;
|
||||
struct _xmlXPathObject {
|
||||
xmlXPathObjectType type;
|
||||
xmlNodeSetPtr nodesetval;
|
||||
int boolval;
|
||||
double floatval;
|
||||
xmlChar *stringval;
|
||||
void *user;
|
||||
int index;
|
||||
void *user2;
|
||||
int index2;
|
||||
};
|
||||
|
||||
/*
|
||||
* A conversion function is associated to a type and used to cast
|
||||
* the new type to primitive values.
|
||||
*/
|
||||
typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type);
|
||||
|
||||
/*
|
||||
* Extra type: a name and a conversion function.
|
||||
*/
|
||||
|
||||
typedef struct _xmlXPathType xmlXPathType;
|
||||
typedef xmlXPathType *xmlXPathTypePtr;
|
||||
struct _xmlXPathType {
|
||||
const xmlChar *name; /* the type name */
|
||||
xmlXPathConvertFunc func; /* the conversion function */
|
||||
};
|
||||
|
||||
/*
|
||||
* Extra variable: a name and a value.
|
||||
*/
|
||||
|
||||
typedef struct _xmlXPathVariable xmlXPathVariable;
|
||||
typedef xmlXPathVariable *xmlXPathVariablePtr;
|
||||
struct _xmlXPathVariable {
|
||||
const xmlChar *name; /* the variable name */
|
||||
xmlXPathObjectPtr value; /* the value */
|
||||
};
|
||||
|
||||
/*
|
||||
* an evaluation function, the parameters are on the context stack
|
||||
*/
|
||||
|
||||
typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
|
||||
/*
|
||||
* Extra function: a name and a evaluation function.
|
||||
*/
|
||||
|
||||
typedef struct _xmlXPathFunct xmlXPathFunct;
|
||||
typedef xmlXPathFunct *xmlXPathFuncPtr;
|
||||
struct _xmlXPathFunct {
|
||||
const xmlChar *name; /* the function name */
|
||||
xmlXPathEvalFunc func; /* the evaluation function */
|
||||
};
|
||||
|
||||
/*
|
||||
* An axis traversal function. To traverse an axis, the engine calls
|
||||
* the first time with cur == NULL and repeat until the function returns
|
||||
* NULL indicating the end of the axis traversal.
|
||||
*/
|
||||
|
||||
typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr cur);
|
||||
|
||||
/*
|
||||
* Extra axis: a name and an axis function.
|
||||
*/
|
||||
|
||||
typedef struct _xmlXPathAxis xmlXPathAxis;
|
||||
typedef xmlXPathAxis *xmlXPathAxisPtr;
|
||||
struct _xmlXPathAxis {
|
||||
const xmlChar *name; /* the axis name */
|
||||
xmlXPathAxisFunc func; /* the search function */
|
||||
};
|
||||
|
||||
/*
|
||||
* Expression evaluation occurs with respect to a context.
|
||||
* he context consists of:
|
||||
* - a node (the context node)
|
||||
* - a node list (the context node list)
|
||||
* - a set of variable bindings
|
||||
* - a function library
|
||||
* - the set of namespace declarations in scope for the expression
|
||||
* Following the switch to hash tables, this need to be trimmed up at
|
||||
* the next binary incompatible release.
|
||||
*/
|
||||
|
||||
struct _xmlXPathContext {
|
||||
xmlDocPtr doc; /* The current document */
|
||||
xmlNodePtr node; /* The current node */
|
||||
|
||||
int nb_variables_unused; /* unused (hash table) */
|
||||
int max_variables_unused; /* unused (hash table) */
|
||||
xmlHashTablePtr varHash; /* Hash table of defined variables */
|
||||
|
||||
int nb_types; /* number of defined types */
|
||||
int max_types; /* max number of types */
|
||||
xmlXPathTypePtr types; /* Array of defined types */
|
||||
|
||||
int nb_funcs_unused; /* unused (hash table) */
|
||||
int max_funcs_unused; /* unused (hash table) */
|
||||
xmlHashTablePtr funcHash; /* Hash table of defined funcs */
|
||||
|
||||
int nb_axis; /* number of defined axis */
|
||||
int max_axis; /* max number of axis */
|
||||
xmlXPathAxisPtr axis; /* Array of defined axis */
|
||||
|
||||
/* the namespace nodes of the context node */
|
||||
xmlNsPtr *namespaces; /* Array of namespaces */
|
||||
int nsNr; /* number of namespace in scope */
|
||||
void *user; /* function to free */
|
||||
|
||||
/* extra variables */
|
||||
int contextSize; /* the context size */
|
||||
int proximityPosition; /* the proximity position */
|
||||
|
||||
/* extra stuff for XPointer */
|
||||
int xptr; /* it this an XPointer context */
|
||||
xmlNodePtr here; /* for here() */
|
||||
xmlNodePtr origin; /* for origin() */
|
||||
|
||||
/* the set of namespace declarations in scope for the expression */
|
||||
xmlHashTablePtr nsHash; /* The namespaces hash table */
|
||||
void *varLookupFunc; /* variable lookup func */
|
||||
void *varLookupData; /* variable lookup data */
|
||||
|
||||
/* Possibility to link in an extra item */
|
||||
void *extra; /* needed for XSLT */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XPath parser context, it contains pure parsing informations,
|
||||
* an xmlXPathContext, and the stack of objects.
|
||||
*/
|
||||
struct _xmlXPathParserContext {
|
||||
const xmlChar *cur; /* the current char being parsed */
|
||||
const xmlChar *base; /* the full expression */
|
||||
|
||||
int error; /* error code */
|
||||
|
||||
xmlXPathContextPtr context; /* the evaluation context */
|
||||
xmlXPathObjectPtr value; /* the current value */
|
||||
int valueNr; /* number of values stacked */
|
||||
int valueMax; /* max number of values stacked */
|
||||
xmlXPathObjectPtr *valueTab; /* stack of values */
|
||||
};
|
||||
|
||||
/*
|
||||
* An XPath function
|
||||
* The arguments (if any) are popped out of the context stack
|
||||
* and the result is pushed on the stack.
|
||||
*/
|
||||
|
||||
typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs);
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Public API *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* Evaluation functions.
|
||||
*/
|
||||
void xmlXPathInit (void);
|
||||
xmlXPathContextPtr xmlXPathNewContext (xmlDocPtr doc);
|
||||
void xmlXPathFreeContext (xmlXPathContextPtr ctxt);
|
||||
xmlXPathObjectPtr xmlXPathEval (const xmlChar *str,
|
||||
xmlXPathContextPtr ctxt);
|
||||
xmlXPathObjectPtr xmlXPathEvalXPtrExpr (const xmlChar *str,
|
||||
xmlXPathContextPtr ctxt);
|
||||
void xmlXPathFreeObject (xmlXPathObjectPtr obj);
|
||||
xmlXPathObjectPtr xmlXPathEvalExpression (const xmlChar *str,
|
||||
xmlXPathContextPtr ctxt);
|
||||
xmlNodeSetPtr xmlXPathNodeSetCreate (xmlNodePtr val);
|
||||
void xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj);
|
||||
void xmlXPathFreeNodeSet (xmlNodeSetPtr obj);
|
||||
xmlXPathObjectPtr xmlXPathObjectCopy (xmlXPathObjectPtr val);
|
||||
int xmlXPathCmpNodes (xmlNodePtr node1,
|
||||
xmlNodePtr node2);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! __XML_XPATH_H__ */
|
236
xpathInternals.h
Normal file
236
xpathInternals.h
Normal file
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* xpath.c: internal interfaces for XML Path Language implementation
|
||||
* used to build new modules on top of XPath
|
||||
*
|
||||
* See COPYRIGHT for the status of this software
|
||||
*
|
||||
* Author: Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XPATH_INTERNALS_H__
|
||||
#define __XML_XPATH_INTERNALS_H__
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Helpers *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
#define CHECK_ERROR \
|
||||
if (ctxt->error != XPATH_EXPRESSION_OK) return
|
||||
|
||||
#define CHECK_ERROR0 \
|
||||
if (ctxt->error != XPATH_EXPRESSION_OK) return(0)
|
||||
|
||||
#define XP_ERROR(X) \
|
||||
{ xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
|
||||
ctxt->error = (X); return; }
|
||||
|
||||
#define XP_ERROR0(X) \
|
||||
{ xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
|
||||
ctxt->error = (X); return(0); }
|
||||
|
||||
#define CHECK_TYPE(typeval) \
|
||||
if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
|
||||
XP_ERROR(XPATH_INVALID_TYPE)
|
||||
|
||||
#define CHECK_ARITY(x) \
|
||||
if (nargs != (x)) \
|
||||
XP_ERROR(XPATH_INVALID_ARITY);
|
||||
|
||||
#define CAST_TO_STRING \
|
||||
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \
|
||||
xmlXPathStringFunction(ctxt, 1);
|
||||
|
||||
#define CAST_TO_NUMBER \
|
||||
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \
|
||||
xmlXPathNumberFunction(ctxt, 1);
|
||||
|
||||
#define CAST_TO_BOOLEAN \
|
||||
if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
|
||||
xmlXPathBooleanFunction(ctxt, 1);
|
||||
|
||||
/*
|
||||
* Varibale Lookup forwarding
|
||||
*/
|
||||
typedef xmlXPathObjectPtr
|
||||
(*xmlXPathVariableLookupFunc) (void *ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri);
|
||||
|
||||
void xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
|
||||
xmlXPathVariableLookupFunc f,
|
||||
void *varCtxt);
|
||||
|
||||
/*
|
||||
* Error reporting
|
||||
*/
|
||||
void xmlXPatherror (xmlXPathParserContextPtr ctxt,
|
||||
const char *file,
|
||||
int line,
|
||||
int no);
|
||||
|
||||
void xmlXPathDebugDumpObject (FILE *output,
|
||||
xmlXPathObjectPtr cur,
|
||||
int depth);
|
||||
|
||||
/**
|
||||
* Extending a context
|
||||
*/
|
||||
|
||||
int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *ns_uri);
|
||||
const xmlChar * xmlXPathNsLookup (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *ns_uri);
|
||||
void xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt);
|
||||
|
||||
int xmlXPathRegisterFunc (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
xmlXPathFunction f);
|
||||
int xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri,
|
||||
xmlXPathFunction f);
|
||||
int xmlXPathRegisterVariable (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
xmlXPathObjectPtr value);
|
||||
int xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri,
|
||||
xmlXPathObjectPtr value);
|
||||
xmlXPathFunction xmlXPathFunctionLookup (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name);
|
||||
xmlXPathFunction xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri);
|
||||
void xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt);
|
||||
xmlXPathObjectPtr xmlXPathVariableLookup (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name);
|
||||
xmlXPathObjectPtr xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns_uri);
|
||||
void xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
|
||||
|
||||
/**
|
||||
* Utilities to extend XPath
|
||||
*/
|
||||
xmlXPathParserContextPtr
|
||||
xmlXPathNewParserContext (const xmlChar *str,
|
||||
xmlXPathContextPtr ctxt);
|
||||
void xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
|
||||
|
||||
/* TODO: remap to xmlXPathValuePop and Push */
|
||||
xmlXPathObjectPtr valuePop (xmlXPathParserContextPtr ctxt);
|
||||
int valuePush (xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr value);
|
||||
|
||||
xmlXPathObjectPtr xmlXPathNewString (const xmlChar *val);
|
||||
xmlXPathObjectPtr xmlXPathNewCString (const char *val);
|
||||
xmlXPathObjectPtr xmlXPathNewFloat (double val);
|
||||
xmlXPathObjectPtr xmlXPathNewBoolean (int val);
|
||||
xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
|
||||
xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val);
|
||||
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
|
||||
xmlNodePtr val);
|
||||
|
||||
|
||||
void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt,
|
||||
int nargs);
|
||||
void xmlXPathRoot (xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt);
|
||||
xmlChar * xmlXPathParseName (xmlXPathParserContextPtr ctxt);
|
||||
xmlChar * xmlXPathParseNCName (xmlXPathParserContextPtr ctxt);
|
||||
|
||||
/*
|
||||
* Debug
|
||||
*/
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
double xmlXPathStringEvalNumber(const xmlChar *str);
|
||||
void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth);
|
||||
#endif
|
||||
/*
|
||||
* Existing functions
|
||||
*/
|
||||
|
||||
int xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr res);
|
||||
void xmlXPathInit(void);
|
||||
void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt);
|
||||
xmlNodeSetPtr xmlXPathNodeSetCreate(xmlNodePtr val);
|
||||
void xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val);
|
||||
xmlNodeSetPtr xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2);
|
||||
void xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val);
|
||||
void xmlXPathNodeSetRemove(xmlNodeSetPtr cur, int val);
|
||||
void xmlXPathFreeNodeSet(xmlNodeSetPtr obj);
|
||||
xmlXPathObjectPtr xmlXPathNewNodeSet(xmlNodePtr val);
|
||||
xmlXPathObjectPtr xmlXPathNewNodeSetList(xmlNodeSetPtr val);
|
||||
xmlXPathObjectPtr xmlXPathWrapNodeSet(xmlNodeSetPtr val);
|
||||
void xmlXPathFreeNodeSetList(xmlXPathObjectPtr obj);
|
||||
|
||||
|
||||
xmlXPathObjectPtr xmlXPathNewFloat(double val);
|
||||
xmlXPathObjectPtr xmlXPathNewBoolean(int val);
|
||||
xmlXPathObjectPtr xmlXPathNewString(const xmlChar *val);
|
||||
xmlXPathObjectPtr xmlXPathNewCString(const char *val);
|
||||
void xmlXPathFreeObject(xmlXPathObjectPtr obj);
|
||||
xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc);
|
||||
void xmlXPathFreeContext(xmlXPathContextPtr ctxt);
|
||||
|
||||
int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
|
||||
int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
|
||||
void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
|
||||
|
||||
|
||||
/*
|
||||
* Some of the axis navigation routines
|
||||
*/
|
||||
xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
|
||||
xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
|
||||
xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
|
||||
/*
|
||||
* The official core of XPath functions
|
||||
*/
|
||||
void xmlXPathRoot(xmlXPathParserContextPtr ctxt);
|
||||
void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! __XML_XPATH_INTERNALS_H__ */
|
2903
xpointer.c
Normal file
2903
xpointer.c
Normal file
File diff suppressed because it is too large
Load Diff
57
xpointer.h
Normal file
57
xpointer.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* xpointer.h : API to handle XML Pointers
|
||||
*
|
||||
* World Wide Web Consortium Working Draft 03-March-1998
|
||||
* http://www.w3.org/TR/1998/WD-xptr-19980303
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_XPTR_H__
|
||||
#define __XML_XPTR_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A Location Set
|
||||
*/
|
||||
typedef struct _xmlLocationSet xmlLocationSet;
|
||||
typedef xmlLocationSet *xmlLocationSetPtr;
|
||||
struct _xmlLocationSet {
|
||||
int locNr; /* number of locations in the set */
|
||||
int locMax; /* size of the array as allocated */
|
||||
xmlXPathObjectPtr *locTab;/* array of locations */
|
||||
};
|
||||
|
||||
/*
|
||||
* Handling of location sets
|
||||
*/
|
||||
|
||||
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
|
||||
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
|
||||
xmlLocationSetPtr val2);
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
xmlXPathContextPtr xmlXPtrNewContext (xmlDocPtr doc,
|
||||
xmlNodePtr here,
|
||||
xmlNodePtr origin);
|
||||
xmlXPathObjectPtr xmlXPtrEval (const xmlChar *str,
|
||||
xmlXPathContextPtr ctx);
|
||||
void xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
|
||||
int nargs);
|
||||
xmlNodePtr xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
|
||||
void xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_XPTR_H__ */
|
Loading…
x
Reference in New Issue
Block a user