# HG changeset patch # User Matthew Wild # Date 1306962865 -3600 # Node ID 24d141cb2d1e66a1bb42b445f049fcc037972f2b Initial commit of LuaExpat 1.1.0 diff -r 000000000000 -r 24d141cb2d1e README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,56 @@ +LuaExpat (http://www.keplerproject.org/luaexpat/) +------------------------------------------------- + +Overview + +LuaExpat is a SAX XML parser based on the Expat library. LuaExpat is free +software and uses the same license as Lua 5.1. + +Status + +Current version is 1.1.0. It was developed for both Lua 5.0 and Lua 5.1, +and has been tested on Linux, Windows (2000/XP) and MacOS X with Expat 2.0.0. + +Download + +LuaExpat source can be downloaded from its LuaForge page. If you are using +LuaBinaries a Windows binary version of LuaExpat can be found at the LuaForge page. + +History + +Version 1.1.0 [05/Jun/2006] + + * adapted to work on both Lua 5.0 and Lua 5.1 + * updated to Expat 2.0.0 + +Version 1.0.2 [23/Mar/2006] + + * minor bugfix, lom correct module name is lxp.lom + +Version 1.0.1 [06/Jun/2005] + + * minor changes for compatibility with Expat version 1.95.8 + +Version 1.0 [2/Dec/2004] +Version 1.0 Beta [4/Apr/2004] +Version 1.0 Alpha [10/Dec/2003] + +References + +LuaExpat uses the Expat library. For details on the C API please refer to the article "Using Expat". +LuaExpat implements the SAX API. + +Credits + +Version 1.0 was designed by Roberto Ierusalimschy, André Carregal and Tomás Guisasola +as part of the Kepler Project which holds its copyright. The implementation was coded +by Roberto Ierusalimschy, based on a previous design by Jay Carlson. + +LuaExpat development was sponsored by Fábrica Digital and FINEP. + +Contact + +For more information please contact us (info at keplerproject dot org). Comments are welcome! +You can also reach other Kepler developers and users on the Kepler Project mailing list. + +$Id: README,v 1.2 2007/06/05 20:03:12 carregal Exp $ diff -r 000000000000 -r 24d141cb2d1e config --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,36 @@ +# Installation directories +# System's libraries directory (where binary libraries are installed) +LUA_LIBDIR= /usr/local/lib/lua/5.0 +# System's lua directory (where Lua libraries are installed) +LUA_DIR= /usr/local/share/lua/5.0 +# Lua includes directory +LUA_INC= /usr/local/include +# Expat includes directory +EXPAT_INC= /usr/local/include + +# OS dependent +LIB_OPTION= -shared #for Linux +#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X + +LIBNAME= $T.so.$V +# Lua version number +# (according to Lua 5.1 definition: +# first version digit * 100 + second version digit +# e.g. Lua 5.0.2 => 500, Lua 5.1 => 501, Lua 5.1.1 => 501) +LUA_VERSION_NUM= 500 +COMPAT_DIR= ../compat/src + +# Compilation parameters +CWARNS = -Wall -pedantic \ + -Waggregate-return \ + -Wcast-align \ + -Wmissing-prototypes \ + -Wstrict-prototypes \ + -Wnested-externs \ + -Wpointer-arith \ + -Wshadow \ + -Wwrite-strings + +CFLAGS = $(CWARNS) -ansi -O2 -I$(LUA_INC) \ + -I$(COMPAT_DIR) -I$(EXPAT_INC) +CC = gcc diff -r 000000000000 -r 24d141cb2d1e debian/Makefile.Debian.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/Makefile.Debian.conf Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,20 @@ +PKG_NAME=expat + +### things relative to the C library part +CLIB_CFLAGS= -I src/ +CLIB_LDFLAGS= -lexpat +CLIB_OBJS= src/lxplib.lo +VERSION_INFO=0:0:0 + +### things relative to the lua library part +LUA_HEADER=src/lxplib.h +LUA_SOURCES=src/lxp +LUA_MODNAME=lxp +LUA_TEST=/usr/bin/shake tests/test.lua + +### this part is relative to pkg-config +PKG_VERSION=$(shell dpkg-parsechangelog|grep ^Ver|cut -d ' ' -f 2|cut -d '-' -f 1) +PKG_LIBS_PRIVATE= +PKG_URL=http://luaforge.net/projects/luaexpat/ +PKG_REQUIRES= +PKG_CONFLICTS= diff -r 000000000000 -r 24d141cb2d1e debian/changelog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/changelog Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,60 @@ +lua-expat (1.1.0-3) unstable; urgency=low + + * depend on lua5.1-policy-dev >= 22 + * changed lua to Lua in the package description + * bumped standards-version to 3.8.2, no changes needed + + -- Enrico Tassi Tue, 21 Jul 2009 12:48:09 +0200 + +lua-expat (1.1.0-2) unstable; urgency=low + + * Renamed cdbs deprecated variable + * Vcs- fields fixed + * Use shake to run compilation tests + * Added Homepage control field + * Removed dpatch build dependency + * Moved -dev package in section libdevel + + -- Enrico Tassi Tue, 18 Mar 2008 17:12:50 +0100 + +lua-expat (1.1.0-1) unstable; urgency=low + + * new upstream release, works out of the box with lua5.1 + + -- Enrico Tassi Fri, 08 Jun 2007 18:42:44 +0200 + +lua-expat (1.0.2-5) unstable; urgency=low + + * Updated to policy 10 that fixes clean target (Closes: #424551) + + -- Enrico Tassi Wed, 16 May 2007 16:20:50 +0200 + +lua-expat (1.0.2-4) unstable; urgency=low + + * made control file binNMU safe + * Added a note about the documentation shipped within the -dev package + in the control file + * Added call to lua5.1-policy-apply --reverse in the clean:: hook + + -- Enrico Tassi Mon, 8 Jan 2007 17:32:37 +0100 + +lua-expat (1.0.2-3) unstable; urgency=low + + * Moved to policy version 7 + * The FTBFS bug #405990 is because of an incompatibility with the policy + version 7 that is not in etch. This incompatibility has been fixed + (Closes: #405990) + + -- Enrico Tassi Mon, 8 Jan 2007 17:30:34 +0100 + +lua-expat (1.0.2-2) unstable; urgency=low + + * added XS-X-Vcs-svn field to control. + + -- Enrico Tassi Sun, 3 Sep 2006 10:26:13 +0200 + +lua-expat (1.0.2-1) unstable; urgency=low + + * Initial release. (Closes: #384350) + + -- Enrico Tassi Wed, 23 Aug 2006 20:12:16 +0200 diff -r 000000000000 -r 24d141cb2d1e debian/control --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/control Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,25 @@ +Source: lua-expat +Section: interpreters +Priority: optional +Maintainer: Enrico Tassi +Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 5), lua5.1-policy-dev (>= 22), libexpat1-dev, shake +Standards-Version: 3.8.2 +Vcs-Svn: svn://svn.debian.org/pkg-lua/packages/lua-expat +Vcs-Browser: http://svn.debian.org/viewsvn/pkg-lua/packages/lua-expat +Homepage: http://www.keplerproject.org/luaexpat/ + +Package: liblua5.1-expat0 +Architecture: any +Depends: ${shlibs:Depends} +Description: libexpat bindings for the Lua language version 5.1 + This package contains the bindings for the expat library. + +Package: liblua5.1-expat-dev +Architecture: any +Depends: liblua5.1-expat0 (= ${binary:Version}) +Section: libdevel +Description: libexpat development files for the Lua language version 5.1 + This package contains the development files of the libexpat lua5.1 bindings, + useful to create a statically linked binary (like a C application or a + standalone Lua interpreter). + Documentation is also shipped within this package. diff -r 000000000000 -r 24d141cb2d1e debian/copyright --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/copyright Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,26 @@ +This package was debianized by Enrico Tassi +Thu Aug 21 12:39:13 CEST 2006. + +It was downloaded from http://luaforge.net/projects/luaexpat/. + + +Copyright © 2003-2006 The Kepler Project. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff -r 000000000000 -r 24d141cb2d1e debian/liblua5.1-expat-dev.docs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/liblua5.1-expat-dev.docs Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,1 @@ +doc/us diff -r 000000000000 -r 24d141cb2d1e debian/patches/00dpatch.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/patches/00dpatch.conf Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,2 @@ +conf_debianonly=1 +conf_origtargzpath=../tarballs/ diff -r 000000000000 -r 24d141cb2d1e debian/rules --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/rules Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,3 @@ +#!/usr/bin/make -f + +include /usr/share/cdbs/1/class/lua.mk diff -r 000000000000 -r 24d141cb2d1e debian/watch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/watch Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,6 @@ +# test this watch file using: +# uscan --watchfile debian/watch --upstream-version 0.0.1 --package luaexpat +# +version=3 +http://luaforge.net/frs/?group_id=13 \ + /frs/download.php/\d+/luaexpat-([\d\.]*).tar.gz diff -r 000000000000 -r 24d141cb2d1e doc/us/examples.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/us/examples.html Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,201 @@ + + + + LuaExpat: XML Expat parsing for the Lua programming language + + + + + +
+ +
+ +
LuaExpat
+
XML Expat parsing for the Lua programming language
+
+ +
+ + + +
+ +

