1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-30 22:43:14 +03:00

CORBA defines fixes, char encoding atodetection, Daniel

This commit is contained in:
Daniel Veillard
1999-05-29 11:51:49 +00:00
parent 5e60f5a236
commit 27d88744f9
12 changed files with 664 additions and 311 deletions

View File

@ -1,10 +1,14 @@
Sat May 29 13:34:42 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* tree.[ch]: unified the XML_NO_CORBA defines.
* parser.c encoding.[ch]: started plugging in char encoding detection
Fri May 28 22:58:42 EDT 1999 Manish Vachharajani <mvachhar@vger.rutgers.edu> Fri May 28 22:58:42 EDT 1999 Manish Vachharajani <mvachhar@vger.rutgers.edu>
* tree.c: (xmlSaveFile) - removed double call of xmlContentDump. * tree.c: (xmlSaveFile) - removed double call of xmlContentDump.
Also freed allocated buffer. Also freed allocated buffer.
Wed Apr 21 22:07:35 CEST 1999 Wed Apr 21 22:07:35 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* parser.[ch] tree.[ch] entities.[ch] valid.[ch] : removed the main * parser.[ch] tree.[ch] entities.[ch] valid.[ch] : removed the main
reentrancy problem at printing. One is left in entities.c, to reentrancy problem at printing. One is left in entities.c, to
remove ASAP remove ASAP

93
SAX.c
View File

@ -26,8 +26,9 @@
* Returns a CHAR * * Returns a CHAR *
*/ */
const CHAR * const CHAR *
getPublicId(xmlParserCtxtPtr ctxt) getPublicId(void *ctx)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
return(NULL); return(NULL);
} }
@ -41,8 +42,9 @@ getPublicId(xmlParserCtxtPtr ctxt)
* Returns a CHAR * * Returns a CHAR *
*/ */
const CHAR * const CHAR *
getSystemId(xmlParserCtxtPtr ctxt) getSystemId(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
return(ctxt->input->filename); return(ctxt->input->filename);
} }
@ -55,8 +57,9 @@ getSystemId(xmlParserCtxtPtr ctxt)
* Returns an int * Returns an int
*/ */
int int
getLineNumber(xmlParserCtxtPtr ctxt) getLineNumber(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
return(ctxt->input->line); return(ctxt->input->line);
} }
@ -69,8 +72,9 @@ getLineNumber(xmlParserCtxtPtr ctxt)
* Returns an int * Returns an int
*/ */
int int
getColumnNumber(xmlParserCtxtPtr ctxt) getColumnNumber(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
return(ctxt->input->col); return(ctxt->input->col);
} }
@ -91,8 +95,9 @@ xmlSAXLocator xmlDefaultSAXLocator = {
* Returns 1 if true * Returns 1 if true
*/ */
int int
isStandalone(xmlParserCtxtPtr ctxt) isStandalone(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
return(ctxt->myDoc->standalone == 1); return(ctxt->myDoc->standalone == 1);
} }
@ -105,8 +110,9 @@ isStandalone(xmlParserCtxtPtr ctxt)
* Returns 1 if true * Returns 1 if true
*/ */
int int
hasInternalSubset(xmlParserCtxtPtr ctxt) hasInternalSubset(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
return(ctxt->myDoc->intSubset != NULL); return(ctxt->myDoc->intSubset != NULL);
} }
@ -119,8 +125,9 @@ hasInternalSubset(xmlParserCtxtPtr ctxt)
* Returns 1 if true * Returns 1 if true
*/ */
int int
hasExternalSubset(xmlParserCtxtPtr ctxt) hasExternalSubset(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
return(ctxt->myDoc->extSubset != NULL); return(ctxt->myDoc->extSubset != NULL);
} }
@ -131,9 +138,10 @@ hasExternalSubset(xmlParserCtxtPtr ctxt)
* Does this document has an internal subset * Does this document has an internal subset
*/ */
void void
internalSubset(xmlParserCtxtPtr ctxt, const CHAR *name, internalSubset(void *ctx, const CHAR *name,
const CHAR *ExternalID, const CHAR *SystemID) const CHAR *ExternalID, const CHAR *SystemID)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.internalSubset(%s, %s, %s)\n", fprintf(stderr, "SAX.internalSubset(%s, %s, %s)\n",
name, ExternalID, SystemID); name, ExternalID, SystemID);
@ -156,8 +164,9 @@ internalSubset(xmlParserCtxtPtr ctxt, const CHAR *name,
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/ */
xmlParserInputPtr xmlParserInputPtr
resolveEntity(xmlParserCtxtPtr ctxt, const CHAR *publicId, const CHAR *systemId) resolveEntity(void *ctx, const CHAR *publicId, const CHAR *systemId)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.resolveEntity(%s, %s)\n", publicId, systemId); fprintf(stderr, "SAX.resolveEntity(%s, %s)\n", publicId, systemId);
@ -179,8 +188,9 @@ resolveEntity(xmlParserCtxtPtr ctxt, const CHAR *publicId, const CHAR *systemId)
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/ */
xmlEntityPtr xmlEntityPtr
getEntity(xmlParserCtxtPtr ctxt, const CHAR *name) getEntity(void *ctx, const CHAR *name)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlEntityPtr ret; xmlEntityPtr ret;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
@ -204,9 +214,10 @@ getEntity(xmlParserCtxtPtr ctxt, const CHAR *name)
* An entity definition has been parsed * An entity definition has been parsed
*/ */
void void
entityDecl(xmlParserCtxtPtr ctxt, const CHAR *name, int type, entityDecl(void *ctx, const CHAR *name, int type,
const CHAR *publicId, const CHAR *systemId, CHAR *content) const CHAR *publicId, const CHAR *systemId, CHAR *content)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", fprintf(stderr, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
@ -227,10 +238,11 @@ entityDecl(xmlParserCtxtPtr ctxt, const CHAR *name, int type,
* An attribute definition has been parsed * An attribute definition has been parsed
*/ */
void void
attributeDecl(xmlParserCtxtPtr ctxt, const CHAR *elem, const CHAR *name, attributeDecl(void *ctx, const CHAR *elem, const CHAR *name,
int type, int def, const CHAR *defaultValue, int type, int def, const CHAR *defaultValue,
xmlEnumerationPtr tree) xmlEnumerationPtr tree)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", fprintf(stderr, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
@ -252,9 +264,10 @@ attributeDecl(xmlParserCtxtPtr ctxt, const CHAR *elem, const CHAR *name,
* An element definition has been parsed * An element definition has been parsed
*/ */
void void
elementDecl(xmlParserCtxtPtr ctxt, const CHAR *name, int type, elementDecl(void *ctx, const CHAR *name, int type,
xmlElementContentPtr content) xmlElementContentPtr content)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.elementDecl(%s, %d, ...)\n", fprintf(stderr, "SAX.elementDecl(%s, %d, ...)\n",
@ -274,9 +287,10 @@ elementDecl(xmlParserCtxtPtr ctxt, const CHAR *name, int type,
* TODO Not handled currently. * TODO Not handled currently.
*/ */
void void
notationDecl(xmlParserCtxtPtr ctxt, const CHAR *name, notationDecl(void *ctx, const CHAR *name,
const CHAR *publicId, const CHAR *systemId) const CHAR *publicId, const CHAR *systemId)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId); fprintf(stderr, "SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId);
#endif #endif
@ -295,10 +309,11 @@ notationDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
* TODO Create an Entity node. * TODO Create an Entity node.
*/ */
void void
unparsedEntityDecl(xmlParserCtxtPtr ctxt, const CHAR *name, unparsedEntityDecl(void *ctx, const CHAR *name,
const CHAR *publicId, const CHAR *systemId, const CHAR *publicId, const CHAR *systemId,
const CHAR *notationName) const CHAR *notationName)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", fprintf(stderr, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
name, publicId, systemId, notationName); name, publicId, systemId, notationName);
@ -314,8 +329,9 @@ unparsedEntityDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
* Everything is available on the context, so this is useless in our case. * Everything is available on the context, so this is useless in our case.
*/ */
void void
setDocumentLocator(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc) setDocumentLocator(void *ctx, xmlSAXLocatorPtr loc)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.setDocumentLocator()\n"); fprintf(stderr, "SAX.setDocumentLocator()\n");
#endif #endif
@ -328,8 +344,9 @@ setDocumentLocator(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc)
* called when the document start being processed. * called when the document start being processed.
*/ */
void void
startDocument(xmlParserCtxtPtr ctxt) startDocument(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlDocPtr doc; xmlDocPtr doc;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
@ -352,8 +369,9 @@ startDocument(xmlParserCtxtPtr ctxt)
* called when the document end has been detected. * called when the document end has been detected.
*/ */
void void
endDocument(xmlParserCtxtPtr ctxt) endDocument(void *ctx)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.endDocument()\n"); fprintf(stderr, "SAX.endDocument()\n");
#endif #endif
@ -371,8 +389,9 @@ endDocument(xmlParserCtxtPtr ctxt)
* the element. * the element.
*/ */
void void
attribute(xmlParserCtxtPtr ctxt, const CHAR *fullname, const CHAR *value) attribute(void *ctx, const CHAR *fullname, const CHAR *value)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlAttrPtr ret; xmlAttrPtr ret;
CHAR *name; CHAR *name;
CHAR *ns; CHAR *ns;
@ -428,8 +447,9 @@ attribute(xmlParserCtxtPtr ctxt, const CHAR *fullname, const CHAR *value)
* TODO We currently have a small pblm with the arguments ... * TODO We currently have a small pblm with the arguments ...
*/ */
void void
startElement(xmlParserCtxtPtr ctxt, const CHAR *fullname, const CHAR **atts) startElement(void *ctx, const CHAR *fullname, const CHAR **atts)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNodePtr ret; xmlNodePtr ret;
xmlNodePtr parent = ctxt->node; xmlNodePtr parent = ctxt->node;
xmlNsPtr ns; xmlNsPtr ns;
@ -515,8 +535,9 @@ startElement(xmlParserCtxtPtr ctxt, const CHAR *fullname, const CHAR **atts)
* called when the end of an element has been detected. * called when the end of an element has been detected.
*/ */
void void
endElement(xmlParserCtxtPtr ctxt, const CHAR *name) endElement(void *ctx, const CHAR *name)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserNodeInfo node_info; xmlParserNodeInfo node_info;
xmlNodePtr cur = ctxt->node; xmlNodePtr cur = ctxt->node;
@ -549,8 +570,9 @@ endElement(xmlParserCtxtPtr ctxt, const CHAR *name)
* called when an entity reference is detected. * called when an entity reference is detected.
*/ */
void void
reference(xmlParserCtxtPtr ctxt, const CHAR *name) reference(void *ctx, const CHAR *name)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNodePtr ret; xmlNodePtr ret;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
@ -570,8 +592,9 @@ reference(xmlParserCtxtPtr ctxt, const CHAR *name)
* Question: how much at a time ??? * Question: how much at a time ???
*/ */
void void
characters(xmlParserCtxtPtr ctxt, const CHAR *ch, int len) characters(void *ctx, const CHAR *ch, int len)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNodePtr lastChild; xmlNodePtr lastChild;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
@ -606,8 +629,9 @@ characters(xmlParserCtxtPtr ctxt, const CHAR *ch, int len)
* Question: how much at a time ??? * Question: how much at a time ???
*/ */
void void
ignorableWhitespace(xmlParserCtxtPtr ctxt, const CHAR *ch, int len) ignorableWhitespace(void *ctx, const CHAR *ch, int len)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.ignorableWhitespace(%.30s, %d)\n", ch, len); fprintf(stderr, "SAX.ignorableWhitespace(%.30s, %d)\n", ch, len);
#endif #endif
@ -623,9 +647,10 @@ ignorableWhitespace(xmlParserCtxtPtr ctxt, const CHAR *ch, int len)
* A processing instruction has been parsed. * A processing instruction has been parsed.
*/ */
void void
processingInstruction(xmlParserCtxtPtr ctxt, const CHAR *target, processingInstruction(void *ctx, const CHAR *target,
const CHAR *data) const CHAR *data)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.processingInstruction(%s, %s)\n", target, data); fprintf(stderr, "SAX.processingInstruction(%s, %s)\n", target, data);
#endif #endif
@ -640,8 +665,9 @@ processingInstruction(xmlParserCtxtPtr ctxt, const CHAR *target,
* An old global namespace has been parsed. * An old global namespace has been parsed.
*/ */
void void
globalNamespace(xmlParserCtxtPtr ctxt, const CHAR *href, const CHAR *prefix) globalNamespace(void *ctx, const CHAR *href, const CHAR *prefix)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.globalNamespace(%s, %s)\n", href, prefix); fprintf(stderr, "SAX.globalNamespace(%s, %s)\n", href, prefix);
#endif #endif
@ -656,8 +682,9 @@ globalNamespace(xmlParserCtxtPtr ctxt, const CHAR *href, const CHAR *prefix)
* Set the current element namespace. * Set the current element namespace.
*/ */
void void
setNamespace(xmlParserCtxtPtr ctxt, const CHAR *name) setNamespace(void *ctx, const CHAR *name)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNsPtr ns; xmlNsPtr ns;
xmlNodePtr parent; xmlNodePtr parent;
@ -682,8 +709,9 @@ setNamespace(xmlParserCtxtPtr ctxt, const CHAR *name)
* Get the current element namespace. * Get the current element namespace.
*/ */
xmlNsPtr xmlNsPtr
getNamespace(xmlParserCtxtPtr ctxt) getNamespace(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNsPtr ret; xmlNsPtr ret;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
@ -702,8 +730,9 @@ getNamespace(xmlParserCtxtPtr ctxt)
* one read upon parsing. * one read upon parsing.
*/ */
int int
checkNamespace(xmlParserCtxtPtr ctxt, CHAR *namespace) checkNamespace(void *ctx, CHAR *namespace)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNodePtr cur = ctxt->node; xmlNodePtr cur = ctxt->node;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
@ -749,8 +778,9 @@ checkNamespace(xmlParserCtxtPtr ctxt, CHAR *namespace)
* A namespace has been parsed. * A namespace has been parsed.
*/ */
void void
namespaceDecl(xmlParserCtxtPtr ctxt, const CHAR *href, const CHAR *prefix) namespaceDecl(void *ctx, const CHAR *href, const CHAR *prefix)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
if (prefix == NULL) if (prefix == NULL)
fprintf(stderr, "SAX.namespaceDecl(%s, NULL)\n", href); fprintf(stderr, "SAX.namespaceDecl(%s, NULL)\n", href);
@ -768,8 +798,9 @@ namespaceDecl(xmlParserCtxtPtr ctxt, const CHAR *href, const CHAR *prefix)
* A comment has been parsed. * A comment has been parsed.
*/ */
void void
comment(xmlParserCtxtPtr ctxt, const CHAR *value) comment(void *ctx, const CHAR *value)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
fprintf(stderr, "SAX.comment(%s)\n", value); fprintf(stderr, "SAX.comment(%s)\n", value);
#endif #endif

View File

@ -19,6 +19,7 @@
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#include <ctype.h>
#include "encoding.h" #include "encoding.h"
/* /*
@ -204,3 +205,109 @@ UTF8ToUTF16(unsigned short* out, int outlen, unsigned char* in, int inlen)
} }
/**
* xmlDetectCharEncoding:
* @in: a pointer to the first bytes of the XML entity, must be at least
* 4 bytes long.
*
* Guess the encoding of the entity using the first bytes of the entity content
* accordingly of the non-normative appendix F of the XML-1.0 recommendation.
*
* Returns one of the XML_CHAR_ENCODING_... values.
*/
xmlCharEncoding
xmlDetectCharEncoding(unsigned char* in)
{
if ((in[0] == 0x00) && (in[1] == 0x00) &&
(in[2] == 0x00) && (in[3] == 0x3C))
return(XML_CHAR_ENCODING_UCS4BE);
if ((in[0] == 0x3C) && (in[1] == 0x00) &&
(in[2] == 0x00) && (in[3] == 0x00))
return(XML_CHAR_ENCODING_UCS4LE);
if ((in[0] == 0x00) && (in[1] == 0x00) &&
(in[2] == 0x3C) && (in[3] == 0x00))
return(XML_CHAR_ENCODING_UCS4_2143);
if ((in[0] == 0x00) && (in[1] == 0x3C) &&
(in[2] == 0x00) && (in[3] == 0x00))
return(XML_CHAR_ENCODING_UCS4_3412);
if ((in[0] == 0xFE) && (in[1] == 0xFF))
return(XML_CHAR_ENCODING_UTF16BE);
if ((in[0] == 0xFF) && (in[1] == 0xFE))
return(XML_CHAR_ENCODING_UTF16LE);
if ((in[0] == 0x4C) && (in[1] == 0x6F) &&
(in[2] == 0xA7) && (in[3] == 0x94))
return(XML_CHAR_ENCODING_EBCDIC);
if ((in[0] == 0x3C) && (in[1] == 0x3F) &&
(in[2] == 0x78) && (in[3] == 0x6D))
return(XML_CHAR_ENCODING_UTF8);
return(XML_CHAR_ENCODING_NONE);
}
/**
* xmlParseCharEncoding:
* @name: the encoding name as parsed, in UTF-8 format (ASCCI actually)
*
* Conpare the string to the known encoding schemes already known. Note
* that the comparison is case insensitive accordingly to the section
* [XML] 4.3.3 Character Encoding in Entities.
*
* Returns one of the XML_CHAR_ENCODING_... values or XML_CHAR_ENCODING_NONE
* if not recognized.
*/
xmlCharEncoding
xmlParseCharEncoding(char* name)
{
char upper[500];
int i;
for (i = 0;i < 499;i++) {
upper[i] = toupper(name[i]);
if (upper[i] == 0) break;
}
upper[i] = 0;
if (!strcmp(upper, "")) return(XML_CHAR_ENCODING_NONE);
if (!strcmp(upper, "UTF-8")) return(XML_CHAR_ENCODING_UTF8);
if (!strcmp(upper, "UTF8")) return(XML_CHAR_ENCODING_UTF8);
/*
* NOTE: if we were able to parse this, the endianness of UTF16 is
* already found and in use
*/
if (!strcmp(upper, "UTF-16")) return(XML_CHAR_ENCODING_UTF16LE);
if (!strcmp(upper, "UTF16")) return(XML_CHAR_ENCODING_UTF16LE);
if (!strcmp(upper, "ISO-10646-UCS-2")) return(XML_CHAR_ENCODING_UCS2);
if (!strcmp(upper, "UCS-2")) return(XML_CHAR_ENCODING_UCS2);
if (!strcmp(upper, "UCS2")) return(XML_CHAR_ENCODING_UCS2);
/*
* NOTE: if we were able to parse this, the endianness of UCS4 is
* already found and in use
*/
if (!strcmp(upper, "ISO-10646-UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
if (!strcmp(upper, "UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
if (!strcmp(upper, "UCS4")) return(XML_CHAR_ENCODING_UCS4LE);
if (!strcmp(upper, "ISO-8859-1")) return(XML_CHAR_ENCODING_8859_1);
if (!strcmp(upper, "ISO-LATIN-1")) return(XML_CHAR_ENCODING_8859_1);
if (!strcmp(upper, "ISO LATIN 1")) return(XML_CHAR_ENCODING_8859_1);
if (!strcmp(upper, "ISO-8859-2")) return(XML_CHAR_ENCODING_8859_2);
if (!strcmp(upper, "ISO-LATIN-2")) return(XML_CHAR_ENCODING_8859_2);
if (!strcmp(upper, "ISO LATIN 2")) return(XML_CHAR_ENCODING_8859_2);
if (!strcmp(upper, "ISO-8859-3")) return(XML_CHAR_ENCODING_8859_3);
if (!strcmp(upper, "ISO-8859-4")) return(XML_CHAR_ENCODING_8859_4);
if (!strcmp(upper, "ISO-8859-5")) return(XML_CHAR_ENCODING_8859_5);
if (!strcmp(upper, "ISO-8859-6")) return(XML_CHAR_ENCODING_8859_6);
if (!strcmp(upper, "ISO-8859-7")) return(XML_CHAR_ENCODING_8859_7);
if (!strcmp(upper, "ISO-8859-8")) return(XML_CHAR_ENCODING_8859_8);
if (!strcmp(upper, "ISO-8859-9")) return(XML_CHAR_ENCODING_8859_9);
if (!strcmp(upper, "ISO-2022-JP")) return(XML_CHAR_ENCODING_2022_JP);
if (!strcmp(upper, "Shift_JIS")) return(XML_CHAR_ENCODING_SHIFT_JIS);
if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
return(XML_CHAR_ENCODING_ERROR);
}

View File

@ -13,22 +13,49 @@
* [US-ASCII] Coded Character Set--7-bit American Standard Code for * [US-ASCII] Coded Character Set--7-bit American Standard Code for
* Information Interchange, ANSI X3.4-1986. * Information Interchange, ANSI X3.4-1986.
* *
* Original code from "Martin J. Duerst" <duerst@w3.org>
*
* See Copyright for the status of this software. * See Copyright for the status of this software.
* *
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifndef __XML_ENCODING_H__ #ifndef __XML_CHAR_ENCODING_H__
#define __XML_ENCODING_H__ #define __XML_CHAR_ENCODING_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
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 */
} xmlCharEncoding;
extern xmlCharEncoding xmlDetectCharEncoding(unsigned char* in);
extern xmlCharEncoding xmlParseCharEncoding(char* name);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __XML_ENCODING_H__ */ #endif /* __XML_CHAR_ENCODING_H__ */

View File

@ -20,8 +20,9 @@
* extra parameters. * extra parameters.
*/ */
void void
xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...) xmlParserError(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
const CHAR *cur, *base; const CHAR *cur, *base;
va_list args; va_list args;
int n; int n;
@ -73,8 +74,9 @@ xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...)
* extra parameters. * extra parameters.
*/ */
void void
xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...) xmlParserWarning(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
const CHAR *cur, *base; const CHAR *cur, *base;
va_list args; va_list args;
int n; int n;

View File

@ -13,22 +13,49 @@
* [US-ASCII] Coded Character Set--7-bit American Standard Code for * [US-ASCII] Coded Character Set--7-bit American Standard Code for
* Information Interchange, ANSI X3.4-1986. * Information Interchange, ANSI X3.4-1986.
* *
* Original code from "Martin J. Duerst" <duerst@w3.org>
*
* See Copyright for the status of this software. * See Copyright for the status of this software.
* *
* Daniel.Veillard@w3.org * Daniel.Veillard@w3.org
*/ */
#ifndef __XML_ENCODING_H__ #ifndef __XML_CHAR_ENCODING_H__
#define __XML_ENCODING_H__ #define __XML_CHAR_ENCODING_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
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 */
} xmlCharEncoding;
extern xmlCharEncoding xmlDetectCharEncoding(unsigned char* in);
extern xmlCharEncoding xmlParseCharEncoding(char* name);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __XML_ENCODING_H__ */ #endif /* __XML_CHAR_ENCODING_H__ */

View File

@ -81,10 +81,10 @@ typedef xmlParserCtxt *xmlParserCtxtPtr;
*/ */
typedef struct xmlSAXLocator { typedef struct xmlSAXLocator {
const CHAR *(*getPublicId)(xmlParserCtxtPtr ctxt); const CHAR *(*getPublicId)(void *ctx);
const CHAR *(*getSystemId)(xmlParserCtxtPtr ctxt); const CHAR *(*getSystemId)(void *ctx);
int (*getLineNumber)(xmlParserCtxtPtr ctxt); int (*getLineNumber)(void *ctx);
int (*getColumnNumber)(xmlParserCtxtPtr ctxt); int (*getColumnNumber)(void *ctx);
} _xmlSAXLocator; } _xmlSAXLocator;
typedef _xmlSAXLocator xmlSAXLocator; typedef _xmlSAXLocator xmlSAXLocator;
typedef xmlSAXLocator *xmlSAXLocatorPtr; typedef xmlSAXLocator *xmlSAXLocatorPtr;
@ -95,48 +95,48 @@ typedef xmlSAXLocator *xmlSAXLocatorPtr;
#include "entities.h" #include "entities.h"
typedef xmlParserInputPtr (*resolveEntitySAXFunc) (xmlParserCtxtPtr ctxt, typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
const CHAR *publicId, const CHAR *systemId); const CHAR *publicId, const CHAR *systemId);
typedef void (*internalSubsetSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*internalSubsetSAXFunc) (void *ctx, const CHAR *name,
const CHAR *ExternalID, const CHAR *SystemID); const CHAR *ExternalID, const CHAR *SystemID);
typedef xmlEntityPtr (*getEntitySAXFunc) (xmlParserCtxtPtr ctxt, typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
const CHAR *name); const CHAR *name);
typedef void (*entityDeclSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*entityDeclSAXFunc) (void *ctx,
const CHAR *name, int type, const CHAR *publicId, const CHAR *name, int type, const CHAR *publicId,
const CHAR *systemId, CHAR *content); const CHAR *systemId, CHAR *content);
typedef void (*notationDeclSAXFunc)(xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*notationDeclSAXFunc)(void *ctx, const CHAR *name,
const CHAR *publicId, const CHAR *systemId); const CHAR *publicId, const CHAR *systemId);
typedef void (*attributeDeclSAXFunc)(xmlParserCtxtPtr ctxt, const CHAR *elem, typedef void (*attributeDeclSAXFunc)(void *ctx, const CHAR *elem,
const CHAR *name, int type, int def, const CHAR *name, int type, int def,
const CHAR *defaultValue, xmlEnumerationPtr tree); const CHAR *defaultValue, xmlEnumerationPtr tree);
typedef void (*elementDeclSAXFunc)(xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*elementDeclSAXFunc)(void *ctx, const CHAR *name,
int type, xmlElementContentPtr content); int type, xmlElementContentPtr content);
typedef void (*unparsedEntityDeclSAXFunc)(xmlParserCtxtPtr ctxt, typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
const CHAR *name, const CHAR *publicId, const CHAR *name, const CHAR *publicId,
const CHAR *systemId, const CHAR *notationName); const CHAR *systemId, const CHAR *notationName);
typedef void (*setDocumentLocatorSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
xmlSAXLocatorPtr loc); xmlSAXLocatorPtr loc);
typedef void (*startDocumentSAXFunc) (xmlParserCtxtPtr ctxt); typedef void (*startDocumentSAXFunc) (void *ctx);
typedef void (*endDocumentSAXFunc) (xmlParserCtxtPtr ctxt); typedef void (*endDocumentSAXFunc) (void *ctx);
typedef void (*startElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*startElementSAXFunc) (void *ctx, const CHAR *name,
const CHAR **atts); const CHAR **atts);
typedef void (*endElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name); typedef void (*endElementSAXFunc) (void *ctx, const CHAR *name);
typedef void (*attributeSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*attributeSAXFunc) (void *ctx, const CHAR *name,
const CHAR *value); const CHAR *value);
typedef void (*referenceSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name); typedef void (*referenceSAXFunc) (void *ctx, const CHAR *name);
typedef void (*charactersSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *ch, typedef void (*charactersSAXFunc) (void *ctx, const CHAR *ch,
int len); int len);
typedef void (*ignorableWhitespaceSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
const CHAR *ch, int len); const CHAR *ch, int len);
typedef void (*processingInstructionSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*processingInstructionSAXFunc) (void *ctx,
const CHAR *target, const CHAR *data); const CHAR *target, const CHAR *data);
typedef void (*commentSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *value); typedef void (*commentSAXFunc) (void *ctx, const CHAR *value);
typedef void (*warningSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...); typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
typedef void (*errorSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...); typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
typedef void (*fatalErrorSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...); typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
typedef int (*isStandaloneSAXFunc) (xmlParserCtxtPtr ctxt); typedef int (*isStandaloneSAXFunc) (void *ctx);
typedef int (*hasInternalSubsetSAXFunc) (xmlParserCtxtPtr ctxt); typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
typedef int (*hasExternalSubsetSAXFunc) (xmlParserCtxtPtr ctxt); typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
typedef struct xmlSAXHandler { typedef struct xmlSAXHandler {
internalSubsetSAXFunc internalSubset; internalSubsetSAXFunc internalSubset;

493
parser.c

File diff suppressed because it is too large Load Diff

View File

@ -81,10 +81,10 @@ typedef xmlParserCtxt *xmlParserCtxtPtr;
*/ */
typedef struct xmlSAXLocator { typedef struct xmlSAXLocator {
const CHAR *(*getPublicId)(xmlParserCtxtPtr ctxt); const CHAR *(*getPublicId)(void *ctx);
const CHAR *(*getSystemId)(xmlParserCtxtPtr ctxt); const CHAR *(*getSystemId)(void *ctx);
int (*getLineNumber)(xmlParserCtxtPtr ctxt); int (*getLineNumber)(void *ctx);
int (*getColumnNumber)(xmlParserCtxtPtr ctxt); int (*getColumnNumber)(void *ctx);
} _xmlSAXLocator; } _xmlSAXLocator;
typedef _xmlSAXLocator xmlSAXLocator; typedef _xmlSAXLocator xmlSAXLocator;
typedef xmlSAXLocator *xmlSAXLocatorPtr; typedef xmlSAXLocator *xmlSAXLocatorPtr;
@ -95,48 +95,48 @@ typedef xmlSAXLocator *xmlSAXLocatorPtr;
#include "entities.h" #include "entities.h"
typedef xmlParserInputPtr (*resolveEntitySAXFunc) (xmlParserCtxtPtr ctxt, typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
const CHAR *publicId, const CHAR *systemId); const CHAR *publicId, const CHAR *systemId);
typedef void (*internalSubsetSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*internalSubsetSAXFunc) (void *ctx, const CHAR *name,
const CHAR *ExternalID, const CHAR *SystemID); const CHAR *ExternalID, const CHAR *SystemID);
typedef xmlEntityPtr (*getEntitySAXFunc) (xmlParserCtxtPtr ctxt, typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
const CHAR *name); const CHAR *name);
typedef void (*entityDeclSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*entityDeclSAXFunc) (void *ctx,
const CHAR *name, int type, const CHAR *publicId, const CHAR *name, int type, const CHAR *publicId,
const CHAR *systemId, CHAR *content); const CHAR *systemId, CHAR *content);
typedef void (*notationDeclSAXFunc)(xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*notationDeclSAXFunc)(void *ctx, const CHAR *name,
const CHAR *publicId, const CHAR *systemId); const CHAR *publicId, const CHAR *systemId);
typedef void (*attributeDeclSAXFunc)(xmlParserCtxtPtr ctxt, const CHAR *elem, typedef void (*attributeDeclSAXFunc)(void *ctx, const CHAR *elem,
const CHAR *name, int type, int def, const CHAR *name, int type, int def,
const CHAR *defaultValue, xmlEnumerationPtr tree); const CHAR *defaultValue, xmlEnumerationPtr tree);
typedef void (*elementDeclSAXFunc)(xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*elementDeclSAXFunc)(void *ctx, const CHAR *name,
int type, xmlElementContentPtr content); int type, xmlElementContentPtr content);
typedef void (*unparsedEntityDeclSAXFunc)(xmlParserCtxtPtr ctxt, typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
const CHAR *name, const CHAR *publicId, const CHAR *name, const CHAR *publicId,
const CHAR *systemId, const CHAR *notationName); const CHAR *systemId, const CHAR *notationName);
typedef void (*setDocumentLocatorSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
xmlSAXLocatorPtr loc); xmlSAXLocatorPtr loc);
typedef void (*startDocumentSAXFunc) (xmlParserCtxtPtr ctxt); typedef void (*startDocumentSAXFunc) (void *ctx);
typedef void (*endDocumentSAXFunc) (xmlParserCtxtPtr ctxt); typedef void (*endDocumentSAXFunc) (void *ctx);
typedef void (*startElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*startElementSAXFunc) (void *ctx, const CHAR *name,
const CHAR **atts); const CHAR **atts);
typedef void (*endElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name); typedef void (*endElementSAXFunc) (void *ctx, const CHAR *name);
typedef void (*attributeSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name, typedef void (*attributeSAXFunc) (void *ctx, const CHAR *name,
const CHAR *value); const CHAR *value);
typedef void (*referenceSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name); typedef void (*referenceSAXFunc) (void *ctx, const CHAR *name);
typedef void (*charactersSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *ch, typedef void (*charactersSAXFunc) (void *ctx, const CHAR *ch,
int len); int len);
typedef void (*ignorableWhitespaceSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
const CHAR *ch, int len); const CHAR *ch, int len);
typedef void (*processingInstructionSAXFunc) (xmlParserCtxtPtr ctxt, typedef void (*processingInstructionSAXFunc) (void *ctx,
const CHAR *target, const CHAR *data); const CHAR *target, const CHAR *data);
typedef void (*commentSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *value); typedef void (*commentSAXFunc) (void *ctx, const CHAR *value);
typedef void (*warningSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...); typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
typedef void (*errorSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...); typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
typedef void (*fatalErrorSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...); typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
typedef int (*isStandaloneSAXFunc) (xmlParserCtxtPtr ctxt); typedef int (*isStandaloneSAXFunc) (void *ctx);
typedef int (*hasInternalSubsetSAXFunc) (xmlParserCtxtPtr ctxt); typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
typedef int (*hasExternalSubsetSAXFunc) (xmlParserCtxtPtr ctxt); typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
typedef struct xmlSAXHandler { typedef struct xmlSAXHandler {
internalSubsetSAXFunc internalSubset; internalSubsetSAXFunc internalSubset;

View File

@ -104,7 +104,7 @@ static CHAR buffer[] =
int int
isStandaloneDebug(xmlParserCtxtPtr ctxt) isStandaloneDebug(xmlParserCtxtPtr ctxt)
{ {
fprintf(stderr, "SAX.isStandalone()\n"); fprintf(stdout, "SAX.isStandalone()\n");
return(0); return(0);
} }
@ -119,7 +119,7 @@ isStandaloneDebug(xmlParserCtxtPtr ctxt)
int int
hasInternalSubsetDebug(xmlParserCtxtPtr ctxt) hasInternalSubsetDebug(xmlParserCtxtPtr ctxt)
{ {
fprintf(stderr, "SAX.hasInternalSubset()\n"); fprintf(stdout, "SAX.hasInternalSubset()\n");
return(0); return(0);
} }
@ -134,7 +134,7 @@ hasInternalSubsetDebug(xmlParserCtxtPtr ctxt)
int int
hasExternalSubsetDebug(xmlParserCtxtPtr ctxt) hasExternalSubsetDebug(xmlParserCtxtPtr ctxt)
{ {
fprintf(stderr, "SAX.hasExternalSubset()\n"); fprintf(stdout, "SAX.hasExternalSubset()\n");
return(0); return(0);
} }
@ -148,7 +148,7 @@ void
internalSubsetDebug(xmlParserCtxtPtr ctxt, const CHAR *name, internalSubsetDebug(xmlParserCtxtPtr ctxt, const CHAR *name,
const CHAR *ExternalID, const CHAR *SystemID) const CHAR *ExternalID, const CHAR *SystemID)
{ {
fprintf(stderr, "SAX.internalSubset(%s, %s, %s)\n", fprintf(stdout, "SAX.internalSubset(%s, %s, %s)\n",
name, ExternalID, SystemID); name, ExternalID, SystemID);
} }
@ -169,7 +169,7 @@ internalSubsetDebug(xmlParserCtxtPtr ctxt, const CHAR *name,
xmlParserInputPtr xmlParserInputPtr
resolveEntityDebug(xmlParserCtxtPtr ctxt, const CHAR *publicId, const CHAR *systemId) resolveEntityDebug(xmlParserCtxtPtr ctxt, const CHAR *publicId, const CHAR *systemId)
{ {
fprintf(stderr, "SAX.resolveEntity(%s, %s)\n", fprintf(stdout, "SAX.resolveEntity(%s, %s)\n",
(char *)publicId, (char *)systemId); (char *)publicId, (char *)systemId);
return(NULL); return(NULL);
} }
@ -186,7 +186,7 @@ resolveEntityDebug(xmlParserCtxtPtr ctxt, const CHAR *publicId, const CHAR *syst
xmlEntityPtr xmlEntityPtr
getEntityDebug(xmlParserCtxtPtr ctxt, const CHAR *name) getEntityDebug(xmlParserCtxtPtr ctxt, const CHAR *name)
{ {
fprintf(stderr, "SAX.getEntity(%s)\n", name); fprintf(stdout, "SAX.getEntity(%s)\n", name);
return(NULL); return(NULL);
} }
@ -206,7 +206,7 @@ void
entityDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *name, int type, entityDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *name, int type,
const CHAR *publicId, const CHAR *systemId, CHAR *content) const CHAR *publicId, const CHAR *systemId, CHAR *content)
{ {
fprintf(stderr, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
name, type, publicId, systemId, content); name, type, publicId, systemId, content);
} }
@ -223,7 +223,7 @@ attributeDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *elem, const CHAR *name,
int type, int def, const CHAR *defaultValue, int type, int def, const CHAR *defaultValue,
xmlEnumerationPtr tree) xmlEnumerationPtr tree)
{ {
fprintf(stderr, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
elem, name, type, def, defaultValue); elem, name, type, def, defaultValue);
} }
@ -240,7 +240,7 @@ void
elementDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *name, int type, elementDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *name, int type,
xmlElementContentPtr content) xmlElementContentPtr content)
{ {
fprintf(stderr, "SAX.elementDecl(%s, %d, ...)\n", fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
name, type); name, type);
} }
@ -258,7 +258,7 @@ void
notationDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *name, notationDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *name,
const CHAR *publicId, const CHAR *systemId) const CHAR *publicId, const CHAR *systemId)
{ {
fprintf(stderr, "SAX.notationDecl(%s, %s, %s)\n", fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
(char *) name, (char *) publicId, (char *) systemId); (char *) name, (char *) publicId, (char *) systemId);
} }
@ -278,7 +278,7 @@ unparsedEntityDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *name,
const CHAR *publicId, const CHAR *systemId, const CHAR *publicId, const CHAR *systemId,
const CHAR *notationName) const CHAR *notationName)
{ {
fprintf(stderr, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
(char *) name, (char *) publicId, (char *) systemId, (char *) name, (char *) publicId, (char *) systemId,
(char *) notationName); (char *) notationName);
} }
@ -294,7 +294,7 @@ unparsedEntityDeclDebug(xmlParserCtxtPtr ctxt, const CHAR *name,
void void
setDocumentLocatorDebug(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc) setDocumentLocatorDebug(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc)
{ {
fprintf(stderr, "SAX.setDocumentLocator()\n"); fprintf(stdout, "SAX.setDocumentLocator()\n");
} }
/** /**
@ -306,7 +306,7 @@ setDocumentLocatorDebug(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc)
void void
startDocumentDebug(xmlParserCtxtPtr ctxt) startDocumentDebug(xmlParserCtxtPtr ctxt)
{ {
fprintf(stderr, "SAX.startDocument()\n"); fprintf(stdout, "SAX.startDocument()\n");
} }
/** /**
@ -318,7 +318,7 @@ startDocumentDebug(xmlParserCtxtPtr ctxt)
void void
endDocumentDebug(xmlParserCtxtPtr ctxt) endDocumentDebug(xmlParserCtxtPtr ctxt)
{ {
fprintf(stderr, "SAX.endDocument()\n"); fprintf(stdout, "SAX.endDocument()\n");
} }
/** /**
@ -334,14 +334,14 @@ startElementDebug(xmlParserCtxtPtr ctxt, const CHAR *name, const CHAR **atts)
{ {
int i; int i;
fprintf(stderr, "SAX.startElement(%s", (char *) name); fprintf(stdout, "SAX.startElement(%s", (char *) name);
if (atts != NULL) { if (atts != NULL) {
for (i = 0;(atts[i] != NULL);i++) { for (i = 0;(atts[i] != NULL);i++) {
fprintf(stderr, ", %s='", atts[i++]); fprintf(stdout, ", %s='", atts[i++]);
fprintf(stderr, "%s'", atts[i]); fprintf(stdout, "%s'", atts[i]);
} }
} }
fprintf(stderr, ")\n"); fprintf(stdout, ")\n");
} }
/** /**
@ -354,7 +354,7 @@ startElementDebug(xmlParserCtxtPtr ctxt, const CHAR *name, const CHAR **atts)
void void
endElementDebug(xmlParserCtxtPtr ctxt, const CHAR *name) endElementDebug(xmlParserCtxtPtr ctxt, const CHAR *name)
{ {
fprintf(stderr, "SAX.endElement(%s)\n", (char *) name); fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
} }
/** /**
@ -369,7 +369,7 @@ endElementDebug(xmlParserCtxtPtr ctxt, const CHAR *name)
void void
charactersDebug(xmlParserCtxtPtr ctxt, const CHAR *ch, int len) charactersDebug(xmlParserCtxtPtr ctxt, const CHAR *ch, int len)
{ {
fprintf(stderr, "SAX.characters(%.30s, %d)\n", (char *) ch, len); fprintf(stdout, "SAX.characters(%.30s, %d)\n", (char *) ch, len);
} }
/** /**
@ -382,7 +382,7 @@ charactersDebug(xmlParserCtxtPtr ctxt, const CHAR *ch, int len)
void void
referenceDebug(xmlParserCtxtPtr ctxt, const CHAR *name) referenceDebug(xmlParserCtxtPtr ctxt, const CHAR *name)
{ {
fprintf(stderr, "SAX.reference(%s)\n", name); fprintf(stdout, "SAX.reference(%s)\n", name);
} }
/** /**
@ -398,7 +398,7 @@ referenceDebug(xmlParserCtxtPtr ctxt, const CHAR *name)
void void
ignorableWhitespaceDebug(xmlParserCtxtPtr ctxt, const CHAR *ch, int len) ignorableWhitespaceDebug(xmlParserCtxtPtr ctxt, const CHAR *ch, int len)
{ {
fprintf(stderr, "SAX.ignorableWhitespace(%.30s, %d)\n", fprintf(stdout, "SAX.ignorableWhitespace(%.30s, %d)\n",
(char *) ch, len); (char *) ch, len);
} }
@ -415,7 +415,7 @@ void
processingInstructionDebug(xmlParserCtxtPtr ctxt, const CHAR *target, processingInstructionDebug(xmlParserCtxtPtr ctxt, const CHAR *target,
const CHAR *data) const CHAR *data)
{ {
fprintf(stderr, "SAX.processingInstruction(%s, %s)\n", fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
(char *) target, (char *) data); (char *) target, (char *) data);
} }
@ -429,7 +429,7 @@ processingInstructionDebug(xmlParserCtxtPtr ctxt, const CHAR *target,
void void
commentDebug(xmlParserCtxtPtr ctxt, const CHAR *value) commentDebug(xmlParserCtxtPtr ctxt, const CHAR *value)
{ {
fprintf(stderr, "SAX.comment(%s)\n", value); fprintf(stdout, "SAX.comment(%s)\n", value);
} }
/** /**
@ -447,8 +447,8 @@ warningDebug(xmlParserCtxtPtr ctxt, const char *msg, ...)
va_list args; va_list args;
va_start(args, msg); va_start(args, msg);
fprintf(stderr, "SAX.warning: "); fprintf(stdout, "SAX.warning: ");
vfprintf(stderr, msg, args); vfprintf(stdout, msg, args);
va_end(args); va_end(args);
} }
@ -467,8 +467,8 @@ errorDebug(xmlParserCtxtPtr ctxt, const char *msg, ...)
va_list args; va_list args;
va_start(args, msg); va_start(args, msg);
fprintf(stderr, "SAX.error: "); fprintf(stdout, "SAX.error: ");
vfprintf(stderr, msg, args); vfprintf(stdout, msg, args);
va_end(args); va_end(args);
} }
@ -487,8 +487,8 @@ fatalErrorDebug(xmlParserCtxtPtr ctxt, const char *msg, ...)
va_list args; va_list args;
va_start(args, msg); va_start(args, msg);
fprintf(stderr, "SAX.fatalError: "); fprintf(stdout, "SAX.fatalError: ");
vfprintf(stderr, msg, args); vfprintf(stdout, msg, args);
va_end(args); va_end(args);
} }
@ -535,7 +535,7 @@ void parseAndPrintFile(char *filename) {
*/ */
doc = xmlSAXParseFile(emptySAXHandler, filename, 0); doc = xmlSAXParseFile(emptySAXHandler, filename, 0);
if (doc != NULL) { if (doc != NULL) {
fprintf(stderr, "xmlSAXParseFile returned non-NULL\n"); fprintf(stdout, "xmlSAXParseFile returned non-NULL\n");
xmlDocDump(stdout, doc); xmlDocDump(stdout, doc);
} }

12
tree.c
View File

@ -395,7 +395,7 @@ xmlNewDoc(const CHAR *version) {
cur->encoding = NULL; cur->encoding = NULL;
cur->standalone = -1; cur->standalone = -1;
cur->compression = xmlCompressMode; cur->compression = xmlCompressMode;
#ifndef WITHOUT_CORBA #ifndef XML_WITHOUT_CORBA
cur->_private = NULL; cur->_private = NULL;
cur->vepv = NULL; cur->vepv = NULL;
#endif #endif
@ -736,7 +736,7 @@ xmlNewProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
cur->val = xmlStringGetNodeList(node->doc, value); cur->val = xmlStringGetNodeList(node->doc, value);
else else
cur->val = NULL; cur->val = NULL;
#ifndef WITHOUT_CORBA #ifndef XML_WITHOUT_CORBA
cur->_private = NULL; cur->_private = NULL;
cur->vepv = NULL; cur->vepv = NULL;
#endif #endif
@ -792,7 +792,7 @@ xmlNewDocProp(xmlDocPtr doc, const CHAR *name, const CHAR *value) {
cur->val = xmlStringGetNodeList(doc, value); cur->val = xmlStringGetNodeList(doc, value);
else else
cur->val = NULL; cur->val = NULL;
#ifndef WITHOUT_CORBA #ifndef XML_WITHOUT_CORBA
cur->_private = NULL; cur->_private = NULL;
cur->vepv = NULL; cur->vepv = NULL;
#endif #endif
@ -879,7 +879,7 @@ xmlNewNode(xmlNsPtr ns, const CHAR *name) {
cur->ns = ns; cur->ns = ns;
cur->nsDef = NULL; cur->nsDef = NULL;
cur->content = NULL; cur->content = NULL;
#ifndef WITHOUT_CORBA #ifndef XML_WITHOUT_CORBA
cur->_private = NULL; cur->_private = NULL;
cur->vepv = NULL; cur->vepv = NULL;
#endif #endif
@ -1502,7 +1502,7 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
ret->content = xmlStrdup(node->content); ret->content = xmlStrdup(node->content);
else else
ret->content = NULL; ret->content = NULL;
#ifndef WITHOUT_CORBA #ifndef XML_WITHOUT_CORBA
ret->_private = NULL; ret->_private = NULL;
ret->vepv = NULL; ret->vepv = NULL;
#endif #endif
@ -2776,9 +2776,7 @@ xmlSaveFile(const char *filename, xmlDocPtr cur) {
if (output == NULL) return(-1); if (output == NULL) return(-1);
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
} }
#endif
#ifdef HAVE_ZLIB_H
if (zoutput != NULL) { if (zoutput != NULL) {
ret = gzwrite(zoutput, buf->content, sizeof(CHAR) * buf->use); ret = gzwrite(zoutput, buf->content, sizeof(CHAR) * buf->use);
gzclose(zoutput); gzclose(zoutput);

View File

@ -3,6 +3,6 @@
#include "parser.h" #include "parser.h"
void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...); void xmlParserError(void *ctx, const char *msg, ...);
void xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...); void xmlParserWarning(void *ctx, const char *msg, ...);
#endif #endif