Compare commits

...
272 Commits
Author SHA1 Message Date
James Clark 9421dd11c1 Add .plg file. 2000-08-18 03:32:44 +00:00
James Clark 2c255ba0e6 Fix bug with xml prefix. 2000-07-05 10:30:04 +00:00
James Clark 013d3f60a4 Add gennmtab.plg 2000-05-27 01:47:00 +00:00
James Clark 1341e9ae25 Add XML_NS 2000-05-27 01:45:28 +00:00
James Clark a62deef4c9 Set up DTD related handlers in XML_ExternalEntityParserCreate. 2000-05-22 03:01:26 +00:00
James Clark 86646a28cb Avoid freeing a NULL pointer. 2000-05-18 11:38:56 +00:00
James Clark f3464902ca Add lib expat.zip 2000-05-12 07:02:22 +00:00
James Clark 778021047d Add xmlwf.plg 2000-05-12 07:02:03 +00:00
James Clark ddae06ab88 Change date. 2000-05-12 06:59:00 +00:00
James Clark dfd331cf71 Report parsed entity declarations 2000-05-12 05:56:27 +00:00
James Clark dcff7a87cc Removed 2000-05-10 05:17:43 +00:00
James Clark 749df96d25 Don't assume MKS toolkit. 2000-05-10 05:16:44 +00:00
James Clark d784dbf4af Update for parameter entity parsing support. 2000-05-10 03:23:43 +00:00
James Clark 45f2d35bfb Fancier Makefile. 2000-05-10 03:20:15 +00:00
James Clark 9b3852311c Fix some Win32 warnings. 2000-05-10 03:13:58 +00:00
James Clark aaa3b6e5bf Sync Mozilla defines. 2000-05-10 03:05:46 +00:00
James Clark 3b0208f5d2 Warning patch from Nisheeth. 2000-05-08 04:26:17 +00:00
James Clark 7e9f661f09 Use void for prototypes without arguments. 2000-05-03 04:07:36 +00:00
James Clark e873b03f16 Avoid doing memcpy with a null pointer. 2000-05-03 04:04:12 +00:00
James Clark 4d724a92cf Add 2000 to the copyright year. 2000-04-21 04:33:46 +00:00
James Clark 8fd4a83318 Fix screwup in changing copyright notices 2000-04-21 04:20:31 +00:00
James Clark 4e9aea4c1b New license and site 2000-04-21 03:58:42 +00:00
James Clark 3923164dc2 Support reporting of ID attributes. 2000-04-14 10:53:33 +00:00
James Clark 8011e61e57 Fix allocation bug with namespaces. 2000-04-14 09:28:21 +00:00
James Clark a27a7609f6 Merge hashtable.c and hashtable.h into xmlparse.c 2000-01-07 07:22:07 +00:00
James Clark 3ec4a069df Fix MPL URL. 1999-11-11 05:01:01 +00:00
James Clark 1b330a5078 Mention the Clark Cooper article. 1999-11-05 02:20:58 +00:00
James Clark 95e916b7a7 Avoid warning for Netscape. 1999-10-27 01:34:43 +00:00
James Clark 92e910d8be C++ version. 1999-10-13 10:50:48 +00:00
James Clark 2a9c1fbbcc Rewrite. 1999-10-13 10:50:34 +00:00
James Clark b7d821935a Change date. 1999-10-13 04:16:25 +00:00
James Clark 55ec9989e5 Don't assume ASCII execution character set 1999-10-13 03:58:17 +00:00
James Clark 3eac12050f Add some comments to storeAtts. 1999-10-11 11:29:49 +00:00
James Clark 195560985f Fix a couple of memory allocation bugs with namespace processing and XML_UNICODE. 1999-10-11 06:58:40 +00:00
James Clark 0c6d9d601b Make it parse without XML_DTD. 1999-10-11 06:03:22 +00:00
James Clark 5bff01f98f Fix bug with tokenized attribute values. 1999-09-22 03:30:35 +00:00
James Clark e2ea2c60e2 Fix comment. 1999-08-07 04:06:56 +00:00
James Clark ab5acbf509 Added start/endDoctypeDeclHandlers 1999-07-28 09:34:18 +00:00
James Clark 17c6938a36 Initialize paramEntityParsing. 1999-07-25 05:25:59 +00:00
James Clark f009a97514 Change date. 1999-07-09 12:19:25 +00:00
James Clark 132c80964e Change namespace handling to use W3C C14N algorithm.
Ifdef other differences on W3C14N.
1999-07-09 12:17:40 +00:00
James Clark 75ccce3db8 Fix bug with default handler and ignored marked section. 1999-07-09 12:03:07 +00:00
James Clark b1b875e78e Fix bug with encoding declaration in prolog. 1999-07-06 00:48:04 +00:00
James Clark 99a358f0c0 Make it compile without XML_DTD 1999-07-04 13:18:00 +00:00
James Clark 4d08f13896 Get rid of expat.mak 1999-06-26 12:34:53 +00:00
James Clark fdd1bd7fc9 Add paragraph for test version. 1999-06-26 12:29:27 +00:00
James Clark 5799228346 Fix bug with XML_UNICODE 1999-06-26 12:10:00 +00:00
James Clark 74ce84265d Mention -DXML_DTD 1999-06-26 11:45:01 +00:00
James Clark a5634c52ea Support for external DTDs completed. 1999-06-26 11:29:49 +00:00
James Clark 39cfb55c81 Tweak previous fix 1999-06-25 14:51:16 +00:00
James Clark 4a9169214b Fix bug with definition of attribute as #IMPLIED before definition with default 1999-06-25 14:47:34 +00:00
James Clark 3dc87550a7 2nd set of changes for full DTD support 1999-06-25 14:28:06 +00:00
James Clark 7488411c11 First part of changes for DTD support. 1999-06-25 10:58:20 +00:00
James Clark e157ebf618 Added some bits of code that may be useful in the future 1999-06-24 09:39:06 +00:00
James Clark 2b29d5ffe4 Add .cvsignore files. Generate nametab.h 1999-06-24 09:22:36 +00:00
James Clark 5c1ae4c2da Not used any more 1999-06-24 08:53:00 +00:00
James Clark ce57b5dc40 Removed expat.pj 1999-06-24 08:52:18 +00:00
James Clark cbfa2aaece Remove old files 1999-06-24 08:48:58 +00:00
James Clark d6eeb473c4 Get rid of remaining missing prototype warnings 1999-06-03 10:21:30 +00:00
James Clark 6695c33ded Fix Apache warnings 1999-06-02 11:20:06 +00:00
James Clark 0333ca86c4 Fix Apache warnings 1999-06-02 11:20:06 +00:00
James Clark 56d5132566 Add initialization to avoid warning 1999-06-02 11:12:21 +00:00
James Clark d311382e80 Fix some infelicities from the Apache folks 1999-06-02 10:56:11 +00:00
James Clark 51f81e81ad Add comment about open variable 1999-06-02 10:45:52 +00:00
James Clark 0f5256c936 Use XmlSizeOfUnknownEncoding(void). 1999-06-02 10:36:45 +00:00
James Clark 4e58e42cf2 +E:/home/work/expat/expat.pj 1999.05.29 16:42:57 revision 1.17 by jjc
checkpointed, new revision 1.17
+E:/home/work/expat/expat.pj 1999.05.29 16:49:42  revision 1.17 by jjc
E:/home/work/expat/MPL-1_1.html drop
+E:/home/work/expat/expat.pj 1999.05.29 16:50:26  revision 1.17 by jjc
E:/home/work/expat/expat.html new-revision 1.19 was 1.18
E:/home/work/expat/files.txt new-revision 1.11 was 1.10
1999-05-29 09:50:48 +00:00
James Clark e5f05fd608 Don't include MPL. 1999-05-29 09:50:26 +00:00
James Clark 12a0ca511f +E:/home/work/expat/expat.pj 1999.04.25 19:37:39 revision 1.16 by jjc
checkpointed, new revision 1.16
+E:/home/work/expat/expat.pj 1999.05.29 09:13:58 AST revision 1.16 by jjc
E:/home/work/expat/files.txt new-revision 1.9 was 1.8
+E:/home/work/expat/expat.pj 1999.05.29 09:14:13 AST revision 1.16 by jjc
E:/home/work/expat/MPL-1_1.html add
+E:/home/work/expat/expat.pj 1999.05.29 09:14:31 AST revision 1.16 by jjc
E:/home/work/expat/MPL-1_1.html new-type a was f
E:/home/work/expat/MPL-1_1.html new-revision 1.1 was none
+E:/home/work/expat/expat.pj 1999.05.29 09:15:44  revision 1.16 by jjc
E:/home/work/expat/MPL-1_0.html drop
+E:/home/work/expat/expat.pj 1999.05.29 09:19:21  revision 1.16 by jjc
E:/home/work/expat/gennmtab/gennmtab.c new-revision 1.3 was 1.2
E:/home/work/expat/xmlparse/hashtable.c new-revision 1.9 was 1.8
E:/home/work/expat/xmlparse/hashtable.h new-revision 1.6 was 1.5
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.85 was 1.84
E:/home/work/expat/xmlparse/xmlparse.h new-revision 1.35 was 1.34
E:/home/work/expat/xmltok/asciitab.h new-revision 1.6 was 1.5
E:/home/work/expat/xmltok/dllmain.c new-revision 1.4 was 1.3
E:/home/work/expat/xmltok/iasciitab.h new-revision 1.4 was 1.3
E:/home/work/expat/xmltok/latin1tab.h new-revision 1.3 was 1.2
E:/home/work/expat/xmltok/utf8tab.h new-revision 1.5 was 1.4
E:/home/work/expat/xmltok/xmldef.h new-revision 1.8 was 1.7
E:/home/work/expat/xmltok/xmlrole.c new-revision 1.11 was 1.10
E:/home/work/expat/xmltok/xmlrole.h new-revision 1.6 was 1.5
E:/home/work/expat/xmltok/xmltok.c new-revision 1.47 was 1.46
E:/home/work/expat/xmltok/xmltok.h new-revision 1.27 was 1.26
E:/home/work/expat/xmltok/xmltok_impl.c new-revision 1.34 was 1.33
E:/home/work/expat/xmltok/xmltok_impl.h new-revision 1.7 was 1.6
E:/home/work/expat/xmlwf/codepage.c new-revision 1.6 was 1.5
E:/home/work/expat/xmlwf/codepage.h new-revision 1.4 was 1.3
E:/home/work/expat/xmlwf/filemap.h new-revision 1.4 was 1.3
E:/home/work/expat/xmlwf/readfilemap.c new-revision 1.4 was 1.3
1999-05-29 09:42:57 +00:00
James Clark f93c2e14fd Add question about minimizing size. 1999-05-29 09:40:17 +00:00
James Clark 3a6f59e946 Add /link50compat option 1999-05-29 02:29:34 +00:00
James Clark 4956ba5d3c Change version.
Change copyright.
1999-05-29 02:23:10 +00:00
James Clark 19b7928723 Remove gplelect.html 1999-05-29 02:22:35 +00:00
James Clark 973ad606fd Change license to MPL 1.1 1999-05-29 02:19:21 +00:00
James Clark a7cd413a1e Change license to MPL 1.1 1999-05-29 02:19:21 +00:00
James Clark 7438be7870 MPL 1.1 1999-05-29 02:14:27 +00:00
James Clark d7a45119ea Change to MPL 1.1 1999-05-29 02:13:53 +00:00
James Clark a5a004adf7 +E:/home/work/expat/expat.pj 1999.03.07 17:18:52 revision 1.15 by jjc
checkpointed, new revision 1.15
+E:/home/work/expat/expat.pj 1999.03.08 08:20:37  revision 1.15 by jjc
E:/home/work/expat/Makefile new-revision 1.11 was 1.10
E:/home/work/expat/xmltok/xmltok.c new-revision 1.46 was 1.45
E:/home/work/expat/xmltok/xmltok_ns.c new-revision 1.4 was 1.3
+E:/home/work/expat/expat.pj 1999.03.20 09:35:09  revision 1.15 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.78 was 1.77
+E:/home/work/expat/expat.pj 1999.03.25 11:58:25  revision 1.15 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.79 was 1.78
+E:/home/work/expat/expat.pj 1999.03.26 10:53:05  revision 1.15 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.80 was 1.79
E:/home/work/expat/xmlparse/xmlparse.h new-revision 1.32 was 1.31
E:/home/work/expat/xmlwf/xmlwf.c new-revision 1.41 was 1.40
+E:/home/work/expat/expat.pj 1999.04.06 19:01:55  revision 1.15 by jjc
E:/home/work/expat/xmltok/xmltok.h new-revision 1.26 was 1.25
+E:/home/work/expat/expat.pj 1999.04.20 09:01:37  revision 1.15 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.81 was 1.80
+E:/home/work/expat/expat.pj 1999.04.20 09:52:43  revision 1.15 by jjc
E:/home/work/expat/xmlwf/xmlwf.c new-revision 1.42 was 1.41
+E:/home/work/expat/expat.pj 1999.04.20 09:53:57  revision 1.15 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.82 was 1.81
E:/home/work/expat/xmlparse/xmlparse.h new-revision 1.33 was 1.32
+E:/home/work/expat/expat.pj 1999.04.20 09:59:32  revision 1.15 by jjc
E:/home/work/expat/expatfaq.html new-revision 1.2 was 1.1
+E:/home/work/expat/expat.pj 1999.04.20 09:59:54  revision 1.15 by jjc
E:/home/work/expat/expat.html new-revision 1.16 was 1.15
+E:/home/work/expat/expat.pj 1999.04.25 10:18:11  revision 1.15 by jjc
E:/home/work/expat/xmlparse/hashtable.h new-revision 1.5 was 1.4
+E:/home/work/expat/expat.pj 1999.04.25 18:34:07  revision 1.15 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.83 was 1.82
1999-04-25 12:37:39 +00:00
James Clark 9e892f5642 Change date 1999-04-25 12:37:12 +00:00
James Clark 78102b202d Fix for possible bug 1999-04-25 12:12:01 +00:00
James Clark f9560ef835 Add GetCurrentByteCount() 1999-04-25 11:34:07 +00:00
James Clark 31facc7d20 Fix from Nisheeth 1999-04-25 03:18:11 +00:00
James Clark 616e521daf Document -s. 1999-04-20 02:59:54 +00:00
James Clark be92e651ff A test version may not always be available. 1999-04-20 02:59:32 +00:00
James Clark 82e73bbdb2 Add NotStandaloneHandler 1999-04-20 02:53:57 +00:00
James Clark d4db56dd39 Add -s option.
Rework option parsing.
1999-04-20 02:52:43 +00:00
James Clark 26bf97fad4 Avoid recursive macros. 1999-04-20 02:01:37 +00:00
James Clark c2095e6b66 Rename convert argument to conv to avoid problems when used
in perl extension.
1999-04-06 12:01:55 +00:00
James Clark d2c1656f5f Add XML_GetSpecifiedAttributeCount(). 1999-03-26 03:53:05 +00:00
James Clark 87d01c84d2 Set up positionPtr in XML_Parse when len is 0. 1999-03-25 04:58:25 +00:00
James Clark bfcc4836d0 Avoid C++ style comment 1999-03-20 02:35:09 +00:00
James Clark 90a5d98cdd Rename BYTE_ORDER to XML_BYTE_ORDER. 1999-03-08 01:20:37 +00:00
James Clark e52f6237f6 Rename BYTE_ORDER to XML_BYTE_ORDER. 1999-03-08 01:20:37 +00:00
James Clark 5f9225a9f9 +E:/home/work/expat/expat.pj 1999.01.09 09:09:07 revision 1.14 by jjc
checkpointed, new revision 1.14
+E:/home/work/expat/expat.pj 1999.03.06 12:23:00  revision 1.14 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.74 was 1.73
+E:/home/work/expat/expat.pj 1999.03.06 12:34:25  revision 1.14 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.75 was 1.74
+E:/home/work/expat/expat.pj 1999.03.06 12:42:52  revision 1.14 by jjc
E:/home/work/expat/xmltok/xmltok.c new-revision 1.45 was 1.44
+E:/home/work/expat/expat.pj 1999.03.07 08:11:14  revision 1.14 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.76 was 1.75
+E:/home/work/expat/expat.pj 1999.03.07 10:33:24  revision 1.14 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.77 was 1.76
E:/home/work/expat/xmlparse/xmlparse.h new-revision 1.31 was 1.30
E:/home/work/expat/xmlwf/xmlwf.c new-revision 1.39 was 1.38
+E:/home/work/expat/expat.pj 1999.03.07 15:44:14  revision 1.14 by jjc
E:/home/work/expat/xmlwf/xmlwf.c new-revision 1.40 was 1.39
+E:/home/work/expat/expat.pj 1999.03.07 17:11:59  revision 1.14 by jjc
E:/home/work/expat/expat.html new-revision 1.15 was 1.14
1999-03-07 10:18:52 +00:00
James Clark 14196603ad Change date. Add link to FAQ. 1999-03-07 10:11:59 +00:00
James Clark 7c0757fca2 Make -t work without -d 1999-03-07 08:44:14 +00:00
James Clark 9aad851790 Add namespace decl handler. Allow -m and -n together. 1999-03-07 03:33:24 +00:00
James Clark 04cd15b799 Expand element type names in end-tags correctly. 1999-03-07 01:11:14 +00:00
James Clark 694bd5eee6 Use 0xA instead of \n etc 1999-03-06 05:42:52 +00:00
James Clark e1f854bf51 Use 0xA instead of \n and so on. 1999-03-06 05:34:25 +00:00
James Clark 02b12ad251 Fix bug with resizing tag buffer 1999-03-06 05:23:00 +00:00
James Clark 46d579b2e1 +E:/home/work/expat/expat.pj 1998.12.31 09:56:11 revision 1.13 by jjc
checkpointed, new revision 1.13
+E:/home/work/expat/expat.pj 1999.01.04 08:22:28 AST revision 1.13 by jjc
E:/home/work/expat/xmlparse/xmlparse.h new-revision 1.30 was 1.29
+E:/home/work/expat/expat.pj 1999.01.09 08:50:44  revision 1.13 by jjc
E:/home/work/expat/xmltok/xmltok_impl.c new-revision 1.33 was 1.32
+E:/home/work/expat/expat.pj 1999.01.09 08:55:53  revision 1.13 by jjc
E:/home/work/expat/expat.html new-revision 1.14 was 1.13
1999-01-09 02:09:07 +00:00
James Clark 347d0b6ceb Change date. 1999-01-09 01:55:53 +00:00
James Clark 2710006ea0 Fix bug with returning wrong number of attributes. 1999-01-09 01:43:27 +00:00
James Clark 547d3c98b4 Fix comment for XML_SetEncoding.
/
1999-01-04 01:22:16 +00:00
James Clark cd75a27f88 +E:/home/work/expat/expat.pj 1998.11.22 10:53:12 revision 1.12 by jjc
checkpointed, new revision 1.12
+E:/home/work/expat/expat.pj 1998.11.24 11:42:40  revision 1.12 by jjc
E:/home/work/expat/xmltok/xmltok_impl.c new-revision 1.31 was 1.30
+E:/home/work/expat/expat.pj 1998.11.24 11:42:51  revision 1.12 by jjc
E:/home/work/expat/xmltok/xmltok.c new-revision 1.40 was 1.39
+E:/home/work/expat/expat.pj 1998.11.24 12:42:17  revision 1.12 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.64 was 1.63
E:/home/work/expat/xmlparse/xmlparse.h new-revision 1.27 was 1.26
E:/home/work/expat/xmlwf/xmlwf.c new-revision 1.35 was 1.34
+E:/home/work/expat/expat.pj 1998.11.24 13:04:53  revision 1.12 by jjc
E:/home/work/expat/xmlwf/win32filemap.c new-revision 1.5 was 1.4
+E:/home/work/expat/expat.pj 1998.11.24 14:07:37  revision 1.12 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.65 was 1.64
+E:/home/work/expat/expat.pj 1998.11.24 14:12:19  revision 1.12 by jjc
E:/home/work/expat/Makefile new-revision 1.8 was 1.7
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.66 was 1.65
E:/home/work/expat/xmlparse/xmlparse.dsp new-revision 1.3 was 1.2
E:/home/work/expat/xmltok/xmltok.c new-revision 1.41 was 1.40
E:/home/work/expat/xmltok/xmltok.dsp new-revision 1.4 was 1.3
E:/home/work/expat/xmltok/xmltok_impl.c new-revision 1.32 was 1.31
+E:/home/work/expat/expat.pj 1998.11.24 14:12:56  revision 1.12 by jjc
E:/home/work/expat/xmltok/xmltok.c new-revision 1.42 was 1.41
+E:/home/work/expat/expat.pj 1998.11.24 14:16:37  revision 1.12 by jjc
E:/home/work/expat/xmlparse/xmlparse.c new-revision 1.67 was 1.66
+E:/home/work/expat/expat.pj 1998.11.24 14:33:01  revision 1.12 by jjc
E:/home/work/expat/xmlparse/hashtable.c new-revision 1.6 was 1.5
+E:/home/work/expat/expat.pj 1998.11.24 14:36:01  revision 1.12 by jjc
E:/home/work/expat/xmlparse/hashtable.c new-revision 1.7 was 1.6
+E:/home/work/expat/expat.pj 1998.11.24 14:39:10  revision 1.12 by jjc
E:/home/work/expat/xmlparse/hashtable.c new-revision 1.8 was 1.7
1998-12-31 02:56:11 +00:00
James Clark a7b896abe0 Mention -DXML_MIN_SIZE 1998-12-31 02:52:20 +00:00
James Clark ad2d74caba Change date. 1998-12-31 02:50:47 +00:00
James Clark 08d228d266 Require an encoding declaration in a textdecl 1998-12-30 09:14:21 +00:00
James Clark e98eefc69a Report errors to stdout not stderr 1998-12-30 09:14:04 +00:00
James Clark 39603886d3 Refine auto-detection algorithm 1998-12-30 08:57:44 +00:00
James Clark cc0924046a Add a function for debugging with Visual C++ 1998-12-27 02:59:59 +00:00
James Clark 1494a6f171 1998-12-11 05:10:21 +00:00
James Clark 3a67e90581 Use win32files.txt 1998-12-11 05:09:22 +00:00
James Clark 045a818850 Move some files into win32files.txt 1998-12-11 05:09:02 +00:00
James Clark f13f1077fb Change date 1998-12-01 03:38:46 +00:00
James Clark bae91258a3 Initial revision 1998-12-01 03:35:26 +00:00
James Clark 7d44233713 *** empty log message *** 1998-12-01 03:32:20 +00:00
James Clark ffcfea14b7 Pass externalEntityRefHandlerArg appropriately 1998-11-27 04:40:07 +00:00
James Clark 2aad4e436b Add XML_SetExternalEntityRefHandlerArg 1998-11-27 04:32:09 +00:00
James Clark 7023da1906 Fix bug in XML_SetEncoding 1998-11-27 02:56:32 +00:00
James Clark 845dd4dd8b Add XML_SetEncoding 1998-11-27 02:24:11 +00:00
James Clark 13594c689a Add metaStartDocument and metaEndDocument 1998-11-25 09:26:02 +00:00
James Clark 74d8ff5b12 *** empty log message *** 1998-11-25 08:32:06 +00:00
James Clark 5bfaa295f9 Initial revision 1998-11-25 08:32:06 +00:00
James Clark 4b4d90b06b Separate file processing into xmlfile.c/h. 1998-11-25 08:31:50 +00:00
James Clark 11d8095453 Add -t option 1998-11-24 15:24:59 +00:00
James Clark 3ada492532 Remove xmldef.h 1998-11-24 09:33:16 +00:00
James Clark 1fb7b5aba9 Define WIN32_LEAN_AND_MEAN 1998-11-24 09:31:04 +00:00
James Clark 0a2a79e3fc Add MinSize config 1998-11-24 09:20:13 +00:00
James Clark d38b08addb Add definition of PR_Realloc under MOZILLA; also fix malloc to use
PR_Malloc
1998-11-24 08:44:37 +00:00
James Clark 48911f1641 Refine XML_WINLIB option 1998-11-24 08:39:10 +00:00
James Clark f2e213ee4b Provide XML_WINLIB define 1998-11-24 08:06:55 +00:00
James Clark f603b68156 Include <stdlib.h> and <string.h> via xmldef.h 1998-11-24 07:39:10 +00:00
James Clark b2eb817999 Fix bug in previous change 1998-11-24 07:36:01 +00:00
James Clark 1e657b6c6d XML_UNICODE_WCHAR_T implies XML_UNICODE
Define keyeq
1998-11-24 07:33:01 +00:00
James Clark 2967177479 Include xmlparse.h after xmldef.h 1998-11-24 07:16:37 +00:00
James Clark 9d6ef1e3c7 Rename XMLSMALL to XML_MIN_SIZE 1998-11-24 07:12:56 +00:00
James Clark ee62d4d2b1 Rename XMLNS to XML_NS 1998-11-24 07:12:19 +00:00
James Clark c7bfa55f73 Include xmlparse.h first 1998-11-24 07:07:37 +00:00
James Clark 68db987c6e Ensure XML_UNICODE is defined if XML_UNICODE_WCHAR_T is. 1998-11-24 06:04:53 +00:00
James Clark 7b4a0046ea Add CDATA section handlers 1998-11-24 05:42:17 +00:00
James Clark ee0c6abbc1 Provide an XMLSMALL compile time option 1998-11-24 04:42:51 +00:00
James Clark bf7110f695 Fix a couple of bugs when MINBPC(enc) isn't constant. 1998-11-24 04:42:40 +00:00
James Clark 237b292db2 +C:/home/work/expat/expat.pj 1998.08.14 11:10:27 revision 1.11 by jjc
checkpointed, new revision 1.11
+C:/home/work/expat/expat.pj 1998.08.23 05:40:37  revision 1.11 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.55 was 1.54
+C:/home/work/expat/expat.pj 1998.08.23 05:40:38  revision 1.11 by jjc
C:/home/work/expat/xmlparse/xmlparse.h new-revision 1.23 was 1.22
+C:/home/work/expat/expat.pj 1998.08.23 05:40:39  revision 1.11 by jjc
C:/home/work/expat/xmltok/asciitab.h new-revision 1.5 was 1.4
+C:/home/work/expat/expat.pj 1998.08.23 05:40:40  revision 1.11 by jjc
C:/home/work/expat/xmltok/iasciitab.h new-revision 1.3 was 1.2
+C:/home/work/expat/expat.pj 1998.08.23 05:40:41  revision 1.11 by jjc
C:/home/work/expat/xmltok/xmlrole.c new-revision 1.10 was 1.9
+C:/home/work/expat/expat.pj 1998.08.23 05:40:42  revision 1.11 by jjc
C:/home/work/expat/xmltok/xmltok.c new-revision 1.36 was 1.35
+C:/home/work/expat/expat.pj 1998.08.23 05:40:43  revision 1.11 by jjc
C:/home/work/expat/xmltok/xmltok.h new-revision 1.25 was 1.24
+C:/home/work/expat/expat.pj 1998.08.23 05:40:44  revision 1.11 by jjc
C:/home/work/expat/xmltok/xmltok_impl.c new-revision 1.27 was 1.26
+C:/home/work/expat/expat.pj 1998.08.23 05:40:45  revision 1.11 by jjc
C:/home/work/expat/xmltok/xmltok_impl.h new-revision 1.6 was 1.5
+C:/home/work/expat/expat.pj 1998.08.23 05:40:46  revision 1.11 by jjc
C:/home/work/expat/xmlwf/xmlwf.c new-revision 1.32 was 1.31
+C:/home/work/expat/expat.pj 1998.08.26 16:10:47  revision 1.11 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.56 was 1.55
+C:/home/work/expat/expat.pj 1998.08.26 16:10:49  revision 1.11 by jjc
C:/home/work/expat/xmlparse/xmlparse.h new-revision 1.24 was 1.23
+C:/home/work/expat/expat.pj 1998.08.26 16:10:50  revision 1.11 by jjc
C:/home/work/expat/xmlwf/xmlwf.c new-revision 1.33 was 1.32
+C:/home/work/expat/expat.pj 1998.09.24 10:40:43  revision 1.11 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.57 was 1.56
1998-11-22 03:53:12 +00:00
James Clark b395aa3afb Change version 1998-11-22 03:52:47 +00:00
James Clark 56d37f2f38 Don't treat FEFF and FFFE as BOMs if there's an external encoding
of iso-8859-1 and we're parsing an external text entity
1998-11-20 23:33:09 +00:00
James Clark c6b194cd9a Add -DXMLNS 1998-11-20 04:10:35 +00:00
James Clark 95bcf45ce3 Define XMLNS 1998-11-20 04:06:40 +00:00
James Clark 3d10abbb60 Fix bug in namespace support 1998-11-20 04:05:24 +00:00
James Clark 0ea7c9e866 Add gplelect.html 1998-11-19 05:42:25 +00:00
James Clark 9d6a61899d *** empty log message *** 1998-11-19 05:41:37 +00:00
James Clark 50b15d16b7 Allow GPL usage 1998-11-19 05:41:26 +00:00
James Clark e5deda3f60 Expand xml: prefix per PR 1998-11-18 13:46:30 +00:00
James Clark 65fc545d5e FIx bug with overwriting memory with large numbers of attributes 1998-11-18 05:40:41 +00:00
James Clark ca00d00f4d Fix bug with standalone 1998-11-17 13:05:37 +00:00
James Clark 6203e0f8ca Redo auto-detection inline with UTF-16 ID 1998-11-17 12:42:16 +00:00
James Clark fc76b09ee5 Allow MINBPC to depend on enc 1998-11-17 09:51:41 +00:00
James Clark 947cd0feac Allow MINBPC to depend on enc.
Separate out ns dependent duplicate code into xmltok_ns.c
1998-11-17 09:51:18 +00:00
James Clark 73b6649f5d Add xmltok_ns.c 1998-11-17 09:49:19 +00:00
James Clark 4b6140b0df Add xmltok/xmltok_ns.c 1998-11-17 09:48:51 +00:00
James Clark 5a9da0c257 Initial revision 1998-11-17 09:45:10 +00:00
James Clark 3f4d87b03a Fix bug with multibyte character after minus in comment 1998-10-30 07:02:08 +00:00
James Clark 9d1e96afa4 Add .dsp .dsw files 1998-10-22 05:43:03 +00:00
James Clark 950a6547e4 Initial revision 1998-10-22 05:41:14 +00:00
James Clark 41fe3243ca Duplicate revision 1998-10-22 05:40:57 +00:00
James Clark 1533718a38 Initial revision 1998-10-22 05:40:57 +00:00
James Clark a277259658 *** empty log message *** 1998-10-22 05:40:46 +00:00
James Clark 237bbb9584 Fix bug with tempPool after calling externalEntityRefHandler 1998-10-22 02:53:12 +00:00
James Clark 58f34c124c Fix bug with position of end element event for empty tags. 1998-09-29 08:08:24 +00:00
James Clark 19fa93c230 Copy defaultExpandInternalEntities when creating external entity parser 1998-09-24 04:37:23 +00:00
James Clark 4b1b0a110c Bump version 1998-09-24 04:31:20 +00:00
James Clark c332060f43 Add comment support 1998-09-24 04:12:12 +00:00
James Clark fe3c72da7a Add XML_SetDefaultHandlerExpand 1998-09-24 03:40:44 +00:00
James Clark 2b1702456d Namespace support 1998-08-26 09:10:50 +00:00
James Clark 9f52171901 Lexical support for namespaces 1998-08-22 22:40:45 +00:00
James Clark dac8f8295d +C:/home/work/expat/expat.pj 1998.06.21 16:11:40 revision 1.10 by jjc
checkpointed, new revision 1.10
+C:/home/work/expat/expat.pj 1998.06.23 09:38:35  revision 1.10 by jjc
C:/home/work/expat/xmlparse/xmlparse.h new-revision 1.22 was 1.21
+C:/home/work/expat/expat.pj 1998.06.23 11:54:38  revision 1.10 by jjc
C:/home/work/expat/xmltok/xmltok.c new-revision 1.34 was 1.33
+C:/home/work/expat/expat.pj 1998.06.26 21:57:50  revision 1.10 by jjc
C:/home/work/expat/xmltok/xmltok.c new-revision 1.35 was 1.34
+C:/home/work/expat/expat.pj 1998.06.27 09:12:47  revision 1.10 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.53 was 1.52
+C:/home/work/expat/expat.pj 1998.06.27 09:18:18  revision 1.10 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.54 was 1.53
+C:/home/work/expat/expat.pj 1998.08.14 11:09:37  revision 1.10 by jjc
C:/home/work/expat/expat.html new-revision 1.8 was 1.7
1998-08-14 04:10:26 +00:00
James Clark f5f79a12ae Update to Version 1.0 1998-08-14 04:09:37 +00:00
James Clark 6f563b2256 Avoid realloc(NULL, n) in defineAttribute 1998-06-27 02:18:17 +00:00
James Clark 34b47abda7 Avoid realloc(NULL, n) 1998-06-27 02:12:47 +00:00
James Clark 2844be94b7 Fix bug in utf8_isNmstrt2 1998-06-26 14:57:49 +00:00
James Clark 75405cf655 Get rid of some compile time warnings 1998-06-23 04:54:38 +00:00
James Clark bb130e9e28 Fix GetErrorByteIndex macro. 1998-06-23 02:38:35 +00:00
James Clark 3b69eb5b92 +C:/home/work/expat/expat.pj 1998.05.14 11:42:18 revision 1.9 by jjc
checkpointed, new revision 1.9
+C:/home/work/expat/expat.pj 1998.05.16 16:18:17  revision 1.9 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.29 was 1.28
+C:/home/work/expat/expat.pj 1998.05.23 14:27:59  revision 1.9 by jjc
C:/home/work/expat/xmltok/xmltok_impl.c new-revision 1.23 was 1.22
+C:/home/work/expat/expat.pj 1998.05.30 17:13:04  revision 1.9 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.30 was 1.29
+C:/home/work/expat/expat.pj 1998.05.30 17:13:06  revision 1.9 by jjc
C:/home/work/expat/xmltok/xmltok.c new-revision 1.25 was 1.24
+C:/home/work/expat/expat.pj 1998.05.30 17:13:07  revision 1.9 by jjc
C:/home/work/expat/xmltok/xmltok.h new-revision 1.17 was 1.16
+C:/home/work/expat/expat.pj 1998.05.30 19:47:06  revision 1.9 by jjc
C:/home/work/expat/xmltok/xmltok.c new-revision 1.26 was 1.25
+C:/home/work/expat/expat.pj 1998.05.30 19:47:07  revision 1.9 by jjc
C:/home/work/expat/xmltok/xmltok.h new-revision 1.18 was 1.17
+C:/home/work/expat/expat.pj 1998.05.31 12:32:40  revision 1.9 by jjc
C:/home/work/expat/xmlparse/hashtable.c new-revision 1.5 was 1.4
+C:/home/work/expat/expat.pj 1998.05.31 12:32:41  revision 1.9 by jjc
C:/home/work/expat/xmlparse/hashtable.h new-revision 1.4 was 1.3
+C:/home/work/expat/expat.pj 1998.05.31 12:32:42  revision 1.9 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.31 was 1.30
+C:/home/work/expat/expat.pj 1998.05.31 12:32:43  revision 1.9 by jjc
C:/home/work/expat/xmlparse/xmlparse.h new-revision 1.7 was 1.6
+C:/home/work/expat/expat.pj 1998.05.31 15:06:00  revision 1.9 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.32 was 1.31
+C:/home/work/expat/expat.pj 1998.05.31 15:06:00  revision 1.9 by jjc
C:/home/work/expat/xmltok/xmltok.c new-revision 1.27 was 1.26
+C:/home/work/expat/expat.pj 1998.05.31 15:06:01  revision 1.9 by jjc
C:/home/work/expat/xmltok/xmltok.h new-revision 1.19 was 1.18
1998-06-21 09:11:40 +00:00
James Clark 22795a8755 Give message about how to run it. 1998-06-21 08:44:14 +00:00
James Clark 7f3efb4802 Fix names of sample files 1998-06-21 08:23:52 +00:00
James Clark 9e81312f63 Initial revision 1998-06-21 08:22:49 +00:00
James Clark fecf35cf44 Add sample files 1998-06-21 08:22:39 +00:00
James Clark 89687a2bfd *** empty log message *** 1998-06-21 08:22:20 +00:00
James Clark 80b4895ce5 *** empty log message *** 1998-06-21 08:10:47 +00:00
James Clark 5700ecb60f Add XML_DefaultCurrent 1998-06-21 06:53:13 +00:00
James Clark 78d38a3fd0 Fix non-Win32 stubs 1998-06-17 11:32:18 +00:00
James Clark 2c080dd19f Avoid dependence on Unicode wchar_t in xmlparse 1998-06-17 11:19:44 +00:00
James Clark d78e5baa21 Improve comment 1998-06-17 10:45:12 +00:00
James Clark 38dc320552 Make locations right for default handler and for character data spread over multiple calls. 1998-06-17 10:18:28 +00:00
James Clark 508f4e99ee Add default handler 1998-06-17 10:04:31 +00:00
James Clark 99eba7a16d Add base address for xmlparse.dll 1998-06-03 13:23:35 +00:00
James Clark 0ee12e8045 Avoid setting eventPtr on error while parsing internal entities. 1998-06-03 13:10:13 +00:00
James Clark 9e2bdba5fb Set the base even if not processing external entities 1998-06-03 11:29:18 +00:00
James Clark 42bd1cb01c Fix typo with -m option 1998-06-03 10:55:52 +00:00
James Clark 5c3919e6bf Fix some bugs in location handling 1998-06-03 10:48:23 +00:00
James Clark 1f49d0a366 Enhance -m option 1998-06-03 10:16:20 +00:00
James Clark e2ae0f492d More comments added. 1998-06-03 09:33:36 +00:00
James Clark b720028b85 Tweak to locations in prolog 1998-06-03 09:28:55 +00:00
James Clark 03f202d614 Change GetErrorCode return type to enum XML_ErrorCode. 1998-06-03 09:24:43 +00:00
James Clark 650ce08322 Add more comments. 1998-06-03 09:23:16 +00:00
James Clark 939ec46566 -1 in unknown encoding lead byte table should use BT_MALFORM 1998-06-03 08:25:08 +00:00
James Clark 0e864d50fb Use ints rather than unsigned shorts in unknown encoding support 1998-06-03 07:52:49 +00:00
James Clark d38e459410 Provide -m option
Set base for external entities
1998-06-03 07:04:44 +00:00
James Clark 069c00e820 Make location information available for all events
Support XML_UseParserAsHandlerArg
1998-06-03 06:35:00 +00:00
James Clark 6b733b9b87 Delete stscanf definition 1998-06-02 09:06:22 +00:00
James Clark 84835ac373 Generalize unknown encoding support 1998-06-02 08:57:14 +00:00
James Clark e8ac3d8f5f Fix typos in CHECK_*_CASES args 1998-06-02 04:20:08 +00:00
James Clark 7ce4d1b852 Mention BYTE_ORDER.
Add codepage.c
1998-06-01 13:02:06 +00:00
James Clark 3e3f6bb7f2 Initial revision 1998-06-01 12:56:04 +00:00
James Clark f310fb4ab9 Ignore encoding decl with protocol specified encoding. Factor out common handling of XML/Text declaration. 1998-06-01 12:54:02 +00:00
James Clark 0fe1372234 Add codepage.c 1998-06-01 12:15:13 +00:00
James Clark 10c3740f1e Initial Revision 1998-06-01 12:12:51 +00:00
James Clark 9efc5049a8 Support for arbitrary single byte encodings 1998-06-01 12:12:35 +00:00
James Clark 3a10246912 New approach for handling predefined entities 1998-06-01 07:28:31 +00:00
James Clark 496af54711 Avoid converting data unnecessarily 1998-06-01 05:55:23 +00:00
James Clark 698686457e Add debugging support for unparsed entities 1998-06-01 04:33:10 +00:00
James Clark c83cd08a8e Report notation and unparsed entity declarations. 1998-06-01 04:30:05 +00:00
James Clark 6ff56dc9dc Add XML_ROLE_NOTATION_NO_SYSTEM_ID 1998-06-01 03:59:07 +00:00
James Clark 28bbc4f64f Ifdef for XML_UNICODE 1998-05-31 11:53:28 +00:00
James Clark 0f3e24272f Fix bug with CDATA sections in internal entity where internal encoding is different from external entity encoding. 1998-05-31 10:18:06 +00:00
James Clark 3bddd238db Fix bug with XML_UNICODE support and duplicate attributes. 1998-05-31 10:14:02 +00:00
James Clark 7eadec98df Make encoding name use XML_Char 1998-05-31 09:38:17 +00:00
James Clark 40962ad8af Make XML_ErrorString return XML_Char * 1998-05-31 08:39:35 +00:00
James Clark a2625a0572 Finish UTF16 conversion support 1998-05-31 08:06:01 +00:00
James Clark 5b77f426ee Ifdef for XML_UNICODE 1998-05-31 05:32:43 +00:00
James Clark c230dddef9 Represent UTF16 as char not UTF16_CHAR 1998-05-30 12:47:06 +00:00
James Clark 583f937102 Change handling of internal encodings in xmltok interface. 1998-05-30 10:13:07 +00:00
James Clark 05fd715a12 Require whitespace between attribute name and following attribute value 1998-05-23 07:27:59 +00:00
James Clark 06fb5cebe8 Split externalEntityInitProcessor into 2. 1998-05-16 09:18:16 +00:00
James Clark 11067a403b +C:/home/work/expat/expat.pj 1998.05.11 16:35:12 revision 1.8 by jjc
checkpointed, new revision 1.8
+C:/home/work/expat/expat.pj 1998.05.11 17:16:37  revision 1.8 by jjc
C:/home/work/expat/xmltok/xmltok.c new-revision 1.24 was 1.23
+C:/home/work/expat/expat.pj 1998.05.14 11:41:52  revision 1.8 by jjc
C:/home/work/expat/expat.html new-revision 1.6 was 1.5
1998-05-14 04:42:18 +00:00
James Clark 0505f1cd36 Update date. 1998-05-14 04:41:52 +00:00
James Clark d504c1c894 Add support for US-ASCII encoding 1998-05-11 10:16:36 +00:00
James Clark 59023a9533 +C:/home/work/expat/expat.pj 1998.05.04 16:40:35 revision 1.7 by jjc
checkpointed, new revision 1.7
+C:/home/work/expat/expat.pj 1998.05.10 17:18:14  revision 1.7 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.26 was 1.25
+C:/home/work/expat/expat.pj 1998.05.10 17:18:14  revision 1.7 by jjc
C:/home/work/expat/xmlparse/xmlparse.h new-revision 1.5 was 1.4
+C:/home/work/expat/expat.pj 1998.05.10 17:18:16  revision 1.7 by jjc
C:/home/work/expat/xmlwf/xmlwf.c new-revision 1.18 was 1.17
+C:/home/work/expat/expat.pj 1998.05.10 17:46:35  revision 1.7 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.27 was 1.26
+C:/home/work/expat/expat.pj 1998.05.10 18:26:58  revision 1.7 by jjc
C:/home/work/expat/xmlparse/xmlparse.h new-revision 1.6 was 1.5
+C:/home/work/expat/expat.pj 1998.05.11 07:59:54  revision 1.7 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.28 was 1.27
+C:/home/work/expat/expat.pj 1998.05.11 16:34:27  revision 1.7 by jjc
C:/home/work/expat/expat.html new-revision 1.5 was 1.4
1998-05-11 09:35:11 +00:00
James Clark d54b83991c Mention -x. Update version. 1998-05-11 09:34:26 +00:00
James Clark 0317338f10 When creating an external entity parser, don't set the processor if the encoding was unknown. 1998-05-11 00:59:52 +00:00
James Clark 5d0c27b76c Add some more comments on new interfaces 1998-05-10 11:26:58 +00:00
James Clark 1250e1d136 Fix dtdCopy bug 1998-05-10 10:46:34 +00:00
James Clark 4b8e8545c5 Support for parsing external entities 1998-05-10 10:18:15 +00:00
James Clark 9900422429 +C:/home/work/expat/expat.pj 1998.05.04 16:36:11 revision 1.6 by jjc
checkpointed, new revision 1.6
+C:/home/work/expat/expat.pj 1998.05.04 16:40:13  revision 1.6 by jjc
C:/home/work/expat/expat.html new-revision 1.4 was 1.3
1998-05-04 09:40:34 +00:00
James Clark 816d517598 Change date. 1998-05-04 09:40:13 +00:00
James Clark 9ca490b20e +C:/home/work/expat/expat.pj 1998.05.02 13:29:28 revision 1.5 by jjc
checkpointed, new revision 1.5
+C:/home/work/expat/expat.pj 1998.05.04 08:38:33  revision 1.5 by jjc
C:/home/work/expat/xmlparse/xmlparse.c new-revision 1.25 was 1.24
1998-05-04 09:36:11 +00:00
James Clark fc76800928 Fix bug with > INIT_ATTS_SIZE attributes 1998-05-04 01:38:32 +00:00
James Clark 4ab64ee501 +C:/home/work/expat/expat.pj 1998.03.28 10:53:06 revision 1.4 by jjc
checkpointed, new revision 1.4
+C:/home/work/expat/expat.pj 1998.03.28 10:58:38  revision 1.4 by jjc
C:/home/work/expat/Makefile new-revision 1.4 was 1.3
+C:/home/work/expat/expat.pj 1998.04.05 16:09:41 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/asciitab.h new-revision 1.4 was 1.3
+C:/home/work/expat/expat.pj 1998.04.05 16:10:09 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/dllmain.c new-revision 1.2 was 1.1
+C:/home/work/expat/expat.pj 1998.04.05 16:10:14 BST revision 1.4 by jjc
C:/home/work/expat/gennmtab/gennmtab.c new-revision 1.2 was 1.1
+C:/home/work/expat/expat.pj 1998.04.05 16:10:17 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/iasciitab.h new-revision 1.2 was 1.1
+C:/home/work/expat/expat.pj 1998.04.05 16:10:20 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/latin1tab.h new-revision 1.2 was 1.1
+C:/home/work/expat/expat.pj 1998.04.05 16:10:24 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/utf8tab.h new-revision 1.4 was 1.3
+C:/home/work/expat/expat.pj 1998.04.05 16:10:27 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/xmldef.h new-revision 1.3 was 1.2
+C:/home/work/expat/expat.pj 1998.04.05 16:10:31 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/xmlrole.c new-revision 1.8 was 1.7
+C:/home/work/expat/expat.pj 1998.04.05 16:10:36 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/xmlrole.h new-revision 1.4 was 1.3
+C:/home/work/expat/expat.pj 1998.04.05 16:10:41 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/xmltok.c new-revision 1.22 was 1.21
+C:/home/work/expat/expat.pj 1998.04.05 16:10:45 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/xmltok.h new-revision 1.14 was 1.13
+C:/home/work/expat/expat.pj 1998.04.05 16:10:50 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/xmltok_impl.c new-revision 1.19 was 1.18
+C:/home/work/expat/expat.pj 1998.04.05 16:10:54 BST revision 1.4 by jjc
C:/home/work/expat/xmltok/xmltok_impl.h new-revision 1.5 was 1.4
1998-05-02 06:29:28 +00:00
James Clark bfd4528e04 Change version date 1998-05-02 06:22:50 +00:00
James Clark 44681484a8 Deal with XML_TOK_PARTIAL_CHAR from XmlCdataSectionTok 1998-05-02 06:15:55 +00:00
James Clark d40b82ff26 Fix bug with end of buffer after ) in prolog 1998-05-02 06:03:28 +00:00
James Clark fa8b616b9c Don't handle CDATA sections as a single token 1998-05-02 05:31:15 +00:00
James Clark 7e71c8f5d5 Fix bug with entity containing ] or ]] 1998-05-02 03:14:22 +00:00
James Clark a9a9179d63 Fix bug with reallocing tag->buf. 1998-05-01 09:48:33 +00:00
James Clark 8190301827 Change parameter entity reference message so that it's not misleading in weird cases. 1998-04-26 07:10:00 +00:00
James Clark 586519240e Conditionally include unistd.h 1998-04-10 06:30:05 +00:00
James Clark 323478ff2a Fix includes 1998-04-05 19:26:55 +00:00
James Clark e479418fc6 Minor tweaks 1998-04-05 19:25:10 +00:00
James Clark 856e13baf4 1998-04-05 19:22:31 +00:00
James Clark 63416bb518 *** empty log message *** 1998-04-05 15:51:24 +00:00
James Clark c446eb4dfc Initial revision 1998-04-05 15:50:55 +00:00
James Clark d4ee1a1ee1 Add copyright notice. 1998-04-05 15:11:29 +00:00
James Clark 3795b9486f Fix for xmltok in subdir 1998-03-28 18:58:38 +00:00
James Clark 9a238f3471 Update for expat rename and xmltok subdir 1998-03-28 18:53:06 +00:00
James Clark 74a9c33687 Update for rename to expat 1998-03-28 18:52:40 +00:00
James Clark 45114e05e0 +C:/home/work/XmlTok/xmltok.pj 1998.02.10 09:07:59 revision 1.2 by jjc
checkpointed, new revision 1.2
+C:/home/work/xmltok/xmltok.pj 1998.03.08 10:39:28  revision 1.2 by jjc
C:/home/work/xmltok/xmlparse/hashtable.c new-revision 1.3 was 1.2
+C:/home/work/xmltok/xmltok.pj 1998.03.08 10:39:30  revision 1.2 by jjc
C:/home/work/xmltok/xmlparse/xmlparse.c new-revision 1.18 was 1.17
+C:/home/work/xmltok/xmltok.pj 1998.03.08 10:39:31  revision 1.2 by jjc
C:/home/work/xmltok/xmlrole.c new-revision 1.7 was 1.6
+C:/home/work/xmltok/xmltok.pj 1998.03.08 10:39:33  revision 1.2 by jjc
C:/home/work/xmltok/xmltok.c new-revision 1.19 was 1.18
+C:/home/work/xmltok/xmltok.pj 1998.03.08 10:39:56  revision 1.2 by jjc
C:/home/work/xmltok/xmldef.h add
+C:/home/work/xmltok/xmltok.pj 1998.03.08 10:39:56  revision 1.2 by jjc
C:/home/work/xmltok/xmldef.h new-type a was f
+C:/home/work/xmltok/xmltok.pj 1998.03.08 10:39:57  revision 1.2 by jjc
C:/home/work/xmltok/xmldef.h new-revision 1.1 was none
+C:/home/work/XmlTok/xmltok.pj 1998.03.09 08:26:13 BST revision 1.2 by jjc
C:/home/work/XmlTok/xmldef.h new-revision 1.2 was 1.1
+C:/home/work/xmltok/xmltok.pj 1998.03.15 19:36:15  revision 1.2 by jjc
C:/home/work/xmltok/xmltok.c new-revision 1.20 was 1.19
+C:/home/work/xmltok/xmltok.pj 1998.03.23 15:42:31  revision 1.2 by jjc
C:/home/work/xmltok/xmltok.c new-revision 1.21 was 1.20
+C:/home/work/expat/expat.pj 1998.03.28 09:57:29  revision 1.2 by jjc
C:/home/work/expat/asciitab.h drop
C:/home/work/expat/dllmain.c drop
C:/home/work/expat/iasciitab.h drop
C:/home/work/expat/latin1tab.h drop
C:/home/work/expat/utf8tab.h drop
C:/home/work/expat/xmldef.h drop
C:/home/work/expat/xmlrole.c drop
C:/home/work/expat/xmlrole.h drop
C:/home/work/expat/xmltok.c drop
C:/home/work/expat/xmltok.h drop
C:/home/work/expat/xmltok.mak drop
C:/home/work/expat/xmltok_impl.c drop
C:/home/work/expat/xmltok_impl.h drop
+C:/home/work/expat/expat.pj 1998.03.28 09:58:22  revision 1.2 by jjc
C:/home/work/expat/xmltok/asciitab.h add
1998-03-28 18:10:28 +00:00
James Clark 17ff609e03 Initial Revision 1998-03-28 18:04:56 +00:00
James Clark f9ba46fd43 Bug in Latin 1 support 1998-03-23 23:42:30 +00:00
James Clark 6509a36b3f Get rid of // comments 1998-03-15 12:36:14 +00:00
James Clark fce5a0395f Define calloc as well. 1998-03-09 01:26:05 +00:00
James Clark a7e34c37ab Initial Revision 1998-03-08 03:39:56 +00:00
James Clark 34e680d0b7 Include xmldef.h 1998-03-08 03:39:32 +00:00
60 changed files with 12541 additions and 2733 deletions
+8
View File
@@ -0,0 +1,8 @@
bin
dbgbin
Debug
expat.ncb
expat.opt
Release
expat.zip
lib
+26 -12
View File
@@ -1,32 +1,46 @@
CC=gcc
CFLAGS=-O2 -I. -Ixmlparse
# 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
OBJS=xmltok.o \
xmlrole.o \
xmlwf/xmlwf.o \
xmlparse/xmlparse.o \
xmlparse/hashtable.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$(EXE)
all: $(XMLWF)
xmlwf/xmlwf$(EXE): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS)
$(XMLWF): $(OBJS) $(LIB)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIB)
$(LIB): $(LIBOBJS)
$(AR) rc $(LIB) $(LIBOBJS)
clean:
rm -f $(OBJS) xmlwf/xmlwf$(EXE)
rm -f $(OBJS) $(LIBOBJS) $(LIB) $(XMLWF)
nametab.h: gennmtab/gennmtab$(EXE)
xmltok/nametab.h: gennmtab/gennmtab$(EXE)
rm -f $@
gennmtab/gennmtab$(EXE) >$@
gennmtab/gennmtab$(EXE): gennmtab/gennmtab.c
$(CC) $(CFLAGS) -o $@ gennmtab/gennmtab.c
xmltok.o: nametab.h
xmltok/xmltok.o: xmltok/nametab.h
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
+20
View File
@@ -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.
+5
View File
@@ -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
+74
View File
@@ -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>
{{{
}}}
###############################################################################
+80
View File
@@ -0,0 +1,80 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<TITLE>expat</TITLE>
<BODY>
<H1>expat - XML Parser Toolkit</H1>
<H3>Version 20000512</H3>
<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. 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
<SAMP>xmltok/xmltok.h</SAMP>.</P>
<P>The directory <SAMP>xmlparse</SAMP> contains an XML parser library
which is built on top of the <SAMP>xmltok</SAMP> library. The
interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>. The
directory <SAMP>sample</SAMP> contains a simple example program using
this interface; <SAMP>sample/build.bat</SAMP> is a batch file to build
the example using Visual C++.</P>
<P>The directory <SAMP>xmlwf</SAMP> contains the <SAMP>xmlwf</SAMP>
application, which uses the <SAMP>xmlparse</SAMP> library. The
arguments to <SAMP>xmlwf</SAMP> are one or more files which are each
to be checked for well-formedness. An option <SAMP>-d
<VAR>dir</VAR></SAMP> can be specified; for each well-formed input
file the corresponding <A
href="http://www.jclark.com/xml/canonxml.html">canonical XML</A> will
be written to <SAMP>dir/<VAR>f</VAR></SAMP>, where
<SAMP><VAR>f</VAR></SAMP> is the filename (without any path) of the
input file. A <CODE>-x</CODE> option will cause references to
external general entities to be processed. 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@ThaiOpenSource.com">James Clark</A>
</ADDRESS>
</BODY>
</HTML>
-1097
View File
File diff suppressed because it is too large Load Diff
-26
View File
@@ -1,26 +0,0 @@
--MKS Project--
$Revision: 1.17 $
EndOptions
$(projectdir)/Makefile a 1.3
$(projectdir)/asciitab.h a 1.3
$(projectdir)/dllmain.c a 1.1
$(projectdir)/iasciitab.h a 1.1
$(projectdir)/latin1tab.h a 1.1
$(projectdir)/utf8tab.h a 1.3
$(projectdir)/xmlrole.c a 1.6
$(projectdir)/xmlrole.h a 1.3
$(projectdir)/xmltok.c a 1.18
$(projectdir)/xmltok.h a 1.13
$(projectdir)/xmltok.mak a 1.10
$(projectdir)/xmltok_impl.c a 1.18
$(projectdir)/xmltok_impl.h a 1.4
$(projectdir)/gennmtab/gennmtab.c a 1.1
$(projectdir)/xmlec/xmlec.c a 1.6
$(projectdir)/xmlparse/hashtable.c a 1.2
$(projectdir)/xmlparse/hashtable.h a 1.2
$(projectdir)/xmlparse/xmlparse.c a 1.17
$(projectdir)/xmlparse/xmlparse.h a 1.2
$(projectdir)/xmlwf/filemap.h a 1.1
$(projectdir)/xmlwf/readfilemap.c a 1.2
$(projectdir)/xmlwf/win32filemap.c a 1.2
$(projectdir)/xmlwf/xmlwf.c a 1.15
+103
View File
@@ -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>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;</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>
+31
View File
@@ -0,0 +1,31 @@
expat.html
xmltok/ascii.h
xmltok/asciitab.h
xmltok/dllmain.c
gennmtab/gennmtab.c
xmltok/iasciitab.h
xmltok/latin1tab.h
Makefile
xmltok/nametab.h
xmltok/utf8tab.h
xmltok/xmldef.h
xmltok/xmlrole.c
xmltok/xmlrole.h
xmltok/xmltok.c
xmltok/xmltok.h
xmltok/xmltok_impl.c
xmltok/xmltok_impl.h
xmltok/xmltok_ns.c
xmlparse/xmlparse.c
xmlparse/xmlparse.h
xmlwf/codepage.c
xmlwf/codepage.h
xmlwf/filemap.h
xmlwf/readfilemap.c
xmlwf/unixfilemap.c
xmlwf/win32filemap.c
xmlwf/xmlfile.c
xmlwf/xmlfile.h
xmlwf/xmltchar.h
xmlwf/xmlwf.c
sample/elements.c
+3
View File
@@ -0,0 +1,3 @@
Debug
Release
gennmtab.plg
+5
View File
@@ -1,3 +1,8 @@
/*
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>
+101
View File
@@ -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
+7
View File
@@ -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
+4
View File
@@ -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
+46
View File
@@ -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;
}
+11
View File
@@ -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
+3
View File
@@ -0,0 +1,3 @@
Debug
Release
xmlparse.plg
-106
View File
@@ -1,106 +0,0 @@
#include "hashtable.h"
#include <stdlib.h>
#include <string.h>
#define INIT_SIZE 64
static
unsigned long hash(const char *s)
{
unsigned long h = 0;
while (*s)
h = (h << 5) + h + (unsigned char)*s++;
return h;
}
NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize)
{
size_t i;
if (table->size == 0) {
if (!createSize)
return 0;
table->v = calloc(INIT_SIZE, sizeof(NAMED *));
if (!table->v)
return 0;
table->size = INIT_SIZE;
table->usedLim = INIT_SIZE / 2;
i = hash(name) & (table->size - 1);
}
else {
unsigned long h = hash(name);
for (i = h & (table->size - 1);
table->v[i];
i == 0 ? i = table->size - 1 : --i) {
if (strcmp(name, table->v[i]->name) == 0)
return table->v[i];
}
if (!createSize)
return 0;
if (table->used == table->usedLim) {
/* check for overflow */
size_t newSize = table->size * 2;
NAMED **newV = calloc(newSize, sizeof(NAMED *));
if (!newV)
return 0;
for (i = 0; i < table->size; i++)
if (table->v[i]) {
size_t j;
for (j = hash(table->v[i]->name) & (newSize - 1);
newV[j];
j == 0 ? j = newSize - 1 : --j)
;
newV[j] = table->v[i];
}
free(table->v);
table->v = newV;
table->size = newSize;
table->usedLim = newSize/2;
for (i = h & (table->size - 1);
table->v[i];
i == 0 ? i = table->size - 1 : --i)
;
}
}
table->v[i] = calloc(1, createSize);
if (!table->v[i])
return 0;
table->v[i]->name = name;
(table->used)++;
return table->v[i];
}
void hashTableDestroy(HASH_TABLE *table)
{
size_t i;
for (i = 0; i < table->size; i++) {
NAMED *p = table->v[i];
if (p)
free(p);
}
free(table->v);
}
void hashTableInit(HASH_TABLE *p)
{
p->size = 0;
p->usedLim = 0;
p->used = 0;
p->v = 0;
}
void hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table)
{
iter->p = table->v;
iter->end = iter->p + table->size;
}
NAMED *hashTableIterNext(HASH_TABLE_ITER *iter)
{
while (iter->p != iter->end) {
NAMED *tem = *(iter->p)++;
if (tem)
return tem;
}
return 0;
}
-25
View File
@@ -1,25 +0,0 @@
#include <stddef.h>
typedef struct {
const char *name;
} NAMED;
typedef struct {
NAMED **v;
size_t size;
size_t used;
size_t usedLim;
} HASH_TABLE;
NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize);
void hashTableInit(HASH_TABLE *);
void hashTableDestroy(HASH_TABLE *);
typedef struct {
NAMED **p;
NAMED **end;
} HASH_TABLE_ITER;
void hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *);
NAMED *hashTableIterNext(HASH_TABLE_ITER *);
+2794 -459
View File
File diff suppressed because it is too large Load Diff
+3693
View File
File diff suppressed because it is too large Load Diff
+194
View File
@@ -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
+438 -22
View File
@@ -1,3 +1,8 @@
/*
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#ifndef XmlParse_INCLUDED
#define XmlParse_INCLUDED 1
@@ -11,32 +16,257 @@ extern "C" {
typedef void *XML_Parser;
/* Constructs a new parser; encoding should be the name of the charset from
the Content-Type header if the Content-Type is text/xml, or null otherwise. */
#ifdef XML_UNICODE_WCHAR_T
XML_Parser XMLPARSEAPI
XML_ParserCreate(const char *encoding);
/* XML_UNICODE_WCHAR_T will work only if sizeof(wchar_t) == 2 and wchar_t
uses Unicode. */
/* Information is UTF-16 encoded as wchar_ts */
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
#include <stddef.h>
typedef wchar_t XML_Char;
typedef wchar_t XML_LChar;
#else /* not XML_UNICODE_WCHAR_T */
#ifdef XML_UNICODE
/* Information is UTF-16 encoded as unsigned shorts */
typedef unsigned short XML_Char;
typedef char XML_LChar;
#else /* not XML_UNICODE */
/* Information is UTF-8 encoded. */
typedef char XML_Char;
typedef char XML_LChar;
/* atts is array of name/value pairs, terminated by NULL;
names and values are '\0' terminated. */
#endif /* not XML_UNICODE */
#endif /* not XML_UNICODE_WCHAR_T */
/* Constructs a new parser; encoding is the encoding specified by the external
protocol or null if there is none specified. */
XML_Parser XMLPARSEAPI
XML_ParserCreate(const XML_Char *encoding);
/* Constructs a new parser and namespace processor. Element type names
and attribute names that belong to a namespace will be expanded;
unprefixed attribute names are never expanded; unprefixed element type
names are expanded only if there is a default namespace. The expanded
name is the concatenation of the namespace URI, the namespace separator character,
and the local part of the name. If the namespace separator is '\0' then
the namespace URI and the local part will be concatenated without any
separator. When a namespace is not declared, the name and prefix will be
passed through without expansion. */
XML_Parser XMLPARSEAPI
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
/* atts is array of name/value pairs, terminated by 0;
names and values are 0 terminated. */
typedef void (*XML_StartElementHandler)(void *userData,
const char *name,
const char **atts);
const XML_Char *name,
const XML_Char **atts);
typedef void (*XML_EndElementHandler)(void *userData,
const char *name);
const XML_Char *name);
/* s is not 0 terminated. */
typedef void (*XML_CharacterDataHandler)(void *userData,
const char *s,
const XML_Char *s,
int len);
/* target and data are '\0' terminated */
/* target and data are 0 terminated */
typedef void (*XML_ProcessingInstructionHandler)(void *userData,
const char *target,
const char *data);
const XML_Char *target,
const XML_Char *data);
/* data is 0 terminated */
typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
typedef void (*XML_StartCdataSectionHandler)(void *userData);
typedef void (*XML_EndCdataSectionHandler)(void *userData);
/* This is called for any characters in the XML document for
which there is no applicable handler. This includes both
characters that are part of markup which is of a kind that is
not reported (comments, markup declarations), or characters
that are part of a construct which could be reported but
for which no handler has been supplied. The characters are passed
exactly as they were in the XML document except that
they will be encoded in UTF-8. Line boundaries are not normalized.
Note that a byte order mark character is not passed to the default handler.
There are no guarantees about how characters are divided between calls
to the default handler: for example, a comment might be split between
multiple calls. */
typedef void (*XML_DefaultHandler)(void *userData,
const XML_Char *s,
int len);
/* This is called for 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.
The other arguments may be. */
typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
const XML_Char *entityName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId,
const XML_Char *notationName);
/* This is called for a declaration of notation.
The base argument is whatever was set by XML_SetBase.
The notationName will never be null. The other arguments can be. */
typedef void (*XML_NotationDeclHandler)(void *userData,
const XML_Char *notationName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId);
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
XML_ExternalEntityParserCreate.
The parser argument is the parser parsing the entity containing the reference;
it can be passed as the parser argument to XML_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 XML_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
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.
In this case the calling parser will return an XML_ERROR_EXTERNAL_ENTITY_HANDLING
error.
Note that unlike other handlers the first argument is the parser, not userData. */
typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
const XML_Char *context,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId);
/* This structure is filled in by the XML_UnknownEncodingHandler
to provide information to the parser about encodings that are unknown
to the parser.
The map[b] member gives information about byte sequences
whose first byte is b.
If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar value c.
If map[b] is -1, then the byte sequence is malformed.
If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
sequence that encodes a single Unicode scalar value.
The data member will be passed as the first argument to the convert function.
The convert function is used to convert multibyte sequences;
s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
The convert function must return the Unicode scalar value
represented by this byte sequence or -1 if the byte sequence is malformed.
The convert function may be null if the encoding is a single-byte encoding,
that is if map[b] >= -1 for all bytes b.
When the parser is finished with the encoding, then if release is not null,
it will call release passing it the data member;
once release has been called, the convert function will not be called again.
Expat places certain restrictions on the encodings that are supported
using this mechanism.
1. Every ASCII character that can appear in a well-formed XML document,
other than the characters
$@\^`{}~
must be represented by a single byte, and that byte must be the
same byte that represents that character in ASCII.
2. No character may require more than 4 bytes to encode.
3. All characters encoded must have Unicode scalar values <= 0xFFFF,
(ie characters that would be encoded by surrogates in UTF-16
are not allowed). Note that this restriction doesn't apply to
the built-in support for UTF-8 and UTF-16.
4. No Unicode character may be encoded by more than one distinct sequence
of bytes. */
typedef struct {
int map[256];
void *data;
int (*convert)(void *data, const char *s);
void (*release)(void *data);
} XML_Encoding;
/* This is called for an encoding that is unknown to the parser.
The encodingHandlerData argument is that which was passed as the
second argument to XML_SetUnknownEncodingHandler.
The name argument gives the name of the encoding as specified in
the encoding declaration.
If the callback can provide information about the encoding,
it must fill in the XML_Encoding structure, and return 1.
Otherwise it must return 0.
If info does not describe a suitable encoding,
then the parser will return an XML_UNKNOWN_ENCODING error. */
typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
const XML_Char *name,
XML_Encoding *info);
void XMLPARSEAPI
XML_SetElementHandler(XML_Parser parser,
@@ -50,11 +280,127 @@ 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);
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,
void *encodingHandlerData);
/* This can be called within a handler for a start element, end element,
processing instruction or character data. It causes the corresponding
markup to be passed to the default handler. */
void XMLPARSEAPI XML_DefaultCurrent(XML_Parser parser);
/* This value is passed as the userData argument to callbacks. */
void XMLPARSEAPI
XML_SetUserData(XML_Parser parser, void *userData);
/* Returns the last value set by XML_SetUserData or null. */
#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. */
void XMLPARSEAPI
XML_UseParserAsHandlerArg(XML_Parser parser);
/* Sets the base to be used for resolving relative URIs in system identifiers in
declarations. Resolving relative identifiers is left to the application:
this value will be passed through as the base argument to the
XML_ExternalEntityRefHandler, XML_NotationDeclHandler
and XML_UnparsedEntityDeclHandler. The base argument will be copied.
Returns zero if out of memory, non-zero otherwise. */
int XMLPARSEAPI
XML_SetBase(XML_Parser parser, const 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). */
@@ -67,8 +413,52 @@ XML_GetBuffer(XML_Parser parser, int len);
int XMLPARSEAPI
XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
/* If XML_Parser or XML_ParseEnd have returned 0, then XML_GetError*
returns information about the error. */
/* 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. */
XML_Parser XMLPARSEAPI
XML_ExternalEntityParserCreate(XML_Parser parser,
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,
@@ -90,19 +480,45 @@ enum XML_Error {
XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
XML_ERROR_MISPLACED_XML_PI,
XML_ERROR_UNKNOWN_ENCODING,
XML_ERROR_INCORRECT_ENCODING
XML_ERROR_INCORRECT_ENCODING,
XML_ERROR_UNCLOSED_CDATA_SECTION,
XML_ERROR_EXTERNAL_ENTITY_HANDLING,
XML_ERROR_NOT_STANDALONE
};
int XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
int XMLPARSEAPI XML_GetErrorLineNumber(XML_Parser parser);
int XMLPARSEAPI XML_GetErrorColumnNumber(XML_Parser parser);
long XMLPARSEAPI XML_GetErrorByteIndex(XML_Parser parser);
/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
returns information about the error. */
enum XML_Error XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
/* These functions return information about the current parse location.
They may be called when XML_Parse or XML_ParseBuffer return 0;
in this case the location is the location of the character at which
the error was detected.
They may also be called from any other callback called to report
some parse event; in this the location is the location of the first
of the sequence of characters that generated the event. */
int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser);
int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser);
long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser);
/* 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
#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
/* Frees memory used by the parser. */
void XMLPARSEAPI
XML_ParserFree(XML_Parser parser);
const char XMLPARSEAPI *
XML_ErrorString(int code);
/* Returns a string describing the error. */
const XML_LChar XMLPARSEAPI *XML_ErrorString(int code);
#ifdef __cplusplus
}
+458
View File
@@ -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 */
+3
View File
@@ -0,0 +1,3 @@
nametab.h
Release
Debug
+86
View File
@@ -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
+6 -1
View File
@@ -1,3 +1,8 @@
/*
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,
@@ -12,7 +17,7 @@
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_NMSTRT, BT_SEMI,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+8
View File
@@ -1,3 +1,11 @@
/*
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)
+6 -1
View File
@@ -1,3 +1,8 @@
/*
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,
@@ -13,7 +18,7 @@
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_NMSTRT, BT_SEMI,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+5
View File
@@ -1,3 +1,8 @@
/*
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,
-152
View File
@@ -1,152 +0,0 @@
static const unsigned namingBitmap[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
0x00000000, 0x04200400, 0xFF7FFFFF, 0xFF7FFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFC3FFFFF,
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
0xFFFFFFFF, 0xF9FF01FF, 0x00000003, 0x0000001F,
0x00000000, 0x00000000, 0x00000000, 0x04000000,
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
0x000000FF, 0x00000000, 0xFFFF0000, 0x000707FF,
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
0xFEF02596, 0x200D6CAE, 0x3000001F, 0x00000000,
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0x83FFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFF07, 0xFFFFFFFF, 0x03FFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
0x00000000, 0x00000000, 0x00000000, 0x80000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x3F2FFC84, 0x01FBFD50, 0x00000000, 0xFFFFFFFF,
0x00000007, 0x00000000, 0x00000000, 0x00000000,
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
0xFFFFFFE0, 0xFFFE1FFF, 0xFFFFFFFF, 0xFFFFFFFF,
0x00007FFF, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
0x00000000, 0x04A00400, 0xFF7FFFFF, 0xFF7FFFFF,
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
0xFFFFFFFF, 0xF9FF01FF, 0x00030003, 0x0000001F,
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x04000003,
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
0xFFFE00FF, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
0xFEF02596, 0x3BFF6CAE, 0x33FF3F5F, 0x00000000,
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
0x0000F000, 0x00007C00, 0x00000000, 0x8000FC00,
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
0x7E1FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
};
static const unsigned char nmstrtPages[] = {
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
0x14, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x16, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x19,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char namePages[] = {
0x1A, 0x03, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x00,
0x00, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
0x27, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x28, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x19,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
+5
View File
@@ -1,3 +1,8 @@
/*
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,
-2
View File
@@ -1,2 +0,0 @@
#define UNICODE 1
#include "xmltok.c"
+52
View File
@@ -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 */
+280 -89
View File
@@ -1,4 +1,11 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#include "xmldef.h"
#include "xmlrole.h"
#include "ascii.h"
/* Doesn't check:
@@ -7,11 +14,44 @@
*/
static const char KW_ANY[] = { ASCII_A, ASCII_N, ASCII_Y, '\0' };
static const char KW_ATTLIST[] = { ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' };
static const char KW_CDATA[] = { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
static const char KW_DOCTYPE[] = { ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' };
static const char KW_ELEMENT[] = { ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' };
static const char KW_EMPTY[] = { ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' };
static const char KW_ENTITIES[] = { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' };
static const char KW_ENTITY[] = { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' };
static const char KW_FIXED[] = { ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' };
static const char KW_ID[] = { ASCII_I, ASCII_D, '\0' };
static const char KW_IDREF[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
static const char KW_IDREFS[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
static const char KW_IGNORE[] = { ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' };
static const char KW_IMPLIED[] = { ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' };
static const char KW_INCLUDE[] = { ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' };
static const char KW_NDATA[] = { ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
static const char KW_NMTOKEN[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
static const char KW_NMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' };
static const char KW_NOTATION[] = { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, '\0' };
static const char KW_PCDATA[] = { ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
static const char KW_PUBLIC[] = { ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' };
static const char KW_REQUIRED[] = { ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D, '\0' };
static const char KW_SYSTEM[] = { ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' };
#ifndef MIN_BYTES_PER_CHAR
#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
#endif
typedef int PROLOG_HANDLER(struct prolog_state *state,
#ifdef XML_DTD
#define setTopLevel(state) \
((state)->handler = ((state)->documentEntity \
? internalSubset \
: externalSubset1))
#else /* not XML_DTD */
#define setTopLevel(state) ((state)->handler = internalSubset)
#endif /* not XML_DTD */
typedef int PROLOG_HANDLER(PROLOG_STATE *state,
int tok,
const char *ptr,
const char *end,
@@ -28,11 +68,15 @@ static PROLOG_HANDLER
attlist7, attlist8, attlist9,
element0, element1, element2, element3, element4, element5, element6,
element7,
#ifdef XML_DTD
externalSubset0, externalSubset1,
condSect0, condSect1, condSect2,
#endif /* XML_DTD */
declClose,
error;
static
int syntaxError(PROLOG_STATE *);
int common(PROLOG_STATE *state, int tok);
static
int prolog0(PROLOG_STATE *state,
@@ -58,7 +102,8 @@ int prolog0(PROLOG_STATE *state,
case XML_TOK_DECL_OPEN:
if (!XmlNameMatchesAscii(enc,
ptr + 2 * MIN_BYTES_PER_CHAR(enc),
"DOCTYPE"))
end,
KW_DOCTYPE))
break;
state->handler = doctype0;
return XML_ROLE_NONE;
@@ -66,7 +111,7 @@ int prolog0(PROLOG_STATE *state,
state->handler = error;
return XML_ROLE_INSTANCE_START;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -86,7 +131,8 @@ int prolog1(PROLOG_STATE *state,
case XML_TOK_DECL_OPEN:
if (!XmlNameMatchesAscii(enc,
ptr + 2 * MIN_BYTES_PER_CHAR(enc),
"DOCTYPE"))
end,
KW_DOCTYPE))
break;
state->handler = doctype0;
return XML_ROLE_NONE;
@@ -94,7 +140,7 @@ int prolog1(PROLOG_STATE *state,
state->handler = error;
return XML_ROLE_INSTANCE_START;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -114,7 +160,7 @@ int prolog2(PROLOG_STATE *state,
state->handler = error;
return XML_ROLE_INSTANCE_START;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -128,10 +174,11 @@ int doctype0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = doctype1;
return XML_ROLE_DOCTYPE_NAME;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -151,17 +198,17 @@ int doctype1(PROLOG_STATE *state,
state->handler = prolog2;
return XML_ROLE_DOCTYPE_CLOSE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
state->handler = doctype3;
return XML_ROLE_NONE;
}
if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
state->handler = doctype2;
return XML_ROLE_NONE;
}
break;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -178,7 +225,7 @@ int doctype2(PROLOG_STATE *state,
state->handler = doctype3;
return XML_ROLE_DOCTYPE_PUBLIC_ID;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -195,7 +242,7 @@ int doctype3(PROLOG_STATE *state,
state->handler = doctype4;
return XML_ROLE_DOCTYPE_SYSTEM_ID;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -215,7 +262,7 @@ int doctype4(PROLOG_STATE *state,
state->handler = prolog2;
return XML_ROLE_DOCTYPE_CLOSE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -232,7 +279,7 @@ int doctype5(PROLOG_STATE *state,
state->handler = prolog2;
return XML_ROLE_DOCTYPE_CLOSE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -248,25 +295,29 @@ int internalSubset(PROLOG_STATE *state,
case XML_TOK_DECL_OPEN:
if (XmlNameMatchesAscii(enc,
ptr + 2 * MIN_BYTES_PER_CHAR(enc),
"ENTITY")) {
end,
KW_ENTITY)) {
state->handler = entity0;
return XML_ROLE_NONE;
}
if (XmlNameMatchesAscii(enc,
ptr + 2 * MIN_BYTES_PER_CHAR(enc),
"ATTLIST")) {
end,
KW_ATTLIST)) {
state->handler = attlist0;
return XML_ROLE_NONE;
}
if (XmlNameMatchesAscii(enc,
ptr + 2 * MIN_BYTES_PER_CHAR(enc),
"ELEMENT")) {
end,
KW_ELEMENT)) {
state->handler = element0;
return XML_ROLE_NONE;
}
if (XmlNameMatchesAscii(enc,
ptr + 2 * MIN_BYTES_PER_CHAR(enc),
"NOTATION")) {
end,
KW_NOTATION)) {
state->handler = notation0;
return XML_ROLE_NONE;
}
@@ -280,9 +331,56 @@ int internalSubset(PROLOG_STATE *state,
state->handler = doctype5;
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
#ifdef XML_DTD
static
int externalSubset0(PROLOG_STATE *state,
int tok,
const char *ptr,
const char *end,
const ENCODING *enc)
{
state->handler = externalSubset1;
if (tok == XML_TOK_XML_DECL)
return XML_ROLE_TEXT_DECL;
return externalSubset1(state, tok, ptr, end, enc);
}
static
int externalSubset1(PROLOG_STATE *state,
int tok,
const char *ptr,
const char *end,
const ENCODING *enc)
{
switch (tok) {
case XML_TOK_COND_SECT_OPEN:
state->handler = condSect0;
return XML_ROLE_NONE;
case XML_TOK_COND_SECT_CLOSE:
if (state->includeLevel == 0)
break;
state->includeLevel -= 1;
return XML_ROLE_NONE;
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_CLOSE_BRACKET:
break;
case XML_TOK_NONE:
if (state->includeLevel)
break;
return XML_ROLE_NONE;
default:
return internalSubset(state, tok, ptr, end, enc);
}
return common(state, tok);
}
#endif /* XML_DTD */
static
int entity0(PROLOG_STATE *state,
int tok,
@@ -300,7 +398,7 @@ int entity0(PROLOG_STATE *state,
state->handler = entity2;
return XML_ROLE_GENERAL_ENTITY_NAME;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -317,7 +415,7 @@ int entity1(PROLOG_STATE *state,
state->handler = entity7;
return XML_ROLE_PARAM_ENTITY_NAME;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -331,11 +429,11 @@ int entity2(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
state->handler = entity4;
return XML_ROLE_NONE;
}
if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
state->handler = entity3;
return XML_ROLE_NONE;
}
@@ -344,7 +442,7 @@ int entity2(PROLOG_STATE *state,
state->handler = declClose;
return XML_ROLE_ENTITY_VALUE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -361,7 +459,7 @@ int entity3(PROLOG_STATE *state,
state->handler = entity4;
return XML_ROLE_ENTITY_PUBLIC_ID;
}
return syntaxError(state);
return common(state, tok);
}
@@ -379,7 +477,7 @@ int entity4(PROLOG_STATE *state,
state->handler = entity5;
return XML_ROLE_ENTITY_SYSTEM_ID;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -393,16 +491,16 @@ int entity5(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_DECL_CLOSE:
state->handler = internalSubset;
return XML_ROLE_NONE;
setTopLevel(state);
return XML_ROLE_EXTERNAL_GENERAL_ENTITY_NO_NOTATION;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "NDATA")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) {
state->handler = entity6;
return XML_ROLE_NONE;
}
break;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -419,7 +517,7 @@ int entity6(PROLOG_STATE *state,
state->handler = declClose;
return XML_ROLE_ENTITY_NOTATION_NAME;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -433,11 +531,11 @@ int entity7(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
state->handler = entity9;
return XML_ROLE_NONE;
}
if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
state->handler = entity8;
return XML_ROLE_NONE;
}
@@ -446,7 +544,7 @@ int entity7(PROLOG_STATE *state,
state->handler = declClose;
return XML_ROLE_ENTITY_VALUE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -463,7 +561,7 @@ int entity8(PROLOG_STATE *state,
state->handler = entity9;
return XML_ROLE_ENTITY_PUBLIC_ID;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -480,7 +578,7 @@ int entity9(PROLOG_STATE *state,
state->handler = declClose;
return XML_ROLE_ENTITY_SYSTEM_ID;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -497,7 +595,7 @@ int notation0(PROLOG_STATE *state,
state->handler = notation1;
return XML_ROLE_NOTATION_NAME;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -511,17 +609,17 @@ int notation1(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
state->handler = notation3;
return XML_ROLE_NONE;
}
if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
state->handler = notation2;
return XML_ROLE_NONE;
}
break;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -538,7 +636,7 @@ int notation2(PROLOG_STATE *state,
state->handler = notation4;
return XML_ROLE_NOTATION_PUBLIC_ID;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -555,7 +653,7 @@ int notation3(PROLOG_STATE *state,
state->handler = declClose;
return XML_ROLE_NOTATION_SYSTEM_ID;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -572,10 +670,10 @@ int notation4(PROLOG_STATE *state,
state->handler = declClose;
return XML_ROLE_NOTATION_SYSTEM_ID;
case XML_TOK_DECL_CLOSE:
state->handler = internalSubset;
return XML_ROLE_NONE;
setTopLevel(state);
return XML_ROLE_NOTATION_NO_SYSTEM_ID;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -589,10 +687,11 @@ int attlist0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist1;
return XML_ROLE_ATTLIST_ELEMENT_NAME;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -606,13 +705,14 @@ int attlist1(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_DECL_CLOSE:
state->handler = internalSubset;
setTopLevel(state);
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist2;
return XML_ROLE_ATTRIBUTE_NAME;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -628,23 +728,23 @@ int attlist2(PROLOG_STATE *state,
case XML_TOK_NAME:
{
static const char *types[] = {
"CDATA",
"ID",
"IDREF",
"IDREFS",
"ENTITY",
"ENTITIES",
"NMTOKEN",
"NMTOKENS",
KW_CDATA,
KW_ID,
KW_IDREF,
KW_IDREFS,
KW_ENTITY,
KW_ENTITIES,
KW_NMTOKEN,
KW_NMTOKENS,
};
int i;
for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++)
if (XmlNameMatchesAscii(enc, ptr, types[i])) {
if (XmlNameMatchesAscii(enc, ptr, end, types[i])) {
state->handler = attlist8;
return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
}
}
if (XmlNameMatchesAscii(enc, ptr, "NOTATION")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) {
state->handler = attlist5;
return XML_ROLE_NONE;
}
@@ -653,7 +753,7 @@ int attlist2(PROLOG_STATE *state,
state->handler = attlist3;
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -668,10 +768,11 @@ int attlist3(PROLOG_STATE *state,
return XML_ROLE_NONE;
case XML_TOK_NMTOKEN:
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist4;
return XML_ROLE_ATTRIBUTE_ENUM_VALUE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -691,7 +792,7 @@ int attlist4(PROLOG_STATE *state,
state->handler = attlist3;
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -708,7 +809,7 @@ int attlist5(PROLOG_STATE *state,
state->handler = attlist6;
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
@@ -726,7 +827,7 @@ int attlist6(PROLOG_STATE *state,
state->handler = attlist7;
return XML_ROLE_ATTRIBUTE_NOTATION_VALUE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -746,7 +847,7 @@ int attlist7(PROLOG_STATE *state,
state->handler = attlist6;
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
/* default value */
@@ -763,19 +864,22 @@ int attlist8(PROLOG_STATE *state,
case XML_TOK_POUND_NAME:
if (XmlNameMatchesAscii(enc,
ptr + MIN_BYTES_PER_CHAR(enc),
"IMPLIED")) {
end,
KW_IMPLIED)) {
state->handler = attlist1;
return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE;
}
if (XmlNameMatchesAscii(enc,
ptr + MIN_BYTES_PER_CHAR(enc),
"REQUIRED")) {
end,
KW_REQUIRED)) {
state->handler = attlist1;
return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE;
}
if (XmlNameMatchesAscii(enc,
ptr + MIN_BYTES_PER_CHAR(enc),
"FIXED")) {
end,
KW_FIXED)) {
state->handler = attlist9;
return XML_ROLE_NONE;
}
@@ -784,7 +888,7 @@ int attlist8(PROLOG_STATE *state,
state->handler = attlist1;
return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -801,7 +905,7 @@ int attlist9(PROLOG_STATE *state,
state->handler = attlist1;
return XML_ROLE_FIXED_ATTRIBUTE_VALUE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -815,10 +919,11 @@ int element0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element1;
return XML_ROLE_ELEMENT_NAME;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -832,11 +937,11 @@ int element1(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "EMPTY")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) {
state->handler = declClose;
return XML_ROLE_CONTENT_EMPTY;
}
if (XmlNameMatchesAscii(enc, ptr, "ANY")) {
if (XmlNameMatchesAscii(enc, ptr, end, KW_ANY)) {
state->handler = declClose;
return XML_ROLE_CONTENT_ANY;
}
@@ -846,7 +951,7 @@ int element1(PROLOG_STATE *state,
state->level = 1;
return XML_ROLE_GROUP_OPEN;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -862,7 +967,8 @@ int element2(PROLOG_STATE *state,
case XML_TOK_POUND_NAME:
if (XmlNameMatchesAscii(enc,
ptr + MIN_BYTES_PER_CHAR(enc),
"PCDATA")) {
end,
KW_PCDATA)) {
state->handler = element3;
return XML_ROLE_CONTENT_PCDATA;
}
@@ -872,6 +978,7 @@ int element2(PROLOG_STATE *state,
state->handler = element6;
return XML_ROLE_GROUP_OPEN;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element7;
return XML_ROLE_CONTENT_ELEMENT;
case XML_TOK_NAME_QUESTION:
@@ -884,7 +991,7 @@ int element2(PROLOG_STATE *state,
state->handler = element7;
return XML_ROLE_CONTENT_ELEMENT_PLUS;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -905,7 +1012,7 @@ int element3(PROLOG_STATE *state,
state->handler = element4;
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -919,10 +1026,11 @@ int element4(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element5;
return XML_ROLE_CONTENT_ELEMENT;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -942,7 +1050,7 @@ int element5(PROLOG_STATE *state,
state->handler = element4;
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -959,6 +1067,7 @@ int element6(PROLOG_STATE *state,
state->level += 1;
return XML_ROLE_GROUP_OPEN;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element7;
return XML_ROLE_CONTENT_ELEMENT;
case XML_TOK_NAME_QUESTION:
@@ -971,7 +1080,7 @@ int element6(PROLOG_STATE *state,
state->handler = element7;
return XML_ROLE_CONTENT_ELEMENT_PLUS;
}
return syntaxError(state);
return common(state, tok);
}
static
@@ -1011,9 +1120,72 @@ int element7(PROLOG_STATE *state,
state->handler = element6;
return XML_ROLE_GROUP_CHOICE;
}
return syntaxError(state);
return common(state, tok);
}
#ifdef XML_DTD
static
int condSect0(PROLOG_STATE *state,
int tok,
const char *ptr,
const char *end,
const ENCODING *enc)
{
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) {
state->handler = condSect1;
return XML_ROLE_NONE;
}
if (XmlNameMatchesAscii(enc, ptr, end, KW_IGNORE)) {
state->handler = condSect2;
return XML_ROLE_NONE;
}
break;
}
return common(state, tok);
}
static
int condSect1(PROLOG_STATE *state,
int tok,
const char *ptr,
const char *end,
const ENCODING *enc)
{
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_OPEN_BRACKET:
state->handler = externalSubset1;
state->includeLevel += 1;
return XML_ROLE_NONE;
}
return common(state, tok);
}
static
int condSect2(PROLOG_STATE *state,
int tok,
const char *ptr,
const char *end,
const ENCODING *enc)
{
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_OPEN_BRACKET:
state->handler = externalSubset1;
return XML_ROLE_IGNORE_SECT;
}
return common(state, tok);
}
#endif /* XML_DTD */
static
int declClose(PROLOG_STATE *state,
int tok,
@@ -1025,10 +1197,10 @@ int declClose(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_DECL_CLOSE:
state->handler = internalSubset;
setTopLevel(state);
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
#if 0
@@ -1047,23 +1219,27 @@ int ignore(PROLOG_STATE *state,
default:
return XML_ROLE_NONE;
}
return syntaxError(state);
return common(state, tok);
}
#endif
static
int error(PROLOG_STATE *state,
int tok,
const char *ptr,
const char *end,
const ENCODING *enc)
int tok,
const char *ptr,
const char *end,
const ENCODING *enc)
{
return XML_ROLE_NONE;
}
static
int syntaxError(PROLOG_STATE *state)
int common(PROLOG_STATE *state, int tok)
{
#ifdef XML_DTD
if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF)
return XML_ROLE_INNER_PARAM_ENTITY_REF;
#endif
state->handler = error;
return XML_ROLE_ERROR;
}
@@ -1071,4 +1247,19 @@ int syntaxError(PROLOG_STATE *state)
void XmlPrologStateInit(PROLOG_STATE *state)
{
state->handler = prolog0;
#ifdef XML_DTD
state->documentEntity = 1;
state->includeLevel = 0;
#endif /* XML_DTD */
}
#ifdef XML_DTD
void XmlPrologStateInitExternalEntity(PROLOG_STATE *state)
{
state->handler = externalSubset0;
state->documentEntity = 0;
state->includeLevel = 0;
}
#endif /* XML_DTD */
+20 -1
View File
@@ -1,3 +1,8 @@
/*
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
@@ -24,6 +29,7 @@ enum {
XML_ROLE_ENTITY_NOTATION_NAME,
XML_ROLE_NOTATION_NAME,
XML_ROLE_NOTATION_SYSTEM_ID,
XML_ROLE_NOTATION_NO_SYSTEM_ID,
XML_ROLE_NOTATION_PUBLIC_ID,
XML_ROLE_ATTRIBUTE_NAME,
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
@@ -56,7 +62,13 @@ enum {
XML_ROLE_CONTENT_ELEMENT_REP,
XML_ROLE_CONTENT_ELEMENT_OPT,
XML_ROLE_CONTENT_ELEMENT_PLUS,
XML_ROLE_PARAM_ENTITY_REF
#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 {
@@ -66,9 +78,16 @@ typedef struct prolog_state {
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))
+1118 -298
View File
File diff suppressed because it is too large Load Diff
+198
View File
@@ -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
+97 -28
View File
@@ -1,3 +1,8 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
#ifndef XmlTok_INCLUDED
#define XmlTok_INCLUDED 1
@@ -9,6 +14,9 @@ extern "C" {
#define XMLTOKAPI /* as nothing */
#endif
/* The following token may be returned by XmlContentTok */
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be start of
illegal ]]> sequence */
/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
@@ -18,7 +26,7 @@ extern "C" {
#define XML_TOK_INVALID 0
/* The following tokens are returned by XmlContentTok; some are also
returned by XmlAttributeValueTok and XmlEntityTok */
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok */
#define XML_TOK_START_TAG_WITH_ATTS 1
#define XML_TOK_START_TAG_NO_ATTS 2
@@ -27,7 +35,7 @@ extern "C" {
#define XML_TOK_END_TAG 5
#define XML_TOK_DATA_CHARS 6
#define XML_TOK_DATA_NEWLINE 7
#define XML_TOK_CDATA_SECTION 8
#define XML_TOK_CDATA_SECT_OPEN 8
#define XML_TOK_ENTITY_REF 9
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
@@ -65,25 +73,41 @@ extern "C" {
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
#define XML_TOK_COMMA 38
/* The following tokens is returned only by XmlAttributeValueTok */
/* The following token is returned only by XmlAttributeValueTok */
#define XML_TOK_ATTRIBUTE_VALUE_S 39
#define XML_N_STATES 2
/* The following token is returned only by XmlCdataSectionTok */
#define XML_TOK_CDATA_SECT_CLOSE 40
/* With namespace processing this is returned by XmlPrologTok
for a name with a colon. */
#define XML_TOK_PREFIXED_NAME 41
#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
#define XML_ENTITY_VALUE_LITERAL 1
#define XML_N_INTERNAL_ENCODINGS 1
#define XML_UTF8_ENCODING 0
#if 0
#define XML_UTF16_ENCODING 1
#define XML_UCS4_ENCODING 2
#endif
#define XML_MAX_BYTES_PER_CHAR 4
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
#define XML_UTF8_ENCODE_MAX 4
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
#define XML_UTF16_ENCODE_MAX 2
typedef struct position {
/* first line and first column are 0 not 1 */
@@ -113,27 +137,32 @@ 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,
POSITION *);
int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
const char **badPtr);
int (*encode)(const ENCODING *enc,
int charNum,
char *buf);
void (*convert[XML_N_INTERNAL_ENCODINGS])(const ENCODING *enc,
const char **fromP,
const char *fromLim,
char **toP,
const char *toLim);
void (*utf8Convert)(const ENCODING *enc,
const char **fromP,
const char *fromLim,
char **toP,
const char *toLim);
void (*utf16Convert)(const ENCODING *enc,
const char **fromP,
const char *fromLim,
unsigned short **toP,
const unsigned short *toLim);
int minBytesPerChar;
char isUtf8;
char isUtf16;
};
/*
@@ -166,6 +195,16 @@ literals, comments and processing instructions.
#define XmlContentTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
#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. */
@@ -180,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))
@@ -195,17 +234,20 @@ the content of a literal that has already been returned by XmlTok. */
#define XmlCharRefNumber(enc, ptr) \
(((enc)->charRefNumber)(enc, ptr))
#define XmlPredefinedEntityName(enc, ptr, end) \
(((enc)->predefinedEntityName)(enc, ptr, end))
#define XmlUpdatePosition(enc, ptr, end, pos) \
(((enc)->updatePosition)(enc, ptr, end, pos))
#define XmlIsPublicId(enc, ptr, end, badPtr) \
(((enc)->isPublicId)(enc, ptr, end, badPtr))
#define XmlEncode(enc, ch, buf) \
(((enc)->encode)(enc, ch, buf))
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
#define XmlConvert(enc, targetEnc, fromP, fromLim, toP, toLim) \
(((enc)->convert[targetEnc])(enc, fromP, fromLim, toP, toLim))
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
typedef struct {
ENCODING initEnc;
@@ -223,8 +265,35 @@ int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity,
int *standalonePtr);
int XMLTOKAPI XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING XMLTOKAPI *XmlGetInternalEncoding(int);
const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncoding(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
+521 -245
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -1,3 +1,8 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file copying.txt for copying permission.
*/
enum {
BT_NONXML,
BT_MALFORM,
@@ -22,6 +27,7 @@ enum {
BT_LSQB,
BT_S,
BT_NMSTRT,
BT_COLON,
BT_HEX,
BT_DIGIT,
BT_NAME,
+96
View File
@@ -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);
}
+3
View File
@@ -0,0 +1,3 @@
Debug
Release
xmlwf.plg
+65
View File
@@ -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 */
+7
View File
@@ -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);
+145
View File
@@ -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;
}
+11
View File
@@ -1,6 +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
+5
View File
@@ -1,3 +1,8 @@
/*
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>
+57
View File
@@ -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;
}
+25 -7
View File
@@ -1,12 +1,30 @@
/*
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 char *);
static void win32perror(const TCHAR *);
int filemap(const char *name,
void (*processor)(const void *, size_t, const char *, void *arg),
int filemap(const TCHAR *name,
void (*processor)(const void *, size_t, const TCHAR *, void *arg),
void *arg)
{
HANDLE f;
@@ -27,7 +45,7 @@ int filemap(const char *name,
return 0;
}
if (sizeHi) {
fprintf(stderr, "%s: bigger than 2Gb\n", name);
_ftprintf(stderr, _T("%s: bigger than 2Gb\n"), name);
return 0;
}
/* CreateFileMapping barfs on zero length files */
@@ -58,7 +76,7 @@ int filemap(const char *name,
}
static
void win32perror(const char *s)
void win32perror(const TCHAR *s)
{
LPVOID buf;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
@@ -68,10 +86,10 @@ void win32perror(const char *s)
(LPTSTR) &buf,
0,
NULL)) {
fprintf(stderr, "%s: %s", s, buf);
_ftprintf(stderr, _T("%s: %s"), s, buf);
fflush(stderr);
LocalFree(buf);
}
else
fprintf(stderr, "%s: unknown Windows error\n", s);
_ftprintf(stderr, _T("%s: unknown Windows error\n"), s);
}
+217
View File
@@ -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;
}
+11
View File
@@ -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);
+161
View File
@@ -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 */
+19
View File
@@ -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
+36
View File
@@ -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 */
+13
View File
@@ -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
+648 -162
View File
@@ -1,212 +1,644 @@
#include "xmlparse.h"
#include "filemap.h"
/*
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>
#ifdef _MSC_VER
#include <io.h>
#endif
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#else
#define O_BINARY 0
#endif
#endif
#include "xmlparse.h"
#include "codepage.h"
#include "xmlfile.h"
#include "xmltchar.h"
#ifdef _MSC_VER
#include <crtdbg.h>
#endif
#ifdef _DEBUG
#define READ_SIZE 16
#else
#define READ_SIZE (1024*8)
#endif
/* This ensures proper sorting. */
static void characterData(void *userData, const char *s, int len)
#define NSSEP T('\001')
static void characterData(void *userData, const XML_Char *s, int len)
{
FILE *fp = userData;
for (; len > 0; --len, ++s) {
switch (*s) {
case '&':
fputs("&amp;", fp);
case T('&'):
fputts(T("&amp;"), fp);
break;
case '<':
fputs("&lt;", fp);
case T('<'):
fputts(T("&lt;"), fp);
break;
case '>':
fputs("&gt;", fp);
case T('>'):
fputts(T("&gt;"), fp);
break;
case '"':
fputs("&quot;", fp);
#ifdef W3C14N
case 13:
fputts(T("&#xD;"), fp);
break;
#else
case T('"'):
fputts(T("&quot;"), fp);
break;
case 9:
case 10:
case 13:
fprintf(fp, "&#%d;", *s);
ftprintf(fp, T("&#%d;"), *s);
break;
#endif
default:
putc(*s, fp);
puttc(*s, fp);
break;
}
}
}
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("&amp;"), fp);
break;
case T('<'):
fputts(T("&lt;"), fp);
break;
case T('"'):
fputts(T("&quot;"), fp);
break;
#ifdef W3C14N
case 9:
fputts(T("&#x9;"), fp);
break;
case 10:
fputts(T("&#xA;"), fp);
break;
case 13:
fputts(T("&#xD;"), fp);
break;
#else
case T('>'):
fputts(T("&gt;"), 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. */
static int attcmp(const void *att1, const void *att2)
{
return strcmp(*(const char **)att1, *(const char **)att2);
return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2);
}
static void startElement(void *userData, const char *name, const char **atts)
static void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
{
int nAtts;
const char **p;
const XML_Char **p;
FILE *fp = userData;
putc('<', fp);
fputs(name, fp);
puttc(T('<'), fp);
fputts(name, fp);
p = atts;
while (*p)
++p;
nAtts = (p - atts) >> 1;
if (nAtts > 1)
qsort((void *)atts, nAtts, sizeof(char *) * 2, attcmp);
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp);
while (*atts) {
putc(' ', fp);
fputs(*atts++, fp);
putc('=', fp);
putc('"', fp);
characterData(userData, *atts, strlen(*atts));
putc('"', fp);
puttc(T(' '), fp);
fputts(*atts++, fp);
attributeValue(fp, *atts);
atts++;
}
putc('>', fp);
puttc(T('>'), fp);
}
static void endElement(void *userData, const char *name)
static void endElement(void *userData, const XML_Char *name)
{
FILE *fp = userData;
putc('<', fp);
putc('/', fp);
fputs(name, fp);
putc('>', fp);
puttc(T('<'), fp);
puttc(T('/'), fp);
fputts(name, fp);
puttc(T('>'), fp);
}
static void processingInstruction(void *userData, const char *target, const char *data)
static 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;
int nsi;
const XML_Char **p;
FILE *fp = userData;
const XML_Char *sep;
puttc(T('<'), fp);
sep = tcsrchr(name, NSSEP);
if (sep) {
fputts(T("n1:"), fp);
fputts(sep + 1, fp);
fputts(T(" xmlns:n1"), fp);
attributeValue(fp, name);
nsi = 2;
}
else {
fputts(name, fp);
nsi = 1;
}
p = atts;
while (*p)
++p;
nAtts = (p - atts) >> 1;
if (nAtts > 1)
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("n%d:"), nsi);
fputts(sep + 1, fp);
}
else
fputts(name, fp);
attributeValue(fp, *atts);
if (sep) {
ftprintf(fp, T(" xmlns:n%d"), nsi++);
attributeValue(fp, name);
}
atts++;
}
puttc(T('>'), fp);
}
static void endElementNS(void *userData, const XML_Char *name)
{
FILE *fp = userData;
fprintf(fp, "<?%s %s?>", target, data);
}
typedef struct {
XML_Parser parser;
int *retPtr;
} PROCESS_ARGS;
static
void reportError(XML_Parser parser, const char *filename)
{
int code = XML_GetErrorCode(parser);
const char *message = XML_ErrorString(code);
if (message)
fprintf(stdout, "%s:%d:%ld: %s\n",
filename,
XML_GetErrorLineNumber(parser),
XML_GetErrorColumnNumber(parser),
message);
else
fprintf(stderr, "%s: (unknown message %d)\n", filename, code);
}
static
void processFile(const void *data, size_t size, const char *filename, void *args)
{
XML_Parser parser = ((PROCESS_ARGS *)args)->parser;
int *retPtr = ((PROCESS_ARGS *)args)->retPtr;
if (!XML_Parse(parser, data, size, 1)) {
reportError(parser, filename);
*retPtr = 0;
const XML_Char *sep;
puttc(T('<'), fp);
puttc(T('/'), fp);
sep = tcsrchr(name, NSSEP);
if (sep) {
fputts(T("n1:"), fp);
fputts(sep + 1, fp);
}
else
*retPtr = 1;
fputts(name, fp);
puttc(T('>'), fp);
}
#ifndef W3C14N
static void processingInstruction(void *userData, const XML_Char *target, const XML_Char *data)
{
FILE *fp = userData;
puttc(T('<'), fp);
puttc(T('?'), fp);
fputts(target, fp);
puttc(T(' '), fp);
fputts(data, fp);
puttc(T('?'), fp);
puttc(T('>'), fp);
}
#endif /* not W3C14N */
static void defaultCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
XML_DefaultCurrent(parser);
}
static void defaultStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
XML_DefaultCurrent(parser);
}
static void defaultEndElement(XML_Parser parser, const XML_Char *name)
{
XML_DefaultCurrent(parser);
}
static void defaultProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
XML_DefaultCurrent(parser);
}
static void nopCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
}
static void nopStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
}
static void nopEndElement(XML_Parser parser, const XML_Char *name)
{
}
static void nopProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
}
static void markup(XML_Parser parser, const XML_Char *s, int len)
{
FILE *fp = XML_GetUserData(parser);
for (; len > 0; --len, ++s)
puttc(*s, fp);
}
static
int processStream(const char *filename, XML_Parser parser)
void metaLocation(XML_Parser parser)
{
int fd = open(filename, O_BINARY|O_RDONLY);
if (fd < 0) {
perror(filename);
const XML_Char *uri = XML_GetBase(parser);
if (uri)
ftprintf(XML_GetUserData(parser), T(" uri=\"%s\""), uri);
ftprintf(XML_GetUserData(parser),
T(" byte=\"%ld\" nbytes=\"%d\" line=\"%d\" col=\"%d\""),
XML_GetCurrentByteIndex(parser),
XML_GetCurrentByteCount(parser),
XML_GetCurrentLineNumber(parser),
XML_GetCurrentColumnNumber(parser));
}
static
void metaStartDocument(XML_Parser parser)
{
fputts(T("<document>\n"), XML_GetUserData(parser));
}
static
void metaEndDocument(XML_Parser parser)
{
fputts(T("</document>\n"), XML_GetUserData(parser));
}
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) {
fputts(T(">\n"), fp);
do {
ftprintf(fp, T("<attribute name=\"%s\" value=\""), atts[0]);
characterData(fp, atts[1], tcslen(atts[1]));
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);
}
else
fputts(T("/>\n"), fp);
}
static
void metaEndElement(XML_Parser parser, const XML_Char *name)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<endtag name=\"%s\""), name);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<pi target=\"%s\" data=\""), target);
characterData(fp, data, tcslen(data));
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaComment(XML_Parser parser, const XML_Char *data)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<comment data=\""), fp);
characterData(fp, data, tcslen(data));
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaStartCdataSection(XML_Parser parser)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<startcdata"), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaEndCdataSection(XML_Parser parser)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<endcdata"), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaCharacterData(XML_Parser parser, const XML_Char *s, int len)
{
FILE *fp = XML_GetUserData(parser);
fputts(T("<chars str=\""), fp);
characterData(fp, s, len);
puttc(T('"'), fp);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void 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)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<entity name=\"%s\""), entityName);
if (publicId)
ftprintf(fp, T(" public=\"%s\""), publicId);
fputts(T(" system=\""), fp);
characterData(fp, systemId, tcslen(systemId));
puttc(T('"'), fp);
ftprintf(fp, T(" notation=\"%s\""), notationName);
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void metaNotationDecl(XML_Parser parser,
const XML_Char *notationName,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
FILE *fp = XML_GetUserData(parser);
ftprintf(fp, T("<notation name=\"%s\""), notationName);
if (publicId)
ftprintf(fp, T(" public=\"%s\""), publicId);
if (systemId) {
fputts(T(" system=\""), fp);
characterData(fp, systemId, tcslen(systemId));
puttc(T('"'), fp);
}
metaLocation(parser);
fputts(T("/>\n"), fp);
}
static
void 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)
{
return codepageConvert(*(int *)data, p);
}
static
int unknownEncoding(void *userData,
const XML_Char *name,
XML_Encoding *info)
{
int cp;
static const XML_Char prefixL[] = T("windows-");
static const XML_Char prefixU[] = T("WINDOWS-");
int i;
for (i = 0; prefixU[i]; i++)
if (name[i] != prefixU[i] && name[i] != prefixL[i])
return 0;
cp = 0;
for (; name[i]; i++) {
static const XML_Char digits[] = T("0123456789");
const XML_Char *s = tcschr(digits, name[i]);
if (!s)
return 0;
cp *= 10;
cp += s - digits;
if (cp >= 0x10000)
return 0;
}
if (!codepageMap(cp, info->map))
return 0;
}
for (;;) {
int nread;
char *buf = XML_GetBuffer(parser, READ_SIZE);
if (!buf) {
close(fd);
fprintf(stderr, "%s: out of memory\n", filename);
return 0;
}
nread = read(fd, buf, READ_SIZE);
if (nread < 0) {
perror(filename);
close(fd);
return 0;
}
if (!XML_ParseBuffer(parser, nread, nread == 0)) {
reportError(parser, filename);
close(fd);
return 0;
}
if (nread == 0) {
close(fd);
break;;
}
}
info->convert = unknownEncodingConvert;
/* We could just cast the code page integer to a void *,
and avoid the use of release. */
info->release = free;
info->data = malloc(sizeof(int));
if (!info->data)
return 0;
*(int *)info->data = cp;
return 1;
}
static
void usage(const char *prog)
int notStandalone(void *userData)
{
fprintf(stderr, "usage: %s [-r] [-d output-dir] [-e encoding] file ...\n", prog);
return 0;
}
static
void usage(const XML_Char *prog)
{
ftprintf(stderr, T("usage: %s [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] [-e encoding] file ...\n"), prog);
exit(1);
}
int main(int argc, char **argv)
int tmain(int argc, XML_Char **argv)
{
int i;
const char *outputDir = 0;
const char *encoding = 0;
int useFilemap = 1;
int 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;
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] == '-') {
int j;
if (argv[i][1] == '-' && argv[i][2] == '\0') {
i++;
break;
}
j = 1;
if (argv[i][j] == 'r') {
useFilemap = 0;
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++;
}
if (argv[i][j] == 'd') {
if (argv[i][j + 1] == '\0') {
switch (argv[i][j]) {
case T('r'):
processFlags &= ~XML_MAP_FILE;
j++;
break;
case T('s'):
requireStandalone = 1;
j++;
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++;
break;
case T('w'):
windowsCodePages = 1;
j++;
break;
case T('m'):
outputType = 'm';
j++;
break;
case T('c'):
outputType = 'c';
useNamespaces = 0;
j++;
break;
case T('t'):
outputType = 't';
j++;
break;
case T('d'):
if (argv[i][j + 1] == T('\0')) {
if (++i == argc)
usage(argv[0]);
outputDir = argv[i];
@@ -214,9 +646,10 @@ int main(int argc, char **argv)
else
outputDir = argv[i] + j + 1;
i++;
}
else if (argv[i][j] == 'e') {
if (argv[i][j + 1] == '\0') {
j = 0;
break;
case T('e'):
if (argv[i][j + 1] == T('\0')) {
if (++i == argc)
usage(argv[0]);
encoding = argv[i];
@@ -224,54 +657,107 @@ int main(int argc, char **argv)
else
encoding = argv[i] + j + 1;
i++;
}
else if (argv[i][j] == '\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]);
for (; i < argc; i++) {
FILE *fp = 0;
char *outName = 0;
XML_Char *outName = 0;
int result;
XML_Parser parser = XML_ParserCreate(encoding);
if (outputDir) {
const char *file = argv[i];
if (strrchr(file, '/'))
file = strrchr(file, '/') + 1;
XML_Parser parser;
if (useNamespaces)
parser = XML_ParserCreateNS(encoding, NSSEP);
else
parser = XML_ParserCreate(encoding);
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;
#ifdef WIN32
if (strrchr(file, '\\'))
file = strrchr(file, '\\') + 1;
if (tcsrchr(file, T('\\')))
file = tcsrchr(file, T('\\')) + 1;
#endif
outName = malloc(strlen(outputDir) + strlen(file) + 2);
strcpy(outName, outputDir);
strcat(outName, "/");
strcat(outName, file);
fp = fopen(outName, "wb");
outName = malloc((tcslen(outputDir) + tcslen(file) + 2) * sizeof(XML_Char));
tcscpy(outName, outputDir);
tcscat(outName, T("/"));
tcscat(outName, file);
fp = tfopen(outName, T("wb"));
if (!fp) {
perror(outName);
tperror(outName);
exit(1);
}
setvbuf(fp, NULL, _IOFBF, 16384);
#ifdef XML_UNICODE
puttc(0xFEFF, fp);
#endif
XML_SetUserData(parser, fp);
XML_SetElementHandler(parser, startElement, endElement);
XML_SetCharacterDataHandler(parser, characterData);
XML_SetProcessingInstructionHandler(parser, processingInstruction);
switch (outputType) {
case 'm':
XML_UseParserAsHandlerArg(parser);
XML_SetElementHandler(parser, metaStartElement, metaEndElement);
XML_SetProcessingInstructionHandler(parser, metaProcessingInstruction);
XML_SetCommentHandler(parser, metaComment);
XML_SetCdataSectionHandler(parser, metaStartCdataSection, metaEndCdataSection);
XML_SetCharacterDataHandler(parser, metaCharacterData);
XML_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':
XML_UseParserAsHandlerArg(parser);
XML_SetDefaultHandler(parser, markup);
XML_SetElementHandler(parser, defaultStartElement, defaultEndElement);
XML_SetCharacterDataHandler(parser, defaultCharacterData);
XML_SetProcessingInstructionHandler(parser, defaultProcessingInstruction);
break;
default:
if (useNamespaces)
XML_SetElementHandler(parser, startElementNS, endElementNS);
else
XML_SetElementHandler(parser, startElement, endElement);
XML_SetCharacterDataHandler(parser, characterData);
#ifndef W3C14N
XML_SetProcessingInstructionHandler(parser, processingInstruction);
#endif /* not W3C14N */
break;
}
}
if (useFilemap) {
PROCESS_ARGS args;
args.retPtr = &result;
args.parser = parser;
if (!filemap(argv[i], processFile, &args))
result = 0;
}
else
result = processStream(argv[i], parser);
if (windowsCodePages)
XML_SetUnknownEncodingHandler(parser, unknownEncoding, 0);
result = XML_ProcessFile(parser, argv[i], processFlags);
if (outputDir) {
if (outputType == 'm')
metaEndDocument(parser);
fclose(fp);
if (!result)
remove(outName);
tremove(outName);
free(outName);
}
XML_ParserFree(parser);
+136
View File
@@ -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
+371
View File
@@ -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);
}