Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f9225a9f9 | ||
|
|
14196603ad | ||
|
|
7c0757fca2 | ||
|
|
9aad851790 | ||
|
|
04cd15b799 | ||
|
|
694bd5eee6 | ||
|
|
e1f854bf51 | ||
|
|
02b12ad251 | ||
|
|
46d579b2e1 | ||
|
|
347d0b6ceb | ||
|
|
2710006ea0 | ||
|
|
547d3c98b4 | ||
|
|
cd75a27f88 | ||
|
|
a7b896abe0 | ||
|
|
ad2d74caba | ||
|
|
08d228d266 | ||
|
|
e98eefc69a | ||
|
|
39603886d3 | ||
|
|
cc0924046a | ||
|
|
1494a6f171 | ||
|
|
3a67e90581 | ||
|
|
045a818850 | ||
|
|
f13f1077fb | ||
|
|
bae91258a3 | ||
|
|
7d44233713 | ||
|
|
ffcfea14b7 | ||
|
|
2aad4e436b | ||
|
|
7023da1906 | ||
|
|
845dd4dd8b | ||
|
|
13594c689a | ||
|
|
74d8ff5b12 | ||
|
|
5bfaa295f9 | ||
|
|
4b4d90b06b | ||
|
|
11d8095453 | ||
|
|
3ada492532 | ||
|
|
1fb7b5aba9 | ||
|
|
0a2a79e3fc | ||
|
|
d38b08addb | ||
|
|
48911f1641 | ||
|
|
f2e213ee4b | ||
|
|
f603b68156 | ||
|
|
b2eb817999 | ||
|
|
1e657b6c6d | ||
|
|
2967177479 | ||
|
|
9d6ef1e3c7 | ||
|
|
ee62d4d2b1 | ||
|
|
c7bfa55f73 | ||
|
|
68db987c6e | ||
|
|
7b4a0046ea | ||
|
|
ee0c6abbc1 | ||
|
|
bf7110f695 | ||
|
|
237b292db2 | ||
|
|
b395aa3afb | ||
|
|
56d37f2f38 | ||
|
|
c6b194cd9a | ||
|
|
95bcf45ce3 | ||
|
|
3d10abbb60 | ||
|
|
0ea7c9e866 | ||
|
|
9d6a61899d | ||
|
|
50b15d16b7 | ||
|
|
e5deda3f60 | ||
|
|
65fc545d5e | ||
|
|
ca00d00f4d | ||
|
|
6203e0f8ca | ||
|
|
fc76b09ee5 | ||
|
|
947cd0feac | ||
|
|
73b6649f5d | ||
|
|
4b6140b0df | ||
|
|
5a9da0c257 | ||
|
|
3f4d87b03a | ||
|
|
9d1e96afa4 | ||
|
|
950a6547e4 | ||
|
|
41fe3243ca | ||
|
|
1533718a38 | ||
|
|
a277259658 | ||
|
|
237bbb9584 | ||
|
|
58f34c124c | ||
|
|
19fa93c230 | ||
|
|
4b1b0a110c | ||
|
|
c332060f43 | ||
|
|
fe3c72da7a | ||
|
|
2b1702456d | ||
|
|
9f52171901 | ||
|
|
dac8f8295d | ||
|
|
f5f79a12ae | ||
|
|
6f563b2256 | ||
|
|
34b47abda7 | ||
|
|
2844be94b7 | ||
|
|
75405cf655 | ||
|
|
bb130e9e28 | ||
|
|
3b69eb5b92 | ||
|
|
22795a8755 | ||
|
|
7f3efb4802 | ||
|
|
9e81312f63 | ||
|
|
fecf35cf44 | ||
|
|
89687a2bfd | ||
|
|
80b4895ce5 | ||
|
|
5700ecb60f | ||
|
|
78d38a3fd0 | ||
|
|
2c080dd19f | ||
|
|
d78e5baa21 | ||
|
|
38dc320552 | ||
|
|
508f4e99ee | ||
|
|
99eba7a16d | ||
|
|
0ee12e8045 | ||
|
|
9e2bdba5fb | ||
|
|
42bd1cb01c | ||
|
|
5c3919e6bf | ||
|
|
1f49d0a366 | ||
|
|
e2ae0f492d | ||
|
|
b720028b85 | ||
|
|
03f202d614 | ||
|
|
650ce08322 | ||
|
|
939ec46566 | ||
|
|
0e864d50fb | ||
|
|
d38e459410 | ||
|
|
069c00e820 | ||
|
|
6b733b9b87 | ||
|
|
84835ac373 | ||
|
|
e8ac3d8f5f | ||
|
|
7ce4d1b852 | ||
|
|
3e3f6bb7f2 | ||
|
|
f310fb4ab9 | ||
|
|
0fe1372234 | ||
|
|
10c3740f1e | ||
|
|
9efc5049a8 | ||
|
|
3a10246912 | ||
|
|
496af54711 | ||
|
|
698686457e | ||
|
|
c83cd08a8e | ||
|
|
6ff56dc9dc | ||
|
|
28bbc4f64f | ||
|
|
0f3e24272f | ||
|
|
3bddd238db | ||
|
|
7eadec98df | ||
|
|
40962ad8af | ||
|
|
a2625a0572 | ||
|
|
5b77f426ee | ||
|
|
c230dddef9 | ||
|
|
583f937102 | ||
|
|
05fd715a12 | ||
|
|
06fb5cebe8 |
+8
-1
@@ -1,11 +1,18 @@
|
||||
CC=gcc
|
||||
CFLAGS=-O2 -Ixmltok -Ixmlparse
|
||||
# If you know what your system's byte order is, define BYTE_ORDER:
|
||||
# use -DBYTE_ORDER=12 for little-endian byte order;
|
||||
# use -DBYTE_ORDER=21 for big-endian (network) byte order.
|
||||
# -DXML_NS adds support for checking of lexical aspects of XML namespaces spec
|
||||
# -DXML_MIN_SIZE makes a smaller but slower parser
|
||||
CFLAGS=-O2 -Ixmltok -Ixmlparse -DXML_NS
|
||||
# Use one of the next two lines; unixfilemap is better if it works.
|
||||
FILEMAP_OBJ=xmlwf/unixfilemap.o
|
||||
#FILEMAP_OBJ=xmlwf/readfilemap.o
|
||||
OBJS=xmltok/xmltok.o \
|
||||
xmltok/xmlrole.o \
|
||||
xmlwf/xmlwf.o \
|
||||
xmlwf/xmlfile.o \
|
||||
xmlwf/codepage.o \
|
||||
xmlparse/xmlparse.o \
|
||||
xmlparse/hashtable.o \
|
||||
$(FILEMAP_OBJ)
|
||||
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
/* This is simple demonstration of how to use expat. This program
|
||||
reads an XML document from standard input and writes a line with the
|
||||
name of each element to standard output indenting child elements by
|
||||
one tab stop more than their parent element. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "xmlparse.h"
|
||||
|
||||
void startElement(void *userData, const char *name, const char **atts)
|
||||
{
|
||||
int i;
|
||||
int *depthPtr = userData;
|
||||
for (i = 0; i < *depthPtr; i++)
|
||||
putchar('\t');
|
||||
puts(name);
|
||||
*depthPtr += 1;
|
||||
}
|
||||
|
||||
void endElement(void *userData, const char *name)
|
||||
{
|
||||
int *depthPtr = userData;
|
||||
*depthPtr -= 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
XML_Parser parser = XML_ParserCreate(NULL);
|
||||
int done;
|
||||
int depth = 0;
|
||||
XML_SetUserData(parser, &depth);
|
||||
XML_SetElementHandler(parser, startElement, endElement);
|
||||
do {
|
||||
size_t len = fread(buf, 1, sizeof(buf), stdin);
|
||||
done = len < sizeof(buf);
|
||||
if (!XML_Parse(parser, buf, len, done)) {
|
||||
fprintf(stderr,
|
||||
"%s at line %d\n",
|
||||
XML_ErrorString(XML_GetErrorCode(parser)),
|
||||
XML_GetCurrentLineNumber(parser));
|
||||
return 1;
|
||||
}
|
||||
} while (!done);
|
||||
XML_ParserFree(parser);
|
||||
return 0;
|
||||
}
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
set LIB=..\xmlparse\Release;..\xmltok\Release;..\lib;%LIB%
|
||||
set INCLUDE=..\xmlparse;..\xmltok;%INCLUDE%
|
||||
set CL=/nologo /DXMLTOKAPI=__declspec(dllimport) /DXMLPARSEAPI=__declspec(dllimport) xmlparse.lib xmltok.lib
|
||||
cl /Fe..\bin\demo demo.c
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "gennmtab"=".\gennmtab\gennmtab.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "xmlparse"=".\xmlparse\xmlparse.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name xmltok
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "xmltok"=".\xmltok\xmltok.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "xmlwf"=".\xmlwf\xmlwf.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name xmlparse
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
+45
-23
@@ -1,30 +1,41 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
|
||||
<HTML>
|
||||
|
||||
<TITLE>expat</TITLE>
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1>expat - XML Parser Toolkit</H1>
|
||||
<H3>Version 19980514</H3>
|
||||
<P>
|
||||
Copyright (c) 1998 James Clark. Expat is subject to the <A
|
||||
|
||||
<H3>Version 19990307</H3>
|
||||
|
||||
<P>Copyright (c) 1998, 1999 James Clark. Expat is subject to the <A
|
||||
HREF="MPL-1_0.html">Mozilla Public License Version 1.0</A>. You may
|
||||
not use expat except in compliance with this license. Please contact
|
||||
me if you wish to negotiate an alternative license.</P><P>
|
||||
Expat is an <A HREF="http://www.w3.org/TR/1998/REC-xml-19980210">XML
|
||||
1.0</A> parser written in C. It aims to be fully conforming. It is
|
||||
currently not a validating XML processor.
|
||||
Expat can be downloaded from <A href =
|
||||
"ftp://ftp.jclark.com/pub/xml/expat.zip">ftp://ftp.jclark.com/pub/xml/expat.zip</A>.
|
||||
This is a beta-test version.</P>
|
||||
<P>
|
||||
The directory <SAMP>xmltok</SAMP> contains a low-level library for
|
||||
tokenizing XML. The interface is documented in <SAMP>xmltok/xmltok.h</SAMP>.</P>
|
||||
<P>
|
||||
The directory <SAMP>xmlparse</SAMP> contains an XML parser library
|
||||
as a special exception <A href="gplelect.html">elect to use the GNU
|
||||
General Public License</A>. Please contact me if you wish to
|
||||
negotiate an alternative license.</P>
|
||||
|
||||
<P>Expat is an <A
|
||||
HREF="http://www.w3.org/TR/1998/REC-xml-19980210">XML 1.0</A> parser
|
||||
written in C. It aims to be fully conforming. It is currently not a
|
||||
validating XML processor. The current production version of expat can
|
||||
be downloaded from <A href = "ftp://ftp.jclark.com/pub/xml/expat.zip"
|
||||
>ftp://ftp.jclark.com/pub/xml/expat.zip</A>.</P>
|
||||
|
||||
<P>The directory <SAMP>xmltok</SAMP> contains a low-level library for
|
||||
tokenizing XML. The interface is documented in
|
||||
<SAMP>xmltok/xmltok.h</SAMP>.</P>
|
||||
|
||||
<P>The directory <SAMP>xmlparse</SAMP> contains an XML parser library
|
||||
which is built on top of the <SAMP>xmltok</SAMP> library. The
|
||||
interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>.</P>
|
||||
<P>
|
||||
The directory <SAMP>xmlwf</SAMP> contains the <SAMP>xmlwf</SAMP>
|
||||
interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>. The
|
||||
directory <SAMP>sample</SAMP> contains a simple example program using
|
||||
this interface; <SAMP>sample/build.bat</SAMP> is a batch file to build
|
||||
the example using Visual C++.</P>
|
||||
|
||||
<P>The directory <SAMP>xmlwf</SAMP> contains the <SAMP>xmlwf</SAMP>
|
||||
application, which uses the <SAMP>xmlparse</SAMP> library. The
|
||||
arguments to <SAMP>xmlwf</SAMP> are one or more files which are each
|
||||
to be checked for well-formedness. An option <SAMP>-d
|
||||
@@ -33,13 +44,24 @@ file the corresponding <A
|
||||
href="http://www.jclark.com/xml/canonxml.html">canonical XML</A> will
|
||||
be written to <SAMP>dir/<VAR>f</VAR></SAMP>, where
|
||||
<SAMP><VAR>f</VAR></SAMP> is the filename (without any path) of the
|
||||
input file.
|
||||
A <CODE>-x</CODE> option will cause references to external general entities
|
||||
to be processed.
|
||||
</P>
|
||||
input file. A <CODE>-x</CODE> option will cause references to
|
||||
external general entities to be processed.</P>
|
||||
|
||||
<P>The <SAMP>bin</SAMP> directory contains Win32 executables. The
|
||||
<SAMP>lib</SAMP> directory contains Win32 import libraries.</P>
|
||||
|
||||
<P>Answers to some frequently asked questions about expat can be found
|
||||
in the <A HREF="http://www.jclark.com/xml/expatfaq.html">expat
|
||||
FAQ</A>.</P>
|
||||
|
||||
<P></P>
|
||||
|
||||
<ADDRESS>
|
||||
|
||||
<A HREF="mailto:jjc@jclark.com">James Clark</A>
|
||||
|
||||
</ADDRESS>
|
||||
|
||||
</BODY>
|
||||
|
||||
</HTML>
|
||||
|
||||
+121
-4
@@ -63,6 +63,7 @@ INTDIR=.\xmlwf\Release
|
||||
ALL : "xmlparse - Win32 Release" ".\bin\xmlwf.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\codepage.obj"
|
||||
-@erase "$(INTDIR)\win32filemap.obj"
|
||||
-@erase "$(INTDIR)\xmlwf.obj"
|
||||
-@erase ".\bin\xmlwf.exe"
|
||||
@@ -115,6 +116,7 @@ LINK32_FLAGS=setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib\
|
||||
odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\
|
||||
/pdb:"$(OUTDIR)/xmlwf.pdb" /machine:I386 /out:"bin/xmlwf.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\codepage.obj" \
|
||||
"$(INTDIR)\win32filemap.obj" \
|
||||
"$(INTDIR)\xmlwf.obj" \
|
||||
".\xmlparse\Release\xmlparse.lib"
|
||||
@@ -142,6 +144,7 @@ INTDIR=.\xmlwf\Debug
|
||||
ALL : "xmlparse - Win32 Debug" ".\dbgbin\xmlwf.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\codepage.obj"
|
||||
-@erase "$(INTDIR)\vc40.idb"
|
||||
-@erase "$(INTDIR)\vc40.pdb"
|
||||
-@erase "$(INTDIR)\win32filemap.obj"
|
||||
@@ -198,6 +201,7 @@ LINK32_FLAGS=setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib\
|
||||
odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes\
|
||||
/pdb:"$(OUTDIR)/xmlwf.pdb" /debug /machine:I386 /out:"dbgbin/xmlwf.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\codepage.obj" \
|
||||
"$(INTDIR)\win32filemap.obj" \
|
||||
"$(INTDIR)\xmlwf.obj" \
|
||||
".\xmlparse\Debug\xmlparse.lib"
|
||||
@@ -430,11 +434,11 @@ BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"bin/xmlparse.dll"
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:0x20000000 /subsystem:windows /dll /machine:I386 /out:"bin/xmlparse.dll"
|
||||
# SUBTRACT LINK32 /profile
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
|
||||
odbccp32.lib /nologo /subsystem:windows /dll /incremental:no\
|
||||
odbccp32.lib /nologo /base:0x20000000 /subsystem:windows /dll /incremental:no\
|
||||
/pdb:"$(OUTDIR)/xmlparse.pdb" /machine:I386 /out:"bin/xmlparse.dll"\
|
||||
/implib:"$(OUTDIR)/xmlparse.lib"
|
||||
LINK32_OBJS= \
|
||||
@@ -521,10 +525,10 @@ BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"dbgbin/xmlparse.dll"
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:0x20000000 /subsystem:windows /dll /debug /machine:I386 /out:"dbgbin/xmlparse.dll"
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
|
||||
odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes\
|
||||
odbccp32.lib /nologo /base:0x20000000 /subsystem:windows /dll /incremental:yes\
|
||||
/pdb:"$(OUTDIR)/xmlparse.pdb" /debug /machine:I386 /out:"dbgbin/xmlparse.dll"\
|
||||
/implib:"$(OUTDIR)/xmlparse.lib"
|
||||
LINK32_OBJS= \
|
||||
@@ -733,6 +737,7 @@ LINK32_OBJS= \
|
||||
SOURCE=.\xmlwf\xmlwf.c
|
||||
DEP_CPP_XMLWF=\
|
||||
".\xmlparse\xmlparse.h"\
|
||||
".\xmlwf\codepage.h"\
|
||||
".\xmlwf\filemap.h"\
|
||||
|
||||
|
||||
@@ -793,6 +798,19 @@ DEP_CPP_READF=\
|
||||
!ENDIF
|
||||
|
||||
# End Project Dependency
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlwf\codepage.c
|
||||
DEP_CPP_CODEP=\
|
||||
".\xmlwf\codepage.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\codepage.obj" : $(SOURCE) $(DEP_CPP_CODEP) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
################################################################################
|
||||
# Begin Target
|
||||
@@ -833,6 +851,9 @@ SOURCE=.\gennmtab\gennmtab.c
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlparse\xmlparse.c
|
||||
|
||||
!IF "$(CFG)" == "xmlparse - Win32 Release"
|
||||
|
||||
DEP_CPP_XMLPA=\
|
||||
".\xmlparse\hashtable.h"\
|
||||
".\xmlparse\xmlparse.h"\
|
||||
@@ -848,11 +869,33 @@ NODEP_CPP_XMLPA=\
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 Debug"
|
||||
|
||||
DEP_CPP_XMLPA=\
|
||||
".\xmlparse\hashtable.h"\
|
||||
".\xmlparse\xmlparse.h"\
|
||||
".\xmltok\xmldef.h"\
|
||||
".\xmltok\xmlrole.h"\
|
||||
".\xmltok\xmltok.h"\
|
||||
|
||||
NODEP_CPP_XMLPA=\
|
||||
".\xmltok\nspr.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\xmlparse.obj" : $(SOURCE) $(DEP_CPP_XMLPA) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlparse\hashtable.c
|
||||
|
||||
!IF "$(CFG)" == "xmlparse - Win32 Release"
|
||||
|
||||
DEP_CPP_HASHT=\
|
||||
".\xmlparse\hashtable.h"\
|
||||
".\xmltok\xmldef.h"\
|
||||
@@ -865,6 +908,22 @@ NODEP_CPP_HASHT=\
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 Debug"
|
||||
|
||||
DEP_CPP_HASHT=\
|
||||
".\xmlparse\hashtable.h"\
|
||||
".\xmltok\xmldef.h"\
|
||||
|
||||
NODEP_CPP_HASHT=\
|
||||
".\xmltok\nspr.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\hashtable.obj" : $(SOURCE) $(DEP_CPP_HASHT) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Project Dependency
|
||||
@@ -901,6 +960,9 @@ NODEP_CPP_HASHT=\
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltok\xmlrole.c
|
||||
|
||||
!IF "$(CFG)" == "xmltok - Win32 Release"
|
||||
|
||||
DEP_CPP_XMLRO=\
|
||||
".\xmltok\xmldef.h"\
|
||||
".\xmltok\xmlrole.h"\
|
||||
@@ -914,11 +976,31 @@ NODEP_CPP_XMLRO=\
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmltok - Win32 Debug"
|
||||
|
||||
DEP_CPP_XMLRO=\
|
||||
".\xmltok\xmldef.h"\
|
||||
".\xmltok\xmlrole.h"\
|
||||
".\xmltok\xmltok.h"\
|
||||
|
||||
NODEP_CPP_XMLRO=\
|
||||
".\xmltok\nspr.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\xmlrole.obj" : $(SOURCE) $(DEP_CPP_XMLRO) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltok\xmltok.c
|
||||
|
||||
!IF "$(CFG)" == "xmltok - Win32 Release"
|
||||
|
||||
DEP_CPP_XMLTO=\
|
||||
".\xmltok\asciitab.h"\
|
||||
".\xmltok\iasciitab.h"\
|
||||
@@ -938,16 +1020,51 @@ NODEP_CPP_XMLTO=\
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmltok - Win32 Debug"
|
||||
|
||||
DEP_CPP_XMLTO=\
|
||||
".\xmltok\asciitab.h"\
|
||||
".\xmltok\iasciitab.h"\
|
||||
".\xmltok\latin1tab.h"\
|
||||
".\xmltok\nametab.h"\
|
||||
".\xmltok\utf8tab.h"\
|
||||
".\xmltok\xmldef.h"\
|
||||
".\xmltok\xmltok.h"\
|
||||
".\xmltok\xmltok_impl.c"\
|
||||
".\xmltok\xmltok_impl.h"\
|
||||
|
||||
NODEP_CPP_XMLTO=\
|
||||
".\xmltok\nspr.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\xmltok.obj" : $(SOURCE) $(DEP_CPP_XMLTO) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltok\dllmain.c
|
||||
|
||||
!IF "$(CFG)" == "xmltok - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dllmain.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmltok - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dllmain.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
+45
-20
@@ -1,29 +1,54 @@
|
||||
--MKS Project--
|
||||
$Revision: 1.17 $
|
||||
block _mks_variant_projects
|
||||
1.11=vp0000.pj, "V1_0maintain"
|
||||
end
|
||||
EndOptions
|
||||
$(projectdir)/MPL-1_0.html a 1.1
|
||||
$(projectdir)/Makefile a 1.5
|
||||
$(projectdir)/expat.html a 1.6
|
||||
$(projectdir)/expat.mak a 1.12
|
||||
$(projectdir)/Makefile a 1.10
|
||||
$(projectdir)/expat.dsw a 1.1
|
||||
$(projectdir)/expat.html a 1.15
|
||||
$(projectdir)/expat.mak a 1.14
|
||||
$(projectdir)/expatfaq.html a 1.1
|
||||
$(projectdir)/files.txt a 1.8
|
||||
$(projectdir)/gplelect.html a 1.1
|
||||
$(projectdir)/makedist.ksh a 1.2
|
||||
$(projectdir)/win32files.txt a 1.1
|
||||
$(projectdir)/gennmtab/gennmtab.c a 1.2
|
||||
$(projectdir)/xmlparse/hashtable.c a 1.4
|
||||
$(projectdir)/xmlparse/hashtable.h a 1.3
|
||||
$(projectdir)/xmlparse/xmlparse.c a 1.28
|
||||
$(projectdir)/xmlparse/xmlparse.h a 1.6
|
||||
$(projectdir)/xmltok/asciitab.h a 1.4
|
||||
$(projectdir)/xmltok/dllmain.c a 1.2
|
||||
$(projectdir)/xmltok/iasciitab.h a 1.2
|
||||
$(projectdir)/gennmtab/gennmtab.dsp a 1.1
|
||||
$(projectdir)/sample/build.bat a 1.2
|
||||
$(projectdir)/sample/elements.c a 1.1
|
||||
$(projectdir)/xmlparse/hashtable.c a 1.8
|
||||
$(projectdir)/xmlparse/hashtable.h a 1.4
|
||||
$(projectdir)/xmlparse/xmlparse.c a 1.77
|
||||
$(projectdir)/xmlparse/xmlparse.dsp a 1.5
|
||||
$(projectdir)/xmlparse/xmlparse.h a 1.31
|
||||
$(projectdir)/xmltok/asciitab.h a 1.5
|
||||
$(projectdir)/xmltok/dllmain.c a 1.3
|
||||
$(projectdir)/xmltok/iasciitab.h a 1.3
|
||||
$(projectdir)/xmltok/latin1tab.h a 1.2
|
||||
$(projectdir)/xmltok/utf8tab.h a 1.4
|
||||
$(projectdir)/xmltok/xmldef.h a 1.3
|
||||
$(projectdir)/xmltok/xmlrole.c a 1.8
|
||||
$(projectdir)/xmltok/xmlrole.h a 1.4
|
||||
$(projectdir)/xmltok/xmltok.c a 1.24
|
||||
$(projectdir)/xmltok/xmltok.h a 1.16
|
||||
$(projectdir)/xmltok/xmltok_impl.c a 1.22
|
||||
$(projectdir)/xmltok/xmltok_impl.h a 1.5
|
||||
$(projectdir)/xmlwf/filemap.h a 1.2
|
||||
$(projectdir)/xmltok/xmldef.h a 1.7
|
||||
$(projectdir)/xmltok/xmlrole.c a 1.10
|
||||
$(projectdir)/xmltok/xmlrole.h a 1.5
|
||||
$(projectdir)/xmltok/xmltok.c a 1.45
|
||||
$(projectdir)/xmltok/xmltok.dsp a 1.4
|
||||
$(projectdir)/xmltok/xmltok.h a 1.25
|
||||
$(projectdir)/xmltok/xmltok_impl.c a 1.33
|
||||
$(projectdir)/xmltok/xmltok_impl.h a 1.6
|
||||
$(projectdir)/xmltok/xmltok_ns.c a 1.3
|
||||
$(projectdir)/xmlwf/codepage.c a 1.5
|
||||
$(projectdir)/xmlwf/codepage.h a 1.3
|
||||
$(projectdir)/xmlwf/filemap.h a 1.3
|
||||
$(projectdir)/xmlwf/readfilemap.c a 1.3
|
||||
$(projectdir)/xmlwf/unixfilemap.c a 1.2
|
||||
$(projectdir)/xmlwf/win32filemap.c a 1.3
|
||||
$(projectdir)/xmlwf/xmlwf.c a 1.18
|
||||
$(projectdir)/xmlwf/win32filemap.c a 1.6
|
||||
$(projectdir)/xmlwf/xmlfile.c a 1.2
|
||||
$(projectdir)/xmlwf/xmlfile.h a 1.1
|
||||
$(projectdir)/xmlwf/xmlmime.c a 1.1
|
||||
$(projectdir)/xmlwf/xmlmime.h a 1.1
|
||||
$(projectdir)/xmlwf/xmltchar.h a 1.1
|
||||
$(projectdir)/xmlwf/xmlurl.h a 1.1
|
||||
$(projectdir)/xmlwf/xmlwf.c a 1.40
|
||||
$(projectdir)/xmlwf/xmlwf.dsp a 1.2
|
||||
$(projectdir)/xmlwf/xmlwin32url.cxx a 1.1
|
||||
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
|
||||
<HTML>
|
||||
|
||||
<TITLE>expat FAQ</TITLE>
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1>Frequently Asked Questions about Expat</H1>
|
||||
|
||||
<H4>Where can I get the latest version of expat?</H4>
|
||||
|
||||
<p>The latest production version is always available from <a
|
||||
href="ftp://ftp.jclark.com/pub/xml/expat.zip"
|
||||
>ftp://ftp.jclark.com/pub/xml/expat.zip</a>. The latest test version
|
||||
is always available from <a
|
||||
href="ftp://ftp.jclark.com/pub/test/expat.zip"
|
||||
>ftp://ftp.jclark.com/pub/test/expat.zip</a>.</p>
|
||||
|
||||
<H4>Where can I get help in using expat?</H4>
|
||||
|
||||
<p>Try the xml-dev mailing list (subscribe by mailing to <a
|
||||
href="mailto:majordomo@ic.ac.uk">majordomo@ic.ac.uk</a> with the
|
||||
message <code>subscribe xml-dev</code>). Alternatively try the <a
|
||||
href="news:comp.text.xml">comp.text.xml</a> USENET newsgroup.</p>
|
||||
|
||||
<H4>Where is expat's API documented?</H4>
|
||||
|
||||
<p>In <code>xmlparse/xmlparse.h</code>. There's also an advanced,
|
||||
low-level API you can use which is documented in
|
||||
<code>xmltok/xmltok.h</code>.</p>
|
||||
|
||||
<H4>Is there a simple example of using expat's API?</H4>
|
||||
|
||||
<p>See <code>sample/elements.c</code></p>
|
||||
|
||||
<H4>How can I get expat to deal with non-ASCII characters?</H4>
|
||||
|
||||
<P>By default, expat assumes that documents are encoded in UTF-8. In
|
||||
UTF-8, ASCII characters are represented by a single byte as they would
|
||||
be in ASCII, but non-ASCII characters are represented by a sequence of
|
||||
two or more bytes all with the 8th bit set. The encoding most widely
|
||||
used for European languages is ISO 8859-1 which is not compatible with
|
||||
UTF-8. To use this encoding, expat must be told either by supplying
|
||||
an argument of <code>"iso-8859-1"</code> to
|
||||
<code>XML_ParserCreate</code>, or by starting the document with
|
||||
<code><?xml version="1.0" encoding="iso-8859-1"?></code>.</P>
|
||||
|
||||
<H4>What encodings does expat support?</H4>
|
||||
|
||||
<P>expat has built in support for the following encodings:</P>
|
||||
|
||||
<ul>
|
||||
<li><code>utf-8</code></li>
|
||||
<li><code>utf-16</code></li>
|
||||
<li><code>iso-8859-1</code></li>
|
||||
<li><code>us-ascii</code></li>
|
||||
</ul>
|
||||
|
||||
<P>Additional encodings can be supported by using
|
||||
<code>XML_SetUnknownEncodingHandler</code>.</P>
|
||||
|
||||
<H4>How can I get expat to validate my XML documents?</H4>
|
||||
|
||||
<p>You can't. expat is not a validating parser.</p>
|
||||
|
||||
<H4>How can I get expat to read my DTD?</H4>
|
||||
|
||||
<p>expat only reads the internal DTD subset. It doesn't process an
|
||||
external DTD nor parameter entity references. This behaviour is in
|
||||
conformance with the XML Recommendation.</p>
|
||||
|
||||
<H4>Why does expat give the wrong result for the more complex example in
|
||||
Appendix D of the XML Recommendation?</H4>
|
||||
|
||||
<P>expat does not process parameter entity references. (The XML
|
||||
Recommendation only requires parsers to process parameter entity
|
||||
references when validating. See section 4.4.8.)</P>
|
||||
|
||||
<H4>Why does expat give the wrong result for test cases in James
|
||||
Clark's test suite in the <code>xmltest/valid/not-sa</code>?</H4>
|
||||
|
||||
<P>expat doesn't process parameter entities.</P>
|
||||
|
||||
<H4>How can I get expat to recover from errors?</H4>
|
||||
|
||||
<p>You can't. All well-formedness errors stop processing. Note that
|
||||
the XML Recommendation does not permit conforming XML processors to
|
||||
continue normal processing after a fatal error.</p>
|
||||
|
||||
<H4>How do I get at the characters between tags?</H4>
|
||||
|
||||
<p>Use <code>XML_SetCharacterDataHandler</code>.</p>
|
||||
|
||||
<ADDRESS>
|
||||
|
||||
<A HREF="mailto:jjc@jclark.com">James Clark</A>
|
||||
|
||||
</ADDRESS>
|
||||
|
||||
</BODY>
|
||||
|
||||
</HTML>
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
expat.html
|
||||
MPL-1_0.html
|
||||
gplelect.html
|
||||
xmltok/asciitab.h
|
||||
xmltok/dllmain.c
|
||||
gennmtab/gennmtab.c
|
||||
xmltok/iasciitab.h
|
||||
xmltok/latin1tab.h
|
||||
Makefile
|
||||
xmltok/nametab.h
|
||||
xmltok/utf8tab.h
|
||||
xmltok/xmldef.h
|
||||
xmltok/xmlrole.c
|
||||
xmltok/xmlrole.h
|
||||
xmltok/xmltok.c
|
||||
xmltok/xmltok.h
|
||||
xmltok/xmltok_impl.c
|
||||
xmltok/xmltok_impl.h
|
||||
xmltok/xmltok_ns.c
|
||||
xmlparse/hashtable.c
|
||||
xmlparse/hashtable.h
|
||||
xmlparse/xmlparse.c
|
||||
xmlparse/xmlparse.h
|
||||
xmlwf/codepage.c
|
||||
xmlwf/codepage.h
|
||||
xmlwf/filemap.h
|
||||
xmlwf/readfilemap.c
|
||||
xmlwf/unixfilemap.c
|
||||
xmlwf/win32filemap.c
|
||||
xmlwf/xmlfile.c
|
||||
xmlwf/xmlfile.h
|
||||
xmlwf/xmltchar.h
|
||||
xmlwf/xmlwf.c
|
||||
sample/elements.c
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
# Microsoft Developer Studio Project File - Name="gennmtab" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=gennmtab - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "gennmtab.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "gennmtab.mak" CFG="gennmtab - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "gennmtab - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "gennmtab - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "gennmtab - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "gennmtab - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "gennmtab - Win32 Release"
|
||||
# Name "gennmtab - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gennmtab.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
|
||||
<HTML>
|
||||
|
||||
<TITLE>Using the GPL for expat</TITLE>
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1>Using the GPL for expat</H1>
|
||||
|
||||
<P>Instead of using the Mozilla Public License, you may instead elect
|
||||
to use the <A href="http://www.gnu.org/copyleft/gpl.html">GNU General
|
||||
Public License</A> (GPL) for a particular copy of expat. The election
|
||||
to use the GPL is irrevocable for that particular copy. If you do
|
||||
elect to use the GPL, then you must replace the copyright notice on
|
||||
each file with the following:</P>
|
||||
|
||||
<PRE>
|
||||
expat XML parser
|
||||
Copyright (C) 1998 James Clark
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
</PRE>
|
||||
|
||||
<P>and you must change readme.html to say that an election has been
|
||||
made to use this copy under the GPL. If you redistribute expat, you
|
||||
should also include a copy of the GPL.</P>
|
||||
|
||||
<P>Note that I will probably not accept patches under terms that allow
|
||||
me to distribute them only under the GPL.</P>
|
||||
|
||||
<P></P>
|
||||
|
||||
<ADDRESS>
|
||||
|
||||
<A HREF="mailto:jjc@jclark.com">James Clark</A>
|
||||
|
||||
</ADDRESS>
|
||||
|
||||
</BODY>
|
||||
|
||||
</HTML>
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
xcopy xmltok\\Release\\xmltok.lib lib
|
||||
xcopy xmlparse\\Release\\xmlparse.lib lib
|
||||
rm -fr expat
|
||||
mkdir expat
|
||||
tar cf - `cat files.txt win32files.txt` | (cd expat; tar xf -)
|
||||
(cd expat; flip -u `cat ../files.txt`)
|
||||
rm -f expat.zip
|
||||
zip -qr expat.zip expat
|
||||
rm -fr expat
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
set LIB=..\xmlparse\Release;..\lib;%LIB%
|
||||
cl /nologo /DXMLTOKAPI=__declspec(dllimport) /DXMLPARSEAPI=__declspec(dllimport) /I..\xmlparse /Fe..\bin\elements elements.c xmlparse.lib
|
||||
@echo Run it using: ..\bin\elements ^<..\expat.html
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
/* This is simple demonstration of how to use expat. This program
|
||||
reads an XML document from standard input and writes a line with the
|
||||
name of each element to standard output indenting child elements by
|
||||
one tab stop more than their parent element. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "xmlparse.h"
|
||||
|
||||
void startElement(void *userData, const char *name, const char **atts)
|
||||
{
|
||||
int i;
|
||||
int *depthPtr = userData;
|
||||
for (i = 0; i < *depthPtr; i++)
|
||||
putchar('\t');
|
||||
puts(name);
|
||||
*depthPtr += 1;
|
||||
}
|
||||
|
||||
void endElement(void *userData, const char *name)
|
||||
{
|
||||
int *depthPtr = userData;
|
||||
*depthPtr -= 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
XML_Parser parser = XML_ParserCreate(NULL);
|
||||
int done;
|
||||
int depth = 0;
|
||||
XML_SetUserData(parser, &depth);
|
||||
XML_SetElementHandler(parser, startElement, endElement);
|
||||
do {
|
||||
size_t len = fread(buf, 1, sizeof(buf), stdin);
|
||||
done = len < sizeof(buf);
|
||||
if (!XML_Parse(parser, buf, len, done)) {
|
||||
fprintf(stderr,
|
||||
"%s at line %d\n",
|
||||
XML_ErrorString(XML_GetErrorCode(parser)),
|
||||
XML_GetCurrentLineNumber(parser));
|
||||
return 1;
|
||||
}
|
||||
} while (!done);
|
||||
XML_ParserFree(parser);
|
||||
return 0;
|
||||
}
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
expat.dsw
|
||||
expat.mak
|
||||
gennmtab/gennmtab.dsp
|
||||
sample/build.bat
|
||||
xmlparse/xmlparse.dsp
|
||||
xmltok/xmltok.dsp
|
||||
xmlwf/xmlwf.dsp
|
||||
bin/xmltok.dll
|
||||
bin/xmlparse.dll
|
||||
bin/xmlwf.exe
|
||||
lib/xmltok.lib
|
||||
lib/xmlparse.lib
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
csompliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
@@ -19,14 +19,28 @@ Contributor(s):
|
||||
*/
|
||||
|
||||
#include "xmldef.h"
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#ifndef XML_UNICODE
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "hashtable.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define INIT_SIZE 64
|
||||
|
||||
static
|
||||
unsigned long hash(const char *s)
|
||||
int keyeq(KEY s1, KEY s2)
|
||||
{
|
||||
for (; *s1 == *s2; s1++, s2++)
|
||||
if (*s1 == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
unsigned long hash(KEY s)
|
||||
{
|
||||
unsigned long h = 0;
|
||||
while (*s)
|
||||
@@ -34,7 +48,7 @@ unsigned long hash(const char *s)
|
||||
return h;
|
||||
}
|
||||
|
||||
NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize)
|
||||
NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize)
|
||||
{
|
||||
size_t i;
|
||||
if (table->size == 0) {
|
||||
@@ -52,7 +66,7 @@ NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize)
|
||||
for (i = h & (table->size - 1);
|
||||
table->v[i];
|
||||
i == 0 ? i = table->size - 1 : --i) {
|
||||
if (strcmp(name, table->v[i]->name) == 0)
|
||||
if (keyeq(name, table->v[i]->name))
|
||||
return table->v[i];
|
||||
}
|
||||
if (!createSize)
|
||||
|
||||
@@ -21,8 +21,14 @@ Contributor(s):
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
typedef const wchar_t *KEY;
|
||||
#else
|
||||
typedef const char *KEY;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
KEY name;
|
||||
} NAMED;
|
||||
|
||||
typedef struct {
|
||||
@@ -32,7 +38,7 @@ typedef struct {
|
||||
size_t usedLim;
|
||||
} HASH_TABLE;
|
||||
|
||||
NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize);
|
||||
NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize);
|
||||
void hashTableInit(HASH_TABLE *);
|
||||
void hashTableDestroy(HASH_TABLE *);
|
||||
|
||||
|
||||
+1565
-485
File diff suppressed because it is too large
Load Diff
Executable
+202
@@ -0,0 +1,202 @@
|
||||
# Microsoft Developer Studio Project File - Name="xmlparse" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=xmlparse - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "xmlparse.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "xmlparse.mak" CFG="xmlparse - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "xmlparse - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "xmlparse - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "xmlparse - Win32 MinSize" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "xmlparse - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\xmltok" /I "..\xmlwf" /D XMLTOKAPI=__declspec(dllimport) /D XMLPARSEAPI=__declspec(dllexport) /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x20000000" /subsystem:windows /dll /machine:I386 /out:"..\bin\xmlparse.dll"
|
||||
# SUBTRACT LINK32 /profile
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\xmltok" /I "..\xmlwf" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D XMLTOKAPI=__declspec(dllimport) /D XMLPARSEAPI=__declspec(dllexport) /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x20000000" /subsystem:windows /dll /debug /machine:I386 /out:"..\dbgbin\xmlparse.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 MinSize"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "MinSize"
|
||||
# PROP BASE Intermediate_Dir "MinSize"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "MinSize"
|
||||
# PROP Intermediate_Dir "MinSize"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\xmltok" /I "..\xmlwf" /D XMLTOKAPI=__declspec(dllimport) /D XMLPARSEAPI=__declspec(dllexport) /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O1 /I "..\xmltok" /I "..\xmlwf" /D "XML_MIN_SIZE" /D "XML_WINLIB" /D XMLPARSEAPI=__declspec(dllexport) /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x20000000" /subsystem:windows /dll /machine:I386 /out:"..\bin\xmlparse.dll"
|
||||
# SUBTRACT BASE LINK32 /profile
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x20000000" /entry:"DllMain" /subsystem:windows /dll /machine:I386 /out:"..\bin\xmlparse.dll"
|
||||
# SUBTRACT LINK32 /profile /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "xmlparse - Win32 Release"
|
||||
# Name "xmlparse - Win32 Debug"
|
||||
# Name "xmlparse - Win32 MinSize"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\xmltok\dllmain.c
|
||||
|
||||
!IF "$(CFG)" == "xmlparse - Win32 Release"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 MinSize"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hashtable.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlparse.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\xmltok\xmlrole.c
|
||||
|
||||
!IF "$(CFG)" == "xmlparse - Win32 Release"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 MinSize"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\xmltok\xmltok.c
|
||||
|
||||
!IF "$(CFG)" == "xmlparse - Win32 Release"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlparse - Win32 MinSize"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hashtable.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlparse.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
+293
-41
@@ -31,34 +31,138 @@ extern "C" {
|
||||
|
||||
typedef void *XML_Parser;
|
||||
|
||||
/* Constructs a new parser; encoding is the externally specified encoding,
|
||||
or null if there is no externally specified encoding. */
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
|
||||
XML_Parser XMLPARSEAPI
|
||||
XML_ParserCreate(const char *encoding);
|
||||
/* XML_UNICODE_WCHAR_T will work only if sizeof(wchar_t) == 2 and wchar_t
|
||||
uses Unicode. */
|
||||
/* Information is UTF-16 encoded as wchar_ts */
|
||||
|
||||
#ifndef XML_UNICODE
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
|
||||
#else /* not XML_UNICODE_WCHAR_T */
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
|
||||
/* Information is UTF-16 encoded as unsigned shorts */
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
|
||||
#else /* not XML_UNICODE */
|
||||
|
||||
/* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
|
||||
/* atts is array of name/value pairs, terminated by NULL;
|
||||
names and values are '\0' terminated. */
|
||||
#endif /* not XML_UNICODE */
|
||||
|
||||
#endif /* not XML_UNICODE_WCHAR_T */
|
||||
|
||||
|
||||
/* Constructs a new parser; encoding is the encoding specified by the external
|
||||
protocol or null if there is none specified. */
|
||||
|
||||
XML_Parser XMLPARSEAPI
|
||||
XML_ParserCreate(const XML_Char *encoding);
|
||||
|
||||
/* Constructs a new parser and namespace processor. Element type names
|
||||
and attribute names that belong to a namespace will be expanded;
|
||||
unprefixed attribute names are never expanded; unprefixed element type
|
||||
names are expanded only if there is a default namespace. The expanded
|
||||
name is the concatenation of the namespace URI, the namespace separator character,
|
||||
and the local part of the name. If the namespace separator is '\0' then
|
||||
the namespace URI and the local part will be concatenated without any
|
||||
separator. When a namespace is not declared, the name and prefix will be
|
||||
passed through without expansion. */
|
||||
|
||||
XML_Parser XMLPARSEAPI
|
||||
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
|
||||
|
||||
|
||||
/* atts is array of name/value pairs, terminated by 0;
|
||||
names and values are 0 terminated. */
|
||||
|
||||
typedef void (*XML_StartElementHandler)(void *userData,
|
||||
const char *name,
|
||||
const char **atts);
|
||||
const XML_Char *name,
|
||||
const XML_Char **atts);
|
||||
|
||||
typedef void (*XML_EndElementHandler)(void *userData,
|
||||
const char *name);
|
||||
const XML_Char *name);
|
||||
|
||||
/* s is not 0 terminated. */
|
||||
typedef void (*XML_CharacterDataHandler)(void *userData,
|
||||
const char *s,
|
||||
const XML_Char *s,
|
||||
int len);
|
||||
|
||||
/* target and data are '\0' terminated */
|
||||
/* target and data are 0 terminated */
|
||||
typedef void (*XML_ProcessingInstructionHandler)(void *userData,
|
||||
const char *target,
|
||||
const char *data);
|
||||
const XML_Char *target,
|
||||
const XML_Char *data);
|
||||
|
||||
/* Reports a reference to an external parsed general entity.
|
||||
/* data is 0 terminated */
|
||||
typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
|
||||
|
||||
typedef void (*XML_StartCdataSectionHandler)(void *userData);
|
||||
typedef void (*XML_EndCdataSectionHandler)(void *userData);
|
||||
|
||||
/* This is called for any characters in the XML document for
|
||||
which there is no applicable handler. This includes both
|
||||
characters that are part of markup which is of a kind that is
|
||||
not reported (comments, markup declarations), or characters
|
||||
that are part of a construct which could be reported but
|
||||
for which no handler has been supplied. The characters are passed
|
||||
exactly as they were in the XML document except that
|
||||
they will be encoded in UTF-8. Line boundaries are not normalized.
|
||||
Note that a byte order mark character is not passed to the default handler.
|
||||
There are no guarantees about how characters are divided between calls
|
||||
to the default handler: for example, a comment might be split between
|
||||
multiple calls. */
|
||||
|
||||
typedef void (*XML_DefaultHandler)(void *userData,
|
||||
const XML_Char *s,
|
||||
int len);
|
||||
|
||||
/* This is called for a declaration of an unparsed (NDATA)
|
||||
entity. The base argument is whatever was set by XML_SetBase.
|
||||
The entityName, systemId and notationName arguments will never be null.
|
||||
The other arguments may be. */
|
||||
|
||||
typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId,
|
||||
const XML_Char *notationName);
|
||||
|
||||
/* This is called for a declaration of notation.
|
||||
The base argument is whatever was set by XML_SetBase.
|
||||
The notationName will never be null. The other arguments can be. */
|
||||
|
||||
typedef void (*XML_NotationDeclHandler)(void *userData,
|
||||
const XML_Char *notationName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
/* When namespace processing is enabled, these are called once for
|
||||
each namespace declaration. The call to the start and end element
|
||||
handlers occur between the calls to the start and end namespace
|
||||
declaration handlers. For an xmlns attribute, prefix will be null.
|
||||
For an xmlns="" attribute, uri will be null. */
|
||||
|
||||
typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
|
||||
const XML_Char *prefix,
|
||||
const XML_Char *uri);
|
||||
|
||||
typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
|
||||
const XML_Char *prefix);
|
||||
|
||||
/* This is called for a reference to an external parsed general entity.
|
||||
The referenced entity is not automatically parsed.
|
||||
The application can parse it immediately or later using
|
||||
XML_ExternalEntityParserCreate.
|
||||
@@ -72,10 +176,9 @@ it may be null.
|
||||
The publicId argument is the public identifier as specified in the entity declaration,
|
||||
or null if none was specified; the whitespace in the public identifier
|
||||
will have been normalized as required by the XML spec.
|
||||
The openEntityNames argument is a space-separated list of the names of the entities
|
||||
that are open for the parse of this entity (including the name of the referenced
|
||||
entity); this can be passed as the openEntityNames argument to
|
||||
XML_ExternalEntityParserCreate; openEntityNames is valid only until the handler
|
||||
The context argument specifies the parsing context in the format
|
||||
expected by the context argument to
|
||||
XML_ExternalEntityParserCreate; context is valid only until the handler
|
||||
returns, so if the referenced entity is to be parsed later, it must be copied.
|
||||
The handler should return 0 if processing should not continue because of
|
||||
a fatal error in the handling of the external entity.
|
||||
@@ -84,10 +187,73 @@ error.
|
||||
Note that unlike other handlers the first argument is the parser, not userData. */
|
||||
|
||||
typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
|
||||
const char *openEntityNames,
|
||||
const char *base,
|
||||
const char *systemId,
|
||||
const char *publicId);
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
/* This structure is filled in by the XML_UnknownEncodingHandler
|
||||
to provide information to the parser about encodings that are unknown
|
||||
to the parser.
|
||||
The map[b] member gives information about byte sequences
|
||||
whose first byte is b.
|
||||
If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar value c.
|
||||
If map[b] is -1, then the byte sequence is malformed.
|
||||
If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
|
||||
sequence that encodes a single Unicode scalar value.
|
||||
The data member will be passed as the first argument to the convert function.
|
||||
The convert function is used to convert multibyte sequences;
|
||||
s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
|
||||
The convert function must return the Unicode scalar value
|
||||
represented by this byte sequence or -1 if the byte sequence is malformed.
|
||||
The convert function may be null if the encoding is a single-byte encoding,
|
||||
that is if map[b] >= -1 for all bytes b.
|
||||
When the parser is finished with the encoding, then if release is not null,
|
||||
it will call release passing it the data member;
|
||||
once release has been called, the convert function will not be called again.
|
||||
|
||||
Expat places certain restrictions on the encodings that are supported
|
||||
using this mechanism.
|
||||
|
||||
1. Every ASCII character that can appear in a well-formed XML document,
|
||||
other than the characters
|
||||
|
||||
$@\^`{}~
|
||||
|
||||
must be represented by a single byte, and that byte must be the
|
||||
same byte that represents that character in ASCII.
|
||||
|
||||
2. No character may require more than 4 bytes to encode.
|
||||
|
||||
3. All characters encoded must have Unicode scalar values <= 0xFFFF,
|
||||
(ie characters that would be encoded by surrogates in UTF-16
|
||||
are not allowed). Note that this restriction doesn't apply to
|
||||
the built-in support for UTF-8 and UTF-16.
|
||||
|
||||
4. No Unicode character may be encoded by more than one distinct sequence
|
||||
of bytes. */
|
||||
|
||||
typedef struct {
|
||||
int map[256];
|
||||
void *data;
|
||||
int (*convert)(void *data, const char *s);
|
||||
void (*release)(void *data);
|
||||
} XML_Encoding;
|
||||
|
||||
/* This is called for an encoding that is unknown to the parser.
|
||||
The encodingHandlerData argument is that which was passed as the
|
||||
second argument to XML_SetUnknownEncodingHandler.
|
||||
The name argument gives the name of the encoding as specified in
|
||||
the encoding declaration.
|
||||
If the callback can provide information about the encoding,
|
||||
it must fill in the XML_Encoding structure, and return 1.
|
||||
Otherwise it must return 0.
|
||||
If info does not describe a suitable encoding,
|
||||
then the parser will return an XML_UNKNOWN_ENCODING error. */
|
||||
|
||||
typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
|
||||
const XML_Char *name,
|
||||
XML_Encoding *info);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetElementHandler(XML_Parser parser,
|
||||
@@ -101,27 +267,95 @@ XML_SetCharacterDataHandler(XML_Parser parser,
|
||||
void XMLPARSEAPI
|
||||
XML_SetProcessingInstructionHandler(XML_Parser parser,
|
||||
XML_ProcessingInstructionHandler handler);
|
||||
void XMLPARSEAPI
|
||||
XML_SetCommentHandler(XML_Parser parser,
|
||||
XML_CommentHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetCdataSectionHandler(XML_Parser parser,
|
||||
XML_StartCdataSectionHandler start,
|
||||
XML_EndCdataSectionHandler end);
|
||||
|
||||
/* This sets the default handler and also inhibits expansion of internal entities.
|
||||
The entity reference will be passed to the default handler. */
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetDefaultHandler(XML_Parser parser,
|
||||
XML_DefaultHandler handler);
|
||||
|
||||
/* This sets the default handler but does not inhibit expansion of internal entities.
|
||||
The entity reference will not be passed to the default handler. */
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetDefaultHandlerExpand(XML_Parser parser,
|
||||
XML_DefaultHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
|
||||
XML_UnparsedEntityDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetNotationDeclHandler(XML_Parser parser,
|
||||
XML_NotationDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetNamespaceDeclHandler(XML_Parser parser,
|
||||
XML_StartNamespaceDeclHandler start,
|
||||
XML_EndNamespaceDeclHandler end);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetExternalEntityRefHandler(XML_Parser parser,
|
||||
XML_ExternalEntityRefHandler handler);
|
||||
|
||||
/* If a non-null value for arg is specified here, then it will be passed
|
||||
as the first argument to the external entity ref handler instead
|
||||
of the parser object. */
|
||||
void XMLPARSEAPI
|
||||
XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetUnknownEncodingHandler(XML_Parser parser,
|
||||
XML_UnknownEncodingHandler handler,
|
||||
void *encodingHandlerData);
|
||||
|
||||
/* This can be called within a handler for a start element, end element,
|
||||
processing instruction or character data. It causes the corresponding
|
||||
markup to be passed to the default handler. */
|
||||
void XMLPARSEAPI XML_DefaultCurrent(XML_Parser parser);
|
||||
|
||||
/* This value is passed as the userData argument to callbacks. */
|
||||
void XMLPARSEAPI
|
||||
XML_SetUserData(XML_Parser parser, void *userData);
|
||||
|
||||
/* Returns the last value set by XML_SetUserData or null. */
|
||||
void XMLPARSEAPI *
|
||||
XML_GetUserData(XML_Parser parser);
|
||||
#define XML_GetUserData(parser) (*(void **)(parser))
|
||||
|
||||
/* This is equivalent to supplying an encoding argument
|
||||
to XML_CreateParser. It must not be called after XML_Parse
|
||||
or XML_ParseBuffer. */
|
||||
|
||||
int XMLPARSEAPI
|
||||
XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
|
||||
|
||||
/* If this function is called, then the parser will be passed
|
||||
as the first argument to callbacks instead of userData.
|
||||
The userData will still be accessible using XML_GetUserData. */
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_UseParserAsHandlerArg(XML_Parser parser);
|
||||
|
||||
/* Sets the base to be used for resolving relative URIs in system identifiers in
|
||||
declarations. Resolving relative identifiers is left to the application:
|
||||
this value will be passed through as the base argumentto the ExternalEntityRefHandler.
|
||||
The base argument will be copied. Returns zero if out of memory, non-zero otherwise. */
|
||||
this value will be passed through as the base argument to the
|
||||
XML_ExternalEntityRefHandler, XML_NotationDeclHandler
|
||||
and XML_UnparsedEntityDeclHandler. The base argument will be copied.
|
||||
Returns zero if out of memory, non-zero otherwise. */
|
||||
|
||||
int XMLPARSEAPI
|
||||
XML_SetBase(XML_Parser parser, const char *base);
|
||||
XML_SetBase(XML_Parser parser, const XML_Char *base);
|
||||
|
||||
const XML_Char XMLPARSEAPI *
|
||||
XML_GetBase(XML_Parser parser);
|
||||
|
||||
/* Parses some input. Returns 0 if a fatal error is detected.
|
||||
The last call to XML_Parse must have isFinal true;
|
||||
@@ -136,10 +370,13 @@ int XMLPARSEAPI
|
||||
XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
|
||||
|
||||
/* Creates an XML_Parser object that can parse an external general entity;
|
||||
openEntityNames is a space-separated list of the names of the entities that are open
|
||||
for the parse of this entity (including the name of this one);
|
||||
encoding is the externally specified encoding,
|
||||
context is a '\0'-terminated string specifying the parse context;
|
||||
encoding is a '\0'-terminated string giving the name of the externally specified encoding,
|
||||
or null if there is no externally specified encoding.
|
||||
The context string consists of a sequence of tokens separated by formfeeds (\f);
|
||||
a token consisting of a name specifies that the general entity of the name
|
||||
is open; a token of the form prefix=uri specifies the namespace for a particular
|
||||
prefix; a token of the form =uri specifies the default namespace.
|
||||
This can be called at any point after the first call to an ExternalEntityRefHandler
|
||||
so longer as the parser has not yet been freed.
|
||||
The new parser is completely independent and may safely be used in a separate thread.
|
||||
@@ -147,11 +384,8 @@ The handlers and userData are initialized from the parser argument.
|
||||
Returns 0 if out of memory. Otherwise returns a new XML_Parser object. */
|
||||
XML_Parser XMLPARSEAPI
|
||||
XML_ExternalEntityParserCreate(XML_Parser parser,
|
||||
const char *openEntityNames,
|
||||
const char *encoding);
|
||||
|
||||
/* If XML_Parser or XML_ParseEnd have returned 0, then XML_GetError*
|
||||
returns information about the error. */
|
||||
const XML_Char *context,
|
||||
const XML_Char *encoding);
|
||||
|
||||
enum XML_Error {
|
||||
XML_ERROR_NONE,
|
||||
@@ -178,16 +412,34 @@ enum XML_Error {
|
||||
XML_ERROR_EXTERNAL_ENTITY_HANDLING
|
||||
};
|
||||
|
||||
int XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
|
||||
int XMLPARSEAPI XML_GetErrorLineNumber(XML_Parser parser);
|
||||
int XMLPARSEAPI XML_GetErrorColumnNumber(XML_Parser parser);
|
||||
long XMLPARSEAPI XML_GetErrorByteIndex(XML_Parser parser);
|
||||
/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
|
||||
returns information about the error. */
|
||||
|
||||
enum XML_Error XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
|
||||
|
||||
/* These functions return information about the current parse location.
|
||||
They may be called when XML_Parse or XML_ParseBuffer return 0;
|
||||
in this case the location is the location of the character at which
|
||||
the error was detected.
|
||||
They may also be called from any other callback called to report
|
||||
some parse event; in this the location is the location of the first
|
||||
of the sequence of characters that generated the event. */
|
||||
|
||||
int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser);
|
||||
int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser);
|
||||
long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser);
|
||||
|
||||
/* For backwards compatibility with previous versions. */
|
||||
#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
|
||||
#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
|
||||
#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
|
||||
|
||||
/* Frees memory used by the parser. */
|
||||
void XMLPARSEAPI
|
||||
XML_ParserFree(XML_Parser parser);
|
||||
|
||||
const char XMLPARSEAPI *
|
||||
XML_ErrorString(int code);
|
||||
/* Returns a string describing the error. */
|
||||
const XML_LChar XMLPARSEAPI *XML_ErrorString(int code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ Contributor(s):
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_NMSTRT, BT_SEMI,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
|
||||
@@ -18,6 +18,9 @@ James Clark. All Rights Reserved.
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#define STRICT 1
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||
|
||||
@@ -33,7 +33,7 @@ Contributor(s):
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_NMSTRT, BT_SEMI,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
|
||||
+22
-1
@@ -18,13 +18,34 @@ James Clark. All Rights Reserved.
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef XML_WINLIB
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
|
||||
#define malloc(x) HeapAlloc(GetProcessHeap(), 0, (x))
|
||||
#define calloc(x, y) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x)*(y))
|
||||
#define free(x) HeapFree(GetProcessHeap(), 0, (x))
|
||||
#define realloc(x, y) HeapReAlloc(GetProcessHeap(), 0, x, y)
|
||||
#define abort() /* as nothing */
|
||||
|
||||
#else /* not XML_WINLIB */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#endif /* not XML_WINLIB */
|
||||
|
||||
/* This file can be used for any definitions needed in
|
||||
particular environments. */
|
||||
|
||||
#ifdef MOZILLA
|
||||
|
||||
#include "nspr.h"
|
||||
#define malloc(x) PR_Calloc(1,(x))
|
||||
#define malloc(x) PR_Malloc(x)
|
||||
#define realloc(x, y) PR_Realloc((x), (y))
|
||||
#define calloc(x, y) PR_Calloc((x),(y))
|
||||
#define free(x) PR_Free(x)
|
||||
#define int int32
|
||||
|
||||
@@ -149,6 +149,7 @@ int doctype0(PROLOG_STATE *state,
|
||||
case XML_TOK_PROLOG_S:
|
||||
return XML_ROLE_NONE;
|
||||
case XML_TOK_NAME:
|
||||
case XML_TOK_PREFIXED_NAME:
|
||||
state->handler = doctype1;
|
||||
return XML_ROLE_DOCTYPE_NAME;
|
||||
}
|
||||
@@ -594,7 +595,7 @@ int notation4(PROLOG_STATE *state,
|
||||
return XML_ROLE_NOTATION_SYSTEM_ID;
|
||||
case XML_TOK_DECL_CLOSE:
|
||||
state->handler = internalSubset;
|
||||
return XML_ROLE_NONE;
|
||||
return XML_ROLE_NOTATION_NO_SYSTEM_ID;
|
||||
}
|
||||
return syntaxError(state);
|
||||
}
|
||||
@@ -610,6 +611,7 @@ int attlist0(PROLOG_STATE *state,
|
||||
case XML_TOK_PROLOG_S:
|
||||
return XML_ROLE_NONE;
|
||||
case XML_TOK_NAME:
|
||||
case XML_TOK_PREFIXED_NAME:
|
||||
state->handler = attlist1;
|
||||
return XML_ROLE_ATTLIST_ELEMENT_NAME;
|
||||
}
|
||||
@@ -630,6 +632,7 @@ int attlist1(PROLOG_STATE *state,
|
||||
state->handler = internalSubset;
|
||||
return XML_ROLE_NONE;
|
||||
case XML_TOK_NAME:
|
||||
case XML_TOK_PREFIXED_NAME:
|
||||
state->handler = attlist2;
|
||||
return XML_ROLE_ATTRIBUTE_NAME;
|
||||
}
|
||||
@@ -689,6 +692,7 @@ int attlist3(PROLOG_STATE *state,
|
||||
return XML_ROLE_NONE;
|
||||
case XML_TOK_NMTOKEN:
|
||||
case XML_TOK_NAME:
|
||||
case XML_TOK_PREFIXED_NAME:
|
||||
state->handler = attlist4;
|
||||
return XML_ROLE_ATTRIBUTE_ENUM_VALUE;
|
||||
}
|
||||
@@ -836,6 +840,7 @@ int element0(PROLOG_STATE *state,
|
||||
case XML_TOK_PROLOG_S:
|
||||
return XML_ROLE_NONE;
|
||||
case XML_TOK_NAME:
|
||||
case XML_TOK_PREFIXED_NAME:
|
||||
state->handler = element1;
|
||||
return XML_ROLE_ELEMENT_NAME;
|
||||
}
|
||||
@@ -893,6 +898,7 @@ int element2(PROLOG_STATE *state,
|
||||
state->handler = element6;
|
||||
return XML_ROLE_GROUP_OPEN;
|
||||
case XML_TOK_NAME:
|
||||
case XML_TOK_PREFIXED_NAME:
|
||||
state->handler = element7;
|
||||
return XML_ROLE_CONTENT_ELEMENT;
|
||||
case XML_TOK_NAME_QUESTION:
|
||||
@@ -940,6 +946,7 @@ int element4(PROLOG_STATE *state,
|
||||
case XML_TOK_PROLOG_S:
|
||||
return XML_ROLE_NONE;
|
||||
case XML_TOK_NAME:
|
||||
case XML_TOK_PREFIXED_NAME:
|
||||
state->handler = element5;
|
||||
return XML_ROLE_CONTENT_ELEMENT;
|
||||
}
|
||||
@@ -980,6 +987,7 @@ int element6(PROLOG_STATE *state,
|
||||
state->level += 1;
|
||||
return XML_ROLE_GROUP_OPEN;
|
||||
case XML_TOK_NAME:
|
||||
case XML_TOK_PREFIXED_NAME:
|
||||
state->handler = element7;
|
||||
return XML_ROLE_CONTENT_ELEMENT;
|
||||
case XML_TOK_NAME_QUESTION:
|
||||
|
||||
@@ -44,6 +44,7 @@ enum {
|
||||
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_PUBLIC_ID,
|
||||
XML_ROLE_ATTRIBUTE_NAME,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
|
||||
|
||||
+1019
-296
File diff suppressed because it is too large
Load Diff
Executable
+162
@@ -0,0 +1,162 @@
|
||||
# Microsoft Developer Studio Project File - Name="xmltok" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=xmltok - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "xmltok.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "xmltok.mak" CFG="xmltok - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "xmltok - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "xmltok - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "xmltok - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /D XMLTOKAPI=__declspec(dllexport) /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"DllMain" /subsystem:windows /dll /machine:I386 /out:"..\bin\xmltok.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmltok - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D XMLTOKAPI=__declspec(dllexport) /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"..\dbgbin\xmltok.dll"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "xmltok - Win32 Release"
|
||||
# Name "xmltok - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dllmain.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlrole.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltok.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\asciitab.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\iasciitab.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\latin1tab.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\nametab.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\utf8tab.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmldef.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlrole.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltok.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltok_impl.c
|
||||
# PROP BASE Exclude_From_Build 1
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltok_impl.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltok_ns.c
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
+56
-21
@@ -94,6 +94,10 @@ extern "C" {
|
||||
/* The following token is returned only by XmlCdataSectionTok */
|
||||
#define XML_TOK_CDATA_SECT_CLOSE 40
|
||||
|
||||
/* With namespace processing this is returned by XmlPrologTok
|
||||
for a name with a colon. */
|
||||
#define XML_TOK_PREFIXED_NAME 41
|
||||
|
||||
#define XML_N_STATES 3
|
||||
#define XML_PROLOG_STATE 0
|
||||
#define XML_CONTENT_STATE 1
|
||||
@@ -103,14 +107,10 @@ extern "C" {
|
||||
#define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||
#define XML_ENTITY_VALUE_LITERAL 1
|
||||
|
||||
#define XML_N_INTERNAL_ENCODINGS 1
|
||||
#define XML_UTF8_ENCODING 0
|
||||
#if 0
|
||||
#define XML_UTF16_ENCODING 1
|
||||
#define XML_UCS4_ENCODING 2
|
||||
#endif
|
||||
|
||||
#define XML_MAX_BYTES_PER_CHAR 4
|
||||
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
|
||||
#define XML_UTF8_ENCODE_MAX 4
|
||||
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
|
||||
#define XML_UTF16_ENCODE_MAX 2
|
||||
|
||||
typedef struct position {
|
||||
/* first line and first column are 0 not 1 */
|
||||
@@ -146,21 +146,26 @@ struct encoding {
|
||||
int (*getAtts)(const ENCODING *enc, const char *ptr,
|
||||
int attsMax, ATTRIBUTE *atts);
|
||||
int (*charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||
int (*predefinedEntityName)(const ENCODING *, const char *, const char *);
|
||||
void (*updatePosition)(const ENCODING *,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
POSITION *);
|
||||
int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **badPtr);
|
||||
int (*encode)(const ENCODING *enc,
|
||||
int charNum,
|
||||
char *buf);
|
||||
void (*convert[XML_N_INTERNAL_ENCODINGS])(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
char **toP,
|
||||
const char *toLim);
|
||||
void (*utf8Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
char **toP,
|
||||
const char *toLim);
|
||||
void (*utf16Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
unsigned short **toP,
|
||||
const unsigned short *toLim);
|
||||
int minBytesPerChar;
|
||||
char isUtf8;
|
||||
char isUtf16;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -225,17 +230,20 @@ the content of a literal that has already been returned by XmlTok. */
|
||||
#define XmlCharRefNumber(enc, ptr) \
|
||||
(((enc)->charRefNumber)(enc, ptr))
|
||||
|
||||
#define XmlPredefinedEntityName(enc, ptr, end) \
|
||||
(((enc)->predefinedEntityName)(enc, ptr, end))
|
||||
|
||||
#define XmlUpdatePosition(enc, ptr, end, pos) \
|
||||
(((enc)->updatePosition)(enc, ptr, end, pos))
|
||||
|
||||
#define XmlIsPublicId(enc, ptr, end, badPtr) \
|
||||
(((enc)->isPublicId)(enc, ptr, end, badPtr))
|
||||
|
||||
#define XmlEncode(enc, ch, buf) \
|
||||
(((enc)->encode)(enc, ch, buf))
|
||||
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
#define XmlConvert(enc, targetEnc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->convert[targetEnc])(enc, fromP, fromLim, toP, toLim))
|
||||
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
typedef struct {
|
||||
ENCODING initEnc;
|
||||
@@ -253,8 +261,35 @@ int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity,
|
||||
int *standalonePtr);
|
||||
|
||||
int XMLTOKAPI XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING XMLTOKAPI *XmlGetInternalEncoding(int);
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncoding();
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncoding();
|
||||
int XMLTOKAPI XmlUtf8Encode(int charNumber, char *buf);
|
||||
int XMLTOKAPI XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||
|
||||
int XMLTOKAPI XmlSizeOfUnknownEncoding();
|
||||
ENCODING XMLTOKAPI *
|
||||
XmlInitUnknownEncoding(void *mem,
|
||||
int *table,
|
||||
int (*convert)(void *userData, const char *p),
|
||||
void *userData);
|
||||
|
||||
int XMLTOKAPI XmlParseXmlDeclNS(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr,
|
||||
int *standalonePtr);
|
||||
int XMLTOKAPI XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncodingNS();
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncodingNS();
|
||||
ENCODING XMLTOKAPI *
|
||||
XmlInitUnknownEncodingNS(void *mem,
|
||||
int *table,
|
||||
int (*convert)(void *userData, const char *p),
|
||||
void *userData);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
+354
-190
File diff suppressed because it is too large
Load Diff
@@ -42,6 +42,7 @@ enum {
|
||||
BT_LSQB,
|
||||
BT_S,
|
||||
BT_NMSTRT,
|
||||
BT_COLON,
|
||||
BT_HEX,
|
||||
BT_DIGIT,
|
||||
BT_NAME,
|
||||
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
const ENCODING *NS(XmlGetUtf8InternalEncoding)()
|
||||
{
|
||||
return &ns(internal_utf8_encoding).enc;
|
||||
}
|
||||
|
||||
const ENCODING *NS(XmlGetUtf16InternalEncoding)()
|
||||
{
|
||||
#if BYTE_ORDER == 12
|
||||
return &ns(internal_little2_encoding).enc;
|
||||
#elif BYTE_ORDER == 21
|
||||
return &ns(internal_big2_encoding).enc;
|
||||
#else
|
||||
const short n = 1;
|
||||
return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
const ENCODING *NS(encodings)[] = {
|
||||
&ns(latin1_encoding).enc,
|
||||
&ns(ascii_encoding).enc,
|
||||
&ns(utf8_encoding).enc,
|
||||
&ns(big2_encoding).enc,
|
||||
&ns(big2_encoding).enc,
|
||||
&ns(little2_encoding).enc,
|
||||
&ns(utf8_encoding).enc /* NO_ENC */
|
||||
};
|
||||
|
||||
static
|
||||
int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
static
|
||||
int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
|
||||
{
|
||||
int i = getEncodingIndex(name);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
INIT_ENC_INDEX(p) = (char)i;
|
||||
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
|
||||
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
|
||||
p->initEnc.updatePosition = initUpdatePosition;
|
||||
p->encPtr = encPtr;
|
||||
*encPtr = &(p->initEnc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
|
||||
{
|
||||
#define ENCODING_MAX 128
|
||||
char buf[ENCODING_MAX];
|
||||
char *p = buf;
|
||||
int i;
|
||||
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
|
||||
if (ptr != end)
|
||||
return 0;
|
||||
*p = 0;
|
||||
if (streqci(buf, "UTF-16") && enc->minBytesPerChar == 2)
|
||||
return enc;
|
||||
i = getEncodingIndex(buf);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
return NS(encodings)[i];
|
||||
}
|
||||
|
||||
int NS(XmlParseXmlDecl)(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **encodingName,
|
||||
const ENCODING **encoding,
|
||||
int *standalone)
|
||||
{
|
||||
return doParseXmlDecl(NS(findEncoding),
|
||||
isGeneralTextEntity,
|
||||
enc,
|
||||
ptr,
|
||||
end,
|
||||
badPtr,
|
||||
versionPtr,
|
||||
encodingName,
|
||||
encoding,
|
||||
standalone);
|
||||
}
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#include "codepage.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define STRICT 1
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
int codepageMap(int cp, int *map)
|
||||
{
|
||||
int i;
|
||||
CPINFO info;
|
||||
if (!GetCPInfo(cp, &info) || info.MaxCharSize > 2)
|
||||
return 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
map[i] = -1;
|
||||
if (info.MaxCharSize > 1) {
|
||||
for (i = 0; i < MAX_LEADBYTES; i++) {
|
||||
int j, lim;
|
||||
if (info.LeadByte[i] == 0 && info.LeadByte[i + 1] == 0)
|
||||
break;
|
||||
lim = info.LeadByte[i + 1];
|
||||
for (j = info.LeadByte[i]; j < lim; j++)
|
||||
map[j] = -2;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (map[i] == -1) {
|
||||
char c = i;
|
||||
unsigned short n;
|
||||
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
|
||||
&c, 1, &n, 1) == 1)
|
||||
map[i] = n;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int codepageConvert(int cp, const char *p)
|
||||
{
|
||||
unsigned short c;
|
||||
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
|
||||
p, 2, &c, 1) == 1)
|
||||
return c;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else /* not WIN32 */
|
||||
|
||||
int codepageMap(int cp, int *map)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int codepageConvert(int cp, const char *p)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* not WIN32 */
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
int codepageMap(int cp, int *map);
|
||||
int codepageConvert(int cp, const char *p);
|
||||
@@ -21,6 +21,12 @@ Contributor(s):
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
int filemap(const wchar_t *name,
|
||||
void (*processor)(const void *, size_t, const wchar_t *, void *arg),
|
||||
void *arg);
|
||||
#else
|
||||
int filemap(const char *name,
|
||||
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||
void *arg);
|
||||
#endif
|
||||
|
||||
@@ -19,14 +19,27 @@ Contributor(s):
|
||||
*/
|
||||
|
||||
#define STRICT 1
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#ifndef XML_UNICODE
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
#define UNICODE
|
||||
#define _UNICODE
|
||||
#endif /* XML_UNICODE */
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include "filemap.h"
|
||||
|
||||
static void win32perror(const char *);
|
||||
static void win32perror(const TCHAR *);
|
||||
|
||||
int filemap(const char *name,
|
||||
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||
int filemap(const TCHAR *name,
|
||||
void (*processor)(const void *, size_t, const TCHAR *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
HANDLE f;
|
||||
@@ -47,7 +60,7 @@ int filemap(const char *name,
|
||||
return 0;
|
||||
}
|
||||
if (sizeHi) {
|
||||
fprintf(stderr, "%s: bigger than 2Gb\n", name);
|
||||
_ftprintf(stderr, _T("%s: bigger than 2Gb\n"), name);
|
||||
return 0;
|
||||
}
|
||||
/* CreateFileMapping barfs on zero length files */
|
||||
@@ -78,7 +91,7 @@ int filemap(const char *name,
|
||||
}
|
||||
|
||||
static
|
||||
void win32perror(const char *s)
|
||||
void win32perror(const TCHAR *s)
|
||||
{
|
||||
LPVOID buf;
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
@@ -88,10 +101,10 @@ void win32perror(const char *s)
|
||||
(LPTSTR) &buf,
|
||||
0,
|
||||
NULL)) {
|
||||
fprintf(stderr, "%s: %s", s, buf);
|
||||
_ftprintf(stderr, _T("%s: %s"), s, buf);
|
||||
fflush(stderr);
|
||||
LocalFree(buf);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "%s: unknown Windows error\n", s);
|
||||
_ftprintf(stderr, _T("%s: unknown Windows error\n"), s);
|
||||
}
|
||||
|
||||
Executable
+228
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include "xmlparse.h"
|
||||
#include "xmlfile.h"
|
||||
#include "xmltchar.h"
|
||||
#include "filemap.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef _POSIX_SOURCE
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#ifdef _O_BINARY
|
||||
#define O_BINARY _O_BINARY
|
||||
#else
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define READ_SIZE 16
|
||||
#else
|
||||
#define READ_SIZE (1024*8)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
XML_Parser parser;
|
||||
int *retPtr;
|
||||
} PROCESS_ARGS;
|
||||
|
||||
static
|
||||
void reportError(XML_Parser parser, const XML_Char *filename)
|
||||
{
|
||||
int code = XML_GetErrorCode(parser);
|
||||
const XML_Char *message = XML_ErrorString(code);
|
||||
if (message)
|
||||
ftprintf(stdout, T("%s:%d:%ld: %s\n"),
|
||||
filename,
|
||||
XML_GetErrorLineNumber(parser),
|
||||
XML_GetErrorColumnNumber(parser),
|
||||
message);
|
||||
else
|
||||
ftprintf(stderr, T("%s: (unknown message %d)\n"), filename, code);
|
||||
}
|
||||
|
||||
static
|
||||
void processFile(const void *data,
|
||||
size_t size,
|
||||
const XML_Char *filename,
|
||||
void *args)
|
||||
{
|
||||
XML_Parser parser = ((PROCESS_ARGS *)args)->parser;
|
||||
int *retPtr = ((PROCESS_ARGS *)args)->retPtr;
|
||||
if (!XML_Parse(parser, data, size, 1)) {
|
||||
reportError(parser, filename);
|
||||
*retPtr = 0;
|
||||
}
|
||||
else
|
||||
*retPtr = 1;
|
||||
}
|
||||
|
||||
static
|
||||
int isAsciiLetter(XML_Char c)
|
||||
{
|
||||
return (T('a') <= c && c <= T('z')) || (T('A') <= c && c <= T('Z'));
|
||||
}
|
||||
|
||||
static
|
||||
const XML_Char *resolveSystemId(const XML_Char *base, const XML_Char *systemId, XML_Char **toFree)
|
||||
{
|
||||
XML_Char *s;
|
||||
*toFree = 0;
|
||||
if (!base
|
||||
|| *systemId == T('/')
|
||||
#ifdef WIN32
|
||||
|| *systemId == T('\\')
|
||||
|| (isAsciiLetter(systemId[0]) && systemId[1] == T(':'))
|
||||
#endif
|
||||
)
|
||||
return systemId;
|
||||
*toFree = (XML_Char *)malloc((tcslen(base) + tcslen(systemId) + 2)*sizeof(XML_Char));
|
||||
if (!*toFree)
|
||||
return systemId;
|
||||
tcscpy(*toFree, base);
|
||||
s = *toFree;
|
||||
if (tcsrchr(s, T('/')))
|
||||
s = tcsrchr(s, T('/')) + 1;
|
||||
#ifdef WIN32
|
||||
if (tcsrchr(s, T('\\')))
|
||||
s = tcsrchr(s, T('\\')) + 1;
|
||||
#endif
|
||||
tcscpy(s, systemId);
|
||||
return *toFree;
|
||||
}
|
||||
|
||||
static
|
||||
int externalEntityRefFilemap(XML_Parser parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
int result;
|
||||
XML_Char *s;
|
||||
const XML_Char *filename;
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
|
||||
PROCESS_ARGS args;
|
||||
args.retPtr = &result;
|
||||
args.parser = entParser;
|
||||
filename = resolveSystemId(base, systemId, &s);
|
||||
XML_SetBase(entParser, filename);
|
||||
if (!filemap(filename, processFile, &args))
|
||||
result = 0;
|
||||
free(s);
|
||||
XML_ParserFree(entParser);
|
||||
return result;
|
||||
}
|
||||
|
||||
static
|
||||
int processStream(const XML_Char *filename, XML_Parser parser)
|
||||
{
|
||||
int fd = topen(filename, O_BINARY|O_RDONLY);
|
||||
if (fd < 0) {
|
||||
tperror(filename);
|
||||
return 0;
|
||||
}
|
||||
for (;;) {
|
||||
int nread;
|
||||
char *buf = XML_GetBuffer(parser, READ_SIZE);
|
||||
if (!buf) {
|
||||
close(fd);
|
||||
ftprintf(stderr, T("%s: out of memory\n"), filename);
|
||||
return 0;
|
||||
}
|
||||
nread = read(fd, buf, READ_SIZE);
|
||||
if (nread < 0) {
|
||||
tperror(filename);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (!XML_ParseBuffer(parser, nread, nread == 0)) {
|
||||
reportError(parser, filename);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (nread == 0) {
|
||||
close(fd);
|
||||
break;;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
int externalEntityRefStream(XML_Parser parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
XML_Char *s;
|
||||
const XML_Char *filename;
|
||||
int ret;
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
|
||||
filename = resolveSystemId(base, systemId, &s);
|
||||
XML_SetBase(entParser, filename);
|
||||
ret = processStream(filename, entParser);
|
||||
free(s);
|
||||
XML_ParserFree(entParser);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int XML_ProcessFile(XML_Parser parser,
|
||||
const XML_Char *filename,
|
||||
unsigned flags)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!XML_SetBase(parser, filename)) {
|
||||
ftprintf(stderr, T("%s: out of memory"), filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (flags & XML_EXTERNAL_ENTITIES)
|
||||
XML_SetExternalEntityRefHandler(parser,
|
||||
(flags & XML_MAP_FILE)
|
||||
? externalEntityRefFilemap
|
||||
: externalEntityRefStream);
|
||||
if (flags & XML_MAP_FILE) {
|
||||
PROCESS_ARGS args;
|
||||
args.retPtr = &result;
|
||||
args.parser = parser;
|
||||
if (!filemap(filename, processFile, &args))
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
result = processStream(filename, parser);
|
||||
return result;
|
||||
}
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.0 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is expat.
|
||||
|
||||
The Initial Developer of the Original Code is James Clark.
|
||||
Portions created by James Clark are Copyright (C) 1998
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#define XML_MAP_FILE 01
|
||||
#define XML_EXTERNAL_ENTITIES 02
|
||||
|
||||
extern int XML_ProcessFile(XML_Parser parser,
|
||||
const XML_Char *filename,
|
||||
unsigned flags);
|
||||
Executable
+161
@@ -0,0 +1,161 @@
|
||||
#include <string.h>
|
||||
#include "xmlmime.h"
|
||||
|
||||
static
|
||||
const char *getTok(const char **pp)
|
||||
{
|
||||
/* inComment means one level of nesting; inComment+1 means two levels etc */
|
||||
enum { inAtom, inString, init, inComment };
|
||||
int state = init;
|
||||
const char *tokStart = 0;
|
||||
for (;;) {
|
||||
switch (**pp) {
|
||||
case '\0':
|
||||
if (state == inAtom)
|
||||
return tokStart;
|
||||
return 0;
|
||||
case ' ':
|
||||
case '\r':
|
||||
case '\t':
|
||||
case '\n':
|
||||
if (state == inAtom)
|
||||
return tokStart;
|
||||
break;
|
||||
case '(':
|
||||
if (state == inAtom)
|
||||
return tokStart;
|
||||
if (state != inString)
|
||||
state++;
|
||||
break;
|
||||
case ')':
|
||||
if (state > init)
|
||||
--state;
|
||||
else if (state != inString)
|
||||
return 0;
|
||||
break;
|
||||
case ';':
|
||||
case '/':
|
||||
case '=':
|
||||
if (state == inAtom)
|
||||
return tokStart;
|
||||
if (state == init)
|
||||
return (*pp)++;
|
||||
break;
|
||||
case '\\':
|
||||
++*pp;
|
||||
if (**pp == '\0')
|
||||
return 0;
|
||||
break;
|
||||
case '"':
|
||||
switch (state) {
|
||||
case inString:
|
||||
++*pp;
|
||||
return tokStart;
|
||||
case inAtom:
|
||||
return tokStart;
|
||||
case init:
|
||||
tokStart = *pp;
|
||||
state = inString;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (state == init) {
|
||||
tokStart = *pp;
|
||||
state = inAtom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
++*pp;
|
||||
}
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
/* key must be lowercase ASCII */
|
||||
|
||||
static
|
||||
int matchkey(const char *start, const char *end, const char *key)
|
||||
{
|
||||
if (!start)
|
||||
return 0;
|
||||
for (; start != end; start++, key++)
|
||||
if (*start != *key && *start != 'A' + (*key - 'a'))
|
||||
return 0;
|
||||
return *key == '\0';
|
||||
}
|
||||
|
||||
void getXMLCharset(const char *buf, char *charset)
|
||||
{
|
||||
const char *next, *p;
|
||||
|
||||
charset[0] = '\0';
|
||||
next = buf;
|
||||
p = getTok(&next);
|
||||
if (matchkey(p, next, "text"))
|
||||
strcpy(charset, "us-ascii");
|
||||
else if (!matchkey(p, next, "application"))
|
||||
return;
|
||||
p = getTok(&next);
|
||||
if (!p || *p != '/')
|
||||
return;
|
||||
p = getTok(&next);
|
||||
#if 0
|
||||
if (!matchkey(p, next, "xml") && charset[0] == '\0')
|
||||
return;
|
||||
#endif
|
||||
p = getTok(&next);
|
||||
while (p) {
|
||||
if (*p == ';') {
|
||||
p = getTok(&next);
|
||||
if (matchkey(p, next, "charset")) {
|
||||
p = getTok(&next);
|
||||
if (p && *p == '=') {
|
||||
p = getTok(&next);
|
||||
if (p) {
|
||||
char *s = charset;
|
||||
if (*p == '"') {
|
||||
while (++p != next - 1) {
|
||||
if (*p == '\\')
|
||||
++p;
|
||||
if (s == charset + CHARSET_MAX - 1) {
|
||||
charset[0] = '\0';
|
||||
break;
|
||||
}
|
||||
*s++ = *p;
|
||||
}
|
||||
*s++ = '\0';
|
||||
}
|
||||
else {
|
||||
if (next - p > CHARSET_MAX - 1)
|
||||
break;
|
||||
while (p != next)
|
||||
*s++ = *p++;
|
||||
*s = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
p = getTok(&next);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char buf[CHARSET_MAX];
|
||||
if (argc <= 1)
|
||||
return 1;
|
||||
printf("%s\n", argv[1]);
|
||||
getXMLCharset(argv[1], buf);
|
||||
printf("charset=\"%s\"\n", buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Registered charset names are at most 40 characters long. */
|
||||
|
||||
#define CHARSET_MAX 41
|
||||
|
||||
/* Figure out the charset to use from the ContentType.
|
||||
buf contains the body of the header field (the part after "Content-Type:").
|
||||
charset gets the charset to use. It must be at least CHARSET_MAX chars long.
|
||||
charset will be empty if the default charset should be used. */
|
||||
|
||||
void getXMLCharset(const char *buf, char *charset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#ifdef XML_UNICODE
|
||||
#ifndef XML_UNICODE_WCHAR_T
|
||||
#error xmlwf requires a 16-bit Unicode-compatible wchar_t
|
||||
#endif
|
||||
#define T(x) L ## x
|
||||
#define ftprintf fwprintf
|
||||
#define tfopen _wfopen
|
||||
#define fputts fputws
|
||||
#define puttc putwc
|
||||
#define tcscmp wcscmp
|
||||
#define tcscpy wcscpy
|
||||
#define tcscat wcscat
|
||||
#define tcschr wcschr
|
||||
#define tcsrchr wcsrchr
|
||||
#define tcslen wcslen
|
||||
#define tperror _wperror
|
||||
#define topen _wopen
|
||||
#define tmain wmain
|
||||
#define tremove _wremove
|
||||
#else /* not XML_UNICODE */
|
||||
#define T(x) x
|
||||
#define ftprintf fprintf
|
||||
#define tfopen fopen
|
||||
#define fputts fputs
|
||||
#define puttc putc
|
||||
#define tcscmp strcmp
|
||||
#define tcscpy strcpy
|
||||
#define tcscat strcat
|
||||
#define tcschr strchr
|
||||
#define tcsrchr strrchr
|
||||
#define tcslen strlen
|
||||
#define tperror perror
|
||||
#define topen open
|
||||
#define tmain main
|
||||
#define tremove remove
|
||||
#endif /* not XML_UNICODE */
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int XML_URLInit();
|
||||
void XML_URLUninit();
|
||||
int XML_ProcessURL(XML_Parser parser,
|
||||
const XML_Char *url,
|
||||
unsigned flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+460
-233
@@ -18,65 +18,46 @@ James Clark. All Rights Reserved.
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
#include "xmlparse.h"
|
||||
#include "filemap.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef _POSIX_SOURCE
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#ifdef _O_BINARY
|
||||
#define O_BINARY _O_BINARY
|
||||
#else
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#endif
|
||||
#include "xmlparse.h"
|
||||
#include "codepage.h"
|
||||
#include "xmlfile.h"
|
||||
#include "xmltchar.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define READ_SIZE 16
|
||||
#else
|
||||
#define READ_SIZE (1024*8)
|
||||
#endif
|
||||
#define NSSEP T('#')
|
||||
|
||||
static void characterData(void *userData, const char *s, int len)
|
||||
static void characterData(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
for (; len > 0; --len, ++s) {
|
||||
switch (*s) {
|
||||
case '&':
|
||||
fputs("&", fp);
|
||||
case T('&'):
|
||||
fputts(T("&"), fp);
|
||||
break;
|
||||
case '<':
|
||||
fputs("<", fp);
|
||||
case T('<'):
|
||||
fputts(T("<"), fp);
|
||||
break;
|
||||
case '>':
|
||||
fputs(">", fp);
|
||||
case T('>'):
|
||||
fputts(T(">"), fp);
|
||||
break;
|
||||
case '"':
|
||||
fputs(""", fp);
|
||||
case T('"'):
|
||||
fputts(T("""), fp);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
fprintf(fp, "&#%d;", *s);
|
||||
ftprintf(fp, T("&#%d;"), *s);
|
||||
break;
|
||||
default:
|
||||
putc(*s, fp);
|
||||
puttc(*s, fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -87,224 +68,442 @@ is equivalent to lexicographically comparing based on the character number. */
|
||||
|
||||
static int attcmp(const void *att1, const void *att2)
|
||||
{
|
||||
return strcmp(*(const char **)att1, *(const char **)att2);
|
||||
return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2);
|
||||
}
|
||||
|
||||
static void startElement(void *userData, const char *name, const char **atts)
|
||||
static void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
int nAtts;
|
||||
const char **p;
|
||||
const XML_Char **p;
|
||||
FILE *fp = userData;
|
||||
putc('<', fp);
|
||||
fputs(name, fp);
|
||||
puttc(T('<'), fp);
|
||||
fputts(name, fp);
|
||||
|
||||
p = atts;
|
||||
while (*p)
|
||||
++p;
|
||||
nAtts = (p - atts) >> 1;
|
||||
if (nAtts > 1)
|
||||
qsort((void *)atts, nAtts, sizeof(char *) * 2, attcmp);
|
||||
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp);
|
||||
while (*atts) {
|
||||
putc(' ', fp);
|
||||
fputs(*atts++, fp);
|
||||
putc('=', fp);
|
||||
putc('"', fp);
|
||||
characterData(userData, *atts, strlen(*atts));
|
||||
putc('"', fp);
|
||||
puttc(T(' '), fp);
|
||||
fputts(*atts++, fp);
|
||||
puttc(T('='), fp);
|
||||
puttc(T('"'), fp);
|
||||
characterData(userData, *atts, tcslen(*atts));
|
||||
puttc(T('"'), fp);
|
||||
atts++;
|
||||
}
|
||||
putc('>', fp);
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static void endElement(void *userData, const char *name)
|
||||
static void endElement(void *userData, const XML_Char *name)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
putc('<', fp);
|
||||
putc('/', fp);
|
||||
fputs(name, fp);
|
||||
putc('>', fp);
|
||||
puttc(T('<'), fp);
|
||||
puttc(T('/'), fp);
|
||||
fputts(name, fp);
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static void processingInstruction(void *userData, const char *target, const char *data)
|
||||
static void startElementNS(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
int nAtts;
|
||||
int nsi;
|
||||
const XML_Char **p;
|
||||
FILE *fp = userData;
|
||||
const XML_Char *sep;
|
||||
puttc(T('<'), fp);
|
||||
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
if (sep) {
|
||||
fputts(T("ns0:"), fp);
|
||||
fputts(sep + 1, fp);
|
||||
fputts(T(" xmlns:ns0=\""), fp);
|
||||
characterData(userData, name, sep - name);
|
||||
puttc(T('"'), fp);
|
||||
nsi = 1;
|
||||
}
|
||||
else {
|
||||
fputts(name, fp);
|
||||
nsi = 0;
|
||||
}
|
||||
|
||||
p = atts;
|
||||
while (*p)
|
||||
++p;
|
||||
nAtts = (p - atts) >> 1;
|
||||
if (nAtts > 1)
|
||||
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp);
|
||||
while (*atts) {
|
||||
name = *atts++;
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
if (sep) {
|
||||
ftprintf(fp, T(" xmlns:ns%d=\""), nsi);
|
||||
characterData(userData, name, sep - name);
|
||||
puttc(T('"'), fp);
|
||||
name = sep + 1;
|
||||
ftprintf(fp, T(" ns%d:"), nsi++);
|
||||
}
|
||||
else
|
||||
puttc(T(' '), fp);
|
||||
fputts(name, fp);
|
||||
puttc(T('='), fp);
|
||||
puttc(T('"'), fp);
|
||||
characterData(userData, *atts, tcslen(*atts));
|
||||
puttc(T('"'), fp);
|
||||
atts++;
|
||||
}
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static void endElementNS(void *userData, const XML_Char *name)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
fprintf(fp, "<?%s %s?>", target, data);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
XML_Parser parser;
|
||||
int *retPtr;
|
||||
} PROCESS_ARGS;
|
||||
|
||||
static
|
||||
void reportError(XML_Parser parser, const char *filename)
|
||||
{
|
||||
int code = XML_GetErrorCode(parser);
|
||||
const char *message = XML_ErrorString(code);
|
||||
if (message)
|
||||
fprintf(stdout, "%s:%d:%ld: %s\n",
|
||||
filename,
|
||||
XML_GetErrorLineNumber(parser),
|
||||
XML_GetErrorColumnNumber(parser),
|
||||
message);
|
||||
else
|
||||
fprintf(stderr, "%s: (unknown message %d)\n", filename, code);
|
||||
}
|
||||
|
||||
static
|
||||
void processFile(const void *data, size_t size, const char *filename, void *args)
|
||||
{
|
||||
XML_Parser parser = ((PROCESS_ARGS *)args)->parser;
|
||||
int *retPtr = ((PROCESS_ARGS *)args)->retPtr;
|
||||
if (!XML_Parse(parser, data, size, 1)) {
|
||||
reportError(parser, filename);
|
||||
*retPtr = 0;
|
||||
const XML_Char *sep;
|
||||
puttc(T('<'), fp);
|
||||
puttc(T('/'), fp);
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
if (sep) {
|
||||
fputts(T("ns0:"), fp);
|
||||
fputts(sep + 1, fp);
|
||||
}
|
||||
else
|
||||
*retPtr = 1;
|
||||
fputts(name, fp);
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static void processingInstruction(void *userData, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
puttc(T('<'), fp);
|
||||
puttc(T('?'), fp);
|
||||
fputts(target, fp);
|
||||
puttc(T(' '), fp);
|
||||
fputts(data, fp);
|
||||
puttc(T('?'), fp);
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static void defaultCharacterData(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
}
|
||||
|
||||
static void defaultStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
}
|
||||
|
||||
static void defaultEndElement(XML_Parser parser, const XML_Char *name)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
}
|
||||
|
||||
static void defaultProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
}
|
||||
|
||||
static void nopCharacterData(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
}
|
||||
|
||||
static void nopStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
}
|
||||
|
||||
static void nopEndElement(XML_Parser parser, const XML_Char *name)
|
||||
{
|
||||
}
|
||||
|
||||
static void nopProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
}
|
||||
|
||||
static void markup(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
for (; len > 0; --len, ++s)
|
||||
puttc(*s, fp);
|
||||
}
|
||||
|
||||
static
|
||||
int isAsciiLetter(char c)
|
||||
void metaLocation(XML_Parser parser)
|
||||
{
|
||||
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
|
||||
const XML_Char *uri = XML_GetBase(parser);
|
||||
if (uri)
|
||||
ftprintf(XML_GetUserData(parser), T(" uri=\"%s\""), uri);
|
||||
ftprintf(XML_GetUserData(parser),
|
||||
T(" byte=\"%ld\" line=\"%d\" col=\"%d\""),
|
||||
XML_GetCurrentByteIndex(parser),
|
||||
XML_GetCurrentLineNumber(parser),
|
||||
XML_GetCurrentColumnNumber(parser));
|
||||
}
|
||||
|
||||
static
|
||||
const char *resolveSystemId(const char *base, const char *systemId, char **toFree)
|
||||
void metaStartDocument(XML_Parser parser)
|
||||
{
|
||||
char *s;
|
||||
*toFree = 0;
|
||||
if (!base
|
||||
|| *systemId == '/'
|
||||
#ifdef WIN32
|
||||
|| *systemId == '\\'
|
||||
|| (isAsciiLetter(systemId[0]) && systemId[1] == ':')
|
||||
#endif
|
||||
)
|
||||
return systemId;
|
||||
*toFree = (char *)malloc(strlen(base) + strlen(systemId) + 2);
|
||||
if (!*toFree)
|
||||
return systemId;
|
||||
strcpy(*toFree, base);
|
||||
s = *toFree;
|
||||
if (strrchr(s, '/'))
|
||||
s = strrchr(s, '/') + 1;
|
||||
#ifdef WIN32
|
||||
if (strrchr(s, '\\'))
|
||||
s = strrchr(s, '\\') + 1;
|
||||
#endif
|
||||
strcpy(s, systemId);
|
||||
return *toFree;
|
||||
fputts(T("<document>\n"), XML_GetUserData(parser));
|
||||
}
|
||||
|
||||
static
|
||||
int externalEntityRefFilemap(XML_Parser parser,
|
||||
const char *openEntityNames,
|
||||
const char *base,
|
||||
const char *systemId,
|
||||
const char *publicId)
|
||||
void metaEndDocument(XML_Parser parser)
|
||||
{
|
||||
int result;
|
||||
char *s;
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, openEntityNames, 0);
|
||||
PROCESS_ARGS args;
|
||||
args.retPtr = &result;
|
||||
args.parser = entParser;
|
||||
if (!filemap(resolveSystemId(base, systemId, &s), processFile, &args))
|
||||
result = 0;
|
||||
free(s);
|
||||
XML_ParserFree(entParser);
|
||||
return result;
|
||||
fputts(T("</document>\n"), XML_GetUserData(parser));
|
||||
}
|
||||
|
||||
static
|
||||
int processStream(const char *filename, XML_Parser parser)
|
||||
void metaStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
int fd = open(filename, O_BINARY|O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror(filename);
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<starttag name=\"%s\""), name);
|
||||
metaLocation(parser);
|
||||
if (*atts) {
|
||||
fputts(T(">\n"), fp);
|
||||
do {
|
||||
ftprintf(fp, T("<attribute name=\"%s\" value=\""), atts[0]);
|
||||
characterData(fp, atts[1], tcslen(atts[1]));
|
||||
fputts(T("\"/>\n"), fp);
|
||||
} while (*(atts += 2));
|
||||
fputts(T("</starttag>\n"), fp);
|
||||
}
|
||||
else
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndElement(XML_Parser parser, const XML_Char *name)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<endtag name=\"%s\""), name);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<pi target=\"%s\" data=\""), target);
|
||||
characterData(fp, data, tcslen(data));
|
||||
puttc(T('"'), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaComment(XML_Parser parser, const XML_Char *data)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<comment data=\""), fp);
|
||||
characterData(fp, data, tcslen(data));
|
||||
puttc(T('"'), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaStartCdataSection(XML_Parser parser)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<startcdata"), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndCdataSection(XML_Parser parser)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<endcdata"), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaCharacterData(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<chars str=\""), fp);
|
||||
characterData(fp, s, len);
|
||||
puttc(T('"'), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaUnparsedEntityDecl(XML_Parser parser,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId,
|
||||
const XML_Char *notationName)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<entity name=\"%s\""), entityName);
|
||||
if (publicId)
|
||||
ftprintf(fp, T(" public=\"%s\""), publicId);
|
||||
fputts(T(" system=\""), fp);
|
||||
characterData(fp, systemId, tcslen(systemId));
|
||||
puttc(T('"'), fp);
|
||||
ftprintf(fp, T(" notation=\"%s\""), notationName);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaNotationDecl(XML_Parser parser,
|
||||
const XML_Char *notationName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<notation name=\"%s\""), notationName);
|
||||
if (publicId)
|
||||
ftprintf(fp, T(" public=\"%s\""), publicId);
|
||||
if (systemId) {
|
||||
fputts(T(" system=\""), fp);
|
||||
characterData(fp, systemId, tcslen(systemId));
|
||||
puttc(T('"'), fp);
|
||||
}
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaStartNamespaceDecl(XML_Parser parser,
|
||||
const XML_Char *prefix,
|
||||
const XML_Char *uri)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<startns"), fp);
|
||||
if (prefix)
|
||||
ftprintf(fp, T(" prefix=\"%s\""), prefix);
|
||||
if (uri) {
|
||||
fputts(T(" ns=\""), fp);
|
||||
characterData(fp, uri, tcslen(uri));
|
||||
fputts(T("\"/>\n"), fp);
|
||||
}
|
||||
else
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndNamespaceDecl(XML_Parser parser, const XML_Char *prefix)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
if (!prefix)
|
||||
fputts(T("<endns/>\n"), fp);
|
||||
else
|
||||
ftprintf(fp, T("<endns prefix=\"%s\"/>\n"), prefix);
|
||||
}
|
||||
|
||||
static
|
||||
int unknownEncodingConvert(void *data, const char *p)
|
||||
{
|
||||
return codepageConvert(*(int *)data, p);
|
||||
}
|
||||
|
||||
static
|
||||
int unknownEncoding(void *userData,
|
||||
const XML_Char *name,
|
||||
XML_Encoding *info)
|
||||
{
|
||||
int cp;
|
||||
static const XML_Char prefixL[] = T("windows-");
|
||||
static const XML_Char prefixU[] = T("WINDOWS-");
|
||||
int i;
|
||||
|
||||
for (i = 0; prefixU[i]; i++)
|
||||
if (name[i] != prefixU[i] && name[i] != prefixL[i])
|
||||
return 0;
|
||||
|
||||
cp = 0;
|
||||
for (; name[i]; i++) {
|
||||
static const XML_Char digits[] = T("0123456789");
|
||||
const XML_Char *s = tcschr(digits, name[i]);
|
||||
if (!s)
|
||||
return 0;
|
||||
cp *= 10;
|
||||
cp += s - digits;
|
||||
if (cp >= 0x10000)
|
||||
return 0;
|
||||
}
|
||||
if (!codepageMap(cp, info->map))
|
||||
return 0;
|
||||
}
|
||||
for (;;) {
|
||||
int nread;
|
||||
char *buf = XML_GetBuffer(parser, READ_SIZE);
|
||||
if (!buf) {
|
||||
close(fd);
|
||||
fprintf(stderr, "%s: out of memory\n", filename);
|
||||
return 0;
|
||||
}
|
||||
nread = read(fd, buf, READ_SIZE);
|
||||
if (nread < 0) {
|
||||
perror(filename);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (!XML_ParseBuffer(parser, nread, nread == 0)) {
|
||||
reportError(parser, filename);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (nread == 0) {
|
||||
close(fd);
|
||||
break;;
|
||||
}
|
||||
}
|
||||
info->convert = unknownEncodingConvert;
|
||||
/* We could just cast the code page integer to a void *,
|
||||
and avoid the use of release. */
|
||||
info->release = free;
|
||||
info->data = malloc(sizeof(int));
|
||||
if (!info->data)
|
||||
return 0;
|
||||
*(int *)info->data = cp;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
int externalEntityRefStream(XML_Parser parser,
|
||||
const char *openEntityNames,
|
||||
const char *base,
|
||||
const char *systemId,
|
||||
const char *publicId)
|
||||
void usage(const XML_Char *prog)
|
||||
{
|
||||
char *s;
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, openEntityNames, 0);
|
||||
int ret = processStream(resolveSystemId(base, systemId, &s), entParser);
|
||||
free(s);
|
||||
XML_ParserFree(entParser);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static
|
||||
void usage(const char *prog)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-r] [-x] [-d output-dir] [-e encoding] file ...\n", prog);
|
||||
ftprintf(stderr, T("usage: %s [-n] [-r] [-w] [-x] [-d output-dir] [-e encoding] file ...\n"), prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int tmain(int argc, XML_Char **argv)
|
||||
{
|
||||
int i;
|
||||
const char *outputDir = 0;
|
||||
const char *encoding = 0;
|
||||
int useFilemap = 1;
|
||||
int processExternalEntities = 0;
|
||||
const XML_Char *outputDir = 0;
|
||||
const XML_Char *encoding = 0;
|
||||
unsigned processFlags = XML_MAP_FILE;
|
||||
int windowsCodePages = 0;
|
||||
int outputType = 0;
|
||||
int useNamespaces = 0;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
i = 1;
|
||||
while (i < argc && argv[i][0] == '-') {
|
||||
while (i < argc && argv[i][0] == T('-')) {
|
||||
int j;
|
||||
if (argv[i][1] == '-' && argv[i][2] == '\0') {
|
||||
if (argv[i][1] == T('-') && argv[i][2] == T('\0')) {
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
j = 1;
|
||||
if (argv[i][j] == 'r') {
|
||||
useFilemap = 0;
|
||||
if (argv[i][j] == T('r')) {
|
||||
processFlags &= ~XML_MAP_FILE;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == 'x') {
|
||||
processExternalEntities = 1;
|
||||
if (argv[i][j] == T('n')) {
|
||||
useNamespaces = 1;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == 'd') {
|
||||
if (argv[i][j + 1] == '\0') {
|
||||
if (argv[i][j] == T('x')) {
|
||||
processFlags |= XML_EXTERNAL_ENTITIES;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('w')) {
|
||||
windowsCodePages = 1;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('m')) {
|
||||
outputType = 'm';
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('c')) {
|
||||
outputType = 'c';
|
||||
useNamespaces = 0;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('t')) {
|
||||
outputType = 't';
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('d')) {
|
||||
if (argv[i][j + 1] == T('\0')) {
|
||||
if (++i == argc)
|
||||
usage(argv[0]);
|
||||
outputDir = argv[i];
|
||||
@@ -313,8 +512,8 @@ int main(int argc, char **argv)
|
||||
outputDir = argv[i] + j + 1;
|
||||
i++;
|
||||
}
|
||||
else if (argv[i][j] == 'e') {
|
||||
if (argv[i][j + 1] == '\0') {
|
||||
else if (argv[i][j] == T('e')) {
|
||||
if (argv[i][j + 1] == T('\0')) {
|
||||
if (++i == argc)
|
||||
usage(argv[0]);
|
||||
encoding = argv[i];
|
||||
@@ -323,7 +522,7 @@ int main(int argc, char **argv)
|
||||
encoding = argv[i] + j + 1;
|
||||
i++;
|
||||
}
|
||||
else if (argv[i][j] == '\0' && j > 1)
|
||||
else if (argv[i][j] == T('\0') && j > 1)
|
||||
i++;
|
||||
else
|
||||
usage(argv[0]);
|
||||
@@ -332,54 +531,82 @@ int main(int argc, char **argv)
|
||||
usage(argv[0]);
|
||||
for (; i < argc; i++) {
|
||||
FILE *fp = 0;
|
||||
char *outName = 0;
|
||||
XML_Char *outName = 0;
|
||||
int result;
|
||||
XML_Parser parser = XML_ParserCreate(encoding);
|
||||
if (outputDir) {
|
||||
const char *file = argv[i];
|
||||
if (strrchr(file, '/'))
|
||||
file = strrchr(file, '/') + 1;
|
||||
#ifdef WIN32
|
||||
if (strrchr(file, '\\'))
|
||||
file = strrchr(file, '\\') + 1;
|
||||
#endif
|
||||
outName = malloc(strlen(outputDir) + strlen(file) + 2);
|
||||
strcpy(outName, outputDir);
|
||||
strcat(outName, "/");
|
||||
strcat(outName, file);
|
||||
fp = fopen(outName, "wb");
|
||||
if (!fp) {
|
||||
perror(outName);
|
||||
exit(1);
|
||||
}
|
||||
XML_SetUserData(parser, fp);
|
||||
XML_SetElementHandler(parser, startElement, endElement);
|
||||
XML_SetCharacterDataHandler(parser, characterData);
|
||||
XML_SetProcessingInstructionHandler(parser, processingInstruction);
|
||||
}
|
||||
if (processExternalEntities) {
|
||||
if (!XML_SetBase(parser, argv[i])) {
|
||||
fprintf(stderr, "%s: out of memory", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
XML_SetExternalEntityRefHandler(parser,
|
||||
useFilemap
|
||||
? externalEntityRefFilemap
|
||||
: externalEntityRefStream);
|
||||
}
|
||||
if (useFilemap) {
|
||||
PROCESS_ARGS args;
|
||||
args.retPtr = &result;
|
||||
args.parser = parser;
|
||||
if (!filemap(argv[i], processFile, &args))
|
||||
result = 0;
|
||||
}
|
||||
XML_Parser parser;
|
||||
if (useNamespaces)
|
||||
parser = XML_ParserCreateNS(encoding, NSSEP);
|
||||
else
|
||||
result = processStream(argv[i], parser);
|
||||
parser = XML_ParserCreate(encoding);
|
||||
if (outputType == 't') {
|
||||
/* This is for doing timings; this gives a more realistic estimate of
|
||||
the parsing time. */
|
||||
outputDir = 0;
|
||||
XML_SetElementHandler(parser, nopStartElement, nopEndElement);
|
||||
XML_SetCharacterDataHandler(parser, nopCharacterData);
|
||||
XML_SetProcessingInstructionHandler(parser, nopProcessingInstruction);
|
||||
}
|
||||
else if (outputDir) {
|
||||
const XML_Char *file = argv[i];
|
||||
if (tcsrchr(file, T('/')))
|
||||
file = tcsrchr(file, T('/')) + 1;
|
||||
#ifdef WIN32
|
||||
if (tcsrchr(file, T('\\')))
|
||||
file = tcsrchr(file, T('\\')) + 1;
|
||||
#endif
|
||||
outName = malloc((tcslen(outputDir) + tcslen(file) + 2) * sizeof(XML_Char));
|
||||
tcscpy(outName, outputDir);
|
||||
tcscat(outName, T("/"));
|
||||
tcscat(outName, file);
|
||||
fp = tfopen(outName, T("wb"));
|
||||
if (!fp) {
|
||||
tperror(outName);
|
||||
exit(1);
|
||||
}
|
||||
setvbuf(fp, NULL, _IOFBF, 16384);
|
||||
#ifdef XML_UNICODE
|
||||
puttc(0xFEFF, fp);
|
||||
#endif
|
||||
XML_SetUserData(parser, fp);
|
||||
switch (outputType) {
|
||||
case 'm':
|
||||
XML_UseParserAsHandlerArg(parser);
|
||||
XML_SetElementHandler(parser, metaStartElement, metaEndElement);
|
||||
XML_SetProcessingInstructionHandler(parser, metaProcessingInstruction);
|
||||
XML_SetCommentHandler(parser, metaComment);
|
||||
XML_SetCdataSectionHandler(parser, metaStartCdataSection, metaEndCdataSection);
|
||||
XML_SetCharacterDataHandler(parser, metaCharacterData);
|
||||
XML_SetUnparsedEntityDeclHandler(parser, metaUnparsedEntityDecl);
|
||||
XML_SetNotationDeclHandler(parser, metaNotationDecl);
|
||||
XML_SetNamespaceDeclHandler(parser, metaStartNamespaceDecl, metaEndNamespaceDecl);
|
||||
metaStartDocument(parser);
|
||||
break;
|
||||
case 'c':
|
||||
XML_UseParserAsHandlerArg(parser);
|
||||
XML_SetDefaultHandler(parser, markup);
|
||||
XML_SetElementHandler(parser, defaultStartElement, defaultEndElement);
|
||||
XML_SetCharacterDataHandler(parser, defaultCharacterData);
|
||||
XML_SetProcessingInstructionHandler(parser, defaultProcessingInstruction);
|
||||
break;
|
||||
default:
|
||||
if (useNamespaces)
|
||||
XML_SetElementHandler(parser, startElementNS, endElementNS);
|
||||
else
|
||||
XML_SetElementHandler(parser, startElement, endElement);
|
||||
XML_SetCharacterDataHandler(parser, characterData);
|
||||
XML_SetProcessingInstructionHandler(parser, processingInstruction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (windowsCodePages)
|
||||
XML_SetUnknownEncodingHandler(parser, unknownEncoding, 0);
|
||||
result = XML_ProcessFile(parser, argv[i], processFlags);
|
||||
if (outputDir) {
|
||||
if (outputType == 'm')
|
||||
metaEndDocument(parser);
|
||||
fclose(fp);
|
||||
if (!result)
|
||||
remove(outName);
|
||||
tremove(outName);
|
||||
free(outName);
|
||||
}
|
||||
XML_ParserFree(parser);
|
||||
|
||||
Executable
+136
@@ -0,0 +1,136 @@
|
||||
# Microsoft Developer Studio Project File - Name="xmlwf" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=xmlwf - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "xmlwf.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "xmlwf.mak" CFG="xmlwf - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "xmlwf - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "xmlwf - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "xmlwf - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\xmlparse" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D XMLTOKAPI=__declspec(dllimport) /D XMLPARSEAPI=__declspec(dllimport) /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\bin\xmlwf.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlwf - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\xmlparse" /I "..\xmlparse" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D XMLTOKAPI=__declspec(dllimport) /D XMLPARSEAPI=__declspec(dllimport) /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\dbgbin\xmlwf.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "xmlwf - Win32 Release"
|
||||
# Name "xmlwf - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\codepage.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readfilemap.c
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\unixfilemap.c
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\win32filemap.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlfile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlwf.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\codepage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlfile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltchar.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
Executable
+371
@@ -0,0 +1,371 @@
|
||||
#include "xmlparse.h"
|
||||
#ifdef XML_UNICODE
|
||||
#define UNICODE
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <urlmon.h>
|
||||
#include <wininet.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include "xmlurl.h"
|
||||
#include "xmlmime.h"
|
||||
|
||||
static
|
||||
int processURL(XML_Parser parser, IMoniker *baseMoniker, const XML_Char *url);
|
||||
|
||||
typedef void (*StopHandler)(void *, HRESULT);
|
||||
|
||||
class Callback : public IBindStatusCallback {
|
||||
public:
|
||||
// IUnknown methods
|
||||
STDMETHODIMP QueryInterface(REFIID,void **);
|
||||
STDMETHODIMP_(ULONG) AddRef();
|
||||
STDMETHODIMP_(ULONG) Release();
|
||||
// IBindStatusCallback methods
|
||||
STDMETHODIMP OnStartBinding(DWORD, IBinding *);
|
||||
STDMETHODIMP GetPriority(LONG *);
|
||||
STDMETHODIMP OnLowResource(DWORD);
|
||||
STDMETHODIMP OnProgress(ULONG, ULONG, ULONG, LPCWSTR);
|
||||
STDMETHODIMP OnStopBinding(HRESULT, LPCWSTR);
|
||||
STDMETHODIMP GetBindInfo(DWORD *, BINDINFO *);
|
||||
STDMETHODIMP OnDataAvailable(DWORD, DWORD, FORMATETC *, STGMEDIUM *);
|
||||
STDMETHODIMP OnObjectAvailable(REFIID, IUnknown *);
|
||||
Callback(XML_Parser, IMoniker *, StopHandler, void *);
|
||||
~Callback();
|
||||
int externalEntityRef(const XML_Char *context, const XML_Char *systemId, const XML_Char *publicId);
|
||||
private:
|
||||
XML_Parser parser_;
|
||||
IMoniker *baseMoniker_;
|
||||
DWORD totalRead_;
|
||||
ULONG ref_;
|
||||
IBinding *pBinding_;
|
||||
StopHandler stopHandler_;
|
||||
void *stopArg_;
|
||||
};
|
||||
|
||||
STDMETHODIMP_(ULONG) Callback::AddRef()
|
||||
{
|
||||
return ref_++;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) Callback::Release()
|
||||
{
|
||||
if (--ref_ == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return ref_;
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::QueryInterface(REFIID riid, void** ppv)
|
||||
{
|
||||
if (IsEqualGUID(riid, IID_IUnknown))
|
||||
*ppv = (IUnknown *)this;
|
||||
else if (IsEqualGUID(riid, IID_IBindStatusCallback))
|
||||
*ppv = (IBindStatusCallback *)this;
|
||||
else
|
||||
return E_NOINTERFACE;
|
||||
((LPUNKNOWN)*ppv)->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::OnStartBinding(DWORD, IBinding* pBinding)
|
||||
{
|
||||
pBinding_ = pBinding;
|
||||
pBinding->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::GetPriority(LONG *)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::OnLowResource(DWORD)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::OnProgress(ULONG, ULONG, ULONG, LPCWSTR)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::OnStopBinding(HRESULT hr, LPCWSTR szError)
|
||||
{
|
||||
if (pBinding_) {
|
||||
pBinding_->Release();
|
||||
pBinding_ = 0;
|
||||
}
|
||||
if (baseMoniker_) {
|
||||
baseMoniker_->Release();
|
||||
baseMoniker_ = 0;
|
||||
}
|
||||
stopHandler_(stopArg_, hr);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::GetBindInfo(DWORD* pgrfBINDF, BINDINFO* pbindinfo)
|
||||
{
|
||||
*pgrfBINDF = BINDF_ASYNCHRONOUS;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static
|
||||
void reportError(XML_Parser parser)
|
||||
{
|
||||
int code = XML_GetErrorCode(parser);
|
||||
const XML_Char *message = XML_ErrorString(code);
|
||||
if (message)
|
||||
_ftprintf(stderr, _T("%s:%d:%ld: %s\n"),
|
||||
XML_GetBase(parser),
|
||||
XML_GetErrorLineNumber(parser),
|
||||
XML_GetErrorColumnNumber(parser),
|
||||
message);
|
||||
else
|
||||
_ftprintf(stderr, _T("%s: (unknown message %d)\n"), XML_GetBase(parser), code);
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::OnDataAvailable(DWORD grfBSCF,
|
||||
DWORD dwSize,
|
||||
FORMATETC *pfmtetc,
|
||||
STGMEDIUM* pstgmed)
|
||||
{
|
||||
if (grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
|
||||
IWinInetHttpInfo *hp;
|
||||
HRESULT hr = pBinding_->QueryInterface(IID_IWinInetHttpInfo, (void **)&hp);
|
||||
if (SUCCEEDED(hr)) {
|
||||
char contentType[1024];
|
||||
DWORD bufSize = sizeof(contentType);
|
||||
DWORD flags = 0;
|
||||
contentType[0] = 0;
|
||||
hr = hp->QueryInfo(HTTP_QUERY_CONTENT_TYPE, contentType, &bufSize, 0, NULL);
|
||||
if (SUCCEEDED(hr)) {
|
||||
char charset[CHARSET_MAX];
|
||||
getXMLCharset(contentType, charset);
|
||||
if (charset[0]) {
|
||||
#ifdef XML_UNICODE
|
||||
XML_Char wcharset[CHARSET_MAX];
|
||||
XML_Char *p1 = wcharset;
|
||||
const char *p2 = charset;
|
||||
while ((*p1++ = (unsigned char)*p2++) != 0)
|
||||
;
|
||||
XML_SetEncoding(parser_, wcharset);
|
||||
#else
|
||||
XML_SetEncoding(parser_, charset);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
hp->Release();
|
||||
}
|
||||
}
|
||||
if (!parser_)
|
||||
return E_ABORT;
|
||||
if (pstgmed->tymed == TYMED_ISTREAM) {
|
||||
while (totalRead_ < dwSize) {
|
||||
#define READ_MAX (64*1024)
|
||||
DWORD nToRead = dwSize - totalRead_;
|
||||
if (nToRead > READ_MAX)
|
||||
nToRead = READ_MAX;
|
||||
void *buf = XML_GetBuffer(parser_, nToRead);
|
||||
if (!buf) {
|
||||
_ftprintf(stderr, _T("out of memory\n"));
|
||||
return E_ABORT;
|
||||
}
|
||||
DWORD nRead;
|
||||
HRESULT hr = pstgmed->pstm->Read(buf, nToRead, &nRead);
|
||||
if (SUCCEEDED(hr)) {
|
||||
totalRead_ += nRead;
|
||||
if (!XML_ParseBuffer(parser_,
|
||||
nRead,
|
||||
(grfBSCF & BSCF_LASTDATANOTIFICATION) != 0
|
||||
&& totalRead_ == dwSize)) {
|
||||
reportError(parser_);
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP Callback::OnObjectAvailable(REFIID, IUnknown *)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int Callback::externalEntityRef(const XML_Char *context, const XML_Char *systemId, const XML_Char *publicId)
|
||||
{
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser_, context, 0);
|
||||
XML_SetBase(entParser, systemId);
|
||||
int ret = processURL(entParser, baseMoniker_, systemId);
|
||||
XML_ParserFree(entParser);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Callback::Callback(XML_Parser parser, IMoniker *baseMoniker, StopHandler stopHandler, void *stopArg)
|
||||
: parser_(parser),
|
||||
baseMoniker_(baseMoniker),
|
||||
ref_(0),
|
||||
pBinding_(0),
|
||||
totalRead_(0),
|
||||
stopHandler_(stopHandler),
|
||||
stopArg_(stopArg)
|
||||
{
|
||||
if (baseMoniker_)
|
||||
baseMoniker_->AddRef();
|
||||
}
|
||||
|
||||
Callback::~Callback()
|
||||
{
|
||||
if (pBinding_)
|
||||
pBinding_->Release();
|
||||
if (baseMoniker_)
|
||||
baseMoniker_->Release();
|
||||
}
|
||||
|
||||
static
|
||||
int externalEntityRef(void *arg,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
return ((Callback *)arg)->externalEntityRef(context, systemId, publicId);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
HRESULT openStream(XML_Parser parser,
|
||||
IMoniker *baseMoniker,
|
||||
const XML_Char *uri,
|
||||
StopHandler stopHandler, void *stopArg)
|
||||
{
|
||||
if (!XML_SetBase(parser, uri))
|
||||
return E_OUTOFMEMORY;
|
||||
HRESULT hr;
|
||||
IMoniker *m;
|
||||
#ifdef XML_UNICODE
|
||||
hr = CreateURLMoniker(0, uri, &m);
|
||||
#else
|
||||
LPWSTR uriw = new wchar_t[strlen(uri) + 1];
|
||||
for (int i = 0;; i++) {
|
||||
uriw[i] = uri[i];
|
||||
if (uriw[i] == 0)
|
||||
break;
|
||||
}
|
||||
hr = CreateURLMoniker(baseMoniker, uriw, &m);
|
||||
delete [] uriw;
|
||||
#endif
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
IBindStatusCallback *cb = new Callback(parser, m, stopHandler, stopArg);
|
||||
XML_SetExternalEntityRefHandler(parser, externalEntityRef);
|
||||
XML_SetExternalEntityRefHandlerArg(parser, cb);
|
||||
cb->AddRef();
|
||||
IBindCtx *b;
|
||||
if (FAILED(hr = CreateAsyncBindCtx(0, cb, 0, &b))) {
|
||||
cb->Release();
|
||||
m->Release();
|
||||
return hr;
|
||||
}
|
||||
cb->Release();
|
||||
IStream *pStream;
|
||||
hr = m->BindToStorage(b, 0, IID_IStream, (void **)&pStream);
|
||||
if (SUCCEEDED(hr)) {
|
||||
if (pStream)
|
||||
pStream->Release();
|
||||
}
|
||||
if (hr == MK_S_ASYNCHRONOUS)
|
||||
hr = S_OK;
|
||||
m->Release();
|
||||
b->Release();
|
||||
return hr;
|
||||
}
|
||||
|
||||
struct QuitInfo {
|
||||
const XML_Char *url;
|
||||
HRESULT hr;
|
||||
int stop;
|
||||
};
|
||||
|
||||
static
|
||||
void winPerror(const XML_Char *url, HRESULT hr)
|
||||
{
|
||||
LPVOID buf;
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
| FORMAT_MESSAGE_FROM_HMODULE,
|
||||
GetModuleHandleA("urlmon.dll"),
|
||||
hr,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &buf,
|
||||
0,
|
||||
NULL)
|
||||
|| FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
| FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0,
|
||||
hr,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &buf,
|
||||
0,
|
||||
NULL)) {
|
||||
/* The system error messages seem to end with a newline. */
|
||||
_ftprintf(stderr, _T("%s: %s"), url, buf);
|
||||
fflush(stderr);
|
||||
LocalFree(buf);
|
||||
}
|
||||
else
|
||||
_ftprintf(stderr, _T("%s: error %x\n"), url, hr);
|
||||
}
|
||||
|
||||
static void threadQuit(void *p, HRESULT hr)
|
||||
{
|
||||
QuitInfo *qi = (QuitInfo *)p;
|
||||
qi->hr = hr;
|
||||
qi->stop = 1;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int XML_URLInit()
|
||||
{
|
||||
return SUCCEEDED(CoInitialize(0));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void XML_URLUninit()
|
||||
{
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
static
|
||||
int processURL(XML_Parser parser, IMoniker *baseMoniker, const XML_Char *url)
|
||||
{
|
||||
QuitInfo qi;
|
||||
qi.stop = 0;
|
||||
qi.url = url;
|
||||
|
||||
XML_SetBase(parser, url);
|
||||
HRESULT hr = openStream(parser, baseMoniker, url, threadQuit, &qi);
|
||||
if (FAILED(hr)) {
|
||||
winPerror(url, hr);
|
||||
return 0;
|
||||
}
|
||||
else if (FAILED(qi.hr)) {
|
||||
winPerror(url, qi.hr);
|
||||
return 0;
|
||||
}
|
||||
MSG msg;
|
||||
while (!qi.stop && GetMessage (&msg, NULL, 0, 0)) {
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int XML_ProcessURL(XML_Parser parser,
|
||||
const XML_Char *url,
|
||||
unsigned flags)
|
||||
{
|
||||
return processURL(parser, 0, url);
|
||||
}
|
||||
Reference in New Issue
Block a user