Added Expat and LuaExpat, XML parsing now available in the API.
FS #336 Windows version only, Linux to be fixed soon. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1374 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
a144681155
commit
48cec90c3f
120
Install/LuaExpat-license.html
Normal file
120
Install/LuaExpat-license.html
Normal file
@ -0,0 +1,120 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LuaExpat: XML Expat parsing for the Lua programming language</title>
|
||||
<link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"><a href="http://www.keplerproject.org">
|
||||
<img alt="LuaExpat logo" src="luaexpat.png"/>
|
||||
</a></div>
|
||||
<div id="product_name"><big><strong>LuaExpat</strong></big></div>
|
||||
<div id="product_description">XML Expat parsing for the Lua programming language</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaExpat</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#overview">Overview</a></li>
|
||||
<li><a href="index.html#status">Status</a></li>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#references">References</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
<li><a href="index.html#contact">Contact</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#introduction">Introduction</a></li>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#parser">Parser Objects</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="examples.html">Examples</a></li>
|
||||
<li><a href="lom.html">Lua Object Model</a></li>
|
||||
<li><a href="http://luaforge.net/projects/luaexpat/">Project</a>
|
||||
<ul>
|
||||
<li><a href="http://luaforge.net/tracker/?group_id=13">Bug Tracker</a></li>
|
||||
<li><a href="http://luaforge.net/scm/?group_id=13">CVS</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>License</strong></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>License</h2>
|
||||
|
||||
<p>
|
||||
LuaExpat is free software: it can be used for both academic and
|
||||
commercial purposes at absolutely no cost. There are no royalties
|
||||
or GNU-like "copyleft" restrictions. LuaExpat qualifies as <a href=
|
||||
"http://www.opensource.org/docs/definition.html">Open Source</a>
|
||||
software. Its licenses are compatible with <a href=
|
||||
"http://www.gnu.org/licenses/gpl.html">GPL</a>. LuaExpat is not in
|
||||
the public domain and the
|
||||
<a href="http://www.keplerproject.org">Kepler Project</a>
|
||||
keep its copyright. The legal details are below.
|
||||
</p>
|
||||
|
||||
<p>The spirit of the license is that you are free to use LuaExpat
|
||||
for any purpose at no cost without having to ask us. The only
|
||||
requirement is that if you do use LuaExpat, then you should give us
|
||||
credit by including the appropriate copyright notice somewhere in
|
||||
your product or its documentation.</p>
|
||||
|
||||
<p>The LuaExpat library is designed and implemented by Roberto
|
||||
Ierusalimschy. The implementation is not derived from licensed
|
||||
software.</p>
|
||||
|
||||
<hr/>
|
||||
<p>Copyright © 2003-2007 The Kepler Project.
|
||||
</p>
|
||||
|
||||
<p>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:</p>
|
||||
|
||||
<p>The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.</p>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
|
||||
<p><small>
|
||||
$Id: license.html,v 1.9 2007/06/05 20:03:12 carregal Exp $
|
||||
</small></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
@ -9,6 +9,7 @@ MCServer*debug.cmd
|
||||
banned.example.ini
|
||||
groups.example.ini
|
||||
Lua-LICENSE.txt
|
||||
LuaExpat-license.html
|
||||
LuaSQLite3-LICENSE.txt
|
||||
MersenneTwister-LICENSE.txt
|
||||
settings.example.ini
|
||||
|
@ -69,6 +69,8 @@ function Initialize(Plugin)
|
||||
BA1:Merge(BA2, 1, 10, 1, cBlockArea.msImprint);
|
||||
BA1:SaveToSchematicFile("schematics/merge.schematic");
|
||||
end
|
||||
else
|
||||
BA1:Create(16, 16, 16);
|
||||
end
|
||||
|
||||
-- Debug block area cuboid filling:
|
||||
@ -166,6 +168,31 @@ function Initialize(Plugin)
|
||||
LOG("SQLite3 failed to open DB! (" .. ErrCode .. ", " .. ErrMsg ..")");
|
||||
end
|
||||
|
||||
|
||||
-- Debug LuaExpat binding:
|
||||
local count = 0
|
||||
callbacks = {
|
||||
StartElement = function (parser, name)
|
||||
LOG("+ " .. string.rep(" ", count) .. name);
|
||||
count = count + 1;
|
||||
end,
|
||||
EndElement = function (parser, name)
|
||||
count = count - 1;
|
||||
LOG("- " .. string.rep(" ", count) .. name);
|
||||
end
|
||||
}
|
||||
|
||||
local p = lxp.new(callbacks);
|
||||
p:parse("<elem1>\nnext line\nanother line");
|
||||
p:parse("text\n");
|
||||
p:parse("<elem2/>\n");
|
||||
p:parse("more text");
|
||||
p:parse("</elem1>");
|
||||
p:parse("\n");
|
||||
p:parse() -- finishes the document
|
||||
p:close() -- closes the parser
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -5,6 +5,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MCServer", "MCServer.vcproj
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{9A476537-42C0-4848-AB40-15CFE83D17A8} = {9A476537-42C0-4848-AB40-15CFE83D17A8}
|
||||
{082E8185-7B3A-4945-8C82-9132341A329D} = {082E8185-7B3A-4945-8C82-9132341A329D}
|
||||
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96} = {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
|
||||
{EEAB54AD-114C-4AB8-8482-0A52D502BD35} = {EEAB54AD-114C-4AB8-8482-0A52D502BD35}
|
||||
{5AAA90B9-946D-4034-83F3-676B06A6E326} = {5AAA90B9-946D-4034-83F3-676B06A6E326}
|
||||
@ -25,6 +26,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Squirrel3", "Squirrel3.vcpr
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CryptoPP", "CryptoPP.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "expat", "expat.vcproj", "{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@ -77,6 +80,12 @@ Global
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release profiled|Win32.Build.0 = Release|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
|
||||
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release profiled|Win32.ActiveCfg = Release|Win32
|
||||
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release profiled|Win32.Build.0 = Release|Win32
|
||||
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -42,8 +42,8 @@
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/MP"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""../zlib-1.2.7";"../jsoncpp-src-0.5.0/include";"../lua-5.1.4/src";"../tolua++-1.0.93/include";../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
AdditionalIncludeDirectories=""../zlib-1.2.7";"../jsoncpp-src-0.5.0/include";"../lua-5.1.4/src";"../tolua++-1.0.93/include";../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
@ -120,7 +120,7 @@
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
WholeProgramOptimization="true"
|
||||
AdditionalIncludeDirectories=""../zlib-1.2.7";"../jsoncpp-src-0.5.0/include";"../lua-5.1.4/src";"../tolua++-1.0.93/include";../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;.."
|
||||
AdditionalIncludeDirectories=""../zlib-1.2.7";"../jsoncpp-src-0.5.0/include";"../lua-5.1.4/src";"../tolua++-1.0.93/include";../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="2"
|
||||
@ -198,7 +198,7 @@
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
WholeProgramOptimization="true"
|
||||
AdditionalIncludeDirectories=""../zlib-1.2.7";"../jsoncpp-src-0.5.0/include";"../lua-5.1.4/src";"../tolua++-1.0.93/include";../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;.."
|
||||
AdditionalIncludeDirectories=""../zlib-1.2.7";"../jsoncpp-src-0.5.0/include";"../lua-5.1.4/src";"../tolua++-1.0.93/include";../squirrel_3_0_1_stable/include;../squirrel_3_0_1_stable;../squirrel_3_0_1_stable/sqrat;..;../expat"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="2"
|
||||
@ -2263,6 +2263,42 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="LuaExpat"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\source\LuaExpat\lxplib.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release profiled|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\LuaExpat\lxplib.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Config files"
|
||||
|
227
VC2008/expat.vcproj
Normal file
227
VC2008/expat.vcproj
Normal file
@ -0,0 +1,227 @@
|
||||
<?xml version="1.0" encoding="windows-1250"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="expat"
|
||||
ProjectGUID="{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}"
|
||||
RootNamespace="expat"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;COMPILED_FROM_DSP"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\expat\ascii.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\asciitab.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\expat.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\expat_external.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\iasciitab.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\internal.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\latin1tab.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\nametab.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\utf8tab.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\winconfig.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\xmlparse.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\xmlrole.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\xmlrole.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\xmltok.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\xmltok.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\xmltok_impl.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\xmltok_impl.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\expat\xmltok_ns.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
92
expat/ascii.h
Normal file
92
expat/ascii.h
Normal file
@ -0,0 +1,92 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING 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
|
||||
#define ASCII_LPAREN 0x28
|
||||
#define ASCII_RPAREN 0x29
|
||||
#define ASCII_FF 0x0C
|
||||
#define ASCII_SLASH 0x2F
|
||||
#define ASCII_HASH 0x23
|
||||
#define ASCII_PIPE 0x7C
|
||||
#define ASCII_COMMA 0x2C
|
36
expat/asciitab.h
Normal file
36
expat/asciitab.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
1014
expat/expat.h
Normal file
1014
expat/expat.h
Normal file
File diff suppressed because it is too large
Load Diff
115
expat/expat_external.h
Normal file
115
expat/expat_external.h
Normal file
@ -0,0 +1,115 @@
|
||||
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef Expat_External_INCLUDED
|
||||
#define Expat_External_INCLUDED 1
|
||||
|
||||
/* External API definitions */
|
||||
|
||||
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||
#define XML_USE_MSC_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
/* Expat tries very hard to make the API boundary very specifically
|
||||
defined. There are two macros defined to control this boundary;
|
||||
each of these can be defined before including this header to
|
||||
achieve some different behavior, but doing so it not recommended or
|
||||
tested frequently.
|
||||
|
||||
XMLCALL - The calling convention to use for all calls across the
|
||||
"library boundary." This will default to cdecl, and
|
||||
try really hard to tell the compiler that's what we
|
||||
want.
|
||||
|
||||
XMLIMPORT - Whatever magic is needed to note that a function is
|
||||
to be imported from a dynamically loaded library
|
||||
(.dll, .so, or .sl, depending on your platform).
|
||||
|
||||
The XMLCALL macro was added in Expat 1.95.7. The only one which is
|
||||
expected to be directly useful in client code is XMLCALL.
|
||||
|
||||
Note that on at least some Unix versions, the Expat library must be
|
||||
compiled with the cdecl calling convention as the default since
|
||||
system headers may assume the cdecl convention.
|
||||
*/
|
||||
#ifndef XMLCALL
|
||||
#if defined(_MSC_VER)
|
||||
#define XMLCALL __cdecl
|
||||
#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
|
||||
#define XMLCALL __attribute__((cdecl))
|
||||
#else
|
||||
/* For any platform which uses this definition and supports more than
|
||||
one calling convention, we need to extend this definition to
|
||||
declare the convention used on that platform, if it's possible to
|
||||
do so.
|
||||
|
||||
If this is the case for your platform, please file a bug report
|
||||
with information on how to identify your platform via the C
|
||||
pre-processor and how to specify the same calling convention as the
|
||||
platform's malloc() implementation.
|
||||
*/
|
||||
#define XMLCALL
|
||||
#endif
|
||||
#endif /* not defined XMLCALL */
|
||||
|
||||
|
||||
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
|
||||
#ifndef XML_BUILDING_EXPAT
|
||||
/* using Expat from an application */
|
||||
|
||||
#ifdef XML_USE_MSC_EXTENSIONS
|
||||
#define XMLIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* not defined XML_STATIC */
|
||||
|
||||
|
||||
/* If we didn't define it above, define it away: */
|
||||
#ifndef XMLIMPORT
|
||||
#define XMLIMPORT
|
||||
#endif
|
||||
|
||||
|
||||
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
#else
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE_WCHAR_T */
|
||||
#else /* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE */
|
||||
|
||||
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
|
||||
typedef __int64 XML_Index;
|
||||
typedef unsigned __int64 XML_Size;
|
||||
#else
|
||||
typedef long long XML_Index;
|
||||
typedef unsigned long long XML_Size;
|
||||
#endif
|
||||
#else
|
||||
typedef long XML_Index;
|
||||
typedef unsigned long XML_Size;
|
||||
#endif /* XML_LARGE_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not Expat_External_INCLUDED */
|
37
expat/iasciitab.h
Normal file
37
expat/iasciitab.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
73
expat/internal.h
Normal file
73
expat/internal.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* internal.h
|
||||
|
||||
Internal definitions used by Expat. This is not needed to compile
|
||||
client code.
|
||||
|
||||
The following calling convention macros are defined for frequently
|
||||
called functions:
|
||||
|
||||
FASTCALL - Used for those internal functions that have a simple
|
||||
body and a low number of arguments and local variables.
|
||||
|
||||
PTRCALL - Used for functions called though function pointers.
|
||||
|
||||
PTRFASTCALL - Like PTRCALL, but for low number of arguments.
|
||||
|
||||
inline - Used for selected internal functions for which inlining
|
||||
may improve performance on some platforms.
|
||||
|
||||
Note: Use of these macros is based on judgement, not hard rules,
|
||||
and therefore subject to change.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
|
||||
/* We'll use this version by default only where we know it helps.
|
||||
|
||||
regparm() generates warnings on Solaris boxes. See SF bug #692878.
|
||||
|
||||
Instability reported with egcs on a RedHat Linux 7.3.
|
||||
Let's comment out:
|
||||
#define FASTCALL __attribute__((stdcall, regparm(3)))
|
||||
and let's try this:
|
||||
*/
|
||||
#define FASTCALL __attribute__((regparm(3)))
|
||||
#define PTRFASTCALL __attribute__((regparm(3)))
|
||||
#endif
|
||||
|
||||
/* Using __fastcall seems to have an unexpected negative effect under
|
||||
MS VC++, especially for function pointers, so we won't use it for
|
||||
now on that platform. It may be reconsidered for a future release
|
||||
if it can be made more effective.
|
||||
Likely reason: __fastcall on Windows is like stdcall, therefore
|
||||
the compiler cannot perform stack optimizations for call clusters.
|
||||
*/
|
||||
|
||||
/* Make sure all of these are defined if they aren't already. */
|
||||
|
||||
#ifndef FASTCALL
|
||||
#define FASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef PTRCALL
|
||||
#define PTRCALL
|
||||
#endif
|
||||
|
||||
#ifndef PTRFASTCALL
|
||||
#define PTRFASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef XML_MIN_SIZE
|
||||
#if !defined(__cplusplus) && !defined(inline)
|
||||
#ifdef __GNUC__
|
||||
#define inline __inline
|
||||
#endif /* __GNUC__ */
|
||||
#endif
|
||||
#endif /* XML_MIN_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define inline inline
|
||||
#else
|
||||
#ifndef inline
|
||||
#define inline
|
||||
#endif
|
||||
#endif
|
36
expat/latin1tab.h
Normal file
36
expat/latin1tab.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
|
||||
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
150
expat/nametab.h
Normal file
150
expat/nametab.h
Normal file
@ -0,0 +1,150 @@
|
||||
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, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0x0000007F, 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, 0x0000001F, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
|
||||
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
|
||||
0x40000000, 0xF580C900, 0x00000007, 0x02010800,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
|
||||
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
|
||||
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
|
||||
0x00000000, 0x00004C40, 0x00000000, 0x00000000,
|
||||
0x00000007, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
|
||||
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
|
||||
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0xFFFE007F, 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, 0x03FF3F5F, 0x00000000,
|
||||
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
|
||||
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
|
||||
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x661FFFFF, 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,
|
||||
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x15, 0x16, 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, 0x17,
|
||||
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, 0x18,
|
||||
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[] = {
|
||||
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
|
||||
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x16, 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, 0x17,
|
||||
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, 0x18,
|
||||
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,
|
||||
};
|
37
expat/utf8tab.h
Normal file
37
expat/utf8tab.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
|
||||
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
|
||||
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
|
30
expat/winconfig.h
Normal file
30
expat/winconfig.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*================================================================
|
||||
** Copyright 2000, Clark Cooper
|
||||
** All rights reserved.
|
||||
**
|
||||
** This is free software. You are permitted to copy, distribute, or modify
|
||||
** it under the terms of the MIT/X license (contained in the COPYING file
|
||||
** with this distribution.)
|
||||
*/
|
||||
|
||||
#ifndef WINCONFIG_H
|
||||
#define WINCONFIG_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
#define XML_NS 1
|
||||
#define XML_DTD 1
|
||||
#define XML_CONTEXT_BYTES 1024
|
||||
|
||||
/* we will assume all Windows platforms are little endian */
|
||||
#define BYTEORDER 1234
|
||||
|
||||
/* Windows has memmove() available. */
|
||||
#define HAVE_MEMMOVE
|
||||
|
||||
#endif /* ndef WINCONFIG_H */
|
6291
expat/xmlparse.c
Normal file
6291
expat/xmlparse.c
Normal file
File diff suppressed because it is too large
Load Diff
1482
expat/xmlrole.c
Normal file
1482
expat/xmlrole.c
Normal file
File diff suppressed because it is too large
Load Diff
114
expat/xmlrole.h
Normal file
114
expat/xmlrole.h
Normal file
@ -0,0 +1,114 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlRole_INCLUDED
|
||||
#define XmlRole_INCLUDED 1
|
||||
|
||||
#ifdef __VMS
|
||||
/* 0 1 2 3 0 1 2 3
|
||||
1234567890123456789012345678901 1234567890123456789012345678901 */
|
||||
#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
|
||||
#endif
|
||||
|
||||
#include "xmltok.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
XML_ROLE_ERROR = -1,
|
||||
XML_ROLE_NONE = 0,
|
||||
XML_ROLE_XML_DECL,
|
||||
XML_ROLE_INSTANCE_START,
|
||||
XML_ROLE_DOCTYPE_NONE,
|
||||
XML_ROLE_DOCTYPE_NAME,
|
||||
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
|
||||
XML_ROLE_DOCTYPE_CLOSE,
|
||||
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||
XML_ROLE_PARAM_ENTITY_NAME,
|
||||
XML_ROLE_ENTITY_NONE,
|
||||
XML_ROLE_ENTITY_VALUE,
|
||||
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||
XML_ROLE_ENTITY_COMPLETE,
|
||||
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_NONE,
|
||||
XML_ROLE_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_PUBLIC_ID,
|
||||
XML_ROLE_ATTRIBUTE_NAME,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||
XML_ROLE_ATTLIST_NONE,
|
||||
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_ELEMENT_NONE,
|
||||
XML_ROLE_ELEMENT_NAME,
|
||||
XML_ROLE_CONTENT_ANY,
|
||||
XML_ROLE_CONTENT_EMPTY,
|
||||
XML_ROLE_CONTENT_PCDATA,
|
||||
XML_ROLE_GROUP_OPEN,
|
||||
XML_ROLE_GROUP_CLOSE,
|
||||
XML_ROLE_GROUP_CLOSE_REP,
|
||||
XML_ROLE_GROUP_CLOSE_OPT,
|
||||
XML_ROLE_GROUP_CLOSE_PLUS,
|
||||
XML_ROLE_GROUP_CHOICE,
|
||||
XML_ROLE_GROUP_SEQUENCE,
|
||||
XML_ROLE_CONTENT_ELEMENT,
|
||||
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||
XML_ROLE_PI,
|
||||
XML_ROLE_COMMENT,
|
||||
#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
|
||||
};
|
||||
|
||||
typedef struct prolog_state {
|
||||
int (PTRCALL *handler) (struct prolog_state *state,
|
||||
int tok,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const ENCODING *enc);
|
||||
unsigned level;
|
||||
int role_none;
|
||||
#ifdef XML_DTD
|
||||
unsigned includeLevel;
|
||||
int documentEntity;
|
||||
int inEntityValue;
|
||||
#endif /* XML_DTD */
|
||||
} PROLOG_STATE;
|
||||
|
||||
void XmlPrologStateInit(PROLOG_STATE *);
|
||||
#ifdef XML_DTD
|
||||
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||
(((state)->handler)(state, tok, ptr, end, enc))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlRole_INCLUDED */
|
1684
expat/xmltok.c
Normal file
1684
expat/xmltok.c
Normal file
File diff suppressed because it is too large
Load Diff
316
expat/xmltok.h
Normal file
316
expat/xmltok.h
Normal file
@ -0,0 +1,316 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlTok_INCLUDED
|
||||
#define XmlTok_INCLUDED 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#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;
|
||||
might be part of CRLF sequence */
|
||||
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
|
||||
#define XML_TOK_PARTIAL -1 /* only part of a token */
|
||||
#define XML_TOK_INVALID 0
|
||||
|
||||
/* The following tokens are returned by XmlContentTok; some are also
|
||||
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
|
||||
*/
|
||||
#define XML_TOK_START_TAG_WITH_ATTS 1
|
||||
#define XML_TOK_START_TAG_NO_ATTS 2
|
||||
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
|
||||
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||
#define XML_TOK_END_TAG 5
|
||||
#define XML_TOK_DATA_CHARS 6
|
||||
#define XML_TOK_DATA_NEWLINE 7
|
||||
#define XML_TOK_CDATA_SECT_OPEN 8
|
||||
#define XML_TOK_ENTITY_REF 9
|
||||
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||
|
||||
/* The following tokens may be returned by both XmlPrologTok and
|
||||
XmlContentTok.
|
||||
*/
|
||||
#define XML_TOK_PI 11 /* processing instruction */
|
||||
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
|
||||
#define XML_TOK_COMMENT 13
|
||||
#define XML_TOK_BOM 14 /* Byte order mark */
|
||||
|
||||
/* The following tokens are returned only by XmlPrologTok */
|
||||
#define XML_TOK_PROLOG_S 15
|
||||
#define XML_TOK_DECL_OPEN 16 /* <!foo */
|
||||
#define XML_TOK_DECL_CLOSE 17 /* > */
|
||||
#define XML_TOK_NAME 18
|
||||
#define XML_TOK_NMTOKEN 19
|
||||
#define XML_TOK_POUND_NAME 20 /* #name */
|
||||
#define XML_TOK_OR 21 /* | */
|
||||
#define XML_TOK_PERCENT 22
|
||||
#define XML_TOK_OPEN_PAREN 23
|
||||
#define XML_TOK_CLOSE_PAREN 24
|
||||
#define XML_TOK_OPEN_BRACKET 25
|
||||
#define XML_TOK_CLOSE_BRACKET 26
|
||||
#define XML_TOK_LITERAL 27
|
||||
#define XML_TOK_PARAM_ENTITY_REF 28
|
||||
#define XML_TOK_INSTANCE_START 29
|
||||
|
||||
/* The following occur only in element type declarations */
|
||||
#define XML_TOK_NAME_QUESTION 30 /* name? */
|
||||
#define XML_TOK_NAME_ASTERISK 31 /* name* */
|
||||
#define XML_TOK_NAME_PLUS 32 /* name+ */
|
||||
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
|
||||
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
|
||||
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
|
||||
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
|
||||
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
|
||||
#define XML_TOK_COMMA 38
|
||||
|
||||
/* The following token is returned only by XmlAttributeValueTok */
|
||||
#define XML_TOK_ATTRIBUTE_VALUE_S 39
|
||||
|
||||
/* 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
|
||||
|
||||
/* 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 */
|
||||
XML_Size lineNumber;
|
||||
XML_Size columnNumber;
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *valuePtr;
|
||||
const char *valueEnd;
|
||||
char normalized;
|
||||
} ATTRIBUTE;
|
||||
|
||||
struct encoding;
|
||||
typedef struct encoding ENCODING;
|
||||
|
||||
typedef int (PTRCALL *SCANNER)(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char **);
|
||||
|
||||
struct encoding {
|
||||
SCANNER scanners[XML_N_STATES];
|
||||
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
||||
int (PTRCALL *sameName)(const ENCODING *,
|
||||
const char *,
|
||||
const char *);
|
||||
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char *);
|
||||
int (PTRFASTCALL *nameLength)(const ENCODING *, const char *);
|
||||
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
|
||||
int (PTRCALL *getAtts)(const ENCODING *enc,
|
||||
const char *ptr,
|
||||
int attsMax,
|
||||
ATTRIBUTE *atts);
|
||||
int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||
int (PTRCALL *predefinedEntityName)(const ENCODING *,
|
||||
const char *,
|
||||
const char *);
|
||||
void (PTRCALL *updatePosition)(const ENCODING *,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
POSITION *);
|
||||
int (PTRCALL *isPublicId)(const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr);
|
||||
void (PTRCALL *utf8Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
char **toP,
|
||||
const char *toLim);
|
||||
void (PTRCALL *utf16Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
unsigned short **toP,
|
||||
const unsigned short *toLim);
|
||||
int minBytesPerChar;
|
||||
char isUtf8;
|
||||
char isUtf16;
|
||||
};
|
||||
|
||||
/* Scan the string starting at ptr until the end of the next complete
|
||||
token, but do not scan past eptr. Return an integer giving the
|
||||
type of token.
|
||||
|
||||
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_PARTIAL when the string does not contain a complete
|
||||
token; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_INVALID when the string does not start a valid
|
||||
token; nextTokPtr will be set to point to the character which made
|
||||
the token invalid.
|
||||
|
||||
Otherwise the string starts with a valid token; nextTokPtr will be
|
||||
set to point to the character following the end of that token.
|
||||
|
||||
Each data character counts as a single token, but adjacent data
|
||||
characters may be returned together. Similarly for characters in
|
||||
the prolog outside literals, comments and processing instructions.
|
||||
*/
|
||||
|
||||
|
||||
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
|
||||
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#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.
|
||||
*/
|
||||
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
|
||||
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||
|
||||
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||
|
||||
#define XmlNameLength(enc, ptr) \
|
||||
(((enc)->nameLength)(enc, ptr))
|
||||
|
||||
#define XmlSkipS(enc, ptr) \
|
||||
(((enc)->skipS)(enc, ptr))
|
||||
|
||||
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
|
||||
(((enc)->getAtts)(enc, ptr, attsMax, atts))
|
||||
|
||||
#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 XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
typedef struct {
|
||||
ENCODING initEnc;
|
||||
const ENCODING **encPtr;
|
||||
} INIT_ENCODING;
|
||||
|
||||
int XmlParseXmlDecl(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **versionEndPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr,
|
||||
int *standalonePtr);
|
||||
|
||||
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncoding(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncoding(void);
|
||||
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
|
||||
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||
int XmlSizeOfUnknownEncoding(void);
|
||||
|
||||
|
||||
typedef int (XMLCALL *CONVERTER) (void *userData, const char *p);
|
||||
|
||||
ENCODING *
|
||||
XmlInitUnknownEncoding(void *mem,
|
||||
int *table,
|
||||
CONVERTER convert,
|
||||
void *userData);
|
||||
|
||||
int XmlParseXmlDeclNS(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **versionEndPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr,
|
||||
int *standalonePtr);
|
||||
|
||||
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
|
||||
ENCODING *
|
||||
XmlInitUnknownEncodingNS(void *mem,
|
||||
int *table,
|
||||
CONVERTER convert,
|
||||
void *userData);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlTok_INCLUDED */
|
1800
expat/xmltok_impl.c
Normal file
1800
expat/xmltok_impl.c
Normal file
File diff suppressed because it is too large
Load Diff
46
expat/xmltok_impl.h
Normal file
46
expat/xmltok_impl.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
enum {
|
||||
BT_NONXML,
|
||||
BT_MALFORM,
|
||||
BT_LT,
|
||||
BT_AMP,
|
||||
BT_RSQB,
|
||||
BT_LEAD2,
|
||||
BT_LEAD3,
|
||||
BT_LEAD4,
|
||||
BT_TRAIL,
|
||||
BT_CR,
|
||||
BT_LF,
|
||||
BT_GT,
|
||||
BT_QUOT,
|
||||
BT_APOS,
|
||||
BT_EQUALS,
|
||||
BT_QUEST,
|
||||
BT_EXCL,
|
||||
BT_SOL,
|
||||
BT_SEMI,
|
||||
BT_NUM,
|
||||
BT_LSQB,
|
||||
BT_S,
|
||||
BT_NMSTRT,
|
||||
BT_COLON,
|
||||
BT_HEX,
|
||||
BT_DIGIT,
|
||||
BT_NAME,
|
||||
BT_MINUS,
|
||||
BT_OTHER, /* known not to be a name or name start character */
|
||||
BT_NONASCII, /* might be a name or name start character */
|
||||
BT_PERCNT,
|
||||
BT_LPAR,
|
||||
BT_RPAR,
|
||||
BT_AST,
|
||||
BT_PLUS,
|
||||
BT_COMMA,
|
||||
BT_VERBAR
|
||||
};
|
||||
|
||||
#include <stddef.h>
|
119
expat/xmltok_ns.c
Normal file
119
expat/xmltok_ns.c
Normal file
@ -0,0 +1,119 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* This file is included! */
|
||||
#ifdef XML_TOK_NS_C
|
||||
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf8InternalEncoding)(void)
|
||||
{
|
||||
return &ns(internal_utf8_encoding).enc;
|
||||
}
|
||||
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf16InternalEncoding)(void)
|
||||
{
|
||||
#if BYTEORDER == 1234
|
||||
return &ns(internal_little2_encoding).enc;
|
||||
#elif BYTEORDER == 4321
|
||||
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 * const 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 PTRCALL
|
||||
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 PTRCALL
|
||||
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 **versionEndPtr,
|
||||
const char **encodingName,
|
||||
const ENCODING **encoding,
|
||||
int *standalone)
|
||||
{
|
||||
return doParseXmlDecl(NS(findEncoding),
|
||||
isGeneralTextEntity,
|
||||
enc,
|
||||
ptr,
|
||||
end,
|
||||
badPtr,
|
||||
versionPtr,
|
||||
versionEndPtr,
|
||||
encodingName,
|
||||
encoding,
|
||||
standalone);
|
||||
}
|
||||
|
||||
#else /* XML_TOK_NS_C */
|
||||
|
||||
int xml_tok_ns_c;
|
||||
|
||||
#endif /* XML_TOK_NS_C */
|
599
source/LuaExpat/lxplib.c
Normal file
599
source/LuaExpat/lxplib.c
Normal file
@ -0,0 +1,599 @@
|
||||
/*
|
||||
** $Id: lxplib.c,v 1.16 2007/06/05 20:03:12 carregal Exp $
|
||||
** LuaExpat: Lua bind for Expat library
|
||||
** See Copyright Notice in license.html
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "expat.h"
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
|
||||
#include "lxplib.h"
|
||||
|
||||
|
||||
#if !defined(lua_pushliteral)
|
||||
#define lua_pushliteral(L, s) \
|
||||
lua_pushstring(L, "" s, (sizeof(s)/sizeof(char))-1)
|
||||
#endif
|
||||
|
||||
|
||||
enum XPState {
|
||||
XPSpre, /* parser just initialized */
|
||||
XPSok, /* state while parsing */
|
||||
XPSfinished, /* state after finished parsing */
|
||||
XPSerror,
|
||||
XPSstring /* state while reading a string */
|
||||
};
|
||||
|
||||
struct lxp_userdata {
|
||||
lua_State *L;
|
||||
XML_Parser parser; /* associated expat parser */
|
||||
int tableref; /* table with callbacks for this parser */
|
||||
enum XPState state;
|
||||
luaL_Buffer *b; /* to concatenate sequences of cdata pieces */
|
||||
};
|
||||
|
||||
typedef struct lxp_userdata lxp_userdata;
|
||||
|
||||
|
||||
static int reporterror (lxp_userdata *xpu) {
|
||||
lua_State *L = xpu->L;
|
||||
XML_Parser p = xpu->parser;
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, XML_ErrorString(XML_GetErrorCode(p)));
|
||||
lua_pushnumber(L, XML_GetCurrentLineNumber(p));
|
||||
lua_pushnumber(L, XML_GetCurrentColumnNumber(p) + 1);
|
||||
lua_pushnumber(L, XML_GetCurrentByteIndex(p) + 1);
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
static lxp_userdata *createlxp (lua_State *L) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)lua_newuserdata(L, sizeof(lxp_userdata));
|
||||
xpu->tableref = LUA_REFNIL; /* in case of errors... */
|
||||
xpu->parser = NULL;
|
||||
xpu->L = NULL;
|
||||
xpu->state = XPSpre;
|
||||
luaL_getmetatable(L, ParserType);
|
||||
lua_setmetatable(L, -2);
|
||||
return xpu;
|
||||
}
|
||||
|
||||
|
||||
static void lxpclose (lua_State *L, lxp_userdata *xpu) {
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, xpu->tableref);
|
||||
xpu->tableref = LUA_REFNIL;
|
||||
if (xpu->parser)
|
||||
XML_ParserFree(xpu->parser);
|
||||
xpu->parser = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Auxiliary function to call a Lua handle
|
||||
*/
|
||||
static void docall (lxp_userdata *xpu, int nargs, int nres) {
|
||||
lua_State *L = xpu->L;
|
||||
assert(xpu->state == XPSok);
|
||||
if (lua_pcall(L, nargs + 1, nres, 0) != 0) {
|
||||
xpu->state = XPSerror;
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, xpu->tableref);
|
||||
xpu->tableref = luaL_ref(L, LUA_REGISTRYINDEX); /* error message */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Check whether there is pending Cdata, and call its handle if necessary
|
||||
*/
|
||||
static void dischargestring (lxp_userdata *xpu) {
|
||||
assert(xpu->state == XPSstring);
|
||||
xpu->state = XPSok;
|
||||
luaL_pushresult(xpu->b);
|
||||
docall(xpu, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Check whether there is a Lua handle for a given event: If so,
|
||||
** put it on the stack (to be called later), and also push `self'
|
||||
*/
|
||||
static int getHandle (lxp_userdata *xpu, const char *handle) {
|
||||
lua_State *L = xpu->L;
|
||||
if (xpu->state == XPSstring) dischargestring(xpu);
|
||||
if (xpu->state == XPSerror)
|
||||
return 0; /* some error happened before; skip all handles */
|
||||
lua_pushstring(L, handle);
|
||||
lua_gettable(L, 3);
|
||||
if (lua_toboolean(L, -1) == 0) {
|
||||
lua_pop(L, 1);
|
||||
return 0;
|
||||
}
|
||||
if (!lua_isfunction(L, -1)) {
|
||||
luaL_error(L, "lxp `%s' callback is not a function", handle);
|
||||
}
|
||||
lua_pushvalue(L, 1); /* first argument in every call (self) */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** {======================================================
|
||||
** Handles
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
|
||||
static void f_StartCdata (void *ud) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (getHandle(xpu, StartCdataKey) == 0) return; /* no handle */
|
||||
docall(xpu, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void f_EndCdataKey (void *ud) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (getHandle(xpu, EndCdataKey) == 0) return; /* no handle */
|
||||
docall(xpu, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void f_CharData (void *ud, const char *s, int len) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (xpu->state == XPSok) {
|
||||
if (getHandle(xpu, CharDataKey) == 0) return; /* no handle */
|
||||
xpu->state = XPSstring;
|
||||
luaL_buffinit(xpu->L, xpu->b);
|
||||
}
|
||||
if (xpu->state == XPSstring)
|
||||
luaL_addlstring(xpu->b, s, len);
|
||||
}
|
||||
|
||||
|
||||
static void f_Comment (void *ud, const char *data) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (getHandle(xpu, CommentKey) == 0) return; /* no handle */
|
||||
lua_pushstring(xpu->L, data);
|
||||
docall(xpu, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
static void f_Default (void *ud, const char *data, int len) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (getHandle(xpu, DefaultKey) == 0) return; /* no handle */
|
||||
lua_pushlstring(xpu->L, data, len);
|
||||
docall(xpu, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
static void f_DefaultExpand (void *ud, const char *data, int len) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (getHandle(xpu, DefaultExpandKey) == 0) return; /* no handle */
|
||||
lua_pushlstring(xpu->L, data, len);
|
||||
docall(xpu, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
static void f_StartElement (void *ud, const char *name, const char **attrs) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
lua_State *L = xpu->L;
|
||||
int lastspec = XML_GetSpecifiedAttributeCount(xpu->parser) / 2;
|
||||
int i = 1;
|
||||
if (getHandle(xpu, StartElementKey) == 0) return; /* no handle */
|
||||
lua_pushstring(L, name);
|
||||
lua_newtable(L);
|
||||
while (*attrs) {
|
||||
if (i <= lastspec) {
|
||||
lua_pushnumber(L, i++);
|
||||
lua_pushstring(L, *attrs);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
lua_pushstring(L, *attrs++);
|
||||
lua_pushstring(L, *attrs++);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
docall(xpu, 2, 0); /* call function with self, name, and attributes */
|
||||
}
|
||||
|
||||
|
||||
static void f_EndElement (void *ud, const char *name) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (getHandle(xpu, EndElementKey) == 0) return; /* no handle */
|
||||
lua_pushstring(xpu->L, name);
|
||||
docall(xpu, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
static int f_ExternaEntity (XML_Parser p, const char *context,
|
||||
const char *base,
|
||||
const char *systemId,
|
||||
const char *publicId) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)XML_GetUserData(p);
|
||||
lua_State *L = xpu->L;
|
||||
lxp_userdata *child;
|
||||
int status;
|
||||
if (getHandle(xpu, ExternalEntityKey) == 0) return 1; /* no handle */
|
||||
child = createlxp(L);
|
||||
child->parser = XML_ExternalEntityParserCreate(p, context, NULL);
|
||||
if (!child->parser)
|
||||
luaL_error(L, "XML_ParserCreate failed");
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, xpu->tableref); /*lua_getref(L, xpu->tableref); */ /* child uses the same table of its father */
|
||||
child->tableref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
lua_pushstring(L, base);
|
||||
lua_pushstring(L, systemId);
|
||||
lua_pushstring(L, publicId);
|
||||
docall(xpu, 4, 1);
|
||||
status = lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
lxpclose(L, child);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static void f_StartNamespaceDecl (void *ud, const char *prefix,
|
||||
const char *uri) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
lua_State *L = xpu->L;
|
||||
if (getHandle(xpu, StartNamespaceDeclKey) == 0) return; /* no handle */
|
||||
lua_pushstring(L, prefix);
|
||||
lua_pushstring(L, uri);
|
||||
docall(xpu, 2, 0);
|
||||
}
|
||||
|
||||
|
||||
static void f_EndNamespaceDecl (void *ud, const char *prefix) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (getHandle(xpu, EndNamespaceDeclKey) == 0) return; /* no handle */
|
||||
lua_pushstring(xpu->L, prefix);
|
||||
docall(xpu, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
static void f_NotationDecl (void *ud, const char *notationName,
|
||||
const char *base,
|
||||
const char *systemId,
|
||||
const char *publicId) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
lua_State *L = xpu->L;
|
||||
if (getHandle(xpu, NotationDeclKey) == 0) return; /* no handle */
|
||||
lua_pushstring(L, notationName);
|
||||
lua_pushstring(L, base);
|
||||
lua_pushstring(L, systemId);
|
||||
lua_pushstring(L, publicId);
|
||||
docall(xpu, 4, 0);
|
||||
}
|
||||
|
||||
|
||||
static int f_NotStandalone (void *ud) {
|
||||
int status;
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
lua_State *L = xpu->L;
|
||||
if (getHandle(xpu, NotStandaloneKey) == 0) return 1; /* no handle */
|
||||
docall(xpu, 0, 1);
|
||||
status = lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static void f_ProcessingInstruction (void *ud, const char *target,
|
||||
const char *data) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
lua_State *L = xpu->L;
|
||||
if (getHandle(xpu, ProcessingInstructionKey) == 0) return; /* no handle */
|
||||
lua_pushstring(L, target);
|
||||
lua_pushstring(L, data);
|
||||
docall(xpu, 2, 0);
|
||||
}
|
||||
|
||||
|
||||
static void f_UnparsedEntityDecl (void *ud, const char *entityName,
|
||||
const char *base,
|
||||
const char *systemId,
|
||||
const char *publicId,
|
||||
const char *notationName) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
lua_State *L = xpu->L;
|
||||
if (getHandle(xpu, UnparsedEntityDeclKey) == 0) return; /* no handle */
|
||||
lua_pushstring(L, entityName);
|
||||
lua_pushstring(L, base);
|
||||
lua_pushstring(L, systemId);
|
||||
lua_pushstring(L, publicId);
|
||||
lua_pushstring(L, notationName);
|
||||
docall(xpu, 5, 0);
|
||||
}
|
||||
|
||||
static void f_StartDoctypeDecl (void *ud, const XML_Char *doctypeName,
|
||||
const XML_Char *sysid,
|
||||
const XML_Char *pubid,
|
||||
int has_internal_subset) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)ud;
|
||||
if (getHandle(xpu, StartDoctypeDeclKey) == 0) return; /* no handle */
|
||||
lua_pushstring(xpu->L, doctypeName);
|
||||
lua_pushstring(xpu->L, sysid);
|
||||
lua_pushstring(xpu->L, pubid);
|
||||
lua_pushboolean(xpu->L, has_internal_subset);
|
||||
docall(xpu, 4, 0);
|
||||
}
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
|
||||
static int hasfield (lua_State *L, const char *fname) {
|
||||
int res;
|
||||
lua_pushstring(L, fname);
|
||||
lua_gettable(L, 1);
|
||||
res = !lua_isnil(L, -1);
|
||||
lua_pop(L, 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static void checkcallbacks (lua_State *L) {
|
||||
static const char *const validkeys[] = {
|
||||
"StartCdataSection", "EndCdataSection", "CharacterData", "Comment",
|
||||
"Default", "DefaultExpand", "StartElement", "EndElement",
|
||||
"ExternalEntityRef", "StartNamespaceDecl", "EndNamespaceDecl",
|
||||
"NotationDecl", "NotStandalone", "ProcessingInstruction",
|
||||
"UnparsedEntityDecl", "StartDoctypeDecl", NULL};
|
||||
if (hasfield(L, "_nonstrict")) return;
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 1)) {
|
||||
lua_pop(L, 1); /* remove value */
|
||||
#if ! defined (LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
|
||||
if (lua_type(L, -1) != LUA_TSTRING ||
|
||||
luaL_findstring(lua_tostring(L, -1), validkeys) < 0)
|
||||
luaL_error(L, "invalid key `%s' in callback table", lua_tostring(L, -1));
|
||||
#else
|
||||
luaL_checkoption(L, -1, NULL, validkeys);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int lxp_make_parser (lua_State *L) {
|
||||
XML_Parser p;
|
||||
char sep = *luaL_optstring(L, 2, "");
|
||||
lxp_userdata *xpu = createlxp(L);
|
||||
p = xpu->parser = (sep == '\0') ? XML_ParserCreate(NULL) :
|
||||
XML_ParserCreateNS(NULL, sep);
|
||||
if (!p)
|
||||
luaL_error(L, "XML_ParserCreate failed");
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
checkcallbacks(L);
|
||||
lua_pushvalue(L, 1);
|
||||
xpu->tableref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
XML_SetUserData(p, xpu);
|
||||
if (hasfield(L, StartCdataKey) || hasfield(L, EndCdataKey))
|
||||
XML_SetCdataSectionHandler(p, f_StartCdata, f_EndCdataKey);
|
||||
if (hasfield(L, CharDataKey))
|
||||
XML_SetCharacterDataHandler(p, f_CharData);
|
||||
if (hasfield(L, CommentKey))
|
||||
XML_SetCommentHandler(p, f_Comment);
|
||||
if (hasfield(L, DefaultKey))
|
||||
XML_SetDefaultHandler(p, f_Default);
|
||||
if (hasfield(L, DefaultExpandKey))
|
||||
XML_SetDefaultHandlerExpand(p, f_DefaultExpand);
|
||||
if (hasfield(L, StartElementKey) || hasfield(L, EndElementKey))
|
||||
XML_SetElementHandler(p, f_StartElement, f_EndElement);
|
||||
if (hasfield(L, ExternalEntityKey))
|
||||
XML_SetExternalEntityRefHandler(p, f_ExternaEntity);
|
||||
if (hasfield(L, StartNamespaceDeclKey) || hasfield(L, EndNamespaceDeclKey))
|
||||
XML_SetNamespaceDeclHandler(p, f_StartNamespaceDecl, f_EndNamespaceDecl);
|
||||
if (hasfield(L, NotationDeclKey))
|
||||
XML_SetNotationDeclHandler(p, f_NotationDecl);
|
||||
if (hasfield(L, NotStandaloneKey))
|
||||
XML_SetNotStandaloneHandler(p, f_NotStandalone);
|
||||
if (hasfield(L, ProcessingInstructionKey))
|
||||
XML_SetProcessingInstructionHandler(p, f_ProcessingInstruction);
|
||||
if (hasfield(L, UnparsedEntityDeclKey))
|
||||
XML_SetUnparsedEntityDeclHandler(p, f_UnparsedEntityDecl);
|
||||
if (hasfield(L, StartDoctypeDeclKey))
|
||||
XML_SetStartDoctypeDeclHandler(p, f_StartDoctypeDecl);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static lxp_userdata *checkparser (lua_State *L, int idx) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)luaL_checkudata(L, idx, ParserType);
|
||||
luaL_argcheck(L, xpu, idx, "expat parser expected");
|
||||
luaL_argcheck(L, xpu->parser, idx, "parser is closed");
|
||||
return xpu;
|
||||
}
|
||||
|
||||
|
||||
static int parser_gc (lua_State *L) {
|
||||
lxp_userdata *xpu = (lxp_userdata *)luaL_checkudata(L, 1, ParserType);
|
||||
luaL_argcheck(L, xpu, 1, "expat parser expected");
|
||||
lxpclose(L, xpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int setbase (lua_State *L) {
|
||||
lxp_userdata *xpu = checkparser(L, 1);
|
||||
if (XML_SetBase(xpu->parser, luaL_checkstring(L, 2)) == 0)
|
||||
luaL_error(L, "no memory to store base");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int getbase (lua_State *L) {
|
||||
lxp_userdata *xpu = checkparser(L, 1);
|
||||
lua_pushstring(L, XML_GetBase(xpu->parser));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int getcallbacks (lua_State *L) {
|
||||
lxp_userdata *xpu = checkparser(L, 1);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, xpu->tableref);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int parse_aux (lua_State *L, lxp_userdata *xpu, const char *s,
|
||||
size_t len) {
|
||||
luaL_Buffer b;
|
||||
int status;
|
||||
xpu->L = L;
|
||||
xpu->state = XPSok;
|
||||
xpu->b = &b;
|
||||
lua_settop(L, 2);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, xpu->tableref); /*lua_getref(L, xpu->tableref);*/ /* to be used by handlers */
|
||||
status = XML_Parse(xpu->parser, s, (int)len, s == NULL);
|
||||
if (xpu->state == XPSstring) dischargestring(xpu);
|
||||
if (xpu->state == XPSerror) { /* callback error? */
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, xpu->tableref); /* get original msg. */
|
||||
lua_error(L);
|
||||
}
|
||||
if (s == NULL) xpu->state = XPSfinished;
|
||||
if (status) {
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
}
|
||||
else { /* error */
|
||||
return reporterror(xpu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int lxp_parse (lua_State *L) {
|
||||
lxp_userdata *xpu = checkparser(L, 1);
|
||||
size_t len;
|
||||
const char *s = luaL_optlstring(L, 2, NULL, &len);
|
||||
if (xpu->state == XPSfinished && s != NULL) {
|
||||
lua_pushnil(L);
|
||||
lua_pushliteral(L, "cannot parse - document is finished");
|
||||
return 2;
|
||||
}
|
||||
return parse_aux(L, xpu, s, len);
|
||||
}
|
||||
|
||||
|
||||
static int lxp_close (lua_State *L) {
|
||||
int status = 1;
|
||||
lxp_userdata *xpu = (lxp_userdata *)luaL_checkudata(L, 1, ParserType);
|
||||
luaL_argcheck(L, xpu, 1, "expat parser expected");
|
||||
if (xpu->state != XPSfinished)
|
||||
status = parse_aux(L, xpu, NULL, 0);
|
||||
lxpclose(L, xpu);
|
||||
if (status > 1) luaL_error(L, "error closing parser: %s",
|
||||
lua_tostring(L, -status+1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int lxp_pos (lua_State *L) {
|
||||
lxp_userdata *xpu = checkparser(L, 1);
|
||||
XML_Parser p = xpu->parser;
|
||||
lua_pushnumber(L, XML_GetCurrentLineNumber(p));
|
||||
lua_pushnumber(L, XML_GetCurrentColumnNumber(p) + 1);
|
||||
lua_pushnumber(L, XML_GetCurrentByteIndex(p) + 1);
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
static int lxp_setencoding (lua_State *L) {
|
||||
lxp_userdata *xpu = checkparser(L, 1);
|
||||
const char *encoding = luaL_checkstring(L, 2);
|
||||
luaL_argcheck(L, xpu->state == XPSpre, 1, "invalid parser state");
|
||||
XML_SetEncoding(xpu->parser, encoding);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lxp_stop (lua_State *L) {
|
||||
lxp_userdata *xpu = checkparser(L, 1);
|
||||
lua_pushboolean(L, XML_StopParser(xpu->parser, XML_FALSE) == XML_STATUS_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined LUA_VERSION_NUM
|
||||
/* Lua 5.0 */
|
||||
#define luaL_Reg luaL_reg
|
||||
#endif
|
||||
|
||||
static const struct luaL_Reg lxp_meths[] = {
|
||||
{"parse", lxp_parse},
|
||||
{"close", lxp_close},
|
||||
{"__gc", parser_gc},
|
||||
{"pos", lxp_pos},
|
||||
{"setencoding", lxp_setencoding},
|
||||
{"getcallbacks", getcallbacks},
|
||||
{"getbase", getbase},
|
||||
{"setbase", setbase},
|
||||
{"stop", lxp_stop},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static const struct luaL_Reg lxp_funcs[] = {
|
||||
{"new", lxp_make_parser},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** Assumes the table is on top of the stack.
|
||||
*/
|
||||
static void set_info (lua_State *L) {
|
||||
lua_pushliteral (L, "_COPYRIGHT");
|
||||
lua_pushliteral (L, "Copyright (C) 2003-2012 Kepler Project");
|
||||
lua_settable (L, -3);
|
||||
lua_pushliteral (L, "_DESCRIPTION");
|
||||
lua_pushliteral (L, "LuaExpat is a SAX XML parser based on the Expat library");
|
||||
lua_settable (L, -3);
|
||||
lua_pushliteral (L, "_VERSION");
|
||||
lua_pushliteral (L, "LuaExpat 1.3.0");
|
||||
lua_settable (L, -3);
|
||||
}
|
||||
|
||||
|
||||
#if !defined LUA_VERSION_NUM || LUA_VERSION_NUM==501
|
||||
/*
|
||||
** Adapted from Lua 5.2.0
|
||||
*/
|
||||
static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
|
||||
luaL_checkstack(L, nup, "too many upvalues");
|
||||
for (; l->name != NULL; l++) { /* fill the table with given functions */
|
||||
int i;
|
||||
for (i = 0; i < nup; i++) /* copy upvalues to the top */
|
||||
lua_pushvalue(L, -nup);
|
||||
lua_pushstring(L, l->name);
|
||||
lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
|
||||
lua_settable(L, -(nup + 3));
|
||||
}
|
||||
lua_pop(L, nup); /* remove upvalues */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int luaopen_lxp (lua_State *L) {
|
||||
luaL_newmetatable(L, ParserType);
|
||||
|
||||
lua_pushliteral(L, "__index");
|
||||
lua_pushvalue(L, -2);
|
||||
lua_rawset(L, -3);
|
||||
|
||||
luaL_setfuncs (L, lxp_meths, 0);
|
||||
lua_pop (L, 1); /* remove metatable */
|
||||
|
||||
// _X 2013_04_09: Modified to allow embedding
|
||||
luaL_openlib (L, "lxp", lxp_funcs, 0);
|
||||
/*
|
||||
lua_newtable (L);
|
||||
luaL_setfuncs (L, lxp_funcs, 0);
|
||||
*/
|
||||
set_info (L);
|
||||
return 1;
|
||||
}
|
24
source/LuaExpat/lxplib.h
Normal file
24
source/LuaExpat/lxplib.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
** See Copyright Notice in license.html
|
||||
*/
|
||||
|
||||
#define ParserType "Expat"
|
||||
|
||||
#define StartCdataKey "StartCdataSection"
|
||||
#define EndCdataKey "EndCdataSection"
|
||||
#define CharDataKey "CharacterData"
|
||||
#define CommentKey "Comment"
|
||||
#define DefaultKey "Default"
|
||||
#define DefaultExpandKey "DefaultExpand"
|
||||
#define StartElementKey "StartElement"
|
||||
#define EndElementKey "EndElement"
|
||||
#define ExternalEntityKey "ExternalEntityRef"
|
||||
#define StartNamespaceDeclKey "StartNamespaceDecl"
|
||||
#define EndNamespaceDeclKey "EndNamespaceDecl"
|
||||
#define NotationDeclKey "NotationDecl"
|
||||
#define NotStandaloneKey "NotStandalone"
|
||||
#define ProcessingInstructionKey "ProcessingInstruction"
|
||||
#define UnparsedEntityDeclKey "UnparsedEntityDecl"
|
||||
#define StartDoctypeDeclKey "StartDoctypeDecl"
|
||||
|
||||
int luaopen_lxp (lua_State *L);
|
@ -24,6 +24,12 @@ extern "C"
|
||||
LUALIB_API int luaopen_lsqlite3(lua_State * L);
|
||||
}
|
||||
|
||||
// fwd: LuaExpat/lxplib.c:
|
||||
extern "C"
|
||||
{
|
||||
int luaopen_lxp(lua_State * L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -84,6 +90,7 @@ bool cPlugin_NewLua::Initialize(void)
|
||||
tolua_AllToLua_open(m_LuaState);
|
||||
ManualBindings::Bind(m_LuaState);
|
||||
luaopen_lsqlite3(m_LuaState);
|
||||
luaopen_lxp(m_LuaState);
|
||||
|
||||
// Inject the identification global variables into the state:
|
||||
lua_pushlightuserdata(m_LuaState, this);
|
||||
|
701
source/XMLParser.h
Normal file
701
source/XMLParser.h
Normal file
@ -0,0 +1,701 @@
|
||||
|
||||
// XMLParser.h
|
||||
|
||||
// Interfaces to the CXMLParser class representing the base class for XML parsing
|
||||
|
||||
// To use, derive a class from this base and override its OnStartElement(), OnEndElement() and OnCharacters() functions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "expat/expat.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CXMLParser
|
||||
{
|
||||
public:
|
||||
CXMLParser(void);
|
||||
virtual ~CXMLParser();
|
||||
|
||||
// The actual parsing, may be called several times; the last time needs iIsFinal == true (-> flush)
|
||||
int Parse(const char * iData, size_t iLength, bool iIsFinal = false);
|
||||
|
||||
private:
|
||||
// LibExpat stuff:
|
||||
XML_Parser mParser;
|
||||
|
||||
static void StartElementHandler(void * iContext, const XML_Char * iElement, const XML_Char ** iAttributes)
|
||||
{
|
||||
((CXMLParser *)iContext)->OnStartElement(iElement, iAttributes);
|
||||
}
|
||||
|
||||
static void EndElementHandler (void * iContext, const XML_Char * iElement)
|
||||
{
|
||||
((CXMLParser *)iContext)->OnEndElement(iElement);
|
||||
}
|
||||
|
||||
static void CharacterDataHandler (void * iContext, const XML_Char * iData, int iLength)
|
||||
{
|
||||
((CXMLParser *)iContext)->OnCharacters(iData, iLength);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void OnStartElement(const XML_Char * iElement, const XML_Char ** iAttributes) = 0;
|
||||
virtual void OnEndElement (const XML_Char * iElement) = 0;
|
||||
virtual void OnCharacters (const XML_Char * iCharacters, int iLength) = 0;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// The following template has been modified from code available at
|
||||
// http://www.codeproject.com/Articles/1847/C-Wrappers-for-the-Expat-XML-Parser
|
||||
// It uses templates to remove the virtual function call penalty (both size and speed) for each callback
|
||||
|
||||
/* Usage:
|
||||
1, Declare a subclass:
|
||||
class CMyParser : public CExpatImpl<CMyParser>
|
||||
2, Declare handlers that you want in that subclass:
|
||||
void CMyParser::OnEndElement(const XML_Char * iTagName);
|
||||
3, Create an instance of your class:
|
||||
CMyParser Parser;
|
||||
4, Call Create():
|
||||
Parser.Create(NULL, NULL);
|
||||
4, Call Parse(), repeatedly:
|
||||
Parser.Parse(Buffer, Length);
|
||||
*/
|
||||
|
||||
template <class _T>
|
||||
class CExpatImpl
|
||||
{
|
||||
|
||||
// @access Constructors and destructors
|
||||
public:
|
||||
|
||||
// @cmember General constructor
|
||||
|
||||
CExpatImpl ()
|
||||
{
|
||||
m_p = NULL;
|
||||
}
|
||||
|
||||
// @cmember Destructor
|
||||
|
||||
~CExpatImpl ()
|
||||
{
|
||||
Destroy ();
|
||||
}
|
||||
|
||||
// @access Parser creation and deletion methods
|
||||
public:
|
||||
|
||||
// @cmember Create a parser
|
||||
|
||||
bool Create (const XML_Char * pszEncoding = NULL, const XML_Char * pszSep = NULL)
|
||||
{
|
||||
// Destroy the old parser
|
||||
Destroy ();
|
||||
|
||||
// If the encoding or seperator are empty, then NULL
|
||||
if (pszEncoding != NULL && pszEncoding [0] == 0)
|
||||
{
|
||||
pszEncoding = NULL;
|
||||
}
|
||||
if (pszSep != NULL && pszSep [0] == 0)
|
||||
{
|
||||
pszSep = NULL;
|
||||
}
|
||||
|
||||
// Create the new parser
|
||||
m_p = XML_ParserCreate_MM (pszEncoding, NULL, pszSep);
|
||||
if (m_p == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Invoke the post create routine
|
||||
_T * pThis = static_cast <_T *> (this);
|
||||
pThis ->OnPostCreate ();
|
||||
|
||||
// Set the user data used in callbacks
|
||||
XML_SetUserData (m_p, (void *) this);
|
||||
return true;
|
||||
}
|
||||
|
||||
// @cmember Destroy the parser
|
||||
|
||||
void Destroy (void)
|
||||
{
|
||||
if (m_p != NULL)
|
||||
{
|
||||
XML_ParserFree (m_p);
|
||||
}
|
||||
m_p = NULL;
|
||||
}
|
||||
|
||||
|
||||
// @cmember Parse a block of data
|
||||
|
||||
bool Parse (const char *pszBuffer, int nLength, bool fIsFinal = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_Parse (m_p, pszBuffer, nLength, fIsFinal) != 0;
|
||||
}
|
||||
|
||||
// @cmember Parse internal buffer
|
||||
|
||||
bool ParseBuffer (int nLength, bool fIsFinal = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_ParseBuffer (m_p, nLength, fIsFinal) != 0;
|
||||
}
|
||||
|
||||
// @cmember Get the internal buffer
|
||||
|
||||
void *GetBuffer (int nLength)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_GetBuffer (m_p, nLength);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
// Parser callback enable/disable methods:
|
||||
|
||||
// @cmember Enable/Disable the start element handler
|
||||
|
||||
void EnableStartElementHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetStartElementHandler (m_p, fEnable ? StartElementHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the end element handler
|
||||
|
||||
void EnableEndElementHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetEndElementHandler (m_p, fEnable ? EndElementHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the element handlers
|
||||
|
||||
void EnableElementHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
EnableStartElementHandler (fEnable);
|
||||
EnableEndElementHandler (fEnable);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the character data handler
|
||||
|
||||
void EnableCharacterDataHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetCharacterDataHandler (m_p, fEnable ? CharacterDataHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the processing instruction handler
|
||||
|
||||
void EnableProcessingInstructionHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetProcessingInstructionHandler (m_p, fEnable ? ProcessingInstructionHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the comment handler
|
||||
|
||||
void EnableCommentHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetCommentHandler (m_p, fEnable ? CommentHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the start CDATA section handler
|
||||
|
||||
void EnableStartCdataSectionHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetStartCdataSectionHandler (m_p, fEnable ? StartCdataSectionHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the end CDATA section handler
|
||||
|
||||
void EnableEndCdataSectionHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetEndCdataSectionHandler (m_p, fEnable ? EndCdataSectionHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the CDATA section handlers
|
||||
|
||||
void EnableCdataSectionHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
EnableStartCdataSectionHandler (fEnable);
|
||||
EnableEndCdataSectionHandler (fEnable);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable default handler
|
||||
|
||||
void EnableDefaultHandler (bool fEnable = true, bool fExpand = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
if (fExpand)
|
||||
{
|
||||
XML_SetDefaultHandlerExpand (m_p, fEnable ? DefaultHandler : NULL);
|
||||
}
|
||||
else
|
||||
XML_SetDefaultHandler (m_p, fEnable ? DefaultHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable external entity ref handler
|
||||
|
||||
void EnableExternalEntityRefHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetExternalEntityRefHandler (m_p, fEnable ? ExternalEntityRefHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable unknown encoding handler
|
||||
|
||||
void EnableUnknownEncodingHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetUnknownEncodingHandler (m_p, fEnable ? UnknownEncodingHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable start namespace handler
|
||||
|
||||
void EnableStartNamespaceDeclHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetStartNamespaceDeclHandler (m_p, fEnable ? StartNamespaceDeclHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable end namespace handler
|
||||
|
||||
void EnableEndNamespaceDeclHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetEndNamespaceDeclHandler (m_p, fEnable ? EndNamespaceDeclHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable namespace handlers
|
||||
|
||||
void EnableNamespaceDeclHandler (bool fEnable = true)
|
||||
{
|
||||
EnableStartNamespaceDeclHandler (fEnable);
|
||||
EnableEndNamespaceDeclHandler (fEnable);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the XML declaration handler
|
||||
|
||||
void EnableXmlDeclHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetXmlDeclHandler (m_p, fEnable ? XmlDeclHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the start DOCTYPE declaration handler
|
||||
|
||||
void EnableStartDoctypeDeclHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetStartDoctypeDeclHandler (m_p, fEnable ? StartDoctypeDeclHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the end DOCTYPE declaration handler
|
||||
|
||||
void EnableEndDoctypeDeclHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
XML_SetEndDoctypeDeclHandler (m_p,
|
||||
fEnable ? EndDoctypeDeclHandler : NULL);
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable the DOCTYPE declaration handler
|
||||
|
||||
void EnableDoctypeDeclHandler (bool fEnable = true)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
EnableStartDoctypeDeclHandler (fEnable);
|
||||
EnableEndDoctypeDeclHandler (fEnable);
|
||||
}
|
||||
|
||||
public:
|
||||
// Parser error reporting methods
|
||||
|
||||
// @cmember Get last error
|
||||
|
||||
enum XML_Error GetErrorCode ()
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_GetErrorCode (m_p);
|
||||
}
|
||||
|
||||
// @cmember Get the current byte index
|
||||
|
||||
long GetCurrentByteIndex ()
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_GetCurrentByteIndex (m_p);
|
||||
}
|
||||
|
||||
// @cmember Get the current line number
|
||||
|
||||
int GetCurrentLineNumber ()
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_GetCurrentLineNumber (m_p);
|
||||
}
|
||||
|
||||
// @cmember Get the current column number
|
||||
|
||||
int GetCurrentColumnNumber ()
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_GetCurrentColumnNumber (m_p);
|
||||
}
|
||||
|
||||
// @cmember Get the current byte count
|
||||
|
||||
int GetCurrentByteCount ()
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_GetCurrentByteCount (m_p);
|
||||
}
|
||||
|
||||
// @cmember Get the input context
|
||||
|
||||
const char *GetInputContext (int *pnOffset, int *pnSize)
|
||||
{
|
||||
assert (m_p != NULL);
|
||||
return XML_GetInputContext (m_p, pnOffset, pnSize);
|
||||
}
|
||||
|
||||
// @cmember Get last error string
|
||||
|
||||
const XML_LChar *GetErrorString ()
|
||||
{
|
||||
return XML_ErrorString (GetErrorCode ());
|
||||
}
|
||||
|
||||
// @cmember Return the version string
|
||||
|
||||
static const XML_LChar *GetExpatVersion ()
|
||||
{
|
||||
return XML_ExpatVersion ();
|
||||
}
|
||||
|
||||
// @cmember Get the version information
|
||||
|
||||
static void GetExpatVersion (int *pnMajor, int *pnMinor, int *pnMicro)
|
||||
{
|
||||
XML_expat_version v = XML_ExpatVersionInfo ();
|
||||
if (pnMajor)
|
||||
*pnMajor = v .major;
|
||||
if (pnMinor)
|
||||
*pnMinor = v .minor;
|
||||
if (pnMicro)
|
||||
*pnMicro = v .micro;
|
||||
}
|
||||
|
||||
// @cmember Get last error string
|
||||
|
||||
static const XML_LChar *GetErrorString (enum XML_Error nError)
|
||||
{
|
||||
return XML_ErrorString (nError);
|
||||
}
|
||||
|
||||
|
||||
// Public handler methods:
|
||||
// The template parameter should provide their own implementation for those handlers that they want
|
||||
|
||||
// @cmember Start element handler
|
||||
|
||||
void OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember End element handler
|
||||
|
||||
void OnEndElement (const XML_Char *pszName)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember Character data handler
|
||||
|
||||
void OnCharacterData (const XML_Char *pszData, int nLength)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember Processing instruction handler
|
||||
|
||||
void OnProcessingInstruction (const XML_Char *pszTarget,
|
||||
const XML_Char *pszData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember Comment handler
|
||||
|
||||
void OnComment (const XML_Char *pszData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember Start CDATA section handler
|
||||
|
||||
void OnStartCdataSection ()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember End CDATA section handler
|
||||
|
||||
void OnEndCdataSection ()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember Default handler
|
||||
|
||||
void OnDefault (const XML_Char *pszData, int nLength)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember External entity ref handler
|
||||
|
||||
bool OnExternalEntityRef (const XML_Char *pszContext,
|
||||
const XML_Char *pszBase, const XML_Char *pszSystemID,
|
||||
const XML_Char *pszPublicID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// @cmember Unknown encoding handler
|
||||
|
||||
bool OnUnknownEncoding (const XML_Char *pszName, XML_Encoding *pInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// @cmember Start namespace declaration handler
|
||||
|
||||
void OnStartNamespaceDecl (const XML_Char *pszPrefix,
|
||||
const XML_Char *pszURI)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember End namespace declaration handler
|
||||
|
||||
void OnEndNamespaceDecl (const XML_Char *pszPrefix)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember XML declaration handler
|
||||
|
||||
void OnXmlDecl (const XML_Char *pszVersion, const XML_Char *pszEncoding,
|
||||
bool fStandalone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember Start DOCTYPE declaration handler
|
||||
|
||||
void OnStartDoctypeDecl (const XML_Char *pszDoctypeName,
|
||||
const XML_Char *pszSysID, const XML_Char *pszPubID,
|
||||
bool fHasInternalSubset)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @cmember End DOCTYPE declaration handler
|
||||
|
||||
void OnEndDoctypeDecl ()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @access Protected methods
|
||||
protected:
|
||||
|
||||
// @cmember Handle any post creation
|
||||
|
||||
void OnPostCreate ()
|
||||
{
|
||||
}
|
||||
|
||||
// @access Protected static methods
|
||||
protected:
|
||||
|
||||
// @cmember Start element handler wrapper
|
||||
|
||||
static void __cdecl StartElementHandler (void *pUserData,
|
||||
const XML_Char *pszName, const XML_Char **papszAttrs)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnStartElement (pszName, papszAttrs);
|
||||
}
|
||||
|
||||
// @cmember End element handler wrapper
|
||||
|
||||
static void __cdecl EndElementHandler (void *pUserData,
|
||||
const XML_Char *pszName)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnEndElement (pszName);
|
||||
}
|
||||
|
||||
// @cmember Character data handler wrapper
|
||||
|
||||
static void __cdecl CharacterDataHandler (void *pUserData,
|
||||
const XML_Char *pszData, int nLength)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnCharacterData (pszData, nLength);
|
||||
}
|
||||
|
||||
// @cmember Processing instruction handler wrapper
|
||||
|
||||
static void __cdecl ProcessingInstructionHandler (void *pUserData,
|
||||
const XML_Char *pszTarget, const XML_Char *pszData)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnProcessingInstruction (pszTarget, pszData);
|
||||
}
|
||||
|
||||
// @cmember Comment handler wrapper
|
||||
|
||||
static void __cdecl CommentHandler (void *pUserData,
|
||||
const XML_Char *pszData)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnComment (pszData);
|
||||
}
|
||||
|
||||
// @cmember Start CDATA section wrapper
|
||||
|
||||
static void __cdecl StartCdataSectionHandler (void *pUserData)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnStartCdataSection ();
|
||||
}
|
||||
|
||||
// @cmember End CDATA section wrapper
|
||||
|
||||
static void __cdecl EndCdataSectionHandler (void *pUserData)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnEndCdataSection ();
|
||||
}
|
||||
|
||||
// @cmember Default wrapper
|
||||
|
||||
static void __cdecl DefaultHandler (void *pUserData,
|
||||
const XML_Char *pszData, int nLength)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnDefault (pszData, nLength);
|
||||
}
|
||||
|
||||
// @cmember External entity ref wrapper
|
||||
|
||||
static int __cdecl ExternalEntityRefHandler (void *pUserData,
|
||||
const XML_Char *pszContext, const XML_Char *pszBase,
|
||||
const XML_Char *pszSystemID, const XML_Char *pszPublicID)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
return pThis ->OnExternalEntityRef (pszContext,
|
||||
pszBase, pszSystemID, pszPublicID) ? 1 : 0;
|
||||
}
|
||||
|
||||
// @cmember Unknown encoding wrapper
|
||||
|
||||
static int __cdecl UnknownEncodingHandler (void * pUserData, const XML_Char * pszName, XML_Encoding * pInfo)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
return pThis ->OnUnknownEncoding (pszName, pInfo) ? 1 : 0;
|
||||
}
|
||||
|
||||
// @cmember Start namespace decl wrapper
|
||||
|
||||
static void __cdecl StartNamespaceDeclHandler (void * pUserData, const XML_Char * pszPrefix, const XML_Char * pszURI)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnStartNamespaceDecl (pszPrefix, pszURI);
|
||||
}
|
||||
|
||||
// @cmember End namespace decl wrapper
|
||||
|
||||
static void __cdecl EndNamespaceDeclHandler (void * pUserData, const XML_Char * pszPrefix)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnEndNamespaceDecl (pszPrefix);
|
||||
}
|
||||
|
||||
// @cmember XML declaration wrapper
|
||||
|
||||
static void __cdecl XmlDeclHandler (void *pUserData, const XML_Char *pszVersion, const XML_Char *pszEncoding, int nStandalone)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnXmlDecl (pszVersion, pszEncoding, nStandalone != 0);
|
||||
}
|
||||
|
||||
// @cmember Start Doctype declaration wrapper
|
||||
|
||||
static void __cdecl StartDoctypeDeclHandler (
|
||||
void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID,
|
||||
const XML_Char *pszPubID, int nHasInternalSubset
|
||||
)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnStartDoctypeDecl (pszDoctypeName, pszSysID,
|
||||
pszPubID, nHasInternalSubset != 0);
|
||||
}
|
||||
|
||||
// @cmember End Doctype declaration wrapper
|
||||
|
||||
static void __cdecl EndDoctypeDeclHandler (void *pUserData)
|
||||
{
|
||||
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
|
||||
pThis ->OnEndDoctypeDecl ();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
XML_Parser m_p;
|
||||
|
||||
/// Returns the value of the specified attribute, if found; NULL otherwise
|
||||
static const XML_Char * FindAttr(const XML_Char ** iAttrs, const XML_Char * iAttrToFind)
|
||||
{
|
||||
for (const XML_Char ** Attr = iAttrs; *Attr != NULL; Attr += 2)
|
||||
{
|
||||
if (strcmp(*Attr, iAttrToFind) == 0)
|
||||
{
|
||||
return *(Attr + 1);
|
||||
}
|
||||
} // for Attr - iAttrs[]
|
||||
return NULL;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user