Examples

+ +

The code excerpt below creates a parser with 2 callbacks and +feeds a test string to it. The parsing of the test string triggers +the callbacks, printing the results.

+ +
+require"lxp"
+
+local count = 0
+callbacks = {
+    StartElement = function (parser, name)
+        io.write("+ ", string.rep(" ", count), name, "\n")
+        count = count + 1
+    end,
+    EndElement = function (parser, name)
+        count = count - 1
+        io.write("- ", string.rep(" ", count), name, "\n")
+    end
+}
+
+p = lxp.new(callbacks)
+
+for l in io.lines() do  -- iterate lines
+    p:parse(l)          -- parses the line
+    p:parse("\n")       -- parses the end of line
+end
+p:parse()               -- finishes the document
+p:close()               -- closes the parser
+
+ +

For a test string like

+ +
+<elem1>
+    text
+    <elem2/>
+    more text
+</elem1>
+
+ +

The example would print

+ +
++ elem1
+    + elem2
+    - elem2
+- elem1
+
+ +

Note that the text parts are not handled since the corresponding +callback (CharacterData) has not been defined. Also note +that defining this callback after the call to lxp.new would make no +difference. But had the callback table been defined as

+ +
+callbacks = {
+    StartElement = function (parser, name)
+        io.write("+ ", string.rep(" ", count), name, "\n")
+        count = count + 1
+    end,
+    EndElement = function (parser, name)
+        count = count - 1
+        io.write("- ", string.rep(" ", count), name, "\n")
+    end,
+    CharacterData = function (parser, string)
+        io.write("* ", string.rep(" ", count), string, "\n")
+    end
+}
+
+ +

The results would have been

+ +
++ elem1
+* text
+    + elem2
+    - elem2
+* more text
+- elem1
+
+ +

Another example would be the use of false as a +placeholder for the callback. Suppose that we would like to print +only the text associated with elem2 elements and that the +XML sample is

+ +
+ <elem1>
+    text
+    <elem2>
+        inside text
+    </elem2>
+    more text
+</elem1>
+
+ +

We could define the new callback table as

+ +
+callbacks = {
+    StartElement = function (parser, name)
+      if name == "elem2" then
+        -- redefines CharacterData behaviour
+        callbacks.CharacterData = function (parser, string)
+          io.write(string, "\n")
+        end
+      end
+    end,
+
+    EndElement = function (parser, name)
+      if name == "elem2" then
+        callbacks.CharacterData = false -- restores placeholder
+      end
+    end,
+
+    CharacterData = false               -- placeholder
+}
+
+ +

The results would have been

+ +
+inside text
+
+ +

Note that this example assumes no other elements are present +inside elem2 tags.

+ +
+ +
+ +
+

Valid XHTML 1.0!

+

+ $Id: examples.html,v 1.5 2006/03/23 00:19:37 carregal Exp $ +

+
+ +
+ + + diff -r 000000000000 -r 24d141cb2d1e doc/us/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/us/index.html Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,157 @@ + + + + LuaExpat: XML Expat parsing for the Lua programming language + + + + + +
+ +
+ +
LuaExpat
+
XML Expat parsing for the Lua programming language
+
+ +
+ + + +
+ +

Overview

+ +

LuaExpat is a SAX XML parser based on the +Expat library.

+ +

LuaExpat is free software and uses the same license +as Lua 5.1.

+ +

Status

+ +

Current version is 1.1.0. It was developed for both Lua 5.0 and Lua 5.1, and has been tested on +Linux, Windows (2000/XP) and MacOS X with Expat 2.0.0.

+ +

Download

+ +

LuaExpat source can be downloaded from its +LuaForge +page. If you are using LuaBinaries +a Windows binary version of LuaExpat can be found at the LuaForge page.

+ +

History

+ +
+
Version 1.1.0 [05/Jun/2007]
+
+
    +
  • adapted to work on both Lua 5.0 and Lua 5.1
  • +
  • updated to use Expat 2.0.0
  • +
+
+ +
Version 1.0.2 [23/Mar/2006]
+
+
    +
  • minor bugfix, lom correct module name is lxp.lom
  • +
+
+ +
Version 1.0.1 [06/Jun/2005]
+
+
    +
  • minor changes for compatibility with Expat version 1.95.8
  • +
+
+ +
Version 1.0 [2/Dec/2004]
+
+ +
Version 1.0 Beta [4/Apr/2004]
+
+ +
Version 1.0 Alpha [10/Dec/2003]
+
+
+ +

References

+ +

LuaExpat uses the +Expat library. +For details on the C API please refer to the article +"Using Expat".

+ +

LuaExpat implements the SAX API.

+ +

Credits

+ +

Version 1.0 was designed by Roberto Ierusalimschy, André +Carregal and Tomás Guisasola as part of the Kepler Project +which holds its copyright. The implementation was coded by +Roberto Ierusalimschy, based on a previous design by +Jay Carlson.

+ +

LuaExpat development was sponsored by +Fábrica Digital and +FINEP.

+ +

Contact

+ +

For more information please +contact us. +Comments are welcome!

+ +

You can also reach other Kepler developers and users on the Kepler Project +mailing list.

+ +
+ +
+ +
+

+ Valid XHTML 1.0!

+

$Id: index.html,v 1.45 2007/06/05 21:11:29 carregal Exp $

+
+ +
+ + + diff -r 000000000000 -r 24d141cb2d1e doc/us/license.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/us/license.html Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,120 @@ + + + + LuaExpat: XML Expat parsing for the Lua programming language + + + + + +
+ +
+ +
LuaExpat
+
XML Expat parsing for the Lua programming language
+
+ +
+ + + +
+ +

License

+ +

+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 Open Source +software. Its licenses are compatible with GPL. LuaExpat is not in +the public domain and the +Kepler Project +keep its copyright. The legal details are below. +

+ +

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.

+ +

The LuaExpat library is designed and implemented by Roberto +Ierusalimschy. The implementation is not derived from licensed +software.

+ +
+

Copyright © 2003-2007 The Kepler Project. +

+ +

Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions:

+ +

The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software.

+ +

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.

+ +
+ +
+ +
+

Valid XHTML 1.0!

+

+ $Id: license.html,v 1.9 2007/06/05 20:03:12 carregal Exp $ +

+
+ +
+ + + diff -r 000000000000 -r 24d141cb2d1e doc/us/lom.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/us/lom.html Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,178 @@ + + + + LuaExpat: XML Expat parsing for the Lua programming language + + + + + +
+ +
+ +
LuaExpat
+
XML Expat parsing for the Lua programming language
+
+ +
+ + + +
+ +

Introduction

+ +

Lua Object Model (LOM) is a representation of XML elements +through Lua data types. Currently it is not supposed to be 100% +complete, but simple.

+ +

LuaExpat's distribution provides an implementation of LOM that +gets an XML documenta (a string) and transforms it to a Lua table. +The only function exported is lxp.lom.parse.

+ + +

Characteristics

+ +

The model represents each XML element as a Lua table. A LOM +table has three special characteristics:

+ +
    +
  • a special field called tag that holds the + element's name;
  • + +
  • an optional field called attr that stores + the element's attributes (see attribute's + section); and
  • + +
  • the element's children are stored at the array-part of + the table. A child could be an ordinary string or another XML + element that will be represented by a Lua table following these + same rules.
  • +
+ + +

Attributes

+ +

The special field attr is a Lua table that +stores the XML element's attributes as pairs +<key>=<value>. To assure an order (if +necessary), the sequence of keys could be placed at the +array-part of this same table.

+ + +

Examples

+ +

For a simple string like

+ +
+    s = [[<abc a1="A1" a2="A2">inside tag `abc'</abc>]]
+
+ +

A call like

+ +
+    tab = lxp.lom.parse (s))
+
+ +

Would result in a table equivalent to

+ +
+tab = {
+        ["attr"] = {
+                [1] = "a1",
+                [2] = "a2",
+                ["a2"] = "A2",
+                ["a1"] = "A1",
+        },
+        [1] = "inside tag `abc'",
+        ["tag"] = "abc",
+}
+
+ +

Now an example with an element nested inside another element

+ +
+tab = lxp.lom.parse(
+[[<qwerty q1="q1" q2="q2">
+    <asdf>some text</asdf>
+</qwerty>]]
+)
+
+ +

The result would have been a table equivalent to

+ +
+tab = {
+        [1] = "\
+        ",
+        [2] = {
+                ["attr"] = {
+                },
+                [1] = "some text",
+                ["tag"] = "asdf",
+        },
+        ["attr"] = {
+                [1] = "q1",
+                [2] = "q2",
+                ["q2"] = "q2",
+                ["q1"] = "q1",
+        },
+        [3] = "\
+",
+        ["tag"] = "qwerty",
+}
+
+ +

Note that even the new-line and tab characters are stored +on the table.

+ +
+ +
+ +
+

Valid XHTML 1.0!

+

+ $Id: lom.html,v 1.6 2006/03/20 22:26:00 carregal Exp $ +

+
+ +
+ + + diff -r 000000000000 -r 24d141cb2d1e doc/us/luaexpat.png Binary file doc/us/luaexpat.png has changed diff -r 000000000000 -r 24d141cb2d1e doc/us/manual.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/us/manual.html Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,363 @@ + + + + LuaExpat: XML Expat parsing for the Lua programming language + + + + + +
+ +
+ +
LuaExpat
+
XML Expat parsing for the Lua programming language
+
+ +
+ + + +
+ +

Introduction

+ +

LuaExpat is a SAX XML +parser based on the Expat library. +SAX is the Simple API for XML and allows programs to: +

+ +
    +
  • process a XML document incrementally, thus being able to handle + huge documents without memory penalties;
  • + +
  • register handler functions which are called by the parser during + the processing of the document, handling the document elements or + text.
  • +
+ +

With an event-based API like SAX the XML document can be fed to +the parser in chunks, and the parsing begins as soon as the parser +receives the first document chunk. LuaExpat reports parsing events +(such as the start and end of elements) directly to the application +through callbacks. The parsing of huge documents can benefit from +this piecemeal operation.

+ +

LuaExpat is distributed as a library and a file lom.lua that +implements the Lua Object Model.

+ + +

Building

+ +

+LuaExpat could be built to Lua 5.0 or to Lua 5.1. +In both cases, +the language library and headers files for the desired version +must be installed properly. +LuaExpat also depends on Expat 2.0.0 which should also be installed. +

+

+LuaExpat offers a Makefile and a separate configuration file, +config, +which should be edited to suit the particularities of the target platform +before running +make. +The file has some definitions like paths to the external libraries, +compiler options and the like. +One important definition is the version of Lua language, +which is not obtained from the installed software. +

+ + +

Installation

+ +

The compiled binary file should be copied to a directory in your +C path. +Lua 5.0 users should also install +Compat-5.1.

+ +

Windows users can use the binary version of LuaExpat (lxp.dll, compatible with +LuaBinaries) available at +LuaForge.

+ +

The file lom.lua should be copied to a directory in your +Lua path.

+ +

Parser objects

+ +

Usually SAX implementations base all operations on the +concept of a parser that allows the registration of callback +functions. LuaExpat offers the same functionality but uses a +different registration method, based on a table of callbacks. This +table contains references to the callback functions which are +responsible for the handling of the document parts. The parser will +assume no behaviour for any undeclared callbacks.

+ +

Constructor

+ +
+
lxp.new(callbacks [, separator])
+
The parser is created by a call to the function lxp.new, + which returns the created parser or raises a Lua error. It + receives the callbacks table and optionally the parser + separator character used in the namespace expanded element names.
+
+ +

Methods

+ +
+
parser:close()
+
Closes the parser, freeing all memory used by it. A call to + parser:close() without a previous call to parser:parse() could + result in an error.
+ +
parser:getbase()
+
Returns the base for resolving relative URIs.
+ +
parser:getcallbacks()
+
Returns the callbacks table.
+ +
parser:parse(s)
+
Parse some more of the document. The string s contains + part (or perhaps all) of the document. When called without + arguments the document is closed (but the parser still has to be + closed).
+ The function returns a non nil value when the parser has been + succesfull, and when the parser finds an error it returns five + results: nil, msg, line, col, and + pos, which are the error message, the line number, + column number and absolute position of the error in the XML document.
+ +
parser:pos()
+
Returns three results: the current parsing line, column, and + absolute position.
+ +
parser:setbase(base)
+
Sets the base to be used for resolving relative URIs in + system identifiers.
+ +
parser:setencoding(encoding)
+
Set the encoding to be used by the parser. There are four + built-in encodings, passed as strings: "US-ASCII", + "UTF-8", "UTF-16", and "ISO-8859-1".
+
+ +

Callbacks

+ +

The Lua callbacks define the handlers of the parser events. The +use of a table in the parser constructor has some advantages over +the registration of callbacks, since there is no need for for the API +to provide a way to manipulate callbacks.

+ +

Another difference lies in the behaviour of the callbacks during +the parsing itself. The callback table contains references to the +functions that can be redefined at will. The only restriction is +that only the callbacks present in the table at creation time +will be called.

+ +

The callbacks table indices are named after the equivalent Expat +callbacks:
+CharacterData, Comment, +Default, DefaultExpand, EndCDataSection, +EndElement, EndNamespaceDecl, +ExternalEntityRef, NotStandalone, +NotationDecl, ProcessingInstruction, +StartCDataSection, StartElement, +StartNamespaceDecl, and UnparsedEntityDecl.

+ +

These indices can be references to functions with +specific signatures, as seen below. The parser constructor also +checks the presence of a field called _nonstrict in the +callbacks table. If _nonstrict is absent, only valid +callback names are accepted as indices in the table +(Defaultexpanded would be considered an error for example). If +_nonstrict is defined, any other fieldnames can be +used (even if not called at all).

+ +

The callbacks can optionally be defined as false, +acting thus as placeholders for future assignment of functions.

+ +

Every callback function receives as the first parameter the +calling parser itself, thus allowing the same functions to be used +for more than one parser for example.

+ +
+
callbacks.CharacterData = function(parser, string)
+
Called when the parser recognizes an XML CDATA string.
+ +
callbacks.Comment = function(parser, string)
+
Called when the parser recognizes an XML comment + string.
+ +
callbacks.Default = function(parser, string)
+
Called when the parser has a string + corresponding to any characters in the document which wouldn't + otherwise be handled. Using this handler has the side effect of + turning off expansion of references to internally defined general + entities. Instead these references are passed to the default + handler.
+ +
callbacks.DefaultExpand = function(parser, string)
+
Called when the parser has a string + corresponding to any characters in the document which wouldn't + otherwise be handled. Using this handler doesn't affect expansion + of internal entity references.
+ +
callbacks.EndCdataSection = function(parser)
+
Called when the parser detects the end of a CDATA + section.
+ +
callbacks.EndElement = function(parser, elementName)
+
Called when the parser detects the ending of an XML + element with elementName.
+ +
callbacks.EndNamespaceDecl = function(parser, namespaceName)
+
Called when the parser detects the ending of an XML + namespace with namespaceName. The handling of the end + namespace is done after the handling of the end tag for the element + the namespace is associated with.
+ +
callbacks.ExternalEntityRef = function(parser, subparser, base, systemId, publicId)
+
Called when the parser detects an external entity + reference.

+ The subparser is a LuaExpat parser created with the + same callbacks and Expat context as the parser and should + be used to parse the external entity.
+ The base parameter is the base to use for relative + system identifiers. It is set by parser:setbase and may be nil.
+ The systemId parameter is the system identifier + specified in the entity declaration and is never nil.
+ The publicId parameter is the public id given in the + entity declaration and may be nil.
+ +
callbacks.NotStandalone = function(parser)
+
Called when the parser detects that the document is not + "standalone". This happens when there is an external subset or a + reference to a parameter entity, but the document does not have standalone set + to "yes" in an XML declaration.
+ +
callbacks.NotationDecl = function(parser, notationName, base, systemId, publicId)
+
Called when the parser detects XML notation + declarations with notationName
+ The base parameter is the base to use for relative + system identifiers. It is set by parser:setbase and may be nil.
+ The systemId parameter is the system identifier + specified in the entity declaration and is never nil.
+ The publicId parameter is the public id given in the + entity declaration and may be nil.
+ +
callbacks.ProcessingInstruction = function(parser, target, data)
+
Called when the parser detects XML processing + instructions. The target is the first word in the + processing instruction. The data is the rest of the + characters in it after skipping all whitespace after the initial + word.
+ +
callbacks.StartCdataSection = function(parser)
+
Called when the parser detects the begining of an XML + CDATA section.
+ +
callbacks.StartElement = function(parser, elementName, attributes)
+
Called when the parser detects the begining of an XML + element with elementName.
+ The attributes parameter is a Lua table with all the + element attribute names and values. The table contains an entry for + every attribute in the element start tag and entries for the + default attributes for that element.
+ The attributes are listed by name (including the inherited ones) + and by position (inherited attributes are not considered in the + position list).
+ As an example if the book element has attributes + author, title and an optional format + attribute (with "printed" as default value), +
+<book author="Ierusalimschy, Roberto" title="Programming in Lua">
+
+ would be represented as
+
+{[1] = "Ierusalimschy, Roberto",
+ [2] = "Programming in Lua",
+ author = "Ierusalimschy, Roberto",
+ format = "printed",
+ title = "Programming in Lua"}
+
+ +
callbacks.StartNamespaceDecl = function(parser, namespaceName)
+
Called when the parser detects an XML namespace + declaration with namespaceName. Namespace declarations + occur inside start tags, but the StartNamespaceDecl handler is + called before the StartElement handler for each namespace declared + in that start tag.
+ +
callbacks.UnparsedEntityDecl = function(parser, entityName, base, systemId, publicId, notationName)
+
Called when the parser receives declarations of + unparsed entities. These are entity declarations that have a + notation (NDATA) field.
+ As an example, in the chunk +
+<!ENTITY logo SYSTEM "images/logo.gif" NDATA gif>
+
+ entityName would be "logo", systemId would be + "images/logo.gif" and notationName would be "gif". + For this example the publicId parameter would be nil. + The base parameter would be whatever has been set with + parser:setbase. If not set, it would be nil.
+
+ +

The separator character

+ +

The optional separator character in the parser constructor +defines the character used in the namespace expanded element names. +The separator character is optional (if not defined the parser will +not handle namespaces) but if defined it must be different from +the character '\0'.

+ +
+ +
+ +
+

+ Valid XHTML 1.0!

+

$Id: manual.html,v 1.27 2007/06/05 20:03:12 carregal Exp $

+
+ +
+ + + diff -r 000000000000 -r 24d141cb2d1e makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makefile Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,30 @@ +T= lxp +V= 1.1.0 +CONFIG= ./config + +include $(CONFIG) + +ifeq "$(LUA_VERSION_NUM)" "500" +COMPAT_O= $(COMPAT_DIR)/compat-5.1.o +endif + +OBJS= src/lxplib.o $(COMPAT_O) +lib: src/$(LIBNAME) + +src/$(LIBNAME) : $(OBJS) + export MACOSX_DEPLOYMENT_TARGET="10.3"; $(CC) -o src/$(LIBNAME) $(LIB_OPTION) $(OBJS) -lexpat + +$(COMPAT_DIR)/compat-5.1.o: $(COMPAT_DIR)/compat-5.1.c + $(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c + +install: + mkdir -p $(LUA_LIBDIR) + cp src/$(LIBNAME) $(LUA_LIBDIR) + cd $(LUA_LIBDIR); ln -f -s $(LIBNAME) $T.so + mkdir -p $(LUA_DIR)/$T + cp src/$T/lom.lua $(LUA_DIR)/$T + +clean: + rm -f src/$(LIBNAME) $(OBJS) + +# $Id: makefile,v 1.33 2006/06/08 20:41:48 tomas Exp $ diff -r 000000000000 -r 24d141cb2d1e makefile.win --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makefile.win Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,29 @@ +LUA_INC=c:\lua5.1\include +LUA_DIR=c:\lua5.1\lua +LUA_LIBDIR=c:\lua5.1 +LUA_LIB=c:\lua5.1\lua5.1.lib + +OBJS= src\lxplib.obj + +EXPAT_INCLUDE=C:\Expat-2.0.0\Source\lib +EXPAT_LIB=C:\Expat-2.0.0\Libs\libexpat.lib + +.c.obj: + cl /c /Fo$@ /O2 /I$(LUA_INC) /I$(EXPAT_INCLUDE) /D_CRT_SECURE_NO_DEPRECATE $< + +src\lxp.dll: $(OBJS) + link /dll /def:src\lxp.def /out:$@ $(OBJS) $(EXPAT_LIB) $(LUA_LIB) + +install: src\lxp.dll + IF NOT EXIST $(LUA_LIBDIR) mkdir $(LUA_LIBDIR) + copy src\lxp.dll $(LUA_LIBDIR) + IF NOT EXIST $(LUA_DIR)\lxp mkdir $(LUA_DIR)\lxp + copy src\lxp\lom.lua $(LUA_DIR)\lxp + +clean: + del src\lxp.dll + del src\*.obj + del src\lxp.exp + del src\lxp.lib + +# $Id: makefile.win,v 1.3 2007/06/05 20:03:12 carregal Exp $ diff -r 000000000000 -r 24d141cb2d1e src/lxp.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lxp.def Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,2 @@ +EXPORTS + luaopen_lxp \ No newline at end of file diff -r 000000000000 -r 24d141cb2d1e src/lxp/lom.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lxp/lom.lua Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,60 @@ +-- See Copyright Notice in license.html +-- $Id: lom.lua,v 1.6 2005/06/09 19:18:40 tuler Exp $ + +require "lxp" + +local tinsert, tremove, getn = table.insert, table.remove, table.getn +local assert, type, print = assert, type, print +local lxp = lxp + +module ("lxp.lom") + +local function starttag (p, tag, attr) + local stack = p:getcallbacks().stack + local newelement = {tag = tag, attr = attr} + tinsert(stack, newelement) +end + +local function endtag (p, tag) + local stack = p:getcallbacks().stack + local element = tremove(stack) + assert(element.tag == tag) + local level = getn(stack) + tinsert(stack[level], element) +end + +local function text (p, txt) + local stack = p:getcallbacks().stack + local element = stack[getn(stack)] + local n = getn(element) + if type(element[n]) == "string" then + element[n] = element[n] .. txt + else + tinsert(element, txt) + end +end + +function parse (o) + local c = { StartElement = starttag, + EndElement = endtag, + CharacterData = text, + _nonstrict = true, + stack = {{}} + } + local p = lxp.new(c) + local status, err + if type(o) == "string" then + status, err = p:parse(o) + if not status then return nil, err end + else + for l in o do + status, err = p:parse(l) + if not status then return nil, err end + end + end + status, err = p:parse() + if not status then return nil, err end + p:close() + return c.stack[1][1] +end + diff -r 000000000000 -r 24d141cb2d1e src/lxplib.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lxplib.c Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,544 @@ +/* +** $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 +#include +#include + +#include "expat.h" + +#include "lua.h" +#include "lauxlib.h" +#if ! defined (LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 +#include "compat-5.1.h" +#endif + + +#include "lxplib.h" + + + +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) { + lua_unref(L, 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_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 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", 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); + 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_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 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}, + {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-2007 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.1.0"); + lua_settable (L, -3); +} + + +int luaopen_lxp (lua_State *L) { + luaL_newmetatable(L, ParserType); + lua_pushliteral(L, "__index"); + lua_pushvalue(L, -2); + lua_rawset(L, -3); + luaL_openlib (L, NULL, lxp_meths, 0); + luaL_openlib (L, "lxp", lxp_funcs, 0); + set_info (L); + + return 1; +} diff -r 000000000000 -r 24d141cb2d1e src/lxplib.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lxplib.h Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,23 @@ +/* +** 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" + +int luaopen_lxp (lua_State *L); diff -r 000000000000 -r 24d141cb2d1e tests/test-lom.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-lom.lua Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,50 @@ +#!/usr/local/bin/lua + +local lom = require "lxp.lom" + +local tests = { + [[inside tag `abc']], + [[ + some text +]], +} + +function table._tostring (tab, indent, spacing) + local s = {} + spacing = spacing or "" + indent = indent or "\t" + table.insert (s, "{\n") + for nome, val in pairs (tab) do + table.insert (s, spacing..indent) + local t = type(nome) + if t == "string" then + table.insert (s, string.format ("[%q] = ", tostring (nome))) + elseif t == "number" or t == "boolean" then + table.insert (s, string.format ("[%s] = ", tostring (nome))) + else + table.insert (s, t) + end + t = type(val) + if t == "string" or t == "number" then + table.insert (s, string.format ("%q", val)) + elseif t == "table" then + table.insert (s, table._tostring (val, indent, spacing..indent)) + else + table.insert (s, t) + end + table.insert (s, ",\n") + end + table.insert (s, spacing.."}") + return table.concat (s) +end + +function table.print (tab, indent, spacing) + io.write (table._tostring (tab, indent, spacing)) +end + + +for i, s in ipairs(tests) do + --s = string.gsub (s, "[\n\r\t]", "") + local ds = assert (lom.parse ([[]]..s)) + print(table._tostring(ds)) +end diff -r 000000000000 -r 24d141cb2d1e tests/test.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test.lua Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,298 @@ +#!/usr/local/bin/lua5.1 +-- See Copyright Notice in license.html +-- $Id: test.lua,v 1.6 2006/06/08 20:34:52 tomas Exp $ + +require"lxp" +print (lxp._VERSION) + +-- basic test with no preamble +local p = lxp.new{} +p:setencoding("ISO-8859-1") +assert(p:parse[[hi]]) +p:close() + + +preamble = [[ + + + + + + + + + + + + + + +]> +]] + +local X +function getargs (...) X = arg end + +function xgetargs (c) + return function (...) + table.insert(arg, 1, c) + table.insert(X, arg) + end +end + + +------------------------------- +print("testing start/end tags") +callbacks = { + StartElement = getargs, + EndElement = getargs, +} +p = lxp.new(callbacks) +assert(p:getcallbacks() == callbacks) +assert(p:parse(preamble)) +assert(p:parse([[ + +]])) +assert(X.n == 3 and X[1] == p and X[2] == "to") +x = X[3] +assert(x.priority=="10" and x.xu=="hi" and x.method=="POST") +assert(x[1] == "priority" and x[2] == "xu" and table.getn(x) == 2) +assert(p:parse("")) +assert(p:parse()) +p:close() + + +------------------------------- +print("testing CharacterData/Cdata") +callbacks = { + CharacterData = getargs, +} +p = lxp.new(callbacks) +assert(p:parse(preamble)) +assert(p:parse"a basic text<>]]>") +assert(X[1] == p and X[2] == "a basic text<<>") +callbacks.chardata = error -- no more calls to `chardata' +assert(p:parse("")) +assert(p:parse()) +-- assert(p:parse()) -- no problem to finish twice. alas, it has problems +assert(p:getcallbacks() == callbacks) +p:close() + +------------------------------- +callbacks = { + CharacterData = xgetargs"c", + StartCdataSection = xgetargs"s", + EndCdataSection = xgetargs"e", +} +X = {} +p = lxp.new(callbacks) +assert(p:parse(preamble)) +assert(p:parse"") +assert(p:parse"") +assert(table.getn(X) == 3) +assert(X[1][1] == "s" and X[1][2] == p) +assert(X[2][1] == "c" and X[2][2] == p and X[2][3] == "hi") +assert(X[3][1] == "e" and X[3][2] == p) +assert(p:parse"") +p:close() + + +------------------------------- +print("testing ProcessingInstruction") +callbacks = {ProcessingInstruction = getargs} +p = lxp.new(callbacks) +assert(p:parse[[ + + ? ?> + +]]) +assert(X[1] == p and X[2] == "lua" and + X[3] == "how is this passed to ? ") +p:close() + + +------------------------------ +print("testing Comment") +callbacks = {Comment = xgetargs"c"; CharacterData = xgetargs"t"} +X = {} +p = lxp.new(callbacks) +assert(p:parse[[ +some text + +some more text + +]]) +p:close() + +assert(X[1][1] == "t" and X[2][1] == "c" and X[3][1] == "t") +assert(X[1][2] == X[2][2] and X[2][2] == X[3][2] and X[3][2] == p) +assert(X[1][3] == "some text\n") +assert(X[2][3] == " with some & symbols ") +assert(X[3][3] == "\nsome more text") + + +---------------------------- +print("testing ExternalEntity") +entities = { +["entity1.xml"] = "" +} + +callbacks = {StartElement = xgetargs"s", EndElement = xgetargs"e", + ExternalEntityRef = function (p, context, base, systemID, publicId) + assert(base == "/base") + return context:parse(entities[systemID]) + end} + +X = {} +p = lxp.new(callbacks) +p:setbase("/base") +assert(p:parse(preamble)) +assert(p:parse[[ + &test-entity; + +]]) +assert(p:getbase() == "/base") +p:close() +assert(X[1][1] == "s" and X[1][3] == "to") +assert(X[2][1] == "s" and X[2][3] == "hi") +assert(X[3][1] == "e" and X[3][3] == "hi") +assert(X[4][1] == "e" and X[4][3] == "to") + + +---------------------------- +print("testing default handles") +text = [[ hi &xuxu; ]] +local t = "" + +callbacks = { Default = function (p, s) t = t .. s end } +p = lxp.new(callbacks) +assert(p:parse(preamble)) +assert(p:parse(text)) +p:close() +assert(t == preamble..text) + +t = "" +callbacks = { DefaultExpand = function (p, s) t = t .. s end } +p = lxp.new(callbacks) +assert(p:parse(preamble)) +assert(p:parse(text)) +p:close() +assert(t == preamble..string.gsub(text, "&xuxu;", "is this a xuxu?")) + + +---------------------------- +print("testing notation declarations and unparsed entities") + +callbacks = { + UnparsedEntityDecl = getargs, + NotationDecl = function (p, name, base, systemId, publicId) + assert(name == "TXT" and systemId == "txt" and base == "/base") + end, + } +p = lxp.new(callbacks) +p:setbase("/base") +assert(p:parse(preamble)) +assert(p:parse[[]]) +p:close() +assert(X[2] == "test-unparsed" and X[3] == "/base" and + X[4] == "unparsed.txt" and X[6] == "txt" and X.n == 6) + + + +---------------------------- +print("testing namespace declarations") +callbacks = { StartNamespaceDecl = xgetargs"sn", + EndNamespaceDecl = xgetargs"en", + StartElement = xgetargs"s", + EndElement = xgetargs"e", +} +X = {} +p = lxp.new(callbacks, "?") +assert(p:parse[[ + + + +]]) +p:close() +x = X[1] +assert(x[1] == "sn" and x[3] == "space" and x[4] == "a/namespace" and table.getn(x) == 4) +x = X[3] +assert(x[1] == "s" and x[3] == "a/namespace?a") +x = X[4] +assert(x[1] == "e" and x[3] == "a/namespace?a") +x = X[6] +assert(x[1] == "en" and x[3] == "space" and table.getn(x) == 3) + + + +-- Error reporting +p = lxp.new{} +data = [[ + + + +]] +local status, msg, line, col, byte = p:parse(data) +assert(status == nil and type(msg) == "string" and line == 2 and col == 9) +assert(string.sub(data, byte, byte) == "<") + +p = lxp.new{} +p:parse("") +local status, msg, line, col, byte = p:parse() +assert(status == nil and line == 1 and col == 5 and byte == 5) + + +-- position reporting +callbacks = { ProcessingInstruction = function (p) + X = {p:pos()} +end +} + +p = lxp.new(callbacks) +assert(p:parse[[ + + +]]) +p:close() +assert(X[1] == 1 and X[2] == 6 and X[3] == 6) -- line, column, abs. position + + + +print("testing errors") +-- invalid keys +assert(not pcall(lxp.new, {StatCdata=print})) +assert(pcall(lxp.new, {StatCdata=print, _nonstrict = true})) + +-- invalid sequences +p = lxp.new{} +assert(p:parse[[]]) +assert(p:parse()) +assert(p:parse(" ") == nil) + +-- closing unfinished document +p = lxp.new{} +assert(p:parse[[]]) +local status, err = pcall(p.close, p) +assert(not status and string.find(err, "error closing parser")) + + +-- test for GC +print("\ntesting garbage collection") +collectgarbage(); collectgarbage() +local x = gcinfo() +for i=1,100000 do + -- due to a small bug in Lua... + if math.mod(i, 100) == 0 then collectgarbage() end + lxp.new({}) +end +collectgarbage(); collectgarbage() +assert(math.abs(gcinfo() - x) <= 2) + + +print"OK" + diff -r 000000000000 -r 24d141cb2d1e vc6/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vc6/README Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,28 @@ +These are the Visual Studio 6 projects provided by the Kepler Project + +Files: + + luaexpat.dsw + luaexpat_dll.dsp + luaexpat_static.dsp + README + +Generated files: + + luaexpat.ncb + luaexpat.opt + + ../lib/liblxp.lib + ../lib/liblxpd.lib + ../lib/lxp.exp + ../lib/lxp.lib + ../lib/lxpd.exp + ../lib/lxpd.lib + ../lib/lxpd.pdb + + ../bin/lxp.dll + ../bin/lxpd.dll + ../bin/lxpd.ilk + +Download source from: + http://www.keplerproject.org/luaexpat/ \ No newline at end of file diff -r 000000000000 -r 24d141cb2d1e vc6/luaexpat.dsw --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vc6/luaexpat.dsw Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,41 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "expat"="..\..\external-src\expat-1.95.8\lib\expat.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "luaexpat_dll"=.\luaexpat_dll.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff -r 000000000000 -r 24d141cb2d1e vc6/luaexpat_dll.dsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vc6/luaexpat_dll.dsp Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,127 @@ +# Microsoft Developer Studio Project File - Name="luaexpat_dll" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=luaexpat_dll - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "luaexpat_dll.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "luaexpat_dll.mak" CFG="luaexpat_dll - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "luaexpat_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "luaexpat_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "luaexpat_dll - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../lib/vc6" +# PROP Intermediate_Dir "luaexpat_dll/Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAEXPAT_DLL_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../external-src/expat-1.95.8/lib" /I "../../external-src/lua50/include" /I "../../compat/src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAEXPAT_DLL_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x416 /d "NDEBUG" +# ADD RSC /l 0x416 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 lua50.lib libexpat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../bin/vc6/lxp.dll" /libpath:"../../external-src/lua50/lib/dll" /libpath:"../../external-src/expat-1.95.8/lib/Release" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=cd ../bin/vc6 zip.exe luaexpat-1.0.1-win32.zip lxp.dll +# End Special Build Tool + +!ELSEIF "$(CFG)" == "luaexpat_dll - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../lib/vc6" +# PROP Intermediate_Dir "luaexpat_dll/Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAEXPAT_DLL_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../external-src/expat-1.95.8/lib" /I "../../external-src/lua50/include" /I "../../compat/src" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAEXPAT_DLL_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x416 /d "_DEBUG" +# ADD RSC /l 0x416 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 lua50.lib libexpat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../bin/vc6/lxpd.dll" /pdbtype:sept /libpath:"../../external-src/lua50/lib/dll" /libpath:"../../external-src/expat-1.95.8/lib/Debug" + +!ENDIF + +# Begin Target + +# Name "luaexpat_dll - Win32 Release" +# Name "luaexpat_dll - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE="..\..\compat\src\compat-5.1.c" +# End Source File +# Begin Source File + +SOURCE=.\lxp.def +# End Source File +# Begin Source File + +SOURCE=..\src\lxplib.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE="..\..\compat\src\compat-5.1.h" +# End Source File +# Begin Source File + +SOURCE=..\src\lxplib.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff -r 000000000000 -r 24d141cb2d1e vc6/luaexpat_static.dsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vc6/luaexpat_static.dsp Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,108 @@ +# Microsoft Developer Studio Project File - Name="luaexpat_static" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=luaexpat_static - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "luaexpat_static.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "luaexpat_static.mak" CFG="luaexpat_static - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "luaexpat_static - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "luaexpat_static - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "luaexpat_static - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../lib/vc6" +# PROP Intermediate_Dir "luaexpat_static/Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../expat/xmlparse" /I "../../lua/include" /I "../../compat" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x416 /d "NDEBUG" +# ADD RSC /l 0x416 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"../lib/vc6/liblxp.lib" + +!ELSEIF "$(CFG)" == "luaexpat_static - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../lib/vc6" +# PROP Intermediate_Dir "luaexpat_static/Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../expat/xmlparse" /I "../../lua/include" /I "../../compat" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x416 /d "_DEBUG" +# ADD RSC /l 0x416 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"../lib/vc6/liblxpd.lib" + +!ENDIF + +# Begin Target + +# Name "luaexpat_static - Win32 Release" +# Name "luaexpat_static - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE="..\..\compat\compat-5.1.c" +# End Source File +# Begin Source File + +SOURCE=..\lxplib.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE="..\..\compat\compat-5.1.h" +# End Source File +# Begin Source File + +SOURCE=..\lxplib.h +# End Source File +# End Group +# End Target +# End Project diff -r 000000000000 -r 24d141cb2d1e vc6/lxp.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vc6/lxp.def Wed Jun 01 22:14:25 2011 +0100 @@ -0,0 +1,9 @@ +LIBRARY lxp.dll + +DESCRIPTION "LuaExpat" + +VERSION 1.0.2 + +EXPORTS + +luaopen_lxp