Compare commits
356
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9421dd11c1 | ||
|
|
2c255ba0e6 | ||
|
|
013d3f60a4 | ||
|
|
1341e9ae25 | ||
|
|
a62deef4c9 | ||
|
|
86646a28cb | ||
|
|
f3464902ca | ||
|
|
778021047d | ||
|
|
ddae06ab88 | ||
|
|
dfd331cf71 | ||
|
|
dcff7a87cc | ||
|
|
749df96d25 | ||
|
|
d784dbf4af | ||
|
|
45f2d35bfb | ||
|
|
9b3852311c | ||
|
|
aaa3b6e5bf | ||
|
|
3b0208f5d2 | ||
|
|
7e9f661f09 | ||
|
|
e873b03f16 | ||
|
|
4d724a92cf | ||
|
|
8fd4a83318 | ||
|
|
4e9aea4c1b | ||
|
|
3923164dc2 | ||
|
|
8011e61e57 | ||
|
|
a27a7609f6 | ||
|
|
3ec4a069df | ||
|
|
1b330a5078 | ||
|
|
95e916b7a7 | ||
|
|
92e910d8be | ||
|
|
2a9c1fbbcc | ||
|
|
b7d821935a | ||
|
|
55ec9989e5 | ||
|
|
3eac12050f | ||
|
|
195560985f | ||
|
|
0c6d9d601b | ||
|
|
5bff01f98f | ||
|
|
e2ea2c60e2 | ||
|
|
ab5acbf509 | ||
|
|
17c6938a36 | ||
|
|
f009a97514 | ||
|
|
132c80964e | ||
|
|
75ccce3db8 | ||
|
|
b1b875e78e | ||
|
|
99a358f0c0 | ||
|
|
4d08f13896 | ||
|
|
fdd1bd7fc9 | ||
|
|
5799228346 | ||
|
|
74ce84265d | ||
|
|
a5634c52ea | ||
|
|
39cfb55c81 | ||
|
|
4a9169214b | ||
|
|
3dc87550a7 | ||
|
|
7488411c11 | ||
|
|
e157ebf618 | ||
|
|
2b29d5ffe4 | ||
|
|
5c1ae4c2da | ||
|
|
ce57b5dc40 | ||
|
|
cbfa2aaece | ||
|
|
d6eeb473c4 | ||
|
|
6695c33ded | ||
|
|
0333ca86c4 | ||
|
|
56d5132566 | ||
|
|
d311382e80 | ||
|
|
51f81e81ad | ||
|
|
0f5256c936 | ||
|
|
4e58e42cf2 | ||
|
|
e5f05fd608 | ||
|
|
12a0ca511f | ||
|
|
f93c2e14fd | ||
|
|
3a6f59e946 | ||
|
|
4956ba5d3c | ||
|
|
19b7928723 | ||
|
|
973ad606fd | ||
|
|
a7cd413a1e | ||
|
|
7438be7870 | ||
|
|
d7a45119ea | ||
|
|
a5a004adf7 | ||
|
|
9e892f5642 | ||
|
|
78102b202d | ||
|
|
f9560ef835 | ||
|
|
31facc7d20 | ||
|
|
616e521daf | ||
|
|
be92e651ff | ||
|
|
82e73bbdb2 | ||
|
|
d4db56dd39 | ||
|
|
26bf97fad4 | ||
|
|
c2095e6b66 | ||
|
|
d2c1656f5f | ||
|
|
87d01c84d2 | ||
|
|
bfcc4836d0 | ||
|
|
90a5d98cdd | ||
|
|
e52f6237f6 | ||
|
|
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 | ||
|
|
11067a403b | ||
|
|
0505f1cd36 | ||
|
|
d504c1c894 | ||
|
|
59023a9533 | ||
|
|
d54b83991c | ||
|
|
0317338f10 | ||
|
|
5d0c27b76c | ||
|
|
1250e1d136 | ||
|
|
4b8e8545c5 | ||
|
|
9900422429 | ||
|
|
816d517598 | ||
|
|
9ca490b20e | ||
|
|
fc76800928 | ||
|
|
4ab64ee501 | ||
|
|
bfd4528e04 | ||
|
|
44681484a8 | ||
|
|
d40b82ff26 | ||
|
|
fa8b616b9c | ||
|
|
7e71c8f5d5 | ||
|
|
a9a9179d63 | ||
|
|
8190301827 | ||
|
|
586519240e | ||
|
|
323478ff2a | ||
|
|
e479418fc6 | ||
|
|
856e13baf4 | ||
|
|
63416bb518 | ||
|
|
c446eb4dfc | ||
|
|
d4ee1a1ee1 | ||
|
|
3795b9486f | ||
|
|
9a238f3471 | ||
|
|
74a9c33687 | ||
|
|
45114e05e0 | ||
|
|
17ff609e03 | ||
|
|
f9ba46fd43 | ||
|
|
6509a36b3f | ||
|
|
fce5a0395f | ||
|
|
a7e34c37ab | ||
|
|
34e680d0b7 | ||
|
|
83a54957bf | ||
|
|
bbc00990f9 | ||
|
|
0f69f9f54b | ||
|
|
7badcb354d | ||
|
|
7e8d1ad72d | ||
|
|
430fdf8c57 | ||
|
|
7bbe2e366d | ||
|
|
7e9d3e8571 | ||
|
|
eb791c7b7e | ||
|
|
51b263674a | ||
|
|
3be0dca473 | ||
|
|
e83509516e | ||
|
|
0a8e3db8c7 | ||
|
|
da063a16cf | ||
|
|
0d2c1a94de | ||
|
|
903d2b7c41 | ||
|
|
59d5826eed | ||
|
|
41400fe1ed | ||
|
|
870e3a8d7e | ||
|
|
2c589fc4e3 | ||
|
|
607997679b | ||
|
|
22099b7770 | ||
|
|
0316f56e51 | ||
|
|
d958fac99a | ||
|
|
b1c9b03eba | ||
|
|
2f74758c1f | ||
|
|
316f90012d | ||
|
|
c0fc74267b | ||
|
|
67bf333e47 | ||
|
|
347e19a658 | ||
|
|
332b10d36c | ||
|
|
7cf6cf3188 | ||
|
|
fdad370c5b | ||
|
|
c70ed036c9 | ||
|
|
3cc8d0075a | ||
|
|
2fd2484a0a | ||
|
|
56440b93f3 | ||
|
|
2ec75e44bc | ||
|
|
12693c93ca | ||
|
|
b07d0e5208 | ||
|
|
207924eb8d | ||
|
|
e2482813bf | ||
|
|
2a4f91e330 | ||
|
|
b2eeefe571 | ||
|
|
db6a73f853 | ||
|
|
cecd64f6ab | ||
|
|
ded70873bc | ||
|
|
675ac10f75 | ||
|
|
dc8aa626cc | ||
|
|
8b6b5840ee | ||
|
|
9f41c277f9 | ||
|
|
42bc6a2d96 | ||
|
|
f237c0f547 | ||
|
|
27c6f1b6c5 | ||
|
|
7af19499b0 | ||
|
|
6a9cec2f7a | ||
|
|
80b9565677 | ||
|
|
dd98d660be | ||
|
|
a5be232444 | ||
|
|
2accf6b0c1 | ||
|
|
2ad2c72b27 | ||
|
|
cd5fb875b4 | ||
|
|
098f26ac79 | ||
|
|
8a1833a65f | ||
|
|
a2c83c96b5 | ||
|
|
0ea9bf349b | ||
|
|
9501138aae | ||
|
|
7fc8cdf625 | ||
|
|
9651443ca7 | ||
|
|
84be77b536 | ||
|
|
81809a3083 | ||
|
|
c310975452 | ||
|
|
69f0244382 | ||
|
|
1197596d3b | ||
|
|
16e9434927 | ||
|
|
9ecf532908 | ||
|
|
7834fbbf8a | ||
|
|
49946f3510 | ||
|
|
7e8cd9500b | ||
|
|
c4894ae2f7 | ||
|
|
e40fe5267f | ||
|
|
23b2379b34 | ||
|
|
cc86706328 | ||
|
|
e8060e4e7a |
+28
@@ -0,0 +1,28 @@
|
||||
# CVS default ignores begin
|
||||
tags
|
||||
TAGS
|
||||
.make.state
|
||||
.nse_depinfo
|
||||
*~
|
||||
#*
|
||||
.#*
|
||||
,*
|
||||
_$*
|
||||
*$
|
||||
*.old
|
||||
*.bak
|
||||
*.BAK
|
||||
*.orig
|
||||
*.rej
|
||||
.del-*
|
||||
*.a
|
||||
*.olb
|
||||
*.o
|
||||
*.obj
|
||||
*.so
|
||||
*.exe
|
||||
*.Z
|
||||
*.elc
|
||||
*.ln
|
||||
core
|
||||
# CVS default ignores end
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
bin
|
||||
dbgbin
|
||||
Debug
|
||||
expat.ncb
|
||||
expat.opt
|
||||
Release
|
||||
expat.zip
|
||||
lib
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
CC=gcc
|
||||
# If you know what your system's byte order is, define XML_BYTE_ORDER:
|
||||
# use -DXML_BYTE_ORDER=12 for little-endian byte order;
|
||||
# use -DXML_BYTE_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
|
||||
# -DXML_DTD adds full support for parsing DTDs
|
||||
CFLAGS=-Wall -O2 -Ixmltok -Ixmlparse -DXML_NS -DXML_DTD
|
||||
AR=ar
|
||||
# Use one of the next two lines; unixfilemap is better if it works.
|
||||
FILEMAP_OBJ=xmlwf/unixfilemap.o
|
||||
#FILEMAP_OBJ=xmlwf/readfilemap.o
|
||||
LIBOBJS=xmltok/xmltok.o \
|
||||
xmltok/xmlrole.o \
|
||||
xmlparse/xmlparse.o
|
||||
|
||||
OBJS=xmlwf/xmlwf.o \
|
||||
xmlwf/xmlfile.o \
|
||||
xmlwf/codepage.o \
|
||||
$(FILEMAP_OBJ)
|
||||
LIB=xmlparse/libexpat.a
|
||||
EXE=
|
||||
XMLWF=xmlwf/xmlwf$(EXE)
|
||||
|
||||
all: $(XMLWF)
|
||||
|
||||
$(XMLWF): $(OBJS) $(LIB)
|
||||
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIB)
|
||||
|
||||
$(LIB): $(LIBOBJS)
|
||||
$(AR) rc $(LIB) $(LIBOBJS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(LIBOBJS) $(LIB) $(XMLWF)
|
||||
|
||||
xmltok/nametab.h: gennmtab/gennmtab$(EXE)
|
||||
rm -f $@
|
||||
gennmtab/gennmtab$(EXE) >$@
|
||||
|
||||
gennmtab/gennmtab$(EXE): gennmtab/gennmtab.c
|
||||
$(CC) $(CFLAGS) -o $@ gennmtab/gennmtab.c
|
||||
|
||||
xmltok/xmltok.o: xmltok/nametab.h
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
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
+74
@@ -0,0 +1,74 @@
|
||||
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>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name gennmtab
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
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>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
+28
-12
@@ -9,21 +9,27 @@
|
||||
|
||||
<H1>expat - XML Parser Toolkit</H1>
|
||||
|
||||
<H3>Version 1.0.2</H3>
|
||||
<H3>Version 20000512</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
|
||||
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>Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center
|
||||
Ltd. Expat is freely available with source under a very liberal <a
|
||||
href="copying.txt">license</a> (the MIT license).</P>
|
||||
|
||||
<P>This is a test version of expat which adds support for parsing
|
||||
external DTDs and parameter entities. Compiling with -DXML_DTD
|
||||
enables this support. There's a new <CODE>-p</CODE> option for xmlwf
|
||||
which will cause it to process external DTDs and parameter entities;
|
||||
this implies the <CODE>-x</CODE> option. See the comment above
|
||||
<CODE>XML_SetParamEntityParsing</CODE> in <CODE>xmlparse.h</CODE> for
|
||||
the API addition that enables this.</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 production
|
||||
version.</P>
|
||||
validating XML processor. The current production version of expat can
|
||||
be downloaded from <A href =
|
||||
"http://www.ThaiOpenSource.com/dist/expat/expat.zip"
|
||||
>http://www.ThaiOpenSource.com/dist/expat/expat.zip</A>.</P>
|
||||
|
||||
<P>The directory <SAMP>xmltok</SAMP> contains a low-level library for
|
||||
tokenizing XML. The interface is documented in
|
||||
@@ -46,16 +52,26 @@ 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>
|
||||
external general entities to be processed. A <CODE>-s</CODE> option
|
||||
will make documents that are not standalone cause an error (a document
|
||||
is considered standalone if either it is intrinsically standalone
|
||||
because it has no external subset and no references to parameter
|
||||
entities in the internal subset or it is declared as standalone in the
|
||||
XML declaration).</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.ThaiOpenSource.com/product/expat/expatfaq.html">expat
|
||||
FAQ</A>.</P>
|
||||
|
||||
<P></P>
|
||||
|
||||
<ADDRESS>
|
||||
|
||||
<A HREF="mailto:jjc@jclark.com">James Clark</A>
|
||||
<A HREF="mailto:jjc@ThaiOpenSource.com">James Clark</A>
|
||||
|
||||
</ADDRESS>
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
--MKS Variant Project--
|
||||
$Revision: 1.17 $
|
||||
$Format: 1.0 $
|
||||
mksvariant=1.11
|
||||
EndOptions
|
||||
$(projectdir)/MPL-1_0.html a 1.1
|
||||
$(projectdir)/Makefile a 1.6
|
||||
$(projectdir)/expat.dsw a 1.1.1.1 _mks_variant=1.1.1
|
||||
$(projectdir)/expat.html a 1.8.1.3 _mks_variant=1.8.1
|
||||
$(projectdir)/expat.mak a 1.14
|
||||
$(projectdir)/files.txt a 1.4.1.2 _mks_variant=1.4.1
|
||||
$(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)/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.5
|
||||
$(projectdir)/xmlparse/hashtable.h a 1.4
|
||||
$(projectdir)/xmlparse/xmlparse.c a 1.54.1.3 _mks_variant=1.54.1
|
||||
$(projectdir)/xmlparse/xmlparse.dsp a 1.1
|
||||
$(projectdir)/xmlparse/xmlparse.h a 1.22.1.1 _mks_variant=1.22.1
|
||||
$(projectdir)/xmltok/asciitab.h a 1.4
|
||||
$(projectdir)/xmltok/dllmain.c a 1.2
|
||||
$(projectdir)/xmltok/iasciitab.h a 1.2
|
||||
$(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.9
|
||||
$(projectdir)/xmltok/xmlrole.h a 1.5
|
||||
$(projectdir)/xmltok/xmltok.c a 1.35.1.2 _mks_variant=1.35.1
|
||||
$(projectdir)/xmltok/xmltok.dsp a 1.1.1.1 _mks_variant=1.1.1
|
||||
$(projectdir)/xmltok/xmltok.h a 1.24
|
||||
$(projectdir)/xmltok/xmltok_impl.c a 1.26.1.3 _mks_variant=1.26.1
|
||||
$(projectdir)/xmltok/xmltok_impl.h a 1.5
|
||||
$(projectdir)/xmlwf/codepage.c a 1.4
|
||||
$(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.4
|
||||
$(projectdir)/xmlwf/xmlwf.c a 1.31.1.1 _mks_variant=1.31.1
|
||||
$(projectdir)/xmlwf/xmlwf.dsp a 1.1
|
||||
Executable
+103
@@ -0,0 +1,103 @@
|
||||
<!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="http://www.ThaiOpenSource.com/dist/expat"
|
||||
>http://www.ThaiOpenSource.com/dist/expat</a>. If there is a test
|
||||
version, then it will be available from <a
|
||||
href="http://www.ThaiOpenSource.com/dist/expat/test"
|
||||
>http://www.ThaiOpenSource.com/dist/expat/test</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@xml.org&BODY=subscribe%20xml-dev">majordomo@xml.org</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>
|
||||
|
||||
<p>There's also an excellent <a
|
||||
href="http://www.xml.com/pub/1999/09/expat/index.html">article</a>
|
||||
about expat on XML.com by Clark Cooper.</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>Compile with <code>-DXML_DTD</code> and call
|
||||
<code>XML_SetParamEntityParsing</code>.</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>
|
||||
|
||||
<H4>How can I minimize the size of expat?</H4>
|
||||
|
||||
<p>Compile with <code>-DXML_MIN_SIZE</code>. With Visual C++, use the
|
||||
<code>Win32 MinSize</code> configuration: this creates an
|
||||
<code>xmlparse.dll</code> that does not require
|
||||
<code>xmltok.dll</code>.</p>
|
||||
|
||||
<ADDRESS>
|
||||
|
||||
<A HREF="mailto:jjc@ThaiOpenSource.com">James Clark</A>
|
||||
|
||||
</ADDRESS>
|
||||
|
||||
</BODY>
|
||||
|
||||
</HTML>
|
||||
+5
-4
@@ -1,6 +1,5 @@
|
||||
expat.html
|
||||
MPL-1_0.html
|
||||
gplelect.html
|
||||
xmltok/ascii.h
|
||||
xmltok/asciitab.h
|
||||
xmltok/dllmain.c
|
||||
gennmtab/gennmtab.c
|
||||
@@ -16,8 +15,7 @@ xmltok/xmltok.c
|
||||
xmltok/xmltok.h
|
||||
xmltok/xmltok_impl.c
|
||||
xmltok/xmltok_impl.h
|
||||
xmlparse/hashtable.c
|
||||
xmlparse/hashtable.h
|
||||
xmltok/xmltok_ns.c
|
||||
xmlparse/xmlparse.c
|
||||
xmlparse/xmlparse.h
|
||||
xmlwf/codepage.c
|
||||
@@ -26,5 +24,8 @@ 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
+3
@@ -0,0 +1,3 @@
|
||||
Debug
|
||||
Release
|
||||
gennmtab.plg
|
||||
Executable
+427
@@ -0,0 +1,427 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct range {
|
||||
int start;
|
||||
int end;
|
||||
};
|
||||
|
||||
struct range nmstrt[] = {
|
||||
{ '_' },
|
||||
{ ':' },
|
||||
/* BaseChar */
|
||||
{ 0x0041, 0x005a },
|
||||
{ 0x0061, 0x007a },
|
||||
{ 0x00c0, 0x00d6 },
|
||||
{ 0x00d8, 0x00f6 },
|
||||
{ 0x00f8, 0x00ff },
|
||||
{ 0x0100, 0x0131 },
|
||||
{ 0x0134, 0x013e },
|
||||
{ 0x0141, 0x0148 },
|
||||
{ 0x014a, 0x017e },
|
||||
{ 0x0180, 0x01c3 },
|
||||
{ 0x01cd, 0x01f0 },
|
||||
{ 0x01f4, 0x01f5 },
|
||||
{ 0x01fa, 0x0217 },
|
||||
{ 0x0250, 0x02a8 },
|
||||
{ 0x02bb, 0x02c1 },
|
||||
{ 0x0386 },
|
||||
{ 0x0388, 0x038a },
|
||||
{ 0x038c },
|
||||
{ 0x038e, 0x03a1 },
|
||||
{ 0x03a3, 0x03ce },
|
||||
{ 0x03d0, 0x03d6 },
|
||||
{ 0x03da },
|
||||
{ 0x03dc },
|
||||
{ 0x03de },
|
||||
{ 0x03e0 },
|
||||
{ 0x03e2, 0x03f3 },
|
||||
{ 0x0401, 0x040c },
|
||||
{ 0x040e, 0x044f },
|
||||
{ 0x0451, 0x045c },
|
||||
{ 0x045e, 0x0481 },
|
||||
{ 0x0490, 0x04c4 },
|
||||
{ 0x04c7, 0x04c8 },
|
||||
{ 0x04cb, 0x04cc },
|
||||
{ 0x04d0, 0x04eb },
|
||||
{ 0x04ee, 0x04f5 },
|
||||
{ 0x04f8, 0x04f9 },
|
||||
{ 0x0531, 0x0556 },
|
||||
{ 0x0559 },
|
||||
{ 0x0561, 0x0586 },
|
||||
{ 0x05d0, 0x05ea },
|
||||
{ 0x05f0, 0x05f2 },
|
||||
{ 0x0621, 0x063a },
|
||||
{ 0x0641, 0x064a },
|
||||
{ 0x0671, 0x06b7 },
|
||||
{ 0x06ba, 0x06be },
|
||||
{ 0x06c0, 0x06ce },
|
||||
{ 0x06d0, 0x06d3 },
|
||||
{ 0x06d5 },
|
||||
{ 0x06e5, 0x06e6 },
|
||||
{ 0x0905, 0x0939 },
|
||||
{ 0x093d },
|
||||
{ 0x0958, 0x0961 },
|
||||
{ 0x0985, 0x098c },
|
||||
{ 0x098f, 0x0990 },
|
||||
{ 0x0993, 0x09a8 },
|
||||
{ 0x09aa, 0x09b0 },
|
||||
{ 0x09b2 },
|
||||
{ 0x09b6, 0x09b9 },
|
||||
{ 0x09dc, 0x09dd },
|
||||
{ 0x09df, 0x09e1 },
|
||||
{ 0x09f0, 0x09f1 },
|
||||
{ 0x0a05, 0x0a0a },
|
||||
{ 0x0a0f, 0x0a10 },
|
||||
{ 0x0a13, 0x0a28 },
|
||||
{ 0x0a2a, 0x0a30 },
|
||||
{ 0x0a32, 0x0a33 },
|
||||
{ 0x0a35, 0x0a36 },
|
||||
{ 0x0a38, 0x0a39 },
|
||||
{ 0x0a59, 0x0a5c },
|
||||
{ 0x0a5e },
|
||||
{ 0x0a72, 0x0a74 },
|
||||
{ 0x0a85, 0x0a8b },
|
||||
{ 0x0a8d },
|
||||
{ 0x0a8f, 0x0a91 },
|
||||
{ 0x0a93, 0x0aa8 },
|
||||
{ 0x0aaa, 0x0ab0 },
|
||||
{ 0x0ab2, 0x0ab3 },
|
||||
{ 0x0ab5, 0x0ab9 },
|
||||
{ 0x0abd },
|
||||
{ 0x0ae0 },
|
||||
{ 0x0b05, 0x0b0c },
|
||||
{ 0x0b0f, 0x0b10 },
|
||||
{ 0x0b13, 0x0b28 },
|
||||
{ 0x0b2a, 0x0b30 },
|
||||
{ 0x0b32, 0x0b33 },
|
||||
{ 0x0b36, 0x0b39 },
|
||||
{ 0x0b3d },
|
||||
{ 0x0b5c, 0x0b5d },
|
||||
{ 0x0b5f, 0x0b61 },
|
||||
{ 0x0b85, 0x0b8a },
|
||||
{ 0x0b8e, 0x0b90 },
|
||||
{ 0x0b92, 0x0b95 },
|
||||
{ 0x0b99, 0x0b9a },
|
||||
{ 0x0b9c },
|
||||
{ 0x0b9e, 0x0b9f },
|
||||
{ 0x0ba3, 0x0ba4 },
|
||||
{ 0x0ba8, 0x0baa },
|
||||
{ 0x0bae, 0x0bb5 },
|
||||
{ 0x0bb7, 0x0bb9 },
|
||||
{ 0x0c05, 0x0c0c },
|
||||
{ 0x0c0e, 0x0c10 },
|
||||
{ 0x0c12, 0x0c28 },
|
||||
{ 0x0c2a, 0x0c33 },
|
||||
{ 0x0c35, 0x0c39 },
|
||||
{ 0x0c60, 0x0c61 },
|
||||
{ 0x0c85, 0x0c8c },
|
||||
{ 0x0c8e, 0x0c90 },
|
||||
{ 0x0c92, 0x0ca8 },
|
||||
{ 0x0caa, 0x0cb3 },
|
||||
{ 0x0cb5, 0x0cb9 },
|
||||
{ 0x0cde },
|
||||
{ 0x0ce0, 0x0ce1 },
|
||||
{ 0x0d05, 0x0d0c },
|
||||
{ 0x0d0e, 0x0d10 },
|
||||
{ 0x0d12, 0x0d28 },
|
||||
{ 0x0d2a, 0x0d39 },
|
||||
{ 0x0d60, 0x0d61 },
|
||||
{ 0x0e01, 0x0e2e },
|
||||
{ 0x0e30 },
|
||||
{ 0x0e32, 0x0e33 },
|
||||
{ 0x0e40, 0x0e45 },
|
||||
{ 0x0e81, 0x0e82 },
|
||||
{ 0x0e84 },
|
||||
{ 0x0e87, 0x0e88 },
|
||||
{ 0x0e8a },
|
||||
{ 0x0e8d },
|
||||
{ 0x0e94, 0x0e97 },
|
||||
{ 0x0e99, 0x0e9f },
|
||||
{ 0x0ea1, 0x0ea3 },
|
||||
{ 0x0ea5 },
|
||||
{ 0x0ea7 },
|
||||
{ 0x0eaa, 0x0eab },
|
||||
{ 0x0ead, 0x0eae },
|
||||
{ 0x0eb0 },
|
||||
{ 0x0eb2, 0x0eb3 },
|
||||
{ 0x0ebd },
|
||||
{ 0x0ec0, 0x0ec4 },
|
||||
{ 0x0f40, 0x0f47 },
|
||||
{ 0x0f49, 0x0f69 },
|
||||
{ 0x10a0, 0x10c5 },
|
||||
{ 0x10d0, 0x10f6 },
|
||||
{ 0x1100 },
|
||||
{ 0x1102, 0x1103 },
|
||||
{ 0x1105, 0x1107 },
|
||||
{ 0x1109 },
|
||||
{ 0x110b, 0x110c },
|
||||
{ 0x110e, 0x1112 },
|
||||
{ 0x113c },
|
||||
{ 0x113e },
|
||||
{ 0x1140 },
|
||||
{ 0x114c },
|
||||
{ 0x114e },
|
||||
{ 0x1150 },
|
||||
{ 0x1154, 0x1155 },
|
||||
{ 0x1159 },
|
||||
{ 0x115f, 0x1161 },
|
||||
{ 0x1163 },
|
||||
{ 0x1165 },
|
||||
{ 0x1167 },
|
||||
{ 0x1169 },
|
||||
{ 0x116d, 0x116e },
|
||||
{ 0x1172, 0x1173 },
|
||||
{ 0x1175 },
|
||||
{ 0x119e },
|
||||
{ 0x11a8 },
|
||||
{ 0x11ab },
|
||||
{ 0x11ae, 0x11af },
|
||||
{ 0x11b7, 0x11b8 },
|
||||
{ 0x11ba },
|
||||
{ 0x11bc, 0x11c2 },
|
||||
{ 0x11eb },
|
||||
{ 0x11f0 },
|
||||
{ 0x11f9 },
|
||||
{ 0x1e00, 0x1e9b },
|
||||
{ 0x1ea0, 0x1ef9 },
|
||||
{ 0x1f00, 0x1f15 },
|
||||
{ 0x1f18, 0x1f1d },
|
||||
{ 0x1f20, 0x1f45 },
|
||||
{ 0x1f48, 0x1f4d },
|
||||
{ 0x1f50, 0x1f57 },
|
||||
{ 0x1f59 },
|
||||
{ 0x1f5b },
|
||||
{ 0x1f5d },
|
||||
{ 0x1f5f, 0x1f7d },
|
||||
{ 0x1f80, 0x1fb4 },
|
||||
{ 0x1fb6, 0x1fbc },
|
||||
{ 0x1fbe },
|
||||
{ 0x1fc2, 0x1fc4 },
|
||||
{ 0x1fc6, 0x1fcc },
|
||||
{ 0x1fd0, 0x1fd3 },
|
||||
{ 0x1fd6, 0x1fdb },
|
||||
{ 0x1fe0, 0x1fec },
|
||||
{ 0x1ff2, 0x1ff4 },
|
||||
{ 0x1ff6, 0x1ffc },
|
||||
{ 0x2126 },
|
||||
{ 0x212a, 0x212b },
|
||||
{ 0x212e },
|
||||
{ 0x2180, 0x2182 },
|
||||
{ 0x3041, 0x3094 },
|
||||
{ 0x30a1, 0x30fa },
|
||||
{ 0x3105, 0x312c },
|
||||
{ 0xac00, 0xd7a3 },
|
||||
/* Ideographic */
|
||||
{ 0x4e00, 0x9fa5 },
|
||||
{ 0x3007 },
|
||||
{ 0x3021, 0x3029 },
|
||||
};
|
||||
|
||||
/* name chars that are not name start chars */
|
||||
struct range name[] = {
|
||||
{ '.' },
|
||||
{ '-' },
|
||||
/* CombiningChar */
|
||||
{ 0x0300, 0x0345 },
|
||||
{ 0x0360, 0x0361 },
|
||||
{ 0x0483, 0x0486 },
|
||||
{ 0x0591, 0x05a1 },
|
||||
{ 0x05a3, 0x05b9 },
|
||||
{ 0x05bb, 0x05bd },
|
||||
{ 0x05bf },
|
||||
{ 0x05c1, 0x05c2 },
|
||||
{ 0x05c4 },
|
||||
{ 0x064b, 0x0652 },
|
||||
{ 0x0670 },
|
||||
{ 0x06d6, 0x06dc },
|
||||
{ 0x06dd, 0x06df },
|
||||
{ 0x06e0, 0x06e4 },
|
||||
{ 0x06e7, 0x06e8 },
|
||||
{ 0x06ea, 0x06ed },
|
||||
{ 0x0901, 0x0903 },
|
||||
{ 0x093c },
|
||||
{ 0x093e, 0x094c },
|
||||
{ 0x094d },
|
||||
{ 0x0951, 0x0954 },
|
||||
{ 0x0962, 0x0963 },
|
||||
{ 0x0981, 0x0983 },
|
||||
{ 0x09bc },
|
||||
{ 0x09be },
|
||||
{ 0x09bf },
|
||||
{ 0x09c0, 0x09c4 },
|
||||
{ 0x09c7, 0x09c8 },
|
||||
{ 0x09cb, 0x09cd },
|
||||
{ 0x09d7 },
|
||||
{ 0x09e2, 0x09e3 },
|
||||
{ 0x0a02 },
|
||||
{ 0x0a3c },
|
||||
{ 0x0a3e },
|
||||
{ 0x0a3f },
|
||||
{ 0x0a40, 0x0a42 },
|
||||
{ 0x0a47, 0x0a48 },
|
||||
{ 0x0a4b, 0x0a4d },
|
||||
{ 0x0a70, 0x0a71 },
|
||||
{ 0x0a81, 0x0a83 },
|
||||
{ 0x0abc },
|
||||
{ 0x0abe, 0x0ac5 },
|
||||
{ 0x0ac7, 0x0ac9 },
|
||||
{ 0x0acb, 0x0acd },
|
||||
{ 0x0b01, 0x0b03 },
|
||||
{ 0x0b3c },
|
||||
{ 0x0b3e, 0x0b43 },
|
||||
{ 0x0b47, 0x0b48 },
|
||||
{ 0x0b4b, 0x0b4d },
|
||||
{ 0x0b56, 0x0b57 },
|
||||
{ 0x0b82, 0x0b83 },
|
||||
{ 0x0bbe, 0x0bc2 },
|
||||
{ 0x0bc6, 0x0bc8 },
|
||||
{ 0x0bca, 0x0bcd },
|
||||
{ 0x0bd7 },
|
||||
{ 0x0c01, 0x0c03 },
|
||||
{ 0x0c3e, 0x0c44 },
|
||||
{ 0x0c46, 0x0c48 },
|
||||
{ 0x0c4a, 0x0c4d },
|
||||
{ 0x0c55, 0x0c56 },
|
||||
{ 0x0c82, 0x0c83 },
|
||||
{ 0x0cbe, 0x0cc4 },
|
||||
{ 0x0cc6, 0x0cc8 },
|
||||
{ 0x0cca, 0x0ccd },
|
||||
{ 0x0cd5, 0x0cd6 },
|
||||
{ 0x0d02, 0x0d03 },
|
||||
{ 0x0d3e, 0x0d43 },
|
||||
{ 0x0d46, 0x0d48 },
|
||||
{ 0x0d4a, 0x0d4d },
|
||||
{ 0x0d57 },
|
||||
{ 0x0e31 },
|
||||
{ 0x0e34, 0x0e3a },
|
||||
{ 0x0e47, 0x0e4e },
|
||||
{ 0x0eb1 },
|
||||
{ 0x0eb4, 0x0eb9 },
|
||||
{ 0x0ebb, 0x0ebc },
|
||||
{ 0x0ec8, 0x0ecd },
|
||||
{ 0x0f18, 0x0f19 },
|
||||
{ 0x0f35 },
|
||||
{ 0x0f37 },
|
||||
{ 0x0f39 },
|
||||
{ 0x0f3e },
|
||||
{ 0x0f3f },
|
||||
{ 0x0f71, 0x0f84 },
|
||||
{ 0x0f86, 0x0f8b },
|
||||
{ 0x0f90, 0x0f95 },
|
||||
{ 0x0f97 },
|
||||
{ 0x0f99, 0x0fad },
|
||||
{ 0x0fb1, 0x0fb7 },
|
||||
{ 0x0fb9 },
|
||||
{ 0x20d0, 0x20dc },
|
||||
{ 0x20e1 },
|
||||
{ 0x302a, 0x302f },
|
||||
{ 0x3099 },
|
||||
{ 0x309a },
|
||||
/* Digit */
|
||||
{ 0x0030, 0x0039 },
|
||||
{ 0x0660, 0x0669 },
|
||||
{ 0x06f0, 0x06f9 },
|
||||
{ 0x0966, 0x096f },
|
||||
{ 0x09e6, 0x09ef },
|
||||
{ 0x0a66, 0x0a6f },
|
||||
{ 0x0ae6, 0x0aef },
|
||||
{ 0x0b66, 0x0b6f },
|
||||
{ 0x0be7, 0x0bef },
|
||||
{ 0x0c66, 0x0c6f },
|
||||
{ 0x0ce6, 0x0cef },
|
||||
{ 0x0d66, 0x0d6f },
|
||||
{ 0x0e50, 0x0e59 },
|
||||
{ 0x0ed0, 0x0ed9 },
|
||||
{ 0x0f20, 0x0f29 },
|
||||
/* Extender */
|
||||
{ 0xb7 },
|
||||
{ 0x02d0 },
|
||||
{ 0x02d1 },
|
||||
{ 0x0387 },
|
||||
{ 0x0640 },
|
||||
{ 0x0e46 },
|
||||
{ 0x0ec6 },
|
||||
{ 0x3005 },
|
||||
{ 0x3031, 0x3035 },
|
||||
{ 0x309d, 0x309e },
|
||||
{ 0x30fc, 0x30fe },
|
||||
};
|
||||
|
||||
void setTab(char *tab, struct range *ranges, size_t nRanges)
|
||||
{
|
||||
size_t i;
|
||||
int j;
|
||||
for (i = 0; i < nRanges; i++) {
|
||||
if (ranges[i].end) {
|
||||
for (j = ranges[i].start; j <= ranges[i].end; j++)
|
||||
tab[j] = 1;
|
||||
}
|
||||
else
|
||||
tab[ranges[i].start] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void printTabs(char *tab)
|
||||
{
|
||||
int nBitmaps = 2;
|
||||
int i, j, k;
|
||||
unsigned char pageIndex[512];
|
||||
|
||||
printf(
|
||||
"static const unsigned namingBitmap[] = {\n\
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,\n\
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,\n\
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n\
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n");
|
||||
for (i = 0; i < 512; i++) {
|
||||
int kind = tab[i*256];
|
||||
for (j = 1; j < 256; j++)
|
||||
if (tab[i*256 +j] != kind) {
|
||||
kind = -1;
|
||||
break;
|
||||
}
|
||||
if (i >= 256 && memcmp(tab + (i - 256)*256, tab + i*256, 256) == 0)
|
||||
pageIndex[i] = pageIndex[i - 256];
|
||||
else if (kind == -1) {
|
||||
pageIndex[i] = nBitmaps++;
|
||||
for (j = 0; j < 8; j++) {
|
||||
unsigned val = 0;
|
||||
for (k = 0; k < 32; k++) {
|
||||
if (tab[i*256 + j*32 +k])
|
||||
val |= (1 << k);
|
||||
}
|
||||
printf("0x%08X,", val);
|
||||
putchar((((j + 1) & 3) == 0) ? '\n' : ' ');
|
||||
}
|
||||
}
|
||||
else
|
||||
pageIndex[i] = kind;
|
||||
}
|
||||
printf("};\n");
|
||||
printf("static const unsigned char nmstrtPages[] = {\n");
|
||||
for (i = 0; i < 512; i++) {
|
||||
if (i == 256)
|
||||
printf("};\nstatic const unsigned char namePages[] = {\n");
|
||||
printf("0x%02X,", pageIndex[i]);
|
||||
putchar((((i + 1) & 7) == 0) ? '\n' : ' ');
|
||||
}
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char tab[2*65536];
|
||||
memset(tab, 0, 65536);
|
||||
setTab(tab, nmstrt, sizeof(nmstrt)/sizeof(nmstrt[0]));
|
||||
memcpy(tab + 65536, tab, 65536);
|
||||
setTab(tab + 65536, name, sizeof(name)/sizeof(name[0]));
|
||||
printTabs(tab);
|
||||
return 0;
|
||||
}
|
||||
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
+7
@@ -0,0 +1,7 @@
|
||||
xcopy /y xmltok\Release\xmltok.lib lib
|
||||
xcopy /y xmlparse\Release\xmlparse.lib lib
|
||||
rm -f expat.zip
|
||||
cd ..
|
||||
sed -e 's;^^;expat/;' expat\files.txt | zip -qr expat\expat.zip -@ -ll
|
||||
sed -e 's;^^;expat/;' expat\win32files.txt | zip -qr expat\expat.zip -@
|
||||
cd 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
+11
@@ -0,0 +1,11 @@
|
||||
expat.dsw
|
||||
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
|
||||
Executable
+191
@@ -0,0 +1,191 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define XMLTOKAPI __declspec(dllimport)
|
||||
#endif
|
||||
#include "xmltok.h"
|
||||
|
||||
#ifndef O_BINARY
|
||||
#ifdef _O_BINARY
|
||||
#define O_BINARY _O_BINARY
|
||||
#else
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void outOfMemory();
|
||||
|
||||
struct XmlTokBuffer {
|
||||
char *buf;
|
||||
char *end;
|
||||
const char *ptr;
|
||||
size_t size;
|
||||
int fd;
|
||||
int state;
|
||||
int eof;
|
||||
unsigned long endOffset;
|
||||
const ENCODING *enc;
|
||||
INIT_ENCODING initEnc;
|
||||
};
|
||||
|
||||
#define XmlTokBufferOffset(tb) ((tb)->endOffset - ((tb)->end - (tb)->ptr))
|
||||
#define READSIZE 1024
|
||||
|
||||
void XmlTokBufferInit(struct XmlTokBuffer *tb, int fd)
|
||||
{
|
||||
tb->buf = malloc(READSIZE);
|
||||
if (!tb->buf)
|
||||
outOfMemory();
|
||||
tb->end = tb->buf;
|
||||
tb->ptr = tb->buf;
|
||||
tb->size = READSIZE;
|
||||
tb->fd = fd;
|
||||
tb->state = XML_PROLOG_STATE;
|
||||
tb->eof = 0;
|
||||
tb->endOffset = 0;
|
||||
XmlInitEncoding(&(tb->initEnc), &(tb->enc));
|
||||
}
|
||||
|
||||
void XmlTokBufferFree(struct XmlTokBuffer *tb)
|
||||
{
|
||||
free(tb->buf);
|
||||
}
|
||||
|
||||
int XmlGetToken(struct XmlTokBuffer *tb, const char **tokStart, size_t *tokLength)
|
||||
{
|
||||
int tok;
|
||||
for (;;) {
|
||||
int nBytes;
|
||||
const char *start = tb->ptr;
|
||||
tok = XmlTok(tb->enc, tb->state, start, tb->end, &tb->ptr);
|
||||
if (tok >= 0) {
|
||||
if (tok == XML_TOK_INSTANCE_START)
|
||||
tb->state = XML_CONTENT_STATE;
|
||||
*tokStart = start;
|
||||
*tokLength = tb->ptr - start;
|
||||
break;
|
||||
}
|
||||
if (tb->eof)
|
||||
break;
|
||||
/* Read in multiples of READSIZE, unless read() has previously
|
||||
less than it could. */
|
||||
if (tb->end == tb->buf + tb->size) {
|
||||
size_t keep = tb->end - tb->ptr;
|
||||
if (keep == 0)
|
||||
tb->ptr = tb->end = tb->buf;
|
||||
else if (keep + READSIZE <= tb->size) {
|
||||
unsigned nBlocks = (tb->size - keep)/READSIZE;
|
||||
char *newEnd = tb->buf + tb->size - (nBlocks * READSIZE);
|
||||
memmove(newEnd - keep, tb->ptr, keep);
|
||||
tb->end = newEnd;
|
||||
tb->ptr = newEnd - keep;
|
||||
}
|
||||
else {
|
||||
char *newBuf, *newEnd;
|
||||
tb->size += READSIZE;
|
||||
newBuf = malloc(tb->size);
|
||||
if (!newBuf)
|
||||
outOfMemory();
|
||||
newEnd = newBuf + tb->size - READSIZE;
|
||||
memcpy(newEnd - keep, tb->ptr, keep);
|
||||
free(tb->buf);
|
||||
tb->buf = newBuf;
|
||||
tb->end = newEnd;
|
||||
tb->ptr = newEnd - keep;
|
||||
}
|
||||
}
|
||||
nBytes = read(tb->fd, tb->end, (tb->buf + tb->size) - tb->end);
|
||||
if (nBytes == 0) {
|
||||
tb->eof = 1;
|
||||
break;
|
||||
}
|
||||
if (nBytes < 0)
|
||||
return XML_TOK_NONE;
|
||||
tb->end += nBytes;
|
||||
tb->endOffset += nBytes;
|
||||
}
|
||||
return tok;
|
||||
}
|
||||
|
||||
int doFile(const char *filename)
|
||||
{
|
||||
unsigned nElements = 0;
|
||||
struct XmlTokBuffer buf;
|
||||
int fd = open(filename, O_RDONLY|O_BINARY);
|
||||
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "%s: cannot open\n", filename);
|
||||
return 0;
|
||||
}
|
||||
XmlTokBufferInit(&buf, fd);
|
||||
for (;;) {
|
||||
const char *tokStr;
|
||||
size_t tokLen;
|
||||
int tok = XmlGetToken(&buf, &tokStr, &tokLen);
|
||||
switch (tok) {
|
||||
case XML_TOK_NONE:
|
||||
if (nElements == 0) {
|
||||
fprintf(stderr, "%s: no instance\n", filename);
|
||||
return 0;
|
||||
}
|
||||
printf("%8u %s\n", nElements, filename);
|
||||
close(fd);
|
||||
XmlTokBufferFree(&buf);
|
||||
return 1;
|
||||
case XML_TOK_INVALID:
|
||||
fprintf(stderr, "%s: well-formedness error at byte %lu\n",
|
||||
filename, XmlTokBufferOffset(&buf));
|
||||
|
||||
close(fd);
|
||||
XmlTokBufferFree(&buf);
|
||||
return 0;
|
||||
case XML_TOK_PARTIAL_CHAR:
|
||||
fprintf(stderr, "%s: unclosed token with partial character started at byte %lu\n",
|
||||
filename, XmlTokBufferOffset(&buf));
|
||||
close(fd);
|
||||
XmlTokBufferFree(&buf);
|
||||
return 0;
|
||||
case XML_TOK_PARTIAL:
|
||||
fprintf(stderr, "%s: unclosed token started at byte %lu\n",
|
||||
filename, XmlTokBufferOffset(&buf));
|
||||
close(fd);
|
||||
XmlTokBufferFree(&buf);
|
||||
return 0;
|
||||
case XML_TOK_START_TAG_WITH_ATTS:
|
||||
case XML_TOK_EMPTY_ELEMENT_WITH_ATTS:
|
||||
case XML_TOK_START_TAG_NO_ATTS:
|
||||
case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
|
||||
nElements++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret = 0;
|
||||
if (argc == 1) {
|
||||
fprintf(stderr, "usage: %s filename ...\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
for (i = 1; i < argc; i++)
|
||||
if (!doFile(argv[i]))
|
||||
ret = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static
|
||||
void outOfMemory()
|
||||
{
|
||||
fprintf(stderr, "out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
Debug
|
||||
Release
|
||||
xmlparse.plg
|
||||
+1730
-382
File diff suppressed because it is too large
Load Diff
Executable
+3693
File diff suppressed because it is too large
Load Diff
Executable
+194
@@ -0,0 +1,194 @@
|
||||
# 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 "XML_NS" /D "WIN32" /D "_WINDOWS" /D "XML_DTD" /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" /link50compat
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!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 XMLTOKAPI=__declspec(dllimport) /D XMLPARSEAPI=__declspec(dllexport) /D "WIN32" /D "_WINDOWS" /D "XML_DTD" /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=.\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=.\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
|
||||
+180
-35
@@ -1,21 +1,6 @@
|
||||
/*
|
||||
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):
|
||||
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlParse_INCLUDED
|
||||
@@ -70,6 +55,19 @@ 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. */
|
||||
@@ -91,6 +89,12 @@ typedef void (*XML_ProcessingInstructionHandler)(void *userData,
|
||||
const XML_Char *target,
|
||||
const XML_Char *data);
|
||||
|
||||
/* 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
|
||||
@@ -100,15 +104,23 @@ 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.
|
||||
If a default handler is set, internal entity references
|
||||
are not expanded. 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. */
|
||||
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 the start of the DOCTYPE declaration when the
|
||||
name of the DOCTYPE is encountered. */
|
||||
typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
|
||||
const XML_Char *doctypeName);
|
||||
|
||||
/* This is called for the start of the DOCTYPE declaration when the
|
||||
closing > is encountered, but after processing any external subset. */
|
||||
typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
|
||||
|
||||
/* 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.
|
||||
@@ -131,6 +143,38 @@ typedef void (*XML_NotationDeclHandler)(void *userData,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
typedef void (*XML_ExternalParsedEntityDeclHandler)(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
typedef void (*XML_InternalParsedEntityDeclHandler)(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *replacementText,
|
||||
int replacementTextLength);
|
||||
|
||||
/* 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 if the document is not standalone (it has an
|
||||
external subset or a reference to a parameter entity, but does not
|
||||
have standalone="yes"). If this handler returns 0, then processing
|
||||
will not continue, and the parser will return a
|
||||
XML_ERROR_NOT_STANDALONE error. */
|
||||
|
||||
typedef int (*XML_NotStandaloneHandler)(void *userData);
|
||||
|
||||
/* 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
|
||||
@@ -145,10 +189,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.
|
||||
@@ -157,7 +200,7 @@ error.
|
||||
Note that unlike other handlers the first argument is the parser, not userData. */
|
||||
|
||||
typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
|
||||
const XML_Char *openEntityNames,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
@@ -237,11 +280,34 @@ 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_SetDoctypeDeclHandler(XML_Parser parser,
|
||||
XML_StartDoctypeDeclHandler start,
|
||||
XML_EndDoctypeDeclHandler end);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
|
||||
XML_UnparsedEntityDeclHandler handler);
|
||||
@@ -250,10 +316,33 @@ void XMLPARSEAPI
|
||||
XML_SetNotationDeclHandler(XML_Parser parser,
|
||||
XML_NotationDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetExternalParsedEntityDeclHandler(XML_Parser parser,
|
||||
XML_ExternalParsedEntityDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetInternalParsedEntityDeclHandler(XML_Parser parser,
|
||||
XML_InternalParsedEntityDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetNamespaceDeclHandler(XML_Parser parser,
|
||||
XML_StartNamespaceDeclHandler start,
|
||||
XML_EndNamespaceDeclHandler end);
|
||||
|
||||
void XMLPARSEAPI
|
||||
XML_SetNotStandaloneHandler(XML_Parser parser,
|
||||
XML_NotStandaloneHandler handler);
|
||||
|
||||
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,
|
||||
@@ -261,10 +350,7 @@ XML_SetUnknownEncodingHandler(XML_Parser parser,
|
||||
|
||||
/* 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.
|
||||
Within the expansion of an internal entity, nothing will be passed
|
||||
to the default handler, although this usually will not happen since
|
||||
setting a default handler inhibits expansion of internal entities. */
|
||||
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. */
|
||||
@@ -274,6 +360,13 @@ XML_SetUserData(XML_Parser parser, void *userData);
|
||||
/* Returns the last value set by XML_SetUserData or null. */
|
||||
#define XML_GetUserData(parser) (*(void **)(parser))
|
||||
|
||||
/* This is equivalent to supplying an encoding argument
|
||||
to XML_ParserCreate. 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. */
|
||||
@@ -294,6 +387,20 @@ XML_SetBase(XML_Parser parser, const XML_Char *base);
|
||||
const XML_Char XMLPARSEAPI *
|
||||
XML_GetBase(XML_Parser parser);
|
||||
|
||||
/* Returns the number of the attribute/value pairs passed in last call
|
||||
to the XML_StartElementHandler that were specified in the start-tag
|
||||
rather than defaulted. Each attribute/value pair counts as 2; thus
|
||||
this correspondds to an index into the atts array passed to the
|
||||
XML_StartElementHandler. */
|
||||
|
||||
int XMLPARSEAPI XML_GetSpecifiedAttributeCount(XML_Parser parser);
|
||||
|
||||
/* Returns the index of the ID attribute passed in the last call to
|
||||
XML_StartElementHandler, or -1 if there is no ID attribute. Each
|
||||
attribute/value pair counts as 2; thus this correspondds to an index
|
||||
into the atts array passed to the XML_StartElementHandler. */
|
||||
int XMLPARSEAPI XML_GetIdAttributeIndex(XML_Parser parser);
|
||||
|
||||
/* Parses some input. Returns 0 if a fatal error is detected.
|
||||
The last call to XML_Parse must have isFinal true;
|
||||
len may be zero for this call (or any other). */
|
||||
@@ -307,10 +414,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.
|
||||
@@ -318,9 +428,38 @@ 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 XML_Char *openEntityNames,
|
||||
const XML_Char *context,
|
||||
const XML_Char *encoding);
|
||||
|
||||
enum XML_ParamEntityParsing {
|
||||
XML_PARAM_ENTITY_PARSING_NEVER,
|
||||
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
|
||||
XML_PARAM_ENTITY_PARSING_ALWAYS
|
||||
};
|
||||
|
||||
/* Controls parsing of parameter entities (including the external DTD
|
||||
subset). If parsing of parameter entities is enabled, then references
|
||||
to external parameter entities (including the external DTD subset)
|
||||
will be passed to the handler set with
|
||||
XML_SetExternalEntityRefHandler. The context passed will be 0.
|
||||
Unlike external general entities, external parameter entities can only
|
||||
be parsed synchronously. If the external parameter entity is to be
|
||||
parsed, it must be parsed during the call to the external entity ref
|
||||
handler: the complete sequence of XML_ExternalEntityParserCreate,
|
||||
XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during
|
||||
this call. After XML_ExternalEntityParserCreate has been called to
|
||||
create the parser for the external parameter entity (context must be 0
|
||||
for this call), it is illegal to make any calls on the old parser
|
||||
until XML_ParserFree has been called on the newly created parser. If
|
||||
the library has been compiled without support for parameter entity
|
||||
parsing (ie without XML_DTD being defined), then
|
||||
XML_SetParamEntityParsing will return 0 if parsing of parameter
|
||||
entities is requested; otherwise it will return non-zero. */
|
||||
|
||||
int XMLPARSEAPI
|
||||
XML_SetParamEntityParsing(XML_Parser parser,
|
||||
enum XML_ParamEntityParsing parsing);
|
||||
|
||||
enum XML_Error {
|
||||
XML_ERROR_NONE,
|
||||
XML_ERROR_NO_MEMORY,
|
||||
@@ -343,7 +482,8 @@ enum XML_Error {
|
||||
XML_ERROR_UNKNOWN_ENCODING,
|
||||
XML_ERROR_INCORRECT_ENCODING,
|
||||
XML_ERROR_UNCLOSED_CDATA_SECTION,
|
||||
XML_ERROR_EXTERNAL_ENTITY_HANDLING
|
||||
XML_ERROR_EXTERNAL_ENTITY_HANDLING,
|
||||
XML_ERROR_NOT_STANDALONE
|
||||
};
|
||||
|
||||
/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
|
||||
@@ -363,6 +503,11 @@ int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser);
|
||||
int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser);
|
||||
long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser);
|
||||
|
||||
/* Return the number of bytes in the current event.
|
||||
Returns 0 if the event is in an internal entity. */
|
||||
|
||||
int XMLPARSEAPI XML_GetCurrentByteCount(XML_Parser parser);
|
||||
|
||||
/* For backwards compatibility with previous versions. */
|
||||
#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
|
||||
#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
|
||||
|
||||
Executable
+458
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (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, 1999
|
||||
James Clark. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms
|
||||
of the GNU General Public License (the "GPL"), in which case the
|
||||
provisions of the GPL are applicable instead of those above. If you
|
||||
wish to allow use of your version of this file only under the terms of
|
||||
the GPL and not to allow others to use your version of this file under
|
||||
the MPL, indicate your decision by deleting the provisions above and
|
||||
replace them with the notice and other provisions required by the
|
||||
GPL. If you do not delete the provisions above, a recipient may use
|
||||
your version of this file under either the MPL or the GPL.
|
||||
*/
|
||||
|
||||
#ifndef XmlParse_INCLUDED
|
||||
#define XmlParse_INCLUDED 1
|
||||
|
||||
#ifndef XMLPARSEAPI
|
||||
#define XMLPARSEAPI /* as nothing */
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
|
||||
/* 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;
|
||||
|
||||
#endif /* not XML_UNICODE */
|
||||
|
||||
#endif /* not XML_UNICODE_WCHAR_T */
|
||||
|
||||
class XML_ElementHandler {
|
||||
public:
|
||||
/* atts is array of name/value pairs, terminated by 0; names and
|
||||
values are 0 terminated. */
|
||||
virtual void startElement(const XML_Char *name, const XML_Char **atts) = 0;
|
||||
virtual void endElement(const XML_Char *name) = 0;
|
||||
};
|
||||
|
||||
class XML_CharacterDataHandler {
|
||||
public:
|
||||
/* s is not 0 terminated. */
|
||||
virtual void characterData(const XML_Char *s, int len) = 0;
|
||||
};
|
||||
|
||||
class XML_ProcessingInstructionHandler {
|
||||
public:
|
||||
/* target and data are 0 terminated */
|
||||
virtual void processingInstruction(const XML_Char *target, const XML_Char *data) = 0;
|
||||
};
|
||||
|
||||
/* data is 0 terminated */
|
||||
class XML_CommentHandler {
|
||||
public:
|
||||
virtual void comment(const XML_Char *data) = 0;
|
||||
};
|
||||
|
||||
class XML_CdataSectionHandler {
|
||||
public:
|
||||
virtual void startCdataSection() = 0;
|
||||
virtual void endCdataSection() = 0;
|
||||
};
|
||||
|
||||
class XML_DefaultHandler {
|
||||
public:
|
||||
/* 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. */
|
||||
virtual void doDefault(const XML_Char *s, int len) = 0;
|
||||
};
|
||||
|
||||
class XML_DoctypeDeclHandler {
|
||||
public:
|
||||
/* This is called for the start of the DOCTYPE declaration when the
|
||||
name of the DOCTYPE is encountered. */
|
||||
virtual void startDoctypeDecl(const XML_Char *doctypeName) = 0;
|
||||
/* This is called for the start of the DOCTYPE declaration when the
|
||||
closing > is encountered, but after processing any external subset. */
|
||||
virtual void endDoctypeDecl() = 0;
|
||||
};
|
||||
|
||||
class XML_UnparsedEntityDeclHandler {
|
||||
public:
|
||||
/* 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. */
|
||||
virtual void unparsedEntityDecl(const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId,
|
||||
const XML_Char *notationName) = 0;
|
||||
};
|
||||
|
||||
class XML_NotationDeclHandler {
|
||||
public:
|
||||
/* 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. */
|
||||
virtual void notationDecl(const XML_Char *notationName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId) = 0;
|
||||
};
|
||||
|
||||
class XML_NamespaceDeclHandler {
|
||||
public:
|
||||
/* 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. */
|
||||
|
||||
virtual void startNamespaceDecl(const XML_Char *prefix,
|
||||
const XML_Char *uri) = 0;
|
||||
|
||||
virtual void endNamespaceDecl(const XML_Char *prefix) = 0;
|
||||
};
|
||||
|
||||
class XML_NotStandaloneHandler {
|
||||
public:
|
||||
/* This is called if the document is not standalone (it has an
|
||||
external subset or a reference to a parameter entity, but does
|
||||
not have standalone="yes"). If this handler returns 0, then
|
||||
processing will not continue, and the parser will return a
|
||||
ERROR_NOT_STANDALONE error. */
|
||||
virtual int notStandalone() = 0;
|
||||
};
|
||||
|
||||
class XML_Parser;
|
||||
|
||||
class XML_ExternalEntityRefHandler {
|
||||
public:
|
||||
/* 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
|
||||
externalEntityParserCreate. The parser argument is the parser
|
||||
parsing the entity containing the reference; it can be passed as
|
||||
the parser argument to externalEntityParserCreate. The systemId
|
||||
argument is the system identifier as specified in the entity
|
||||
declaration; it will not be null. The base argument is the
|
||||
system identifier that should be used as the base for resolving
|
||||
systemId if systemId was relative; this is set by setBase; 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 context argument
|
||||
specifies the parsing context in the format expected by the
|
||||
context argument to 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. In this case the calling parser
|
||||
will return an ERROR_EXTERNAL_ENTITY_HANDLING error. Note that
|
||||
unlike other handlers the first argument is the parser, not
|
||||
userData. */
|
||||
|
||||
virtual int externalEntityRef(XML_Parser *parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId) = 0;
|
||||
};
|
||||
|
||||
/* This object is returned 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. */
|
||||
|
||||
class XMLPARSEAPI XML_Encoding {
|
||||
public:
|
||||
int map[256];
|
||||
virtual int convert(const char *s);
|
||||
virtual void release();
|
||||
};
|
||||
|
||||
class XML_UnknownEncodingHandler {
|
||||
public:
|
||||
/* 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. */
|
||||
virtual XML_Encoding *unknownEncoding(const XML_Char *name) = 0;
|
||||
};
|
||||
|
||||
class XMLPARSEAPI XML_Parser {
|
||||
public:
|
||||
/* Constructs a new parser; encoding is the encoding specified by
|
||||
the external protocol or null if there is none specified. */
|
||||
static XML_Parser *parserCreate(const XML_Char *encoding = 0);
|
||||
|
||||
/* 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. */
|
||||
|
||||
static XML_Parser *parserCreateNS(const XML_Char *encoding,
|
||||
XML_Char namespaceSeparator);
|
||||
|
||||
virtual void release() = 0;
|
||||
virtual void setElementHandler(XML_ElementHandler *handler) = 0;
|
||||
virtual void setCharacterDataHandler(XML_CharacterDataHandler *handler) = 0;
|
||||
virtual void setProcessingInstructionHandler(XML_ProcessingInstructionHandler *handler) = 0;
|
||||
virtual void setCommentHandler(XML_CommentHandler *handler) = 0;
|
||||
virtual void setCdataSectionHandler(XML_CdataSectionHandler *handler) = 0;
|
||||
|
||||
/* This sets the default handler and also inhibits expansion of
|
||||
internal entities. The entity reference will be passed to the
|
||||
default handler. */
|
||||
|
||||
virtual void setDefaultHandler(XML_DefaultHandler *handler) = 0;
|
||||
|
||||
/* This sets the default handler but does not inhibit expansion of
|
||||
internal entities. The entity reference will not be passed to
|
||||
the default handler. */
|
||||
|
||||
virtual void setDefaultHandlerExpand(XML_DefaultHandler *handler) = 0;
|
||||
|
||||
virtual void setDoctypeDeclHandler(XML_DoctypeDeclHandler *handler) = 0;
|
||||
virtual void setUnparsedEntityDeclHandler(XML_UnparsedEntityDeclHandler *handler) = 0;
|
||||
virtual void setNotationDeclHandler(XML_NotationDeclHandler *handler) = 0;
|
||||
virtual void setNamespaceDeclHandler(XML_NamespaceDeclHandler *handler) = 0;
|
||||
virtual void setNotStandaloneHandler(XML_NotStandaloneHandler *handler) = 0;
|
||||
virtual void setExternalEntityRefHandler(XML_ExternalEntityRefHandler *handler) = 0;
|
||||
virtual void setUnknownEncodingHandler(XML_UnknownEncodingHandler *handler) = 0;
|
||||
|
||||
/* 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. */
|
||||
virtual void defaultCurrent() = 0;
|
||||
|
||||
/* This is equivalent to supplying an encoding argument
|
||||
to XML_ParserCreate. It must not be called after XML_Parse
|
||||
or XML_ParseBuffer. */
|
||||
virtual int setEncoding(const XML_Char *encoding) = 0;
|
||||
|
||||
/* 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 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. */
|
||||
|
||||
virtual int setBase(const XML_Char *base) = 0;
|
||||
|
||||
virtual const XML_Char *getBase() = 0;
|
||||
|
||||
/* Returns the number of the attributes passed in last call to the
|
||||
XML_StartElementHandler that were specified in the start-tag rather
|
||||
than defaulted. */
|
||||
virtual int getSpecifiedAttributeCount() = 0;
|
||||
|
||||
/* Parses some input. Returns 0 if a fatal error is detected.
|
||||
The last call to XML_Parse must have isFinal true;
|
||||
len may be zero for this call (or any other). */
|
||||
virtual int parse(const char *s, int len, int isFinal) = 0;
|
||||
|
||||
virtual char *getBuffer(int len) = 0;
|
||||
|
||||
virtual int parseBuffer(int len, int isFinal) = 0;
|
||||
|
||||
/* Creates an XML_Parser object that can parse an external general
|
||||
entity; 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. The
|
||||
handlers and userData are initialized from the parser argument.
|
||||
Returns 0 if out of memory. Otherwise returns a new XML_Parser
|
||||
object. */
|
||||
|
||||
virtual XML_Parser *externalEntityParserCreate(const XML_Char *context,
|
||||
const XML_Char *encoding) = 0;
|
||||
|
||||
enum ParamEntityParsing {
|
||||
PARAM_ENTITY_PARSING_NEVER,
|
||||
PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
|
||||
PARAM_ENTITY_PARSING_ALWAYS
|
||||
};
|
||||
|
||||
/* Controls parsing of parameter entities (including the external
|
||||
DTD subset). If parsing of parameter entities is enabled, then
|
||||
references to external parameter entities (including the external
|
||||
DTD subset) will be passed to the handler set with
|
||||
XML_SetExternalEntityRefHandler. The context passed will be 0.
|
||||
Unlike external general entities, external parameter entities can
|
||||
only be parsed synchronously. If the external parameter entity
|
||||
is to be parsed, it must be parsed during the call to the
|
||||
external entity ref handler: the complete sequence of
|
||||
XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
|
||||
XML_ParserFree calls must be made during this call. After
|
||||
XML_ExternalEntityParserCreate has been called to create the
|
||||
parser for the external parameter entity (context must be 0 for
|
||||
this call), it is illegal to make any calls on the old parser
|
||||
until XML_ParserFree has been called on the newly created parser.
|
||||
If the library has been compiled without support for parameter
|
||||
entity parsing (ie without XML_DTD being defined), then
|
||||
XML_SetParamEntityParsing will return 0 if parsing of parameter
|
||||
entities is requested; otherwise it will return non-zero. */
|
||||
|
||||
virtual int setParamEntityParsing(ParamEntityParsing parsing) = 0;
|
||||
|
||||
enum Error {
|
||||
ERROR_NONE,
|
||||
ERROR_NO_MEMORY,
|
||||
ERROR_SYNTAX,
|
||||
ERROR_NO_ELEMENTS,
|
||||
ERROR_INVALID_TOKEN,
|
||||
ERROR_UNCLOSED_TOKEN,
|
||||
ERROR_PARTIAL_CHAR,
|
||||
ERROR_TAG_MISMATCH,
|
||||
ERROR_DUPLICATE_ATTRIBUTE,
|
||||
ERROR_JUNK_AFTER_DOC_ELEMENT,
|
||||
ERROR_PARAM_ENTITY_REF,
|
||||
ERROR_UNDEFINED_ENTITY,
|
||||
ERROR_RECURSIVE_ENTITY_REF,
|
||||
ERROR_ASYNC_ENTITY,
|
||||
ERROR_BAD_CHAR_REF,
|
||||
ERROR_BINARY_ENTITY_REF,
|
||||
ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
|
||||
ERROR_MISPLACED_XML_PI,
|
||||
ERROR_UNKNOWN_ENCODING,
|
||||
ERROR_INCORRECT_ENCODING,
|
||||
ERROR_UNCLOSED_CDATA_SECTION,
|
||||
ERROR_EXTERNAL_ENTITY_HANDLING,
|
||||
ERROR_NOT_STANDALONE
|
||||
};
|
||||
|
||||
/* If parse or XML_parseBuffer have returned 0, then XML_GetErrorCode
|
||||
returns information about the error. */
|
||||
|
||||
virtual Error getErrorCode() = 0;
|
||||
|
||||
/* 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. */
|
||||
|
||||
virtual int getCurrentLineNumber() = 0;
|
||||
virtual int getCurrentColumnNumber() = 0;
|
||||
virtual long getCurrentByteIndex() = 0;
|
||||
|
||||
/* Return the number of bytes in the current event.
|
||||
Returns 0 if the event is in an internal entity. */
|
||||
virtual int getCurrentByteCount() = 0;
|
||||
|
||||
/* Returns a string describing the error. */
|
||||
static const XML_LChar *errorString(int code);
|
||||
protected:
|
||||
~XML_Parser() { }
|
||||
};
|
||||
|
||||
#endif /* not XmlParse_INCLUDED */
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
nametab.h
|
||||
Release
|
||||
Debug
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#define ASCII_A 0x41
|
||||
#define ASCII_B 0x42
|
||||
#define ASCII_C 0x43
|
||||
#define ASCII_D 0x44
|
||||
#define ASCII_E 0x45
|
||||
#define ASCII_F 0x46
|
||||
#define ASCII_G 0x47
|
||||
#define ASCII_H 0x48
|
||||
#define ASCII_I 0x49
|
||||
#define ASCII_J 0x4A
|
||||
#define ASCII_K 0x4B
|
||||
#define ASCII_L 0x4C
|
||||
#define ASCII_M 0x4D
|
||||
#define ASCII_N 0x4E
|
||||
#define ASCII_O 0x4F
|
||||
#define ASCII_P 0x50
|
||||
#define ASCII_Q 0x51
|
||||
#define ASCII_R 0x52
|
||||
#define ASCII_S 0x53
|
||||
#define ASCII_T 0x54
|
||||
#define ASCII_U 0x55
|
||||
#define ASCII_V 0x56
|
||||
#define ASCII_W 0x57
|
||||
#define ASCII_X 0x58
|
||||
#define ASCII_Y 0x59
|
||||
#define ASCII_Z 0x5A
|
||||
|
||||
#define ASCII_a 0x61
|
||||
#define ASCII_b 0x62
|
||||
#define ASCII_c 0x63
|
||||
#define ASCII_d 0x64
|
||||
#define ASCII_e 0x65
|
||||
#define ASCII_f 0x66
|
||||
#define ASCII_g 0x67
|
||||
#define ASCII_h 0x68
|
||||
#define ASCII_i 0x69
|
||||
#define ASCII_j 0x6A
|
||||
#define ASCII_k 0x6B
|
||||
#define ASCII_l 0x6C
|
||||
#define ASCII_m 0x6D
|
||||
#define ASCII_n 0x6E
|
||||
#define ASCII_o 0x6F
|
||||
#define ASCII_p 0x70
|
||||
#define ASCII_q 0x71
|
||||
#define ASCII_r 0x72
|
||||
#define ASCII_s 0x73
|
||||
#define ASCII_t 0x74
|
||||
#define ASCII_u 0x75
|
||||
#define ASCII_v 0x76
|
||||
#define ASCII_w 0x77
|
||||
#define ASCII_x 0x78
|
||||
#define ASCII_y 0x79
|
||||
#define ASCII_z 0x7A
|
||||
|
||||
#define ASCII_0 0x30
|
||||
#define ASCII_1 0x31
|
||||
#define ASCII_2 0x32
|
||||
#define ASCII_3 0x33
|
||||
#define ASCII_4 0x34
|
||||
#define ASCII_5 0x35
|
||||
#define ASCII_6 0x36
|
||||
#define ASCII_7 0x37
|
||||
#define ASCII_8 0x38
|
||||
#define ASCII_9 0x39
|
||||
|
||||
#define ASCII_TAB 0x09
|
||||
#define ASCII_SPACE 0x20
|
||||
#define ASCII_EXCL 0x21
|
||||
#define ASCII_QUOT 0x22
|
||||
#define ASCII_AMP 0x26
|
||||
#define ASCII_APOS 0x27
|
||||
#define ASCII_MINUS 0x2D
|
||||
#define ASCII_PERIOD 0x2E
|
||||
#define ASCII_COLON 0x3A
|
||||
#define ASCII_SEMI 0x3B
|
||||
#define ASCII_LT 0x3C
|
||||
#define ASCII_EQUALS 0x3D
|
||||
#define ASCII_GT 0x3E
|
||||
#define ASCII_LSQB 0x5B
|
||||
#define ASCII_RSQB 0x5D
|
||||
#define ASCII_UNDERSCORE 0x5F
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 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_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,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#define STRICT 1
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 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_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,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
|
||||
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
|
||||
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
|
||||
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#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. */
|
||||
|
||||
/* Mozilla specific defines */
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
#include "nspr.h"
|
||||
#define malloc(x) PR_Malloc((size_t)(x))
|
||||
#define realloc(x, y) PR_Realloc((x), (size_t)(y))
|
||||
#define calloc(x, y) PR_Calloc((x),(y))
|
||||
#define free(x) PR_Free(x)
|
||||
#if PR_BYTES_PER_INT != 4
|
||||
#define int int32
|
||||
#endif
|
||||
|
||||
/* Enable Unicode string processing in expat. */
|
||||
#ifndef XML_UNICODE
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
/* Enable external parameter entity parsing in expat */
|
||||
#ifndef XML_DTD
|
||||
#define XML_DTD 1
|
||||
#endif
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
Executable
+1265
File diff suppressed because it is too large
Load Diff
Executable
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlRole_INCLUDED
|
||||
#define XmlRole_INCLUDED 1
|
||||
|
||||
#include "xmltok.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
XML_ROLE_ERROR = -1,
|
||||
XML_ROLE_NONE = 0,
|
||||
XML_ROLE_XML_DECL,
|
||||
XML_ROLE_INSTANCE_START,
|
||||
XML_ROLE_DOCTYPE_NAME,
|
||||
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||
XML_ROLE_DOCTYPE_CLOSE,
|
||||
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||
XML_ROLE_PARAM_ENTITY_NAME,
|
||||
XML_ROLE_ENTITY_VALUE,
|
||||
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||
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,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_ELEMENT_NAME,
|
||||
XML_ROLE_CONTENT_ANY,
|
||||
XML_ROLE_CONTENT_EMPTY,
|
||||
XML_ROLE_CONTENT_PCDATA,
|
||||
XML_ROLE_GROUP_OPEN,
|
||||
XML_ROLE_GROUP_CLOSE,
|
||||
XML_ROLE_GROUP_CLOSE_REP,
|
||||
XML_ROLE_GROUP_CLOSE_OPT,
|
||||
XML_ROLE_GROUP_CLOSE_PLUS,
|
||||
XML_ROLE_GROUP_CHOICE,
|
||||
XML_ROLE_GROUP_SEQUENCE,
|
||||
XML_ROLE_CONTENT_ELEMENT,
|
||||
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||
#ifdef XML_DTD
|
||||
XML_ROLE_TEXT_DECL,
|
||||
XML_ROLE_IGNORE_SECT,
|
||||
XML_ROLE_INNER_PARAM_ENTITY_REF,
|
||||
#endif /* XML_DTD */
|
||||
XML_ROLE_PARAM_ENTITY_REF,
|
||||
XML_ROLE_EXTERNAL_GENERAL_ENTITY_NO_NOTATION
|
||||
};
|
||||
|
||||
typedef struct prolog_state {
|
||||
int (*handler)(struct prolog_state *state,
|
||||
int tok,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const ENCODING *enc);
|
||||
unsigned level;
|
||||
#ifdef XML_DTD
|
||||
unsigned includeLevel;
|
||||
int documentEntity;
|
||||
#endif /* XML_DTD */
|
||||
} PROLOG_STATE;
|
||||
|
||||
void XMLTOKAPI XmlPrologStateInit(PROLOG_STATE *);
|
||||
#ifdef XML_DTD
|
||||
void XMLTOKAPI XmlPrologStateInitExternalEntity(PROLOG_STATE *);
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||
(((state)->handler)(state, tok, ptr, end, enc))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlRole_INCLUDED */
|
||||
+695
-279
File diff suppressed because it is too large
Load Diff
Executable
+198
@@ -0,0 +1,198 @@
|
||||
# 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 "NDEBUG" /D "XML_NS" /D XMLTOKAPI=__declspec(dllexport) /D "WIN32" /D "_WINDOWS" /D "XML_DTD" /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" /link50compat
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!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 XMLTOKAPI=__declspec(dllexport) /D "WIN32" /D "_WINDOWS" /D "XML_DTD" /D "XML_NS" /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=..\gennmtab\gennmtab.c
|
||||
|
||||
!IF "$(CFG)" == "xmltok - Win32 Release"
|
||||
|
||||
# PROP Ignore_Default_Tool 1
|
||||
# Begin Custom Build - Creating nametab.h
|
||||
InputDir=\home\work\xmls\gennmtab
|
||||
OutDir=.\Release
|
||||
ProjDir=.
|
||||
InputPath=..\gennmtab\gennmtab.c
|
||||
|
||||
"$(ProjDir)\nametab.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(InputDir)\$(OutDir)\gennmtab >$(ProjDir)\nametab.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmltok - Win32 Debug"
|
||||
|
||||
# PROP Ignore_Default_Tool 1
|
||||
# Begin Custom Build - Creating nametab.h
|
||||
InputDir=\home\work\xmls\gennmtab
|
||||
OutDir=.\Debug
|
||||
ProjDir=.
|
||||
InputPath=..\gennmtab\gennmtab.c
|
||||
|
||||
"$(ProjDir)\nametab.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(InputDir)\$(OutDir)\gennmtab >$(ProjDir)\nametab.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# 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
|
||||
+59
-26
@@ -1,21 +1,6 @@
|
||||
/*
|
||||
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):
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlTok_INCLUDED
|
||||
@@ -49,8 +34,7 @@ extern "C" {
|
||||
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||
#define XML_TOK_END_TAG 5
|
||||
#define XML_TOK_DATA_CHARS 6
|
||||
/* A carriage-return in data that must be normalized to a newline. */
|
||||
#define XML_TOK_DATA_CR 7
|
||||
#define XML_TOK_DATA_NEWLINE 7
|
||||
#define XML_TOK_CDATA_SECT_OPEN 8
|
||||
#define XML_TOK_ENTITY_REF 9
|
||||
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||
@@ -94,13 +78,27 @@ extern "C" {
|
||||
|
||||
/* The following token is returned only by XmlCdataSectionTok */
|
||||
#define XML_TOK_CDATA_SECT_CLOSE 40
|
||||
/* A carriage return that is ignored because it is followed by a line-feed. */
|
||||
#define XML_TOK_IGNORE_CR 41
|
||||
|
||||
/* With namespace processing this is returned by XmlPrologTok
|
||||
for a name with a colon. */
|
||||
#define XML_TOK_PREFIXED_NAME 41
|
||||
|
||||
#ifdef XML_DTD
|
||||
#define XML_TOK_IGNORE_SECT 42
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#ifdef XML_DTD
|
||||
#define XML_N_STATES 4
|
||||
#else /* not XML_DTD */
|
||||
#define XML_N_STATES 3
|
||||
#endif /* not XML_DTD */
|
||||
|
||||
#define XML_PROLOG_STATE 0
|
||||
#define XML_CONTENT_STATE 1
|
||||
#define XML_CDATA_SECTION_STATE 2
|
||||
#ifdef XML_DTD
|
||||
#define XML_IGNORE_SECTION_STATE 3
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#define XML_N_LITERAL_TYPES 2
|
||||
#define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||
@@ -139,12 +137,13 @@ struct encoding {
|
||||
int (*sameName)(const ENCODING *,
|
||||
const char *, const char *);
|
||||
int (*nameMatchesAscii)(const ENCODING *,
|
||||
const char *, const char *);
|
||||
const char *, const char *, const char *);
|
||||
int (*nameLength)(const ENCODING *, const char *);
|
||||
const char *(*skipS)(const ENCODING *, const char *);
|
||||
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,
|
||||
@@ -199,6 +198,13 @@ literals, comments and processing instructions.
|
||||
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#ifdef XML_DTD
|
||||
|
||||
#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#endif /* XML_DTD */
|
||||
|
||||
/* This is used for performing a 2nd-level tokenization on
|
||||
the content of a literal that has already been returned by XmlTok. */
|
||||
|
||||
@@ -213,8 +219,8 @@ the content of a literal that has already been returned by XmlTok. */
|
||||
|
||||
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||
|
||||
#define XmlNameMatchesAscii(enc, ptr1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, ptr2))
|
||||
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||
|
||||
#define XmlNameLength(enc, ptr) \
|
||||
(((enc)->nameLength)(enc, ptr))
|
||||
@@ -228,6 +234,9 @@ 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))
|
||||
|
||||
@@ -256,11 +265,35 @@ int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity,
|
||||
int *standalonePtr);
|
||||
|
||||
int XMLTOKAPI XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncoding();
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncoding();
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncoding(void);
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncoding(void);
|
||||
int XMLTOKAPI XmlUtf8Encode(int charNumber, char *buf);
|
||||
int XMLTOKAPI XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||
|
||||
int XMLTOKAPI XmlSizeOfUnknownEncoding(void);
|
||||
ENCODING XMLTOKAPI *
|
||||
XmlInitUnknownEncoding(void *mem,
|
||||
int *table,
|
||||
int (*conv)(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(void);
|
||||
const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncodingNS(void);
|
||||
ENCODING XMLTOKAPI *
|
||||
XmlInitUnknownEncodingNS(void *mem,
|
||||
int *table,
|
||||
int (*conv)(void *userData, const char *p),
|
||||
void *userData);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
+394
-280
File diff suppressed because it is too large
Load Diff
Executable
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
enum {
|
||||
BT_NONXML,
|
||||
BT_MALFORM,
|
||||
BT_LT,
|
||||
BT_AMP,
|
||||
BT_RSQB,
|
||||
BT_LEAD2,
|
||||
BT_LEAD3,
|
||||
BT_LEAD4,
|
||||
BT_TRAIL,
|
||||
BT_CR,
|
||||
BT_LF,
|
||||
BT_GT,
|
||||
BT_QUOT,
|
||||
BT_APOS,
|
||||
BT_EQUALS,
|
||||
BT_QUEST,
|
||||
BT_EXCL,
|
||||
BT_SOL,
|
||||
BT_SEMI,
|
||||
BT_NUM,
|
||||
BT_LSQB,
|
||||
BT_S,
|
||||
BT_NMSTRT,
|
||||
BT_COLON,
|
||||
BT_HEX,
|
||||
BT_DIGIT,
|
||||
BT_NAME,
|
||||
BT_MINUS,
|
||||
BT_OTHER, /* known not to be a name or name start character */
|
||||
BT_NONASCII, /* might be a name or name start character */
|
||||
BT_PERCNT,
|
||||
BT_LPAR,
|
||||
BT_RPAR,
|
||||
BT_AST,
|
||||
BT_PLUS,
|
||||
BT_COMMA,
|
||||
BT_VERBAR
|
||||
};
|
||||
|
||||
#include <stddef.h>
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
const ENCODING *NS(XmlGetUtf8InternalEncoding)(void)
|
||||
{
|
||||
return &ns(internal_utf8_encoding).enc;
|
||||
}
|
||||
|
||||
const ENCODING *NS(XmlGetUtf16InternalEncoding)(void)
|
||||
{
|
||||
#if XML_BYTE_ORDER == 12
|
||||
return &ns(internal_little2_encoding).enc;
|
||||
#elif XML_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;
|
||||
SET_INIT_ENC_INDEX(p, 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, KW_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
+3
@@ -0,0 +1,3 @@
|
||||
Debug
|
||||
Release
|
||||
xmlwf.plg
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#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
+7
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
int codepageMap(int cp, int *map);
|
||||
int codepageConvert(int cp, const char *p);
|
||||
Executable
+145
@@ -0,0 +1,145 @@
|
||||
#define CHARSET_MAX 41
|
||||
|
||||
static
|
||||
const char *getTok(const char **pp)
|
||||
{
|
||||
enum { inAtom, inString, init, inComment };
|
||||
int state = init;
|
||||
const char *tokStart = 0;
|
||||
for (;;) {
|
||||
switch (**pp) {
|
||||
case '\0':
|
||||
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 (matchkey(p, next, "xml"))
|
||||
isXml = 1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
p = getTok(&next);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char buf[CHARSET_MAX];
|
||||
getXMLCharset(argv[1], buf);
|
||||
printf("charset = \"%s\"\n", buf);
|
||||
return 0;
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
|
||||
#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
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef S_ISREG
|
||||
#ifndef S_IFREG
|
||||
#define S_IFREG _S_IFREG
|
||||
#endif
|
||||
#ifndef S_IFMT
|
||||
#define S_IFMT _S_IFMT
|
||||
#endif
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif /* not S_ISREG */
|
||||
|
||||
#ifndef O_BINARY
|
||||
#ifdef _O_BINARY
|
||||
#define O_BINARY _O_BINARY
|
||||
#else
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int filemap(const char *name,
|
||||
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
size_t nbytes;
|
||||
int fd;
|
||||
int n;
|
||||
struct stat sb;
|
||||
void *p;
|
||||
|
||||
fd = open(name, O_RDONLY|O_BINARY);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
return 0;
|
||||
}
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
perror(name);
|
||||
return 0;
|
||||
}
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
fprintf(stderr, "%s: not a regular file\n", name);
|
||||
return 0;
|
||||
}
|
||||
nbytes = sb.st_size;
|
||||
p = malloc(nbytes);
|
||||
if (!p) {
|
||||
fprintf(stderr, "%s: out of memory\n", name);
|
||||
return 0;
|
||||
}
|
||||
n = read(fd, p, nbytes);
|
||||
if (n < 0) {
|
||||
perror(name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (n != nbytes) {
|
||||
fprintf(stderr, "%s: read unexpected number of bytes\n", name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
processor(p, nbytes, name, arg);
|
||||
free(p);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
#include "filemap.h"
|
||||
|
||||
int filemap(const char *name,
|
||||
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
int fd;
|
||||
size_t nbytes;
|
||||
struct stat sb;
|
||||
void *p;
|
||||
|
||||
fd = open(name, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
return 0;
|
||||
}
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
perror(name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
close(fd);
|
||||
fprintf(stderr, "%s: not a regular file\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nbytes = sb.st_size;
|
||||
p = (void *)mmap((caddr_t)0, (size_t)nbytes, PROT_READ,
|
||||
MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
|
||||
if (p == (void *)-1) {
|
||||
perror(name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
processor(p, nbytes, name, arg);
|
||||
munmap((caddr_t)p, nbytes);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
Executable
+953
@@ -0,0 +1,953 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "wfcheck.h"
|
||||
#include "hashtable.h"
|
||||
|
||||
#include "xmltok.h"
|
||||
#include "xmlrole.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *textPtr;
|
||||
size_t textLen;
|
||||
const char *docTextPtr;
|
||||
const char *systemId;
|
||||
const char *publicId;
|
||||
const char *notation;
|
||||
char open;
|
||||
char wfInContent;
|
||||
char wfInAttribute;
|
||||
char magic;
|
||||
} ENTITY;
|
||||
|
||||
#define INIT_BLOCK_SIZE 1024
|
||||
|
||||
typedef struct block {
|
||||
struct block *next;
|
||||
char s[1];
|
||||
} BLOCK;
|
||||
|
||||
typedef struct {
|
||||
BLOCK *blocks;
|
||||
const char *end;
|
||||
char *ptr;
|
||||
char *start;
|
||||
} STRING_POOL;
|
||||
|
||||
typedef struct {
|
||||
HASH_TABLE generalEntities;
|
||||
HASH_TABLE paramEntities;
|
||||
STRING_POOL pool;
|
||||
int containsRef;
|
||||
int standalone;
|
||||
char *groupConnector;
|
||||
size_t groupSize;
|
||||
} DTD;
|
||||
|
||||
typedef struct {
|
||||
DTD dtd;
|
||||
size_t stackSize;
|
||||
const char **startName;
|
||||
int attsSize;
|
||||
ATTRIBUTE *atts;
|
||||
} CONTEXT;
|
||||
|
||||
static void poolInit(STRING_POOL *);
|
||||
static void poolDestroy(STRING_POOL *);
|
||||
static const char *poolAppend(STRING_POOL *pool, const ENCODING *enc,
|
||||
const char *ptr, const char *end);
|
||||
static const char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
|
||||
const char *ptr, const char *end);
|
||||
static int poolGrow(STRING_POOL *);
|
||||
static int dtdInit(DTD *);
|
||||
static void dtdDestroy(DTD *);
|
||||
static int contextInit(CONTEXT *);
|
||||
static void contextDestroy(CONTEXT *);
|
||||
|
||||
#define poolStart(pool) ((pool)->start)
|
||||
#define poolDiscard(pool) ((pool)->ptr = (pool)->start)
|
||||
#define poolFinish(pool) ((pool)->start = (pool)->ptr)
|
||||
|
||||
static enum WfCheckResult
|
||||
checkProlog(DTD *, const char *s, const char *end, const char **, const ENCODING **enc);
|
||||
static enum WfCheckResult
|
||||
checkContent(size_t level, CONTEXT *context, const ENCODING *enc,
|
||||
const char *s, const char *end, const char **badPtr);
|
||||
static enum WfCheckResult
|
||||
checkGeneralTextEntity(CONTEXT *context,
|
||||
const char *s, const char *end,
|
||||
const char **nextPtr,
|
||||
const ENCODING **enc);
|
||||
static enum WfCheckResult
|
||||
checkAttributeValue(DTD *, const ENCODING *, const char *, const char *, const char **);
|
||||
static enum WfCheckResult
|
||||
checkAttributeUniqueness(CONTEXT *context, const ENCODING *enc, int nAtts,
|
||||
const char **badPtr);
|
||||
static enum WfCheckResult
|
||||
checkParsedEntities(CONTEXT *context, const char **badPtr);
|
||||
|
||||
static
|
||||
enum WfCheckResult storeEntity(DTD *dtd,
|
||||
const ENCODING *enc,
|
||||
int isParam,
|
||||
const char *entityNamePtr,
|
||||
const char *entityNameEnd,
|
||||
const char *entityTextPtr,
|
||||
const char *entityTextEnd,
|
||||
const char **badPtr);
|
||||
|
||||
|
||||
enum WfCheckResult
|
||||
wfCheck(enum EntityType entityType, const char *s, size_t n,
|
||||
const char **badPtr, unsigned long *badLine, unsigned long *badCol)
|
||||
{
|
||||
CONTEXT context;
|
||||
const ENCODING *enc;
|
||||
const char *start = s;
|
||||
const char *end = s + n;
|
||||
const char *next = 0;
|
||||
enum WfCheckResult result;
|
||||
|
||||
if (!contextInit(&context)) {
|
||||
contextDestroy(&context);
|
||||
return noMemory;
|
||||
}
|
||||
if (entityType == documentEntity) {
|
||||
result = checkProlog(&context.dtd, s, end, &next, &enc);
|
||||
s = next;
|
||||
if (!result) {
|
||||
result = checkParsedEntities(&context, &next);
|
||||
s = next;
|
||||
if (!result) {
|
||||
result = checkContent(0, &context, enc, s, end, &next);
|
||||
s = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = checkGeneralTextEntity(&context, s, end, &next, &enc);
|
||||
s = next;
|
||||
}
|
||||
if (result && s) {
|
||||
POSITION pos;
|
||||
memset(&pos, 0, sizeof(POSITION));
|
||||
XmlUpdatePosition(enc, start, s, &pos);
|
||||
*badPtr = s;
|
||||
*badLine = pos.lineNumber;
|
||||
*badCol = pos.columnNumber;
|
||||
}
|
||||
contextDestroy(&context);
|
||||
return result;
|
||||
}
|
||||
|
||||
static
|
||||
int contextInit(CONTEXT *p)
|
||||
{
|
||||
p->stackSize = 1024;
|
||||
p->startName = malloc(p->stackSize * sizeof(char *));
|
||||
p->attsSize = 1024;
|
||||
p->atts = malloc(p->attsSize * sizeof(ATTRIBUTE));
|
||||
return dtdInit(&(p->dtd)) && p->atts && p->startName;
|
||||
}
|
||||
|
||||
static
|
||||
void contextDestroy(CONTEXT *p)
|
||||
{
|
||||
dtdDestroy(&(p->dtd));
|
||||
free((void *)p->startName);
|
||||
free((void *)p->atts);
|
||||
}
|
||||
|
||||
static enum WfCheckResult
|
||||
checkContent(size_t level, CONTEXT *context, const ENCODING *enc,
|
||||
const char *s, const char *end, const char **badPtr)
|
||||
{
|
||||
size_t startLevel = level;
|
||||
const char *next;
|
||||
int tok = XmlContentTok(enc, s, end, &next);
|
||||
for (;;) {
|
||||
switch (tok) {
|
||||
case XML_TOK_TRAILING_CR:
|
||||
case XML_TOK_NONE:
|
||||
if (startLevel > 0) {
|
||||
if (level != startLevel) {
|
||||
*badPtr = s;
|
||||
return asyncEntity;
|
||||
}
|
||||
return wellFormed;
|
||||
}
|
||||
*badPtr = s;
|
||||
return noElements;
|
||||
case XML_TOK_INVALID:
|
||||
*badPtr = next;
|
||||
return invalidToken;
|
||||
case XML_TOK_PARTIAL:
|
||||
*badPtr = s;
|
||||
return unclosedToken;
|
||||
case XML_TOK_PARTIAL_CHAR:
|
||||
*badPtr = s;
|
||||
return partialChar;
|
||||
case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
|
||||
break;
|
||||
case XML_TOK_ENTITY_REF:
|
||||
{
|
||||
const char *name = poolStoreString(&context->dtd.pool, enc,
|
||||
s + enc->minBytesPerChar,
|
||||
next - enc->minBytesPerChar);
|
||||
ENTITY *entity = (ENTITY *)lookup(&context->dtd.generalEntities, name, 0);
|
||||
poolDiscard(&context->dtd.pool);
|
||||
if (!entity) {
|
||||
if (!context->dtd.containsRef || context->dtd.standalone) {
|
||||
*badPtr = s;
|
||||
return undefinedEntity;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (entity->wfInContent)
|
||||
break;
|
||||
if (entity->open) {
|
||||
*badPtr = s;
|
||||
return recursiveEntityRef;
|
||||
}
|
||||
if (entity->notation) {
|
||||
*badPtr = s;
|
||||
return binaryEntityRef;
|
||||
}
|
||||
if (entity) {
|
||||
if (entity->textPtr) {
|
||||
enum WfCheckResult result;
|
||||
const ENCODING *internalEnc = XmlGetInternalEncoding(XML_UTF8_ENCODING);
|
||||
entity->open = 1;
|
||||
result = checkContent(level, context, internalEnc,
|
||||
entity->textPtr, entity->textPtr + entity->textLen,
|
||||
badPtr);
|
||||
entity->open = 0;
|
||||
if (result && *badPtr) {
|
||||
*badPtr = s;
|
||||
return result;
|
||||
}
|
||||
entity->wfInContent = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XML_TOK_START_TAG_NO_ATTS:
|
||||
if (level == context->stackSize) {
|
||||
context->startName
|
||||
= realloc((void *)context->startName, (context->stackSize *= 2) * sizeof(char *));
|
||||
if (!context->startName)
|
||||
return noMemory;
|
||||
}
|
||||
context->startName[level++] = s + enc->minBytesPerChar;
|
||||
break;
|
||||
case XML_TOK_START_TAG_WITH_ATTS:
|
||||
if (level == context->stackSize) {
|
||||
context->startName = realloc((void *)context->startName, (context->stackSize *= 2) * sizeof(char *));
|
||||
if (!context->startName)
|
||||
return noMemory;
|
||||
}
|
||||
context->startName[level++] = s + enc->minBytesPerChar;
|
||||
/* fall through */
|
||||
case XML_TOK_EMPTY_ELEMENT_WITH_ATTS:
|
||||
{
|
||||
int i;
|
||||
int n = XmlGetAttributes(enc, s, context->attsSize, context->atts);
|
||||
if (n > context->attsSize) {
|
||||
context->attsSize = 2*n;
|
||||
context->atts = realloc((void *)context->atts, context->attsSize * sizeof(ATTRIBUTE));
|
||||
if (!context->atts)
|
||||
return noMemory;
|
||||
XmlGetAttributes(enc, s, n, context->atts);
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!context->atts[i].normalized) {
|
||||
enum WfCheckResult result
|
||||
= checkAttributeValue(&context->dtd, enc,
|
||||
context->atts[i].valuePtr,
|
||||
context->atts[i].valueEnd,
|
||||
badPtr);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (i > 1) {
|
||||
enum WfCheckResult result = checkAttributeUniqueness(context, enc, n, badPtr);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XML_TOK_END_TAG:
|
||||
if (level == startLevel) {
|
||||
*badPtr = s;
|
||||
return asyncEntity;
|
||||
}
|
||||
--level;
|
||||
if (!XmlSameName(enc, context->startName[level], s + enc->minBytesPerChar * 2)) {
|
||||
*badPtr = s;
|
||||
return tagMismatch;
|
||||
}
|
||||
break;
|
||||
case XML_TOK_CHAR_REF:
|
||||
if (XmlCharRefNumber(enc, s) < 0) {
|
||||
*badPtr = s;
|
||||
return badCharRef;
|
||||
}
|
||||
break;
|
||||
case XML_TOK_XML_DECL:
|
||||
*badPtr = s;
|
||||
return misplacedXmlPi;
|
||||
}
|
||||
s = next;
|
||||
if (level == 0) {
|
||||
do {
|
||||
tok = XmlPrologTok(enc, s, end, &next);
|
||||
switch (tok) {
|
||||
case XML_TOK_TRAILING_CR:
|
||||
case XML_TOK_NONE:
|
||||
return wellFormed;
|
||||
case XML_TOK_PROLOG_S:
|
||||
case XML_TOK_COMMENT:
|
||||
case XML_TOK_PI:
|
||||
s = next;
|
||||
break;
|
||||
default:
|
||||
if (tok > 0) {
|
||||
*badPtr = s;
|
||||
return junkAfterDocElement;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (tok > 0);
|
||||
}
|
||||
else
|
||||
tok = XmlContentTok(enc, s, end, &next);
|
||||
}
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
static
|
||||
int attcmp(const void *p1, const void *p2)
|
||||
{
|
||||
const ATTRIBUTE *a1 = p1;
|
||||
const ATTRIBUTE *a2 = p2;
|
||||
size_t n1 = a1->valuePtr - a1->name;
|
||||
size_t n2 = a2->valuePtr - a2->name;
|
||||
|
||||
if (n1 == n2) {
|
||||
int n = memcmp(a1->name, a2->name, n1);
|
||||
if (n)
|
||||
return n;
|
||||
/* Sort identical attribute names by position, so that we always
|
||||
report the first duplicate attribute. */
|
||||
if (a1->name < a2->name)
|
||||
return -1;
|
||||
else if (a1->name > a2->name)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else if (n1 < n2)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Note that this trashes the attribute values. */
|
||||
|
||||
static enum WfCheckResult
|
||||
checkAttributeUniqueness(CONTEXT *context, const ENCODING *enc, int nAtts,
|
||||
const char **badPtr)
|
||||
{
|
||||
#define QSORT_MIN_ATTS 10
|
||||
if (nAtts < QSORT_MIN_ATTS) {
|
||||
int i;
|
||||
for (i = 1; i < nAtts; i++) {
|
||||
int j;
|
||||
for (j = 0; j < i; j++) {
|
||||
if (XmlSameName(enc, context->atts[i].name, context->atts[j].name)) {
|
||||
*badPtr = context->atts[i].name;
|
||||
return duplicateAttribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
const char *dup = 0;
|
||||
/* Store the end of the name in valuePtr */
|
||||
for (i = 0; i < nAtts; i++) {
|
||||
ATTRIBUTE *a = context->atts + i;
|
||||
a->valuePtr = a->name + XmlNameLength(enc, a->name);
|
||||
}
|
||||
qsort(context->atts, nAtts, sizeof(ATTRIBUTE), attcmp);
|
||||
for (i = 1; i < nAtts; i++) {
|
||||
ATTRIBUTE *a = context->atts + i;
|
||||
if (XmlSameName(enc, a->name, a[-1].name)) {
|
||||
if (!dup || a->name < dup)
|
||||
dup = a->name;
|
||||
}
|
||||
}
|
||||
if (dup) {
|
||||
*badPtr = dup;
|
||||
return duplicateAttribute;
|
||||
}
|
||||
}
|
||||
return wellFormed;
|
||||
}
|
||||
|
||||
static enum WfCheckResult
|
||||
checkProlog(DTD *dtd, const char *s, const char *end,
|
||||
const char **nextPtr, const ENCODING **enc)
|
||||
{
|
||||
const char *entityNamePtr, *entityNameEnd;
|
||||
int entityIsParam;
|
||||
PROLOG_STATE state;
|
||||
ENTITY *entity;
|
||||
INIT_ENCODING initEnc;
|
||||
XmlInitEncoding(&initEnc, enc);
|
||||
XmlPrologStateInit(&state);
|
||||
for (;;) {
|
||||
const char *next;
|
||||
int tok = XmlPrologTok(*enc, s, end, &next);
|
||||
switch (XmlTokenRole(&state, tok, s, next, *enc)) {
|
||||
case XML_ROLE_XML_DECL:
|
||||
{
|
||||
const char *encodingName = 0;
|
||||
const ENCODING *encoding = 0;
|
||||
const char *version;
|
||||
int standalone = -1;
|
||||
if (!XmlParseXmlDecl(0,
|
||||
*enc,
|
||||
s,
|
||||
next,
|
||||
nextPtr,
|
||||
&version,
|
||||
&encodingName,
|
||||
&encoding,
|
||||
&standalone))
|
||||
return syntaxError;
|
||||
if (encoding) {
|
||||
if (encoding->minBytesPerChar != (*enc)->minBytesPerChar) {
|
||||
*nextPtr = encodingName;
|
||||
return incorrectEncoding;
|
||||
}
|
||||
*enc = encoding;
|
||||
}
|
||||
else if (encodingName) {
|
||||
*nextPtr = encodingName;
|
||||
return unknownEncoding;
|
||||
}
|
||||
if (standalone == 1)
|
||||
dtd->standalone = 1;
|
||||
break;
|
||||
}
|
||||
case XML_ROLE_DOCTYPE_SYSTEM_ID:
|
||||
dtd->containsRef = 1;
|
||||
break;
|
||||
case XML_ROLE_DOCTYPE_PUBLIC_ID:
|
||||
case XML_ROLE_ENTITY_PUBLIC_ID:
|
||||
case XML_ROLE_NOTATION_PUBLIC_ID:
|
||||
if (!XmlIsPublicId(*enc, s, next, nextPtr))
|
||||
return syntaxError;
|
||||
break;
|
||||
case XML_ROLE_INSTANCE_START:
|
||||
*nextPtr = s;
|
||||
return wellFormed;
|
||||
case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
|
||||
case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
|
||||
{
|
||||
const char *tem = 0;
|
||||
enum WfCheckResult result
|
||||
= checkAttributeValue(dtd, *enc, s + (*enc)->minBytesPerChar,
|
||||
next - (*enc)->minBytesPerChar,
|
||||
&tem);
|
||||
if (result) {
|
||||
if (tem)
|
||||
*nextPtr = tem;
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XML_ROLE_ENTITY_VALUE:
|
||||
{
|
||||
enum WfCheckResult result
|
||||
= storeEntity(dtd,
|
||||
*enc,
|
||||
entityIsParam,
|
||||
entityNamePtr,
|
||||
entityNameEnd,
|
||||
s,
|
||||
next,
|
||||
nextPtr);
|
||||
if (result != wellFormed)
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
case XML_ROLE_ENTITY_SYSTEM_ID:
|
||||
{
|
||||
const char *name = poolStoreString(&dtd->pool, *enc, entityNamePtr, entityNameEnd);
|
||||
entity = (ENTITY *)lookup(entityIsParam ? &dtd->paramEntities : &dtd->generalEntities,
|
||||
name, sizeof(ENTITY));
|
||||
if (entity->name != name) {
|
||||
poolDiscard(&dtd->pool);
|
||||
entity = 0;
|
||||
}
|
||||
else {
|
||||
poolFinish(&dtd->pool);
|
||||
entity->systemId = poolStoreString(&dtd->pool, *enc,
|
||||
s + (*enc)->minBytesPerChar,
|
||||
next - (*enc)->minBytesPerChar);
|
||||
poolFinish(&dtd->pool);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XML_ROLE_PARAM_ENTITY_REF:
|
||||
{
|
||||
const char *name = poolStoreString(&dtd->pool, *enc,
|
||||
s + (*enc)->minBytesPerChar,
|
||||
next - (*enc)->minBytesPerChar);
|
||||
ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0);
|
||||
poolDiscard(&dtd->pool);
|
||||
if (!entity) {
|
||||
if (!dtd->containsRef || dtd->standalone) {
|
||||
*nextPtr = s;
|
||||
return undefinedEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XML_ROLE_ENTITY_NOTATION_NAME:
|
||||
if (entity) {
|
||||
entity->notation = poolStoreString(&dtd->pool, *enc, s, next);
|
||||
poolFinish(&dtd->pool);
|
||||
}
|
||||
break;
|
||||
case XML_ROLE_GENERAL_ENTITY_NAME:
|
||||
entityNamePtr = s;
|
||||
entityNameEnd = next;
|
||||
entityIsParam = 0;
|
||||
break;
|
||||
case XML_ROLE_PARAM_ENTITY_NAME:
|
||||
entityNamePtr = s;
|
||||
entityNameEnd = next;
|
||||
entityIsParam = 1;
|
||||
break;
|
||||
case XML_ROLE_ERROR:
|
||||
*nextPtr = s;
|
||||
switch (tok) {
|
||||
case XML_TOK_PARAM_ENTITY_REF:
|
||||
return paramEntityRef;
|
||||
case XML_TOK_INVALID:
|
||||
*nextPtr = next;
|
||||
return invalidToken;
|
||||
case XML_TOK_NONE:
|
||||
return noElements;
|
||||
case XML_TOK_PARTIAL:
|
||||
return unclosedToken;
|
||||
case XML_TOK_PARTIAL_CHAR:
|
||||
return partialChar;
|
||||
case XML_TOK_TRAILING_CR:
|
||||
*nextPtr = s + (*enc)->minBytesPerChar;
|
||||
return noElements;
|
||||
case XML_TOK_XML_DECL:
|
||||
return misplacedXmlPi;
|
||||
default:
|
||||
return syntaxError;
|
||||
}
|
||||
case XML_ROLE_GROUP_OPEN:
|
||||
if (state.level >= dtd->groupSize) {
|
||||
if (dtd->groupSize)
|
||||
dtd->groupConnector = realloc(dtd->groupConnector, dtd->groupSize *= 2);
|
||||
else
|
||||
dtd->groupConnector = malloc(dtd->groupSize = 32);
|
||||
if (!dtd->groupConnector)
|
||||
return noMemory;
|
||||
}
|
||||
dtd->groupConnector[state.level] = 0;
|
||||
break;
|
||||
case XML_ROLE_GROUP_SEQUENCE:
|
||||
if (dtd->groupConnector[state.level] == '|') {
|
||||
*nextPtr = s;
|
||||
return syntaxError;
|
||||
}
|
||||
dtd->groupConnector[state.level] = ',';
|
||||
break;
|
||||
case XML_ROLE_GROUP_CHOICE:
|
||||
if (dtd->groupConnector[state.level] == ',') {
|
||||
*nextPtr = s;
|
||||
return syntaxError;
|
||||
}
|
||||
dtd->groupConnector[state.level] = '|';
|
||||
break;
|
||||
case XML_ROLE_NONE:
|
||||
if (tok == XML_TOK_PARAM_ENTITY_REF)
|
||||
dtd->containsRef = 1;
|
||||
break;
|
||||
}
|
||||
s = next;
|
||||
}
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
static enum WfCheckResult
|
||||
checkParsedEntities(CONTEXT *context, const char **badPtr)
|
||||
{
|
||||
HASH_TABLE_ITER iter;
|
||||
hashTableIterInit(&iter, &context->dtd.generalEntities);
|
||||
for (;;) {
|
||||
ENTITY *entity = (ENTITY *)hashTableIterNext(&iter);
|
||||
if (!entity)
|
||||
break;
|
||||
if (entity->textPtr && !entity->wfInContent && !entity->magic) {
|
||||
enum WfCheckResult result;
|
||||
const ENCODING *internalEnc = XmlGetInternalEncoding(XML_UTF8_ENCODING);
|
||||
entity->open = 1;
|
||||
result = checkContent(1, context, internalEnc,
|
||||
entity->textPtr, entity->textPtr + entity->textLen,
|
||||
badPtr);
|
||||
entity->open = 0;
|
||||
if (result && *badPtr) {
|
||||
*badPtr = entity->docTextPtr;
|
||||
return result;
|
||||
}
|
||||
entity->wfInContent = 1;
|
||||
}
|
||||
}
|
||||
return wellFormed;
|
||||
}
|
||||
|
||||
static enum WfCheckResult
|
||||
checkGeneralTextEntity(CONTEXT *context,
|
||||
const char *s, const char *end,
|
||||
const char **nextPtr,
|
||||
const ENCODING **enc)
|
||||
{
|
||||
INIT_ENCODING initEnc;
|
||||
const char *next;
|
||||
int tok;
|
||||
|
||||
XmlInitEncoding(&initEnc, enc);
|
||||
tok = XmlContentTok(*enc, s, end, &next);
|
||||
|
||||
if (tok == XML_TOK_BOM) {
|
||||
s = next;
|
||||
tok = XmlContentTok(*enc, s, end, &next);
|
||||
}
|
||||
if (tok == XML_TOK_XML_DECL) {
|
||||
const char *encodingName = 0;
|
||||
const ENCODING *encoding = 0;
|
||||
const char *version;
|
||||
if (!XmlParseXmlDecl(1,
|
||||
*enc,
|
||||
s,
|
||||
next,
|
||||
nextPtr,
|
||||
&version,
|
||||
&encodingName,
|
||||
&encoding,
|
||||
0))
|
||||
return syntaxError;
|
||||
if (encoding) {
|
||||
if (encoding->minBytesPerChar != (*enc)->minBytesPerChar) {
|
||||
*nextPtr = encodingName;
|
||||
return incorrectEncoding;
|
||||
}
|
||||
*enc = encoding;
|
||||
}
|
||||
else if (encodingName) {
|
||||
*nextPtr = encodingName;
|
||||
return unknownEncoding;
|
||||
}
|
||||
s = next;
|
||||
}
|
||||
context->dtd.containsRef = 1;
|
||||
return checkContent(1, context, *enc, s, end, nextPtr);
|
||||
}
|
||||
|
||||
static enum WfCheckResult
|
||||
checkAttributeValue(DTD *dtd, const ENCODING *enc,
|
||||
const char *ptr, const char *end, const char **badPtr)
|
||||
{
|
||||
for (;;) {
|
||||
const char *next;
|
||||
int tok = XmlAttributeValueTok(enc, ptr, end, &next);
|
||||
switch (tok) {
|
||||
case XML_TOK_TRAILING_CR:
|
||||
case XML_TOK_NONE:
|
||||
return wellFormed;
|
||||
case XML_TOK_INVALID:
|
||||
*badPtr = next;
|
||||
return invalidToken;
|
||||
case XML_TOK_PARTIAL:
|
||||
*badPtr = ptr;
|
||||
return invalidToken;
|
||||
case XML_TOK_CHAR_REF:
|
||||
if (XmlCharRefNumber(enc, ptr) < 0) {
|
||||
*badPtr = ptr;
|
||||
return badCharRef;
|
||||
}
|
||||
break;
|
||||
case XML_TOK_DATA_CHARS:
|
||||
case XML_TOK_DATA_NEWLINE:
|
||||
break;
|
||||
case XML_TOK_ENTITY_REF:
|
||||
{
|
||||
const char *name = poolStoreString(&dtd->pool, enc,
|
||||
ptr + enc->minBytesPerChar,
|
||||
next - enc->minBytesPerChar);
|
||||
ENTITY *entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0);
|
||||
poolDiscard(&dtd->pool);
|
||||
if (!entity) {
|
||||
if (!dtd->containsRef) {
|
||||
*badPtr = ptr;
|
||||
return undefinedEntity;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (entity->wfInAttribute)
|
||||
break;
|
||||
if (entity->open) {
|
||||
*badPtr = ptr;
|
||||
return recursiveEntityRef;
|
||||
}
|
||||
if (entity->notation) {
|
||||
*badPtr = ptr;
|
||||
return binaryEntityRef;
|
||||
}
|
||||
if (entity) {
|
||||
if (entity->textPtr) {
|
||||
enum WfCheckResult result;
|
||||
const ENCODING *internalEnc = XmlGetInternalEncoding(XML_UTF8_ENCODING);
|
||||
const char *textEnd = entity->textPtr + entity->textLen;
|
||||
entity->open = 1;
|
||||
result = checkAttributeValue(dtd, internalEnc, entity->textPtr, textEnd, badPtr);
|
||||
entity->open = 0;
|
||||
if (result && *badPtr) {
|
||||
*badPtr = ptr;
|
||||
return result;
|
||||
}
|
||||
entity->wfInAttribute = 1;
|
||||
}
|
||||
else {
|
||||
*badPtr = ptr;
|
||||
return attributeExternalEntityRef;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
ptr = next;
|
||||
}
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
static
|
||||
void poolInit(STRING_POOL *pool)
|
||||
{
|
||||
pool->blocks = 0;
|
||||
pool->start = 0;
|
||||
pool->ptr = 0;
|
||||
pool->end = 0;
|
||||
}
|
||||
|
||||
static
|
||||
void poolDestroy(STRING_POOL *pool)
|
||||
{
|
||||
BLOCK *p = pool->blocks;
|
||||
while (p) {
|
||||
BLOCK *tem = p->next;
|
||||
free(p);
|
||||
p = tem;
|
||||
}
|
||||
pool->blocks = 0;
|
||||
pool->ptr = 0;
|
||||
pool->start = 0;
|
||||
pool->end = 0;
|
||||
}
|
||||
|
||||
static
|
||||
const char *poolAppend(STRING_POOL *pool, const ENCODING *enc,
|
||||
const char *ptr, const char *end)
|
||||
{
|
||||
for (;;) {
|
||||
XmlConvert(enc, XML_UTF8_ENCODING, &ptr, end, &(pool->ptr), pool->end);
|
||||
if (ptr == end)
|
||||
break;
|
||||
if (!poolGrow(pool))
|
||||
return 0;
|
||||
}
|
||||
return pool->start;
|
||||
}
|
||||
|
||||
static
|
||||
const char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
|
||||
const char *ptr, const char *end)
|
||||
{
|
||||
if (!poolAppend(pool, enc, ptr, end))
|
||||
return 0;
|
||||
if (pool->ptr == pool->end && !poolGrow(pool))
|
||||
return 0;
|
||||
*(pool->ptr)++ = 0;
|
||||
return pool->start;
|
||||
}
|
||||
|
||||
static
|
||||
int poolGrow(STRING_POOL *pool)
|
||||
{
|
||||
if (pool->blocks && pool->start == pool->blocks->s) {
|
||||
size_t blockSize = (pool->end - pool->start)*2;
|
||||
pool->blocks = realloc(pool->blocks, offsetof(BLOCK, s) + blockSize);
|
||||
if (!pool->blocks)
|
||||
return 0;
|
||||
pool->ptr = pool->blocks->s + (pool->ptr - pool->start);
|
||||
pool->start = pool->blocks->s;
|
||||
pool->end = pool->start + blockSize;
|
||||
}
|
||||
else {
|
||||
BLOCK *tem;
|
||||
size_t blockSize = pool->end - pool->start;
|
||||
if (blockSize < INIT_BLOCK_SIZE)
|
||||
blockSize = INIT_BLOCK_SIZE;
|
||||
else
|
||||
blockSize *= 2;
|
||||
tem = malloc(offsetof(BLOCK, s) + blockSize);
|
||||
if (!tem)
|
||||
return 0;
|
||||
tem->next = pool->blocks;
|
||||
pool->blocks = tem;
|
||||
memcpy(tem->s, pool->start, pool->ptr - pool->start);
|
||||
pool->ptr = tem->s + (pool->ptr - pool->start);
|
||||
pool->start = tem->s;
|
||||
pool->end = tem->s + blockSize;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int dtdInit(DTD *dtd)
|
||||
{
|
||||
static const char *names[] = { "lt", "amp", "gt", "quot", "apos" };
|
||||
static const char chars[] = { '<', '&', '>', '"', '\'' };
|
||||
int i;
|
||||
|
||||
poolInit(&(dtd->pool));
|
||||
hashTableInit(&(dtd->generalEntities));
|
||||
for (i = 0; i < 5; i++) {
|
||||
ENTITY *entity = (ENTITY *)lookup(&(dtd->generalEntities), names[i], sizeof(ENTITY));
|
||||
if (!entity)
|
||||
return 0;
|
||||
entity->textPtr = chars + i;
|
||||
entity->textLen = 1;
|
||||
entity->magic = 1;
|
||||
entity->wfInContent = 1;
|
||||
entity->wfInAttribute = 1;
|
||||
}
|
||||
hashTableInit(&(dtd->paramEntities));
|
||||
dtd->containsRef = 0;
|
||||
dtd->groupSize = 0;
|
||||
dtd->groupConnector = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void dtdDestroy(DTD *dtd)
|
||||
{
|
||||
poolDestroy(&(dtd->pool));
|
||||
hashTableDestroy(&(dtd->generalEntities));
|
||||
hashTableDestroy(&(dtd->paramEntities));
|
||||
free(dtd->groupConnector);
|
||||
}
|
||||
|
||||
static
|
||||
enum WfCheckResult storeEntity(DTD *dtd,
|
||||
const ENCODING *enc,
|
||||
int isParam,
|
||||
const char *entityNamePtr,
|
||||
const char *entityNameEnd,
|
||||
const char *entityTextPtr,
|
||||
const char *entityTextEnd,
|
||||
const char **badPtr)
|
||||
{
|
||||
ENTITY *entity;
|
||||
const ENCODING *utf8 = XmlGetInternalEncoding(XML_UTF8_ENCODING);
|
||||
STRING_POOL *pool = &(dtd->pool);
|
||||
if (!poolStoreString(pool, enc, entityNamePtr, entityNameEnd))
|
||||
return noMemory;
|
||||
entity = (ENTITY *)lookup(isParam ? &(dtd->paramEntities) : &(dtd->generalEntities),
|
||||
pool->start,
|
||||
sizeof(ENTITY));
|
||||
if (entity->name != pool->start) {
|
||||
poolDiscard(pool);
|
||||
entityNamePtr = 0;
|
||||
}
|
||||
else
|
||||
poolFinish(pool);
|
||||
entityTextPtr += enc->minBytesPerChar;
|
||||
entityTextEnd -= enc->minBytesPerChar;
|
||||
entity->docTextPtr = entityTextPtr;
|
||||
for (;;) {
|
||||
const char *next;
|
||||
int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next);
|
||||
switch (tok) {
|
||||
case XML_TOK_PARAM_ENTITY_REF:
|
||||
*badPtr = entityTextPtr;
|
||||
return syntaxError;
|
||||
case XML_TOK_NONE:
|
||||
if (entityNamePtr) {
|
||||
entity->textPtr = pool->start;
|
||||
entity->textLen = pool->ptr - pool->start;
|
||||
poolFinish(pool);
|
||||
}
|
||||
else
|
||||
poolDiscard(pool);
|
||||
return wellFormed;
|
||||
case XML_TOK_ENTITY_REF:
|
||||
case XML_TOK_DATA_CHARS:
|
||||
if (!poolAppend(pool, enc, entityTextPtr, next))
|
||||
return noMemory;
|
||||
break;
|
||||
case XML_TOK_TRAILING_CR:
|
||||
next = entityTextPtr + enc->minBytesPerChar;
|
||||
/* fall through */
|
||||
case XML_TOK_DATA_NEWLINE:
|
||||
if (pool->end == pool->ptr && !poolGrow(pool))
|
||||
return noMemory;
|
||||
*(pool->ptr)++ = '\n';
|
||||
break;
|
||||
case XML_TOK_CHAR_REF:
|
||||
{
|
||||
char buf[XML_MAX_BYTES_PER_CHAR];
|
||||
int i;
|
||||
int n = XmlCharRefNumber(enc, entityTextPtr);
|
||||
if (n < 0) {
|
||||
*badPtr = entityTextPtr;
|
||||
return badCharRef;
|
||||
}
|
||||
n = XmlEncode(utf8, n, buf);
|
||||
if (!n) {
|
||||
*badPtr = entityTextPtr;
|
||||
return badCharRef;
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
if (pool->end == pool->ptr && !poolGrow(pool))
|
||||
return noMemory;
|
||||
*(pool->ptr)++ = buf[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XML_TOK_PARTIAL:
|
||||
*badPtr = entityTextPtr;
|
||||
return invalidToken;
|
||||
case XML_TOK_INVALID:
|
||||
*badPtr = next;
|
||||
return invalidToken;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
entityTextPtr = next;
|
||||
}
|
||||
/* not reached */
|
||||
}
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
enum WfCheckResult {
|
||||
wellFormed,
|
||||
noMemory,
|
||||
syntaxError,
|
||||
noElements,
|
||||
invalidToken,
|
||||
unclosedToken,
|
||||
partialChar,
|
||||
tagMismatch,
|
||||
duplicateAttribute,
|
||||
junkAfterDocElement,
|
||||
paramEntityRef,
|
||||
undefinedEntity,
|
||||
recursiveEntityRef,
|
||||
asyncEntity,
|
||||
badCharRef,
|
||||
binaryEntityRef,
|
||||
attributeExternalEntityRef,
|
||||
misplacedXmlPi,
|
||||
unknownEncoding,
|
||||
incorrectEncoding
|
||||
};
|
||||
|
||||
enum EntityType {
|
||||
documentEntity,
|
||||
generalTextEntity
|
||||
};
|
||||
|
||||
enum WfCheckResult wfCheck(enum EntityType entityType,
|
||||
const char *s, size_t n,
|
||||
const char **errorPtr,
|
||||
unsigned long *errorLineNumber,
|
||||
unsigned long *errorColNumber);
|
||||
const char *wfCheckMessage(enum WfCheckResult);
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#include "wfcheck.h"
|
||||
|
||||
const char *wfCheckMessage(enum WfCheckResult result)
|
||||
{
|
||||
static const char *message[] = {
|
||||
0,
|
||||
"out of memory",
|
||||
"syntax error",
|
||||
"no element found",
|
||||
"not well-formed",
|
||||
"unclosed token",
|
||||
"unclosed token",
|
||||
"mismatched tag",
|
||||
"duplicate attribute",
|
||||
"junk after document element",
|
||||
"parameter entity reference not allowed within declaration in internal subset",
|
||||
"undefined entity",
|
||||
"recursive entity reference",
|
||||
"asynchronous entity",
|
||||
"reference to invalid character number",
|
||||
"reference to binary entity",
|
||||
"reference to external entity in attribute",
|
||||
"xml pi not at start of external entity",
|
||||
"unknown encoding",
|
||||
"encoding specified in XML declaration is incorrect"
|
||||
};
|
||||
if (result > 0 && result < sizeof(message)/sizeof(message[0]))
|
||||
return message[result];
|
||||
return 0;
|
||||
}
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#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 TCHAR *);
|
||||
|
||||
int filemap(const TCHAR *name,
|
||||
void (*processor)(const void *, size_t, const TCHAR *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
HANDLE f;
|
||||
HANDLE m;
|
||||
DWORD size;
|
||||
DWORD sizeHi;
|
||||
void *p;
|
||||
|
||||
f = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||
FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
if (f == INVALID_HANDLE_VALUE) {
|
||||
win32perror(name);
|
||||
return 0;
|
||||
}
|
||||
size = GetFileSize(f, &sizeHi);
|
||||
if (size == (DWORD)-1) {
|
||||
win32perror(name);
|
||||
return 0;
|
||||
}
|
||||
if (sizeHi) {
|
||||
_ftprintf(stderr, _T("%s: bigger than 2Gb\n"), name);
|
||||
return 0;
|
||||
}
|
||||
/* CreateFileMapping barfs on zero length files */
|
||||
if (size == 0) {
|
||||
static const char c = '\0';
|
||||
processor(&c, 0, name, arg);
|
||||
CloseHandle(f);
|
||||
return 1;
|
||||
}
|
||||
m = CreateFileMapping(f, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (m == NULL) {
|
||||
win32perror(name);
|
||||
CloseHandle(f);
|
||||
return 0;
|
||||
}
|
||||
p = MapViewOfFile(m, FILE_MAP_READ, 0, 0, 0);
|
||||
if (p == NULL) {
|
||||
win32perror(name);
|
||||
CloseHandle(m);
|
||||
CloseHandle(f);
|
||||
return 0;
|
||||
}
|
||||
processor(p, size, name, arg);
|
||||
UnmapViewOfFile(p);
|
||||
CloseHandle(m);
|
||||
CloseHandle(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
void win32perror(const TCHAR *s)
|
||||
{
|
||||
LPVOID buf;
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &buf,
|
||||
0,
|
||||
NULL)) {
|
||||
_ftprintf(stderr, _T("%s: %s"), s, buf);
|
||||
fflush(stderr);
|
||||
LocalFree(buf);
|
||||
}
|
||||
else
|
||||
_ftprintf(stderr, _T("%s: unknown Windows error\n"), s);
|
||||
}
|
||||
Executable
+217
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#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:%d: %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;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
static
|
||||
int isAsciiLetter(XML_Char c)
|
||||
{
|
||||
return (T('a') <= c && c <= T('z')) || (T('A') <= c && c <= T('Z'));
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
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
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#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
|
||||
+266
-114
@@ -1,21 +1,6 @@
|
||||
/*
|
||||
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):
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -28,14 +13,12 @@ Contributor(s):
|
||||
#include "xmlfile.h"
|
||||
#include "xmltchar.h"
|
||||
|
||||
#ifdef XML_URL
|
||||
#include "xmlurl.h"
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
/* This ensures proper sorting. */
|
||||
|
||||
#define NSSEP T('\001')
|
||||
|
||||
static void characterData(void *userData, const XML_Char *s, int len)
|
||||
@@ -52,6 +35,11 @@ static void characterData(void *userData, const XML_Char *s, int len)
|
||||
case T('>'):
|
||||
fputts(T(">"), fp);
|
||||
break;
|
||||
#ifdef W3C14N
|
||||
case 13:
|
||||
fputts(T("
"), fp);
|
||||
break;
|
||||
#else
|
||||
case T('"'):
|
||||
fputts(T("""), fp);
|
||||
break;
|
||||
@@ -60,6 +48,7 @@ static void characterData(void *userData, const XML_Char *s, int len)
|
||||
case 13:
|
||||
ftprintf(fp, T("&#%d;"), *s);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
puttc(*s, fp);
|
||||
break;
|
||||
@@ -67,6 +56,53 @@ static void characterData(void *userData, const XML_Char *s, int len)
|
||||
}
|
||||
}
|
||||
|
||||
static void attributeValue(FILE *fp, const XML_Char *s)
|
||||
{
|
||||
puttc(T('='), fp);
|
||||
puttc(T('"'), fp);
|
||||
for (;;) {
|
||||
switch (*s) {
|
||||
case 0:
|
||||
case NSSEP:
|
||||
puttc(T('"'), fp);
|
||||
return;
|
||||
case T('&'):
|
||||
fputts(T("&"), fp);
|
||||
break;
|
||||
case T('<'):
|
||||
fputts(T("<"), fp);
|
||||
break;
|
||||
case T('"'):
|
||||
fputts(T("""), fp);
|
||||
break;
|
||||
#ifdef W3C14N
|
||||
case 9:
|
||||
fputts(T("	"), fp);
|
||||
break;
|
||||
case 10:
|
||||
fputts(T("
"), fp);
|
||||
break;
|
||||
case 13:
|
||||
fputts(T("
"), fp);
|
||||
break;
|
||||
#else
|
||||
case T('>'):
|
||||
fputts(T(">"), fp);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
ftprintf(fp, T("&#%d;"), *s);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
puttc(*s, fp);
|
||||
break;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Lexicographically comparing UTF-8 encoded attribute values,
|
||||
is equivalent to lexicographically comparing based on the character number. */
|
||||
|
||||
@@ -92,10 +128,7 @@ static void startElement(void *userData, const XML_Char *name, const XML_Char **
|
||||
while (*atts) {
|
||||
puttc(T(' '), fp);
|
||||
fputts(*atts++, fp);
|
||||
puttc(T('='), fp);
|
||||
puttc(T('"'), fp);
|
||||
characterData(userData, *atts, tcslen(*atts));
|
||||
puttc(T('"'), fp);
|
||||
attributeValue(fp, *atts);
|
||||
atts++;
|
||||
}
|
||||
puttc(T('>'), fp);
|
||||
@@ -110,6 +143,17 @@ static void endElement(void *userData, const XML_Char *name)
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static int nsattcmp(const void *p1, const void *p2)
|
||||
{
|
||||
const XML_Char *att1 = *(const XML_Char **)p1;
|
||||
const XML_Char *att2 = *(const XML_Char **)p2;
|
||||
int sep1 = (tcsrchr(att1, NSSEP) != 0);
|
||||
int sep2 = (tcsrchr(att1, NSSEP) != 0);
|
||||
if (sep1 != sep2)
|
||||
return sep1 - sep2;
|
||||
return tcscmp(att1, att2);
|
||||
}
|
||||
|
||||
static void startElementNS(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
int nAtts;
|
||||
@@ -121,16 +165,15 @@ static void startElementNS(void *userData, const XML_Char *name, const XML_Char
|
||||
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
if (sep) {
|
||||
fputts(T("ns0:"), fp);
|
||||
fputts(T("n1:"), fp);
|
||||
fputts(sep + 1, fp);
|
||||
fputts(T(" xmlns:ns0=\""), fp);
|
||||
characterData(userData, name, sep - name);
|
||||
puttc(T('"'), fp);
|
||||
nsi = 1;
|
||||
fputts(T(" xmlns:n1"), fp);
|
||||
attributeValue(fp, name);
|
||||
nsi = 2;
|
||||
}
|
||||
else {
|
||||
fputts(name, fp);
|
||||
nsi = 0;
|
||||
nsi = 1;
|
||||
}
|
||||
|
||||
p = atts;
|
||||
@@ -138,24 +181,22 @@ static void startElementNS(void *userData, const XML_Char *name, const XML_Char
|
||||
++p;
|
||||
nAtts = (p - atts) >> 1;
|
||||
if (nAtts > 1)
|
||||
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp);
|
||||
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, nsattcmp);
|
||||
while (*atts) {
|
||||
name = *atts++;
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
puttc(T(' '), fp);
|
||||
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++);
|
||||
ftprintf(fp, T("n%d:"), nsi);
|
||||
fputts(sep + 1, fp);
|
||||
}
|
||||
else
|
||||
puttc(T(' '), fp);
|
||||
fputts(name, fp);
|
||||
puttc(T('='), fp);
|
||||
puttc(T('"'), fp);
|
||||
characterData(userData, *atts, tcslen(*atts));
|
||||
puttc(T('"'), fp);
|
||||
fputts(name, fp);
|
||||
attributeValue(fp, *atts);
|
||||
if (sep) {
|
||||
ftprintf(fp, T(" xmlns:n%d"), nsi++);
|
||||
attributeValue(fp, name);
|
||||
}
|
||||
atts++;
|
||||
}
|
||||
puttc(T('>'), fp);
|
||||
@@ -169,7 +210,7 @@ static void endElementNS(void *userData, const XML_Char *name)
|
||||
puttc(T('/'), fp);
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
if (sep) {
|
||||
fputts(T("ns0:"), fp);
|
||||
fputts(T("n1:"), fp);
|
||||
fputts(sep + 1, fp);
|
||||
}
|
||||
else
|
||||
@@ -177,6 +218,8 @@ static void endElementNS(void *userData, const XML_Char *name)
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
#ifndef W3C14N
|
||||
|
||||
static void processingInstruction(void *userData, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
@@ -189,6 +232,8 @@ static void processingInstruction(void *userData, const XML_Char *target, const
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
#endif /* not W3C14N */
|
||||
|
||||
static void defaultCharacterData(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
@@ -239,8 +284,9 @@ void metaLocation(XML_Parser parser)
|
||||
if (uri)
|
||||
ftprintf(XML_GetUserData(parser), T(" uri=\"%s\""), uri);
|
||||
ftprintf(XML_GetUserData(parser),
|
||||
T(" byte=\"%ld\" line=\"%d\" col=\"%d\""),
|
||||
T(" byte=\"%ld\" nbytes=\"%d\" line=\"%d\" col=\"%d\""),
|
||||
XML_GetCurrentByteIndex(parser),
|
||||
XML_GetCurrentByteCount(parser),
|
||||
XML_GetCurrentLineNumber(parser),
|
||||
XML_GetCurrentColumnNumber(parser));
|
||||
}
|
||||
@@ -261,6 +307,15 @@ static
|
||||
void metaStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
const XML_Char **specifiedAttsEnd
|
||||
= atts + XML_GetSpecifiedAttributeCount(parser);
|
||||
const XML_Char **idAttPtr;
|
||||
int idAttIndex = XML_GetIdAttributeIndex(parser);
|
||||
if (idAttIndex < 0)
|
||||
idAttPtr = 0;
|
||||
else
|
||||
idAttPtr = atts + idAttIndex;
|
||||
|
||||
ftprintf(fp, T("<starttag name=\"%s\""), name);
|
||||
metaLocation(parser);
|
||||
if (*atts) {
|
||||
@@ -268,7 +323,12 @@ void metaStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **
|
||||
do {
|
||||
ftprintf(fp, T("<attribute name=\"%s\" value=\""), atts[0]);
|
||||
characterData(fp, atts[1], tcslen(atts[1]));
|
||||
fputts(T("\"/>\n"), fp);
|
||||
if (atts >= specifiedAttsEnd)
|
||||
fputts(T("\" defaulted=\"yes\"/>\n"), fp);
|
||||
else if (atts == idAttPtr)
|
||||
fputts(T("\" id=\"yes\"/>\n"), fp);
|
||||
else
|
||||
fputts(T("\"/>\n"), fp);
|
||||
} while (*(atts += 2));
|
||||
fputts(T("</starttag>\n"), fp);
|
||||
}
|
||||
@@ -336,13 +396,31 @@ void metaCharacterData(XML_Parser parser, const XML_Char *s, int len)
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaStartDoctypeDecl(XML_Parser parser, const XML_Char *doctypeName)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<startdoctype name=\"%s\""), doctypeName);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndDoctypeDecl(XML_Parser parser)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<enddoctype"), 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)
|
||||
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);
|
||||
@@ -377,6 +455,66 @@ void metaNotationDecl(XML_Parser parser,
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void metaExternalParsedEntityDecl(XML_Parser parser,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
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);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaInternalParsedEntityDecl(XML_Parser parser,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *text,
|
||||
int textLen)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<entity name=\"%s\""), entityName);
|
||||
metaLocation(parser);
|
||||
puttc(T('>'), fp);
|
||||
characterData(fp, text, textLen);
|
||||
fputts(T("</entity/>\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)
|
||||
{
|
||||
@@ -421,76 +559,85 @@ int unknownEncoding(void *userData,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
int notStandalone(void *userData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void usage(const XML_Char *prog)
|
||||
{
|
||||
ftprintf(stderr, T("usage: %s [-n] [-r] [-w] [-x] [-d output-dir] [-e encoding] file ...\n"), prog);
|
||||
ftprintf(stderr, T("usage: %s [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] [-e encoding] file ...\n"), prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int tmain(int argc, XML_Char **argv)
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
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 XML_URL
|
||||
int url = 0;
|
||||
#endif
|
||||
int requireStandalone = 0;
|
||||
int paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
i = 1;
|
||||
while (i < argc && argv[i][0] == T('-')) {
|
||||
int j;
|
||||
if (argv[i][1] == T('-') && argv[i][2] == T('\0')) {
|
||||
i++;
|
||||
break;
|
||||
j = 0;
|
||||
while (i < argc) {
|
||||
if (j == 0) {
|
||||
if (argv[i][0] != T('-'))
|
||||
break;
|
||||
if (argv[i][1] == T('-') && argv[i][2] == T('\0')) {
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
j = 1;
|
||||
if (argv[i][j] == T('r')) {
|
||||
switch (argv[i][j]) {
|
||||
case T('r'):
|
||||
processFlags &= ~XML_MAP_FILE;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('n')) {
|
||||
useNamespaces = 1;
|
||||
outputType = 0;
|
||||
break;
|
||||
case T('s'):
|
||||
requireStandalone = 1;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('x')) {
|
||||
break;
|
||||
case T('n'):
|
||||
useNamespaces = 1;
|
||||
j++;
|
||||
break;
|
||||
case T('p'):
|
||||
paramEntityParsing = XML_PARAM_ENTITY_PARSING_ALWAYS;
|
||||
/* fall through */
|
||||
case T('x'):
|
||||
processFlags |= XML_EXTERNAL_ENTITIES;
|
||||
j++;
|
||||
}
|
||||
#ifdef XML_URL
|
||||
if (argv[i][j] == T('u')) {
|
||||
url = 1;
|
||||
j++;
|
||||
}
|
||||
#endif
|
||||
if (argv[i][j] == T('w')) {
|
||||
break;
|
||||
case T('w'):
|
||||
windowsCodePages = 1;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('m')) {
|
||||
break;
|
||||
case T('m'):
|
||||
outputType = 'm';
|
||||
useNamespaces = 0;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('c')) {
|
||||
break;
|
||||
case T('c'):
|
||||
outputType = 'c';
|
||||
useNamespaces = 0;
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('t')) {
|
||||
break;
|
||||
case T('t'):
|
||||
outputType = 't';
|
||||
j++;
|
||||
}
|
||||
if (argv[i][j] == T('d')) {
|
||||
break;
|
||||
case T('d'):
|
||||
if (argv[i][j + 1] == T('\0')) {
|
||||
if (++i == argc)
|
||||
usage(argv[0]);
|
||||
@@ -499,8 +646,9 @@ int tmain(int argc, XML_Char **argv)
|
||||
else
|
||||
outputDir = argv[i] + j + 1;
|
||||
i++;
|
||||
}
|
||||
else if (argv[i][j] == T('e')) {
|
||||
j = 0;
|
||||
break;
|
||||
case T('e'):
|
||||
if (argv[i][j + 1] == T('\0')) {
|
||||
if (++i == argc)
|
||||
usage(argv[0]);
|
||||
@@ -509,18 +657,21 @@ int tmain(int argc, XML_Char **argv)
|
||||
else
|
||||
encoding = argv[i] + j + 1;
|
||||
i++;
|
||||
}
|
||||
else if (argv[i][j] == T('\0') && j > 1)
|
||||
i++;
|
||||
else
|
||||
j = 0;
|
||||
break;
|
||||
case T('\0'):
|
||||
if (j > 1) {
|
||||
i++;
|
||||
j = 0;
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
default:
|
||||
usage(argv[0]);
|
||||
}
|
||||
}
|
||||
if (i == argc)
|
||||
usage(argv[0]);
|
||||
#ifdef XML_URL
|
||||
if (url)
|
||||
XML_URLInit();
|
||||
#endif
|
||||
for (; i < argc; i++) {
|
||||
FILE *fp = 0;
|
||||
XML_Char *outName = 0;
|
||||
@@ -530,7 +681,18 @@ int tmain(int argc, XML_Char **argv)
|
||||
parser = XML_ParserCreateNS(encoding, NSSEP);
|
||||
else
|
||||
parser = XML_ParserCreate(encoding);
|
||||
if (outputDir) {
|
||||
if (requireStandalone)
|
||||
XML_SetNotStandaloneHandler(parser, notStandalone);
|
||||
XML_SetParamEntityParsing(parser, paramEntityParsing);
|
||||
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;
|
||||
@@ -560,8 +722,12 @@ int tmain(int argc, XML_Char **argv)
|
||||
XML_SetCommentHandler(parser, metaComment);
|
||||
XML_SetCdataSectionHandler(parser, metaStartCdataSection, metaEndCdataSection);
|
||||
XML_SetCharacterDataHandler(parser, metaCharacterData);
|
||||
XML_SetDoctypeDeclHandler(parser, metaStartDoctypeDecl, metaEndDoctypeDecl);
|
||||
XML_SetUnparsedEntityDeclHandler(parser, metaUnparsedEntityDecl);
|
||||
XML_SetNotationDeclHandler(parser, metaNotationDecl);
|
||||
XML_SetExternalParsedEntityDeclHandler(parser, metaExternalParsedEntityDecl);
|
||||
XML_SetInternalParsedEntityDeclHandler(parser, metaInternalParsedEntityDecl);
|
||||
XML_SetNamespaceDeclHandler(parser, metaStartNamespaceDecl, metaEndNamespaceDecl);
|
||||
metaStartDocument(parser);
|
||||
break;
|
||||
case 'c':
|
||||
@@ -571,31 +737,21 @@ int tmain(int argc, XML_Char **argv)
|
||||
XML_SetCharacterDataHandler(parser, defaultCharacterData);
|
||||
XML_SetProcessingInstructionHandler(parser, defaultProcessingInstruction);
|
||||
break;
|
||||
case 't':
|
||||
/* This is for doing timings; this gives a more realistic estimate of
|
||||
the parsing time. */
|
||||
XML_SetElementHandler(parser, nopStartElement, nopEndElement);
|
||||
XML_SetCharacterDataHandler(parser, nopCharacterData);
|
||||
XML_SetProcessingInstructionHandler(parser, nopProcessingInstruction);
|
||||
break;
|
||||
default:
|
||||
if (useNamespaces)
|
||||
XML_SetElementHandler(parser, startElementNS, endElementNS);
|
||||
else
|
||||
XML_SetElementHandler(parser, startElement, endElement);
|
||||
XML_SetCharacterDataHandler(parser, characterData);
|
||||
#ifndef W3C14N
|
||||
XML_SetProcessingInstructionHandler(parser, processingInstruction);
|
||||
#endif /* not W3C14N */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (windowsCodePages)
|
||||
XML_SetUnknownEncodingHandler(parser, unknownEncoding, 0);
|
||||
#ifdef XML_URL
|
||||
if (url)
|
||||
result = XML_ProcessURL(parser, argv[i], 0);
|
||||
else
|
||||
#endif
|
||||
result = XML_ProcessFile(parser, argv[i], processFlags);
|
||||
result = XML_ProcessFile(parser, argv[i], processFlags);
|
||||
if (outputDir) {
|
||||
if (outputType == 'm')
|
||||
metaEndDocument(parser);
|
||||
@@ -606,9 +762,5 @@ int tmain(int argc, XML_Char **argv)
|
||||
}
|
||||
XML_ParserFree(parser);
|
||||
}
|
||||
#ifdef XML_URL
|
||||
if (url)
|
||||
XML_URLUninit();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
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