pax_global_header00006660000000000000000000000064123127130730014511gustar00rootroot0000000000000052 comment=eed8338401196cc155e59280adbe58d78933ead0 lua-wsapi-1.6.1/000077500000000000000000000000001231271307300134205ustar00rootroot00000000000000lua-wsapi-1.6.1/Makefile000066400000000000000000000027401231271307300150630ustar00rootroot00000000000000# $Id: Makefile,v 1.14 2008/04/04 02:01:01 mascarenhas Exp $ include config DESTDIR := / LDIR := $(DESTDIR)/$(LUA_DIR) WDIR := $(DESTDIR)/$(LUA_DIR)/wsapi CDIR := $(DESTDIR)/$(LUA_LIBDIR) BDIR := $(DESTDIR)/$(BIN_DIR) all: cgi fastcgi cgi: config: touch config fastcgi: src/fastcgi/lfcgi.so fcgi: fastcgi src/fastcgi/lfcgi.so: src/fastcgi/lfcgi.h $(CC) $(CFLAGS) $(LDFLAGS) $(LIB_OPTION) -o src/fastcgi/lfcgi.so src/fastcgi/lfcgi.c -lfcgi $(INC) install: @mkdir -p $(LDIR) $(WDIR) $(BDIR) @cp src/*.lua $(LDIR) @cp src/wsapi/*.lua $(WDIR) @cp src/launcher/wsapi.cgi $(BDIR) @cp src/launcher/wsapi.fcgi $(BDIR) @echo "Installing of Lua WSAPI part is done!" install-fcgi: @mkdir -p $(CDIR) @cp src/fastcgi/lfcgi.so $(CDIR) @echo "Installing of bundled Lua-fcgi lib is done!" install-rocks: install mkdir -p $(PREFIX)/samples cp -r samples/* $(PREFIX)/samples mkdir -p $(PREFIX)/doc cp -r doc/* $(PREFIX)/doc clean: @rm -f config src/fastcgi/lfcgi.so @echo "Cleaning is done!" snapshot: git archive --format=tar --prefix=wsapi-$(VERSION)/ HEAD | gzip > wsapi-$(VERSION).tar.gz rockspecs: for pkg in wsapi wsapi-fcgi wsapi-xavante ; do cp rockspec/$$pkg-$(VERSION_OLD)-1.rockspec rockspec/$$pkg-$(VERSION_NEW)-1.rockspec ; done for pkg in wsapi wsapi-fcgi wsapi-xavante; do sed -e "s/$(VERSION_OLD)/$(VERSION_NEW)/g" -i "" rockspec/$$pkg-$(VERSION_NEW)-1.rockspec ; done for pkg in wsapi wsapi-fcgi wsapi-xavante; do git add rockspec/$$pkg-$(VERSION_NEW)-1.rockspec ; done lua-wsapi-1.6.1/Makefile.win000066400000000000000000000053101231271307300156530ustar00rootroot00000000000000# $Id: Makefile.win,v 1.28 2009/01/22 16:50:28 mascarenhas Exp $ LUA_INCLUDE= c:\lua5.1\include LUA_LIB= c:\lua5.1\lua5.1.lib LUA_DIR= c:\lua5.1\lua LUA_LIBDIR= c:\lua5.1 .c.obj: $(CC) /c /MD /Fo$@ $(CFLAGS) /I$(LUA_INCLUDE) $< src\launcher\launcher.exe: src\launcher\launcher.obj link /out:src\launcher\launcher.exe src\launcher\launcher.obj $(LUA_LIB) mt -manifest src\launcher\launcher.exe.manifest -outputresource:src\launcher\launcher.exe;1 src\launcher\wsapi.exe: src\launcher\wsapi.obj lua5.1 src\launcher\make_rc.lua src\launcher\wsapi.cgi > src\launcher\wsapi.rc rc /r /fosrc\launcher\wsapi.res src\launcher\wsapi.rc link /out:src\launcher\wsapi.exe src\launcher\wsapi.obj src\launcher\wsapi.res $(LUA_LIB) user32.lib mt -manifest src\launcher\wsapi.exe.manifest -outputresource:src\launcher\wsapi.exe;1 src\launcher\wsapi-fcgi.exe: src\launcher\wsapi.obj lua5.1 src\launcher\make_rc.lua src\launcher\wsapi.fcgi > src\launcher\wsapi-fcgi.rc rc /r /fosrc\launcher\wsapi-fcgi.res src\launcher\wsapi-fcgi.rc link /out:src\launcher\wsapi-fcgi.exe src\launcher\wsapi.obj src\launcher\wsapi-fcgi.res $(LUA_LIB) user32.lib mt -manifest src\launcher\wsapi-fcgi.exe.manifest -outputresource:src\launcher\wsapi-fcgi.exe;1 all: cgi fcgi cgi: src\launcher\launcher.exe src\launcher\wsapi.exe src\fastcgi\lfcgi.dll: src\fastcgi\lfcgi.obj link /manifest:no /dll /out:src\fastcgi\lfcgi.dll /def:src\fastcgi\lfcgi.def $(LIB_OPTION) src\fastcgi\lfcgi.obj Ws2_32.lib fcgi: src\fastcgi\lfcgi.dll src\launcher\wsapi-fcgi.exe install: IF NOT EXIST $(LUA_DIR)\wsapi mkdir $(LUA_DIR)\wsapi copy src\*.lua $(LUA_DIR) copy src\wsapi\*.lua $(LUA_DIR)\wsapi install-rocks: IF NOT EXIST "$(PREFIX)\lua" mkdir "$(PREFIX)\lua" IF NOT EXIST "$(PREFIX)\lua\wsapi" mkdir "$(PREFIX)\lua\wsapi" copy src\wsapi\*.lua "$(PREFIX)\lua\wsapi" del "$(PREFIX)\lua\wsapi\fastcgi.lua" del "$(PREFIX)\lua\wsapi\xavante.lua" IF NOT EXIST "$(PREFIX)\bin" "mkdir $(PREFIX)\bin" copy src\launcher\launcher.exe "$(PREFIX)\bin" copy src\launcher\wsapi.exe "$(PREFIX)\bin" IF NOT EXIST "$(PREFIX)\samples" mkdir "$(PREFIX)\samples" copy samples\* "$(PREFIX)\samples" IF NOT EXIST "$(PREFIX)\doc" mkdir "$(PREFIX)\doc" IF NOT EXIST "$(PREFIX)\doc\us" mkdir "$(PREFIX)\doc\us" copy doc\us\* "$(PREFIX)\doc\us" install-fcgi: IF NOT EXIST "$(PREFIX)\lua" mkdir "$(PREFIX)\lua" IF NOT EXIST "$(PREFIX)\lua\wsapi" mkdir "$(PREFIX)\lua\wsapi" copy src\wsapi\fastcgi.lua "$(PREFIX)\lua\wsapi" copy src\launcher\wsapi-fcgi.exe "$(BIN_DIR)" copy src\fastcgi\lfcgi.dll "$(LUA_LIBDIR)\" clean: del src\launcher\launcher.obj del src\launcher\launcher.exe del src\launcher\launcher.exe.manifest del src\fastcgi\lfcgi.dll del src\launcher\wsapi-fcgi.exe lua-wsapi-1.6.1/README000066400000000000000000000143101231271307300142770ustar00rootroot00000000000000WSAPI ( http://keplerproject.github.com/wsapi ) Overview WSAPI is an API that abstracts the web server from Lua web applications. By coding against WSAPI your application can run on any of the supported servers and interfaces (currently CGI, FastCGI and Xavante, on Windows and UNIX-based systems). WSAPI provides a set of helper libraries that help with request processing and output buffering. You can also write applications that act as filters that provide some kind of service to other applications, such as authentication, file uploads, request isolation, or multiplexing. WSAPI's main influence is Ruby's Rack framework, but it was also influenced by Python's WSGI (PEP 333). It's not a direct clone of either of them, though, and tries to follow standard Lua idioms. WSAPI is free software and uses the same license as Lua 5.1 Status Current version is 1.6.1. It supports both Lua 5.1 and Lua 5.2. Download WSAPI can be downloaded from its LuaForge page. You can also get WSAPI using LuaRocks: luarocks install wsapi Latest Sources and Bug Tracker WSAPI CVS and bug tracker are available at its Github page. History WSAPI 1.6.1 [21/Mar/2014] * Restores Lua 5.1 compatibility (incorrect usage of coxpcall) * Improvements to wsapi.mock * wsapi.request.qs_encode produces proper querystrings * FastCGI fixes * Additional options for cookies such as httponly and max age. WSAPI 1.6 [30/Jan/2013] * Lua 5.2 compatibility WSAPI 1.5 [21/Apr/2011] * Add lfcgi.finish() to lfcgi, to close the current FastCGI request in case the application does not want to call lfcgi.accept() right away * Fix response headers in sapi.lua * Fix reloading in non-isolated launchers * Errors in mock handler now go in response.wsapi_errors WSAPI 1.4 [19/Nov/2010] * Remove unecessary !# from sapi.lua * Added mock WSAPI handler (by Norman Clarke) * Flush output pipe after writing content * Respect rules specified in config file for "wsapi" launcher * Fix bug where common.load_wsapi would not return the module if it was already require'd * Fix bug where wsapi.ringer would try to close an already closed state * Refactoring of request, response, and util modules, to work with mk (http://github.com/keplerproject/mk) * New methods for wsapi.request: qs_encode (encodes a table as a query string), route_link (makes a link to a mk route, link (makes an internal app link), absolute_link (makes an absolute link), static_link (makes an external link), empty (checks if a string is just blanks or nil), empty_param (checks if a request param is empty), and renamed parse_post_data method to parse_post * New methods for wsapi.response: forward (sets path_info and returns an mk "keep parsing" code), content_type (sets Content-Type header), redirect (sets Location header and returns redirect WSAPI response), changed write to take multiple parameters and flatten nested tables * New functions in wsapi.util: make_env_get (makes a mock WSAPI environment for a GET request from a query string), make_env_post (makes a mock WSAPI environment for a POST request from a postdata string, a postdata type, default x-www-form-urlencoded, and a query string) WSAPI 1.3.4 [23/Mar/2010] * Bugfix release, fix bug introduced by previous fix :-) WSAPI 1.3.3 [22/Mar/2010] * Bugfix release, fix memory leak with reload option for persistent loaders WSAPI 1.3.2 [19/Mar/2010] * Bugfix release, do not send Transfer-Encoding header unless it is raw HTTP response WSAPI 1.3.1 [19/Mar/2010] * Bugfix release, fix the unknown symbol in lfcgi.getenv() WSAPI 1.3 [18/Mar/2010] * Fixed segmentation fault when non-string is provided to lfcgi.getenv() (thanks to mkottman@github) * Added CGILua bootstrap to wsapi.sapi, so CGILua can run without a kepler_init module present * Added an `extra_vars` paremeter to wsapi.xavante.makeHandler and wsapi.xavante.makeGenericHandler, to let you pass extra variables in the WSAPI environment * Added `overwrite` option to wsapi.request that tells the parameter parser to overwrite repeated parameters instead of collecting them in a list * Added a parameter `isolated` to the persistent generic loaders that controls whether you isolate each script in a Lua state or not * Added parameters to the persistent generic loaders that let the user control the life cycle of Lua states: `period` sets how long WSAPI should wait between collecting stale states, and `ttl` sets the period after which a state becomes stale * Fixed bug in wsapi.ringer that didn't let you use wsapi.input:read inside the response iterator * Parameter `vars` for the WSAPI generic loaders that which variables WSAPI should check to get the physical path of the script, and in which order. Defaults tro trying SCRIPT_FILENAME first and PATH_TRANSLATED second WSAPI 1.2 [27/Oct/2009] * Adds time-based collection of Lua states to FCGI and Xavante launchers * Adds "wsapi" laucher script, to start a Xavante WSAPI server * Fixed "undefined media type" error * Added is_empty utility function to check if a string is nil or '' * Fixed bug with empty bodies in wsapi.xavante, and added full http status codes to responses * Changing order of evaluating PATH_TRANSLATED and SCRIPT_FILENAME, to make non-wrapped launchers work in OSX Apache * Reload support for load_isolated_launcher WSAPI 1.1 [04/Feb/2009] * Adds options table to wsapi.request.new, *delay_post* option delays POST processing until req:parsepostdata() is called * Moves call to lfs.setmode from wsapi.common to wsapi.cgi * Adds wsapi.util.make_rewindable(wsapi_env) method - wraps wsapi_env in a new environment that lets you process the POST data more than once. * Correctly handles PATH_TRANSLATED and SCRIPT_FILENAME in case the web server gets creative * Statically links the FastCGI version on Windows WSAPI 1.0 [18/May/2008] * First public version. * Includes CGI, FastCGI and Xavante WSAPI connectors. Credits WSAPI was designed and developed by Fabio Mascarenhas and Andre Carregal, and is maintained by Fabio Mascarenhas. For more information please check the HTML documentation at /doc/us lua-wsapi-1.6.1/configure000077500000000000000000000014241231271307300153300ustar00rootroot00000000000000#!/bin/sh if [ $1 == "--help" ]; then echo "Usage: configure lua51" echo "where lua51 is the name of your Lua executable" exit 0 fi echo "Trying to find where you installed Lua..." if [ $1 != "" ]; then lua=$1 else lua="lua51" fi lua_bin=`which $lua` lua_bin_dir=`dirname $lua_bin` lua_root=`dirname $lua_bin_dir` if [ $lua_root != "" ]; then echo "Lua is in $lua_root" echo "Writing config" lua_share=$lua_root/share/lua/5.1 lua_lib=$lua_root/lib/lua/5.1 bin_dir=$lua_root/bin echo "LIB_OPTION= -shared -fPIC" > config echo "LUA_DIR= $lua_share" >> config echo "BIN_DIR= $bin_dir" >> config echo "LUA_LIBDIR= $lua_lib" >> config echo "Now run 'make && sudo make install'" else echo "Lua not found, please install Lua 5.1 (and put in your PATH)" fi lua-wsapi-1.6.1/doc/000077500000000000000000000000001231271307300141655ustar00rootroot00000000000000lua-wsapi-1.6.1/doc/us/000077500000000000000000000000001231271307300146145ustar00rootroot00000000000000lua-wsapi-1.6.1/doc/us/doc.css000066400000000000000000000077761231271307300161140ustar00rootroot00000000000000body { margin-left: 1em; margin-right: 1em; font-family: arial, helvetica, geneva, sans-serif; background-color:#ffffff; margin:0px; } code { font-family: "Andale Mono", monospace; } tt { font-family: "Andale Mono", monospace; } body, td, th { font-size: 11pt; } h1, h2, h3, h4 { margin-left: 0em; } textarea, pre, tt { font-size:10pt; } body, td, th { color:#000000; } small { font-size:0.85em; } h1 { font-size:1.5em; } h2 { font-size:1.25em; } h3 { font-size:1.15em; } h4 { font-size:1.06em; } a:link { font-weight:bold; color: #004080; text-decoration: none; } a:visited { font-weight:bold; color: #006699; text-decoration: none; } a:link:hover { text-decoration:underline; } hr { color:#cccccc } img { border-width: 0px; } h3 { padding-top: 1em; } p { margin-left: 1em; } p.name { font-family: "Andale Mono", monospace; padding-top: 1em; margin-left: 0em; } blockquote { margin-left: 3em; } .example { background-color: rgb(245, 245, 245); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: silver; border-right-color: silver; border-bottom-color: silver; border-left-color: silver; padding: 1em; margin-left: 1em; margin-right: 1em; font-family: "Andale Mono", monospace; font-size: smaller; } hr { margin-left: 0em; background: #00007f; border: 0px; height: 1px; } ul { list-style-type: disc; } table.index { border: 1px #00007f; } table.index td { text-align: left; vertical-align: top; } table.index ul { padding-top: 0em; margin-top: 0em; } table { border: 1px solid black; border-collapse: collapse; margin-left: auto; margin-right: auto; } th { border: 1px solid black; padding: 0.5em; } td { border: 1px solid black; padding: 0.5em; } div.header, div.footer { margin-left: 0em; } #container { margin-left: 1em; margin-right: 1em; background-color: #f0f0f0; } #product { text-align: center; border-bottom: 1px solid #cccccc; background-color: #ffffff; } #product big { font-size: 2em; } #product_logo { } #product_name { } #product_description { } #main { background-color: #f0f0f0; border-left: 2px solid #cccccc; } #navigation { float: left; width: 12em; margin: 0; vertical-align: top; background-color: #f0f0f0; overflow:visible; } #navigation h1 { background-color:#e7e7e7; font-size:1.1em; color:#000000; text-align:left; margin:0px; padding:0.2em; border-top:1px solid #dddddd; border-bottom:1px solid #dddddd; } #navigation ul { font-size:1em; list-style-type: none; padding: 0; margin: 1px; } #navigation li { text-indent: -1em; margin: 0em 0em 0em 0.5em; display: block; padding: 3px 0px 0px 12px; } #navigation li li a { padding: 0px 3px 0px -1em; } #content { margin-left: 12em; padding: 1em; border-left: 2px solid #cccccc; border-right: 2px solid #cccccc; background-color: #ffffff; } #about { clear: both; margin: 0; padding: 5px; border-top: 2px solid #cccccc; background-color: #ffffff; } @media print { body { font: 10pt "Times New Roman", "TimeNR", Times, serif; } a { font-weight:bold; color: #004080; text-decoration: underline; } #main { background-color: #ffffff; border-left: 0px; } #container { margin-left: 2%; margin-right: 2%; background-color: #ffffff; } #content { margin-left: 0px; padding: 1em; border-left: 0px; border-right: 0px; background-color: #ffffff; } #navigation { display: none; } #product_logo { display: none; } #about img { display: none; } .example { font-family: "Andale Mono", monospace; font-size: 8pt; page-break-inside: avoid; } } lua-wsapi-1.6.1/doc/us/index.html000066400000000000000000000252051231271307300166150ustar00rootroot00000000000000 WSAPI
WSAPI
Lua Web Server API

Overview

WSAPI is an API that abstracts the web server from Lua web applications. By coding against WSAPI your application can run on any of the supported servers and interfaces (currently CGI, FastCGI and Xavante, on Windows and UNIX-based systems).

WSAPI provides a set of helper libraries that help with request processing and output buffering. You can also write applications that act as filters that provide some kind of service to other applications, such as authentication, file uploads, request isolation, or multiplexing.

WSAPI's main influence is Ruby's Rack framework, but it was also influenced by Python's WSGI (PEP 333). It's not a direct clone of either of them, though, and tries to follow standard Lua idioms.

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

Status

Current version is 1.6.1. It supports both Lua 5.1 and Lua 5.2.

Download

You can get WSAPI using LuaRocks:

luarocks install wsapi-xavante

Unix Installer Script

You can also get an installer script that installs Lua+LuaRocks+WSAPI here. See the manual for installation instructions.

Customizing the installer

There is a section of wsapi-install-1.6 with the parameters that control the installer:

# Installer parameters

LUA_VERSION=5.2.1
PACKAGE=WSAPI
PACKAGE_OPT=wsapi
PACKAGE_ROCK=wsapi-xavante
INSTALLER_VERSION=0.7
PACKAGE_VERSION=1.6
LUAROCKS_REPO=http://luarocks.org/repositories/rocks
LUAROCKS_URL=http://www.luarocks.org/releases/luarocks-2.0.12.tar.gz
LUAROCKS_VERSION=2.0.12

To install something else change PACKAGE to the full name of the package, PACKAGE_OPT to the name of the --with-foo option that lets the user override the version (or skip installation of the package), PACKAGE_ROCK to the name of the rock, and PACKAGE_VERSION to the version. Also change LUAROCKS_REPO if you want to use another repository (the installer uses --from, so will pull packages from other repositories if the one you specified does not have them).

If there is a LuaRocks update then change LUAROCKS_URL and LUAROCKS_VERSION. Changing Lua version is much more involved, so I won't go into that.

Now to make the tarball, put the installer script in an empty folder and run:

bash ./your-install-script --prefix=/tmp/anything --bootstrap

After it finishes you will have lua-5.2.1.tar.gz, luarocks-2.0.12.tar.gz, and a rocks folder with .src.rocks for all the rocks that the installer installs.

Latest Sources and Bug Tracker

WSAPI sources and bug tracker are available at its Github page.

History

WSAPI 1.6.1 [21/Mar/2014]

  • Restores Lua 5.1 compatibility (incorrect usage of coxpcall)
  • Improvements to wsapi.mock
  • wsapi.request.qs_encode produces proper querystrings
  • FastCGI fixes
  • Additional options for cookies such as httponly and max age.

WSAPI 1.6 [30/Jan/2013]

  • Lua 5.2 compatibility

WSAPI 1.5 [21/Apr/2011]

  • Add lfcgi.finish() to lfcgi, to close the current FastCGI request in case the application does not want to call lfcgi.accept() right away
  • Fix response headers in sapi.lua
  • Fix reloading in non-isolated launchers
  • Errors in mock handler now go in response.wsapi_errors

WSAPI 1.4 [19/Nov/2010]

  • Remove unecessary !# from sapi.lua
  • Added mock WSAPI handler (by Norman Clarke)
  • Flush output pipe after writing content
  • Respect rules specified in config file for wsapi launcher
  • Fix bug where common.load_wsapi would not return the module if it was already require'd
  • Fix bug where wsapi.ringer would try to close an already closed state
  • Refactoring of request, response, and util modules, to work with mk
  • New methods for wsapi.request: qs_encode (encodes a table as a query string), route_link (makes a link to a mk route, link (makes an internal app link), absolute_link (makes an absolute link), static_link (makes an external link), empty (checks if a string is just blanks or nil), empty_param (checks if a request param is empty), and renamed parse_post_data method to parse_post
  • New methods for wsapi.response: forward (sets path_info and returns an mk "keep parsing" code), content_type (sets Content-Type header), redirect (sets Location header and returns redirect WSAPI response), changed write to take multiple parameters and flatten nested tables
  • New functions in wsapi.util: make_env_get (makes a mock WSAPI environment for a GET request from a query string), make_env_post (makes a mock WSAPI environment for a POST request from a postdata string, a postdata type, default x-www-form-urlencoded, and a query string)

WSAPI 1.3.4 [23/Mar/2010]

  • Bugfix release, fix bug introduced by previous fix :-)

WSAPI 1.3.3 [22/Mar/2010]

  • Bugfix release, fix memory leak with reload option for persistent loaders

WSAPI 1.3.2 [19/Mar/2010]

  • Bugfix release, do not send Transfer-Encoding header unless it is raw HTTP response

WSAPI 1.3.1 [19/Mar/2010]

  • Bugfix release, fix the unknown symbol in lfcgi.getenv()

WSAPI 1.3 [18/Mar/2010]

  • Fixed segmentation fault when non-string is provided to lfcgi.getenv() (thanks to mkottman@github)
  • Added CGILua bootstrap to wsapi.sapi, so CGILua can run without a kepler_init module present
  • Added an extra_vars paremeter to wsapi.xavante.makeHandler and wsapi.xavante.makeGenericHandler, to let you pass extra variables in the WSAPI environment
  • Added overwrite option to wsapi.request that tells the parameter parser to overwrite repeated parameters instead of collecting them in a list
  • Added a parameter isolated to the persistent generic loaders that controls whether you isolate each script in a Lua state or not
  • Added parameters to the persistent generic loaders that let the user control the life cycle of Lua states: period sets how long WSAPI should wait between collecting stale states, and ttl sets the period after which a state becomes stale
  • Fixed bug in wsapi.ringer that didn't let you use wsapi.input:read inside the response iterator
  • Parameter vars for the WSAPI generic loaders that which variables WSAPI should check to get the physical path of the script, and in which order. Defaults tro trying SCRIPT_FILENAME first and PATH_TRANSLATED second

WSAPI 1.2 [27/Oct/2009]

  • Adds time-based collection of Lua states to FCGI and Xavante launchers
  • Adds "wsapi" laucher script, to start a Xavante WSAPI server
  • Fixed "undefined media type" error
  • Added is_empty utility function to check if a string is nil or ''
  • Fixed bug with empty bodies in wsapi.xavante, and added full http status codes to responses
  • Changing order of evaluating PATH_TRANSLATED and SCRIPT_FILENAME, to make non-wrapped launchers work in OSX Apache
  • Reload support for load_isolated_launcher

WSAPI 1.1 [04/Feb/2009]

  • Adds options table to wsapi.request.new, *delay_post* option delays POST processing until req:parsepostdata() is called
  • Moves call to lfs.setmode from wsapi.common to wsapi.cgi
  • Adds wsapi.util.make_rewindable(wsapi_env) method - wraps wsapi_env in a new environment that lets you process the POST data more than once.
  • Correctly handles PATH_TRANSLATED and SCRIPT_FILENAME in case the web server gets creative
  • Statically links the FastCGI version on Windows

WSAPI 1.0 [18/May/2008]

  • First public version.
  • Includes CGI, FastCGI and Xavante WSAPI connectors.

Credits

WSAPI was designed and developed by Fabio Mascarenhas and André Carregal, and is maintained by Fabio Mascarenhas.

Contact Us

For more information please contact us. Comments are welcome!

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

Valid XHTML 1.0!

lua-wsapi-1.6.1/doc/us/index.md000066400000000000000000000177141231271307300162570ustar00rootroot00000000000000## Overview *WSAPI* is an API that abstracts the web server from Lua web applications. By coding against WSAPI your application can run on any of the supported servers and interfaces (currently CGI, FastCGI and Xavante, on Windows and UNIX-based systems). WSAPI provides a set of helper libraries that help with request processing and output buffering. You can also write applications that act as filters that provide some kind of service to other applications, such as authentication, file uploads, request isolation, or multiplexing. WSAPI's main influence is Ruby's [Rack](http://rack.rubyforge.org/) framework, but it was also influenced by Python's [WSGI](http://wsgi.org/wsgi) (PEP 333). It's not a direct clone of either of them, though, and tries to follow standard Lua idioms. WSAPI is free software and uses the same license as Lua 5.1. ## Status Current version is 1.6.1. It supports both Lua 5.1 and Lua 5.2. ## Download You can get WSAPI using [LuaRocks](http://luarocks.org):
luarocks install wsapi-xavante
### Unix Installer Script You can also get an installer script that installs Lua+LuaRocks+WSAPI [here](http://www.keplerproject.org/files/wsapi-install-1.6.1.tar.gz). See the [manual](manual.html) for installation instructions. ### Customizing the installer There is a section of wsapi-install-1.6 with the parameters that control the installer:
# Installer parameters

LUA_VERSION=5.2.1
PACKAGE=WSAPI
PACKAGE_OPT=wsapi
PACKAGE_ROCK=wsapi-xavante
INSTALLER_VERSION=0.7
PACKAGE_VERSION=1.6
LUAROCKS_REPO=http://luarocks.org/repositories/rocks
LUAROCKS_URL=http://www.luarocks.org/releases/luarocks-2.0.12.tar.gz
LUAROCKS_VERSION=2.0.12
To install something else change PACKAGE to the full name of the package, PACKAGE\_OPT to the name of the --with-foo option that lets the user override the version (or skip installation of the package), PACKAGE\_ROCK to the name of the rock, and PACKAGE\_VERSION to the version. Also change LUAROCKS\_REPO if you want to use another repository (the installer uses --from, so will pull packages from other repositories if the one you specified does not have them). If there is a LuaRocks update then change LUAROCKS\_URL and LUAROCKS\_VERSION. Changing Lua version is much more involved, so I won't go into that. Now to make the tarball, put the installer script in an empty folder and run:
bash ./your-install-script --prefix=/tmp/anything --bootstrap
After it finishes you will have lua-5.2.1.tar.gz, luarocks-2.0.12.tar.gz, and a rocks folder with .src.rocks for all the rocks that the installer installs. ## Latest Sources and Bug Tracker WSAPI sources and bug tracker are available at its [Github](http://github.com/keplerproject/wsapi/) page. ## History **WSAPI 1.6.1** [21/Mar/2014] * Restores Lua 5.1 compatibility (incorrect usage of coxpcall) * Improvements to wsapi.mock * wsapi.request.qs_encode produces proper querystrings * FastCGI fixes * Additional options for cookies such as httponly and max age. **WSAPI 1.6** [30/Jan/2013] * Lua 5.2 compatibility **WSAPI 1.5** [21/Apr/2011] * Add lfcgi.finish() to lfcgi, to close the current FastCGI request in case the application does not want to call lfcgi.accept() right away * Fix response headers in sapi.lua * Fix reloading in non-isolated launchers * Errors in mock handler now go in response.wsapi_errors **WSAPI 1.4** [19/Nov/2010] * Remove unecessary !# from `sapi.lua` * Added mock WSAPI handler (by Norman Clarke) * Flush output pipe after writing content * Respect rules specified in config file for `wsapi` launcher * Fix bug where `common.load_wsapi` would not return the module if it was already require'd * Fix bug where `wsapi.ringer` would try to close an already closed state * Refactoring of request, response, and util modules, to work with [mk](http://github.com/keplerproject/mk) * New methods for `wsapi.request`: qs\_encode (encodes a table as a query string), route\_link (makes a link to a mk route, link (makes an internal app link), absolute\_link (makes an absolute link), static\_link (makes an external link), empty (checks if a string is just blanks or nil), empty\_param (checks if a request param is empty), and renamed parse\_post\_data method to parse\_post * New methods for `wsapi.response`: forward (sets path_info and returns an mk "keep parsing" code), content\_type (sets Content-Type header), redirect (sets Location header and returns redirect WSAPI response), changed write to take multiple parameters and flatten nested tables * New functions in `wsapi.util`: make\_env\_get (makes a mock WSAPI environment for a GET request from a query string), make\_env\_post (makes a mock WSAPI environment for a POST request from a postdata string, a postdata type, default x-www-form-urlencoded, and a query string) **WSAPI 1.3.4** [23/Mar/2010] * Bugfix release, fix bug introduced by previous fix :-) **WSAPI 1.3.3** [22/Mar/2010] * Bugfix release, fix memory leak with reload option for persistent loaders **WSAPI 1.3.2** [19/Mar/2010] * Bugfix release, do not send Transfer-Encoding header unless it is raw HTTP response **WSAPI 1.3.1** [19/Mar/2010] * Bugfix release, fix the unknown symbol in lfcgi.getenv() **WSAPI 1.3** [18/Mar/2010] * Fixed segmentation fault when non-string is provided to lfcgi.getenv() (thanks to mkottman@github) * Added CGILua bootstrap to wsapi.sapi, so CGILua can run without a kepler_init module present * Added an `extra_vars` paremeter to wsapi.xavante.makeHandler and wsapi.xavante.makeGenericHandler, to let you pass extra variables in the WSAPI environment * Added `overwrite` option to wsapi.request that tells the parameter parser to overwrite repeated parameters instead of collecting them in a list * Added a parameter `isolated` to the persistent generic loaders that controls whether you isolate each script in a Lua state or not * Added parameters to the persistent generic loaders that let the user control the life cycle of Lua states: `period` sets how long WSAPI should wait between collecting stale states, and `ttl` sets the period after which a state becomes stale * Fixed bug in wsapi.ringer that didn't let you use wsapi.input:read inside the response iterator * Parameter `vars` for the WSAPI generic loaders that which variables WSAPI should check to get the physical path of the script, and in which order. Defaults tro trying SCRIPT\_FILENAME first and PATH\_TRANSLATED second **WSAPI 1.2** [27/Oct/2009] * Adds time-based collection of Lua states to FCGI and Xavante launchers * Adds "wsapi" laucher script, to start a Xavante WSAPI server * Fixed "undefined media type" error * Added is_empty utility function to check if a string is nil or '' * Fixed bug with empty bodies in wsapi.xavante, and added full http status codes to responses * Changing order of evaluating PATH\_TRANSLATED and SCRIPT\_FILENAME, to make non-wrapped launchers work in OSX Apache * Reload support for load\_isolated\_launcher **WSAPI 1.1** [04/Feb/2009] * Adds *options* table to **wsapi.request.new**, *delay_post* option delays POST processing until **req:parse_post_data()** is called * Moves call to **lfs.setmode** from wsapi.common to wsapi.cgi * Adds **wsapi.util.make\_rewindable(*wsapi\_env*)** method - wraps *wsapi\_env* in a new environment that lets you process the POST data more than once. * Correctly handles PATH\_TRANSLATED and SCRIPT\_FILENAME in case the web server gets creative * Statically links the FastCGI version on Windows [**WSAPI 1.0**](http://wsapi.luaforge.net/1.0/) [18/May/2008] * First public version. * Includes CGI, FastCGI and Xavante WSAPI connectors. ## Credits WSAPI was designed and developed by Fabio Mascarenhas and André Carregal, and is maintained by Fabio Mascarenhas. ## Contact Us For more information please [contact us](mailto:info-NO-SPAM-THANKS@keplerproject.org). Comments are welcome! You can also reach us and other developers and users on the Kepler Project [mailing list](http://luaforge.net/mail/?group_id=104). lua-wsapi-1.6.1/doc/us/libraries.html000066400000000000000000000212421231271307300174570ustar00rootroot00000000000000 WSAPI
WSAPI
Lua Web Server API

Overview

WSAPI includes a set of helper libraries to make writing applications and web frameworks easier. To use these libraries just require them in your application or framework.

Request

wsapi.request.new(wsapi_env, [options]) - creates a new request object wrapping wsapi_env; options is an (optional) table of extra options for the request; the delay_post option tells wsapi.request to not process POST data on creation, the overwrite option tells WSAPI to overwrite input parameters with the same name instead of collecting them in a list, and the mk_app option passes the mk application that created the request object, used in some of the methods

req:parse_post() - processed the POST data in case the processing was delayed by passing delay_post = true on creation of the request

req:qd_encode(tab) - encodes tab as a query string

req:route_link(route, tab, ...) - creates a link to mk route route, encoding tab as the query string and passing extra arguments to the link builder of the route

req:link_<route>(tab, ...) - same as req:route_link(route, tab, ...)

req:link(uri, tab) - makes an internal application link to the specified resource uri, with tab encoded as a query string. For example, if the app is addressed by /foo/bar.lua then req:link("/baz", { id = 2 }) returns "/foo/bar.lua/baz?id=2"

req:static_link(uri, tab) - as req:link, but builds a link external to the application. In the previous example it would return "/foo/baz?id=2"

req:absolute_link(url, tab) - just encodes tab as a query string and appends it to url. Use it to make non-decorated links

req:empty(s) - returns true if s is nil or a blank string, false otherwise

req:empty_param(name) - same as req:empty(req.params[name])

req.GET - table with GET parameters of request

req.POST - table with POST parameters of request

req.method - request method (usually "GET" or "POST")

req.path_info - PATH_INFO metavariable

req.script_name - SCRIPT_NAME metavariable

req.doc_root - DOCUMENT_ROOT metavariable

req.env - the original WSAPI environment

req.app_path - the path of the WSAPI application currently running

req.query_string - unparsed query string

req.params - union of req.GET and req.POST, built on demand

req.cookies[name] - gets value of a cookie from browser

Response

wsapi.response.new([status, headers]) - creates a new response object, optionally setting an initial status code and header table. If a Content-Type was not passed in the initial header table then sets it as "text/html". The default status code is 200

res.status - status code to be returned to server

res.headers - table with headers to be returned to server

res:content_type(mime) - sets the Content-Type header to mime

res:write(...) - adds the arguments to the body, flattening an argument if it is a table

res:set_cookie(name, value) - sets the value of a cookie, value can be either a string or a table with fields value, expires (expiration date), domain, path, and secure. All fields except value are optional

res:delete_cookie(name, path) - tells the browser to erase a cookie, with an optional path

res:delete_cookie(name, path) - tells the browser to erase a cookie, with an optional path and domain

res:redirect(url) - sets status and headers for a redirect response to url, and returns a WSAPI response that does the redirect

res:forward(uri) - sets the PATH_INFO metavariable to uri (if not nil) and returns a mk FORWARD response to tell mk to keep trying to find a request handler

res:finish() - finishes response, returning status, headers and an iterator for the body

Util

wsapi.util.url_encode(s) - encodes s according to RFC2396

wsapi.util.url_decode(s) - decodes s according to RFC2396

wsapi.util.sanitize(text) - sanitizes all HTML tags in text, replacing < and > with the corresponding entity codes

wsapi.util.not_empty(s) - returns true if s is not nil or the empty string

wsapi.util.getopt(arg, options) - POSIX style command line argument parser, arg contains the command line arguments in a standard table, options is a string with the letters that expect string values. Returns a table with the options that have been passed and their values

wsapi.util.make_env_get(qs) - makes a mock WSAPI environment with GET method and qs as the query string

wsapi.util.make_env_post(pd, type, qs) - makes a mock WSAPI environment with POST method and pd as the postdata, type as the encoding (x-www-form-urlenconded default), and qs as the query string

wsapi.util.make_rewindable(wsapi_env) - wraps wsapi_env in a new environment that lets you process the POST data more than once. This new environment's input object has a rewind method that you can call to allow you to read the POST data again.

Mock

make_handler(wsapi_app) - Creates a mock handler for testing the WSAPI application you pass in.

The resulting handler will be a table with three fields:

app - The app itself.

get - A function to perform GET requests.

post - A function to perform POST requests.

The get and post functions both accept the following arguments:

path (required) - The path to request. Do not include the query string, this is specified in params.

params (optional) - A table of query or form data parameters.

headers (optional) - Any request headers you wish to specify.

Valid XHTML 1.0!

lua-wsapi-1.6.1/doc/us/libraries.md000066400000000000000000000131311231271307300171110ustar00rootroot00000000000000## Overview WSAPI includes a set of helper libraries to make writing applications and web frameworks easier. To use these libraries just `require` them in your application or framework. ## Request **wsapi.request.new(*wsapi\_env*, [*options*])** - creates a new request object wrapping *wsapi\_env*; *options* is an (optional) table of extra options for the request; the *delay\_post* option tells wsapi.request to not process POST data on creation, the *overwrite* option tells WSAPI to overwrite input parameters with the same name instead of collecting them in a list, and the *mk\_app* option passes the [mk](http://github.com/keplerproject/mk) application that created the request object, used in some of the methods **req:parse\_post()** - processed the POST data in case the processing was delayed by passing *delay\_post = true* on creation of the request **req:qd\_encode(*tab*)** - encodes *tab* as a query string **req:route\_link(*route*, *tab*, ...)** - creates a link to mk route *route*, encoding *tab* as the query string and passing extra arguments to the link builder of the route **req:link\_<route>(*tab*, ...)** - same as **req:route\_link(*route*, *tab*, ...)** **req:link(*uri*, *tab*)** - makes an internal application link to the specified resource *uri*, with *tab* encoded as a query string. For example, if the app is addressed by /foo/bar.lua then **req:link("/baz", { id = 2 })** returns "/foo/bar.lua/baz?id=2" **req:static\_link(*uri*, *tab*)** - as **req:link**, but builds a link external to the application. In the previous example it would return "/foo/baz?id=2" **req:absolute\_link(*url*, *tab*)** - just encodes *tab* as a query string and appends it to *url*. Use it to make non-decorated links **req:empty(*s*)** - returns `true` if *s* is `nil` or a blank string, `false` otherwise **req:empty\_param(*name*)** - same as **req:empty(req.params[*name*])** **req.GET** - table with GET parameters of request **req.POST** - table with POST parameters of request **req.method** - request method (usually "GET" or "POST") **req.path\_info** - PATH\_INFO metavariable **req.script\_name** - SCRIPT\_NAME metavariable **req.doc\_root** - DOCUMENT\_ROOT metavariable **req.env** - the original WSAPI environment **req.app\_path** - the path of the WSAPI application currently running **req.query\_string** - unparsed query string **req.params** - union of **req.GET** and **req.POST**, built on demand **req.cookies[*name*]** - gets value of a cookie from browser ## Response **wsapi.response.new([*status*, *headers*])** - creates a new response object, optionally setting an initial status code and header table. If a Content-Type was not passed in the initial header table then sets it as "text/html". The default status code is 200 **res.status** - status code to be returned to server **res.headers** - table with headers to be returned to server **res:content\_type(*mime*)** - sets the Content-Type header to *mime* **res:write(...)** - adds the arguments to the body, flattening an argument if it is a table **res:set\_cookie(*name*, *value*)** - sets the value of a cookie, *value* can be either a string or a table with fields *value*, *expires* (expiration date), *domain*, *path*, and *secure*. All fields except *value* are optional **res:delete\_cookie(*name*, *path*, *domain*)** - tells the browser to erase a cookie, with an optional *path* and *domain* **res:redirect(*url*)** - sets status and headers for a redirect response to *url*, and returns a WSAPI response that does the redirect **res:forward(*uri*)** - sets the PATH\_INFO metavariable to *uri* (if not nil) and returns a mk FORWARD response to tell [mk](http://github.com/keplerproject/mk) to keep trying to find a request handler **res:finish()** - finishes response, returning status, headers and an iterator for the body ## Util **wsapi.util.url\_encode(*s*)** - encodes *s* according to RFC2396 **wsapi.util.url\_decode(*s*)** - decodes *s* according to RFC2396 **wsapi.util.sanitize(*text*)** - sanitizes all HTML tags in *text*, replacing < and > with the corresponding entity codes **wsapi.util.not\_empty(*s*)** - returns `true` if *s* is not `nil` or the empty string **wsapi.util.getopt(*arg*, *options*)** - POSIX style command line argument parser, *arg* contains the command line arguments in a standard table, *options* is a string with the letters that expect string values. Returns a table with the options that have been passed and their values **wsapi.util.make\_env\_get(*qs*)** - makes a mock WSAPI environment with GET method and *qs* as the query string **wsapi.util.make\_env\_post(*pd*, *type*, *qs*)** - makes a mock WSAPI environment with POST method and *pd* as the postdata, *type* as the encoding (x-www-form-urlenconded default), and *qs* as the query string **wsapi.util.make\_rewindable(*wsapi\_env*)** - wraps *wsapi\_env* in a new environment that lets you process the POST data more than once. This new environment's input object has a *rewind* method that you can call to allow you to read the POST data again. ## Mock **make\_handler(*wsapi\_app*)** - Creates a mock handler for testing the WSAPI application you pass in. The resulting handler will be a table with three fields: **app** - The app itself. **get** - A function to perform GET requests. **post** - A function to perform POST requests. The `get` and `post` functions both accept the following arguments: **path** (required) - The path to request. Do not include the query string, this is specified in `params`. **params** (optional) - A table of query or form data parameters. **headers** (optional) - Any request headers you wish to specify.lua-wsapi-1.6.1/doc/us/license.html000066400000000000000000000066021231271307300171300ustar00rootroot00000000000000 WSAPI
WSAPI
Lua Web Server API

License

WSAPI 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. WSAPI qualifies as Open Source software. Its licenses are compatible with GPL. WSAPI 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 WSAPI for any purpose at no cost without having to ask us. The only requirement is that if you do use WSAPI, then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.

The WSAPI library is designed and implemented by Fábio Mascarenhas and André Carregal. The implementation is not derived from licensed software.


Copyright © 2007-2014 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!

lua-wsapi-1.6.1/doc/us/license.md000066400000000000000000000040611231271307300165610ustar00rootroot00000000000000

License

WSAPI 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. WSAPI qualifies as Open Source software. Its licenses are compatible with GPL. WSAPI 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 WSAPI for any purpose at no cost without having to ask us. The only requirement is that if you do use WSAPI, then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.

The WSAPI library is designed and implemented by Fábio Mascarenhas and André Carregal. The implementation is not derived from licensed software.


Copyright © 2007-2014 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.

lua-wsapi-1.6.1/doc/us/makedoc.lua000066400000000000000000000054551231271307300167330ustar00rootroot00000000000000local cosmo = require "cosmo" require "markdown" local pages = { { name = "Home", file = "index", sections = {} }, { name = "Manual", file = "manual", sections = {} }, { name = "Libraries", file = "libraries", sections = {} }, { name = "License", file = "license", sections = {} } } local project = { name = "WSAPI", blurb = "Lua Web Server API", logo = "wsapi.png", } local template = [==[ $name
$name
$blurb
$content

Valid XHTML 1.0!

]==] local function readfile(filename) local file = io.open(filename) local contents = file:read("*a") file:close() return contents end local function writefile(filename, contents) local file = io.open(filename, "w+") file:write(contents) file:close() end local function gen_page(project, pages, p) project.pages = function () for _, page in ipairs(pages) do local namelink if page.file == p.file then namelink = cosmo.fill([[$name]], { name = page.name}) else namelink = cosmo.fill([[$name]], { name = page.name, file = page.file}) end cosmo.yield{ namelink = namelink, sections = function () for _, s in ipairs(page.sections) do cosmo.yield{ name = s.name, anchor = page.file .. ".html#" .. s.anchor } end end } end end return (cosmo.fill(template, project)) end for _, p in ipairs(pages) do project.content = markdown(readfile(p.file .. ".md")) writefile(p.file .. ".html", gen_page(project, pages, p)) end lua-wsapi-1.6.1/doc/us/manual.html000066400000000000000000000305001231271307300167550ustar00rootroot00000000000000 WSAPI
WSAPI
Lua Web Server API

Installation

To install WSAPI you need to have LuaRocks. Just install the wsapi package. If you want FastCGI support you need to have the FastCGI dev kit installed, and use the wsapi-fcgi LuaRocks package. If you want Xavante support installed use the wsapi-xavante LuaRocks package.

The WSAPI rock copies samples, docs and support files to its path inside your local Rocks repository.

There is an all-in-one installer script that installs Lua, LuaRocks, and wsapi-xavante in a single step. Download the tarball, unpack it, then run the provided wsapi-install script in its path. Run wsapi-install --help for installation options.

About web servers

To run WSAPI applications you will also need a web server such as Xavante, Apache, Lighttpd, or IIS (available only for Windows). Xavante is a webserver written in pure Lua. To use the Xavante connector, install the "wsapi-xavante" rock (it is already installed if you used the wsapi-install script).

A Simple WSAPI Application

WSAPI applications are Lua functions that take an environment and return the status code, response headers and an output iterator. A very simple application is the following:

function hello(wsapi_env)
  local headers = { ["Content-type"] = "text/html" }

  local function hello_text()
    coroutine.yield("<html><body>")
    coroutine.yield("<p>Hello Wsapi!</p>")
    coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
    coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
    coroutine.yield("</body></html>")
  end

  return 200, headers, coroutine.wrap(hello_text)
end

If you have some experience with web development the example code above should be self-explanatory.

Applications usually are not implemented as naked functions, though, but packaged inside Lua modules with a run function that is the entry point for WSAPI. This run function is then passed to your server's WSAPI connector. The generic application launchers provided with WSAPI respect this pattern.

This is how the above example would look packaged this way (for example, in a hello.lua file):

#!/usr/bin/env wsapi.cgi

local _M = {}

function _M.run(wsapi_env)
  local headers = { ["Content-type"] = "text/html" }

  local function hello_text()
    coroutine.yield("<html><body>")
    coroutine.yield("<p>Hello Wsapi!</p>")
    coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
    coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
    coroutine.yield("</body></html>")
  end

  return 200, headers, coroutine.wrap(hello_text)
end

return _M

The first line tells the UNIX-based web servers such as Apache to run WSAPI's generic CGI launcher when executing this file as a CGI script.

Running the application

This step depends on your server and the connector you want to use.

Xavante

If you installed the wsapi-xavante package you already have a Xavante launcher with WSAPI support. Just run the wsapi script in the path you want as your document root, and point your browser either to the hello.lua or hello.ws script (both extensions are treated as WSAPI applications). See wsapi --help for the launcher's configuration options.

UNIX-like (Apache, Lighty, etc.) CGI/FastCGI

You can run hello.lua directly as a CGI script, through the generic CGI launcher wsapi. Just give execute permission hello.lua and put it in a URL-accessible path with execute permission. You should then see something like this when accessing the corresponding hello.lua URL:

    Hello Wsapi!
    PATH\_INFO: /
    SCRIPT\_NAME: /cgi-bin/hello.lua

The generic FastCGI launcher wsapi-fcgi can also run the hello.lua file directly. Configuration depends on your web server, but you should tell it to run .lua files as FastCGI scripts with wsapi-fcgi as the wrapper (the configuration is analogous to the necessary for running PHP scripts with FastCGI). As an example, this are the changes in httpd.conf for using Apache's *mod_fcgid*:

    AddHandler fcgid-script .lua
    FCGIWrapper /usr/bin/wsapi-fcgi .lua

You can also run hello.lua through a launcher script specially tailored to it. The driver script is very similar for both connectors. For CGI it can be this one (hello.cgi):

#!/usr/bin/env lua

local cgi = require "wsapi.cgi"
local hello = require "hello"
cgi.run(hello.run)

For FastCGI (hello.fcgi):

#!/usr/bin/env lua

local fastcgi = require "wsapi.fastcgi"
local hello = require "hello"
fastcgi.run(hello.run)

You may need to change lua to the name or your Lua interpreter executable. Now flag the launcher as executable and put it in a URL-accessible path that has execute permissions. You should see something like this when accessing the corresponding URL:

    Hello Wsapi!
    PATH\_INFO: /
    SCRIPT\_NAME: /cgi-bin/hello.cgi

Windows IIS CGI/FastCGI

The generic launchers on Windows are called wsapi.exe and wsapi-fcgi.exe. You should associate the .lua file extension with one of them on IIS' management console. Then copy hello.lua to some URL-accessible path.

For CGI there is also a launcher.exe that you can rename to hello.exe and it will run the hello.cgi application launcher (not the hello.lua application!). Both should be in the same path, and it should be URL-accessible and have execute permissions on IIS. You should point your browser to hello.exe.

Writing WSAPI connectors

A WSAPI connector builds the environment from information passed by the web server and calls a WSAPI application, sending the response back to the web server. The first thing a connector needs is a way to specify which application to run, and this is highly connector specific. Most connectors receive the application entry point as a parameter (but WSAPI provides special applications called generic launchers as a convenience).

The environment is a Lua table containing the CGI metavariables (at minimum the RFC3875 ones) plus any server-specific metainformation. It also contains an input field, a stream for the request's data, and an error field, a stream for the server's error log. The input field answers to the read([n]) method, where n is the number of bytes you want to read (or nil if you want the whole input). The error field answers to the write(...) method.

The environment should return the empty string instead of nil for undefined metavariables, and the PATH\_INFO variable should return "/" even if the path is empty. Behavior among the connectors should be uniform: SCRIPT\_NAME should hold the URI up to the part where you identify which application you are serving, if applicable (again, this is highly connector specific), while PATH\_INFO should hold the rest of the URL.

After building the environment the connector calls the application passing the environment to it, and collecting three return values: the HTTP status code, a table with headers, and the output iterator. The connector sends the status and headers right away to the server, as WSAPI does not guarantee any buffering itself. After that it begins calling the iterator and sending output to the server until it returns nil.

The connectors are careful to treat errors gracefully: if they occur before sending the status and headers they return an "Error 500" page instead, if they occur while iterating over the response they append the error message to the response.

Conveniences for application writers

WSAPI is very low-level and just lets your application pretend that web servers and gateway interfaces are similar, but it does not do any kind of processing/parsing on the request, nor any buffering on the output. Most web applications need these features, so we provide helper libraries to do it.

The first library is wsapi.request. This library encapsulates the environment, parsing the request data (GET and POST) and also handling file uploads and incoming cookies.

The other helper is wsapi.response, which offers a simpler interface (along with buffering) for output instead of the inversion of control of the iterator. It also lets you easily send cookies back to the browser.

Finally there is wsapi.util, which provides URI encoding/decoding and other utility functions.

WSAPI frameworks

The facilities above make it easier to write applications, but still are very basic. For more advanced web programming there are also frameworks built on top of WSAPI. Examples would be Orbit, which adds niceties as dispatch based on pattern matching over the PATH_INFO, easy serving of static content, easy access to databases, and easy page caching, and SAPI, included in the WSAPI package as the wsapi.sapi application, for running CGILua scripts and Lua pages.

Testing WSAPI applications

WSAPI comes with a mock connector that can be used for testing. It provides methods to send requests to your application and format responses. Functionality such as assertions and validations is left entirely to the testing framework you choose to use. Here's a simple example of how to use the mock connector:

local connector = require "wsapi.mock"

function hello(wsapi_env)
  local headers = { ["Content-type"] = "text/html" }
  local function hello_text()
    coroutine.yield("hello world!")
  end
  return 200, headers, coroutine.wrap(hello_text)
end

local app = connector.make_handler(hello)

do
  local response, request = app:get("/", {hello = "world"})
  assert(response.code                    == 200)
  assert(request.request_method           == "GET")
  assert(request.query_string             == "?hello=world")
  assert(response.headers["Content-type"] == "text/html")
  assert(response.body                    == "hello world!")
end

Valid XHTML 1.0!

lua-wsapi-1.6.1/doc/us/manual.md000066400000000000000000000241771231271307300164260ustar00rootroot00000000000000## Installation To install WSAPI you need to have [LuaRocks](http://luarocks.org). Just install the `wsapi` package. If you want FastCGI support you need to have the [FastCGI dev kit](http://www.fastcgi.com/#TheDevKit) installed, and use the `wsapi-fcgi` LuaRocks package. If you want Xavante support installed use the `wsapi-xavante` LuaRocks package. The WSAPI rock copies samples, docs and support files to its path inside your local Rocks repository. There is an all-in-one installer script that installs Lua, LuaRocks, and `wsapi-xavante` in a single step. Download the [tarball](http://www.keplerproject.org/files/wsapi-install-1.6.0.tar.gz), unpack it, then run the provided `wsapi-install` script in its path. Run `wsapi-install --help` for installation options. ### About web servers To run WSAPI applications you will also need a web server such as [Xavante](http://keplerproject.github.com/xavante/), [Apache](http://www.apache.org/), [Lighttpd](http://www.lighttpd.net/), or [IIS](http://www.iis.net/) (available only for Windows). Xavante is a webserver written in pure Lua. To use the Xavante connector, install the "wsapi-xavante" rock (it is already installed if you used the `wsapi-install` script). ## A Simple WSAPI Application WSAPI applications are Lua functions that take an *environment* and return the status code, response headers and an output iterator. A very simple application is the following:
function hello(wsapi_env)
  local headers = { ["Content-type"] = "text/html" }

  local function hello_text()
    coroutine.yield("<html><body>")
    coroutine.yield("<p>Hello Wsapi!</p>")
    coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
    coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
    coroutine.yield("</body></html>")
  end

  return 200, headers, coroutine.wrap(hello_text)
end
If you have some experience with web development the example code above should be self-explanatory. Applications usually are not implemented as naked functions, though, but packaged inside Lua modules with a `run` function that is the entry point for WSAPI. This `run` function is then passed to your server's WSAPI connector. The generic application launchers provided with WSAPI respect this pattern. This is how the above example would look packaged this way (for example, in a *hello.lua* file):
#!/usr/bin/env wsapi.cgi

local _M = {}

function _M.run(wsapi_env)
  local headers = { ["Content-type"] = "text/html" }

  local function hello_text()
    coroutine.yield("<html><body>")
    coroutine.yield("<p>Hello Wsapi!</p>")
    coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
    coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
    coroutine.yield("</body></html>")
  end

  return 200, headers, coroutine.wrap(hello_text)
end

return _M
The first line tells the UNIX-based web servers such as Apache to run WSAPI's generic CGI launcher when executing this file as a CGI script. ## Running the application This step depends on your server and the connector you want to use. ### Xavante If you installed the `wsapi-xavante` package you already have a Xavante launcher with WSAPI support. Just run the `wsapi` script in the path you want as your document root, and point your browser either to the `hello.lua` or `hello.ws` script (both extensions are treated as WSAPI applications). See `wsapi --help` for the launcher's configuration options. ### UNIX-like (Apache, Lighty, etc.) CGI/FastCGI You can run *hello.lua* directly as a CGI script, through the generic CGI launcher *wsapi*. Just give execute permission *hello.lua* and put it in a URL-accessible path with execute permission. You should then see something like this when accessing the corresponding *hello.lua* URL: Hello Wsapi! PATH\_INFO: / SCRIPT\_NAME: /cgi-bin/hello.lua The generic FastCGI launcher *wsapi-fcgi* can also run the *hello.lua* file directly. Configuration depends on your web server, but you should tell it to run *.lua* files as FastCGI scripts with *wsapi-fcgi* as the wrapper (the configuration is analogous to the necessary for running PHP scripts with FastCGI). As an example, this are the changes in `httpd.conf` for using Apache's *mod_fcgid*: AddHandler fcgid-script .lua FCGIWrapper /usr/bin/wsapi-fcgi .lua You can also run *hello.lua* through a launcher script specially tailored to it. The driver script is very similar for both connectors. For CGI it can be this one (*hello.cgi*):
#!/usr/bin/env lua

local cgi = require "wsapi.cgi"
local hello = require "hello"
cgi.run(hello.run)
For FastCGI (*hello.fcgi*):
#!/usr/bin/env lua

local fastcgi = require "wsapi.fastcgi"
local hello = require "hello"
fastcgi.run(hello.run)
You may need to change *lua* to the name or your Lua interpreter executable. Now flag the launcher as executable and put it in a URL-accessible path that has execute permissions. You should see something like this when accessing the corresponding URL: Hello Wsapi! PATH\_INFO: / SCRIPT\_NAME: /cgi-bin/hello.cgi ### Windows IIS CGI/FastCGI The generic launchers on Windows are called *wsapi.exe* and *wsapi-fcgi.exe*. You should associate the *.lua* file extension with one of them on IIS' management console. Then copy *hello.lua* to some URL-accessible path. For CGI there is also a *launcher.exe* that you can rename to *hello.exe* and it will run the *hello.cgi* application launcher (**not** the *hello.lua* application!). Both should be in the same path, and it should be URL-accessible and have execute permissions on IIS. You should point your browser to *hello.exe*. ## Writing WSAPI connectors A WSAPI connector builds the environment from information passed by the web server and calls a WSAPI application, sending the response back to the web server. The first thing a connector needs is a way to specify which application to run, and this is highly connector specific. Most connectors receive the application entry point as a parameter (but WSAPI provides special applications called *generic launchers* as a convenience). The environment is a Lua table containing the CGI metavariables (at minimum the RFC3875 ones) plus any server-specific metainformation. It also contains an *input* field, a stream for the request's data, and an *error* field, a stream for the server's error log. The input field answers to the *read([n])* method, where *n* is the number of bytes you want to read (or nil if you want the whole input). The error field answers to the *write(...)* method. The environment should return the empty string instead of nil for undefined metavariables, and the `PATH\_INFO` variable should return "/" even if the path is empty. Behavior among the connectors should be uniform: `SCRIPT\_NAME` should hold the URI up to the part where you identify which application you are serving, if applicable (again, this is highly connector specific), while `PATH\_INFO` should hold the rest of the URL. After building the environment the connector calls the application passing the environment to it, and collecting three return values: the HTTP status code, a table with headers, and the output iterator. The connector sends the status and headers right away to the server, as WSAPI does not guarantee any buffering itself. After that it begins calling the iterator and sending output to the server until it returns nil. The connectors are careful to treat errors gracefully: if they occur before sending the status and headers they return an "Error 500" page instead, if they occur while iterating over the response they append the error message to the response. ## Conveniences for application writers WSAPI is very low-level and just lets your application pretend that web servers and gateway interfaces are similar, but it does not do any kind of processing/parsing on the request, nor any buffering on the output. Most web applications need these features, so we provide helper libraries to do it. The first library is *wsapi.request*. This library encapsulates the environment, parsing the request data (GET and POST) and also handling file uploads and incoming cookies. The other helper is *wsapi.response*, which offers a simpler interface (along with buffering) for output instead of the inversion of control of the iterator. It also lets you easily send cookies back to the browser. Finally there is *wsapi.util*, which provides URI encoding/decoding and other utility functions. ## WSAPI frameworks The facilities above make it easier to write applications, but still are very basic. For more advanced web programming there are also frameworks built on top of WSAPI. Examples would be **[Orbit](http://keplerproject.github.com/orbit)**, which adds niceties as dispatch based on pattern matching over the PATH\_INFO, easy serving of static content, easy access to databases, and easy page caching, and **SAPI**, included in the WSAPI package as the *wsapi.sapi* application, for running **[CGILua](http://www.keplerproject.org/cgilua/)** scripts and Lua pages. ## Testing WSAPI applications WSAPI comes with a mock connector that can be used for testing. It provides methods to send requests to your application and format responses. Functionality such as assertions and validations is left entirely to the testing framework you choose to use. Here's a simple example of how to use the mock connector:
local connector = require "wsapi.mock"

function hello(wsapi_env)
  local headers = { ["Content-type"] = "text/html" }
  local function hello_text()
    coroutine.yield("hello world!")
  end
  return 200, headers, coroutine.wrap(hello_text)
end

local app = connector.make_handler(hello)

do
  local response, request = app:get("/", {hello = "world"})
  assert(response.code                    == 200)
  assert(request.request_method           == "GET")
  assert(request.query_string             == "?hello=world")
  assert(response.headers["Content-type"] == "text/html")
  assert(response.body                    == "hello world!")
end
lua-wsapi-1.6.1/doc/us/wsapi.png000066400000000000000000000205521231271307300164510ustar00rootroot00000000000000‰PNG  IHDR€€Ã>aËbKGDÿÿÿ ½§“ pHYsHHFÉk> ²IDATxÚíy\ÔÕÞÇ?¿Yv†D–a_%D pI42SPÛ¬4ËÌRŸÖ§§[¯ûÜnO×Ûz³õ–™áV¦)Yä‚(ˆ˜ „,âìÛ°Ì0ë÷ùÃ+‰lóf`0ßÁëw~sÎùžÏïìç{"Â]þ¼pF;w]î àOÎ]üɹ+€?9wð'çŽÝÊè̘@{{;íܹ“ªªªF;)c–1- ÔÔÔ ¸¸x´“2fáv†B£ÑPyy9JJJ R©ooo0 Ãðx<ÆÛÛ›JJJpÿý÷Ã0Ìh§w¬a´P*•”——‡sçÎA"‘ÀÅÅÈÎÎF||<ÂÃÃþþþHNNF[[lmmG;Ùc£@VVedd@£Ñ`âĉX¾|9„B!£R©()) ÇŽChh(q¹\Æ×× Ã@,cÊ”)Zýþ±cǨ¥¥2™ jµjµ«W¯‡Ãé©A¤R);wVVV°¶¶†££#lllÀårG¥–Q«5ÔÒ"CK‹ {{s…¦àp†Wë¥är9¤R)Ö­[‡ž òxM§NBxx8„BaO&ýýý¡R©PQQ¡÷´0 ؘ˜0...Œ‹‹Kà …BH$|÷Ýwøðñÿ~’Éd:ÏK45uQ\Ü.¬YóÓ …;ÅÅ,Z´Ï"""˜ˆˆtuu‘X,Fyy9N¿U[ÛA³gïDQQ³ÎéÙ±#W¯¶!9ùq²´º6bFc­±±‘NNNX²d œ{%–ˆh×®](++ƒ‹‹ ¢¢¢ ×o¦:Dåååxùå—YU#Amm-q88;;˜¶®.MŸþ5rrêõç¢E8xð‘!;‰£ÒØÛÛC  ,, jµ_}õ.\¸@·Né2 ÃDGGfÍš…{¨ðÀÏÏׯ_Gs³î_¡¸té¶nÝŠýû÷£¹¹¹ß/î7Žë­ðàðá"lÞ|~Èp£RÀÞ½{I¥Ráá‡ÆÏ?ÿŒ¼¼<aáÂ…077g€µÀ–-[`aa§žzjÐ/[©TRWWlllŒ® "*++Cjj*0qâD<ðÀ=ÃÎÜÜzŠŒÜF¿eac#@IÉ89Y hQëz{{£²²\.ñññx衇PZZŠmÛ¶áêÕ«ܨ¢¢¢PQQúúÁ¿>ŸÏ…BÆØ ÿf>|}}™Õ«W#>>¦¦¦½æÞÿŒÞ ÚÛåHL¼0h˜Q€R©DUU†a‚ƒƒáåå…ööv|ûí·HKK#FCaaa°°°À¹sçF+©zƒÃá0aaaÌý÷ßßSømmÝtøp‘ÁâüöÛÜAWK 6 "êèè@gg'ûôô`ccƒòòr0 C‡‚@ ÀªU«Ó§O£¢¢ ˆŽŽFGGˆèŽ›ï?}ú*d2•Á~¿¢¢ ÅÅ:ôûÜ J¥täÈ‚ˆ`nnŽ„„òõõí)<†a‘HD.\@ff&¢££ Ǹ»»“H$BJJ 1uêT£k×õENNÁãÈή9H¥RÚ±cø|>žzê)XXX ''ŽŽŽ}Âúøø 77Ë–-CHHH/q„‡‡#88˜ú›#¸“¨¬¼nð8ª«ŽCïHIIŸÏÇÊ•+{¦EçÍ›×oX‘Hèîîî÷¹> Ÿˆ¨¶¶m¸zµ MM]hn–B&S¡»ûFljÊ…©)æpt4‡——"‘-Üܬ VÉ冫þµ‰C¯J¥TPP€Ç¼×œ8QMM Ξ=‹¦¦&Œ?sæÌ¥¥%ãììLeeeˆŒŒÔk¦¯_—Szú5dfVâܹjäå5 ¥E¦ÓoÙÚš",Ì™¢¢ÆcÚ4̘á S½ÂÂÂD¯ùî?þ€Ïô-h4˜˜ü‘©ŽŽJMMÅåË—amm  ©© «V­"äää@£ÑЭC#]¨¯ï¤ƒ¯àÀBdfVéíëjmíFzú5¤§_ÃdB à":Ú‚°dI0ƳÒ9Ý^^B=Y°8Þ'¡×‰ FCŸþ9fΜ‰ÚÚZüöÛoàr¹ˆÅĉÁår™ŠŠ Ú¹s'ž~úi0 ƒööv„††êTͪTJIãË//!%¥*•Æà½.—Á¼y¾X½:>èÏzIöĉrš3ç[ƒ¦±²òe¸»Ûô›®a àÚµkäááÑSxÕÕÕ´gÏH¥Rp8DFF"66¶gv¸!”÷Þ{ñññ ÕéëéîVÑιøä“,””H j@mññ±ÅË/GcÕª˜™iבɔ4nÜÇhkëÖ&8kÂÃ]“³fÀkXhhh ­[·bÖ¬Y˜6mZO$ÝÝÝTWWXYõ­Åb1íÙ³6l€­­-+¨ÕÚ¹ó2Þ}÷4®^m3ˆÑ†‹»»5Þ~û>¬Z¡U°nÝ/¤Í¼½.|þùX·nÊ€i–Ôj58pW®\Á¼yóÝ'¢Û'oš››é›o¾App0xàV…Ÿ™YI6¤ ;Ûðcg}îŒM›â0c†ç Í[ee;~™L©×øÝÝ­QT´ææ|ø!‚ƒ¢   ,ÀäÉ“{"S*•´oß>Œ7"‘õõõÈÈÈÀ¸qãðØca°Õ½[éèÓ›ožÀ–- 2gnH8Ï>;|0gБÃdÒo×k܇=ŠE‹µ±^:†:„¼¼<,Z´=«yÈÌÌ„\.‡™™î½÷^LŸ>]ëÍ•¿ýVMO>ybq‹6Á‘ÈIIñ˜:Õ£ß|«ÕZ²ä{èk]àµ×bðá‡s ³!¤­­n_vÕh4”œœŒË—/#!!aaa=ÏT*uuuÁÒÒRë‚'"Ú¼ù^}õ( µ^Œ2Úðù¼ÿþ¼ôRT¿M‚Tª¤„„ïpôhé°âY³&›7/—;tÿƒµÄb1íÞ½vvvðõõ…ŸŸ<==abbÂh4:rärss±téRëÔÃW(Ôô ?cûöìáYÜHyòÉpüûß ajÚ· T(Ôô?ÿs›6ýƺ¹xظqö€ëÖ(//§Ý»wÃÜÜ666¨©©ǃ——üüüàãレ¬,äääàá‡F@@+ttÈiÉ’ïqüx™þ-oDÌœé…|Baÿý‚³g«èÍ7O =ýÚ¿Åá0X´(ÿøÇl:°²·NM@aa!íß¿óçÏGHHÊÊÊ ‹QVV©T {{{´··žxâ xyyi•¨ÖV-X°YYÕ0¹aápp¹ ˆµZmÌ:iÒ8¤¤<ó~íCD”—×€® #£EEÍhm•a89Y 8ر±^Xº4"‘P§‰4;999”œœŒÅ‹#<<œnôjjj ‹QZZŠææf<ÿüó°³³2aííÝ4o^~û­FÏEc¸\³f‰„˜wˆD¶°²2ZMhn–"?¿©©åøî»‚Aç+&NtÅñãOÁÎÎlTV=µÀÍ%·*Œˆ(++ 'NœÀÃ?ŒÀÀÞà ""…B@0dƺ»U· §N] °æ‘GBðÎ;±ººU©4ôÃWðæ›'BLŒ;ŽjÐñº¡ÐJ¹¹¹tîÜ9„††"88¶¶¶=b8yò$={Ë—/‡H$bµšèÉ'bïÞü‘Î;klmMñÍ7‹ñÐC¬óÙÙ©  R°cGN¿Ï‚ðý÷Ë´ê¹ßNkk+åææbæÌ™¬›­ö* À‰'ðÙgŸáË/¿Dff&µµµQll,"""°oß>ÔÔÔ°nOþùÏŒ1Qø®®VÈÈX¥Sဥ¥ ³}ûCøûßcû}~ð`!þö·S:¥M&“!==b±˜õ»Z÷ˆˆÚÛÛQTT„¢¢"TVVB£Ñ`üøñFqq1ššš°råJ899ie¤cÇJ).n·ÑÏîYY™àÌ™U˜0ÁeØU4Ñk¯Ã'ŸdõyÆ0ÀáÃaáBv#'Ø¿?577cÍš5`³¬®s'P*•’X,Faa!ÊÊÊ TÞ˜ÇvrrÂÚµk‡¬Š:)"b+êê:‡kSƒ³cÇ"¬\¡·öY©TÓôé_÷Ûáut4GnîZÖ{ $ %&&bñâŽ&á†B/SÁJ¥’ÊÊÊPTT‘HÔ3*"¢„„ïpèá¶Cë‹iÓ<žþ´Þ·„]ºTKS¦|Ùoíç‡#Gg}öÿСC‹/Y°å‡ hÙ²ý#¯.=ú$æÎõ1Hï|Ñ¢½”œÜ¿£¤¤<ñÄVñ*•JâñxÆ}<¼£CN/½ôëHG«^^BÌž-2Øï¯Z1à³W_=ж¶nV_'ŸÏg}2jÄðþûgPS£ý¹÷Ñ$.ÎW§a™¶Ì™ãn¿Ï»ðÿ—nð<ލêê:èÓOÇίI“Æô÷ÍÍùLHˆã€Ï7o>ÊÊvƒ¶Ñ#*€>ÈDW—~w½OOá¨ÆÑÝ­ÂÆ¬³ªªŠöíÛG¤EoÄ ‘HéË//TtzÁÌŒ?üsóÁãøæ›\44t²ªÌÌÌPTTm<¨Ž˜¶m»4¦¾~`dNíÜ<•4ØóÍ›/hùk7°··‡“““VTGD*•†¾újl}ýPUÕnð8*+‡Žãë¯s P¨µ®þã9 ÅÅÅC:Òf%¹\NÝÝÝZµ-·’–VŠŠ6ýZn¸tɰ»årýþ{ãájj®ãØ1vdÐÞÞŽŽŽÁG\¬PTT„O?ý »Ó7{÷þ®/›(¿þZ Æp3eiiW‡ln²g»3777¼þúë°¶¶ÖŸ“¨êêj8;;³r—ªTª êÔ”Hpö¬á\ÑóM®Öaþ¹„•ÿ?‡Ãhã´’µÆÏ*“YYÕ:ŸÊ5þñtƒ\HQTÔD\Ñ:üõërddTê=Z @¡PPCCk w‹óh“’Rª÷E+†hýúÖY aK­ “ÉàííÍZÚìj5vV¯NFyy‹Þj3pâD9ë÷22ØÙ’ˆ¨¤¤„ÚÚÚL»Ö°±±ažxâ ¦¿ÃžÑÝ­¢±rŽo0$æÏß…ªªáMËýûßé¯MÓéýË—ÐÙ©`•†ääd””” øÜ ó%%H¥ckòg ÄâÄÄlGff¥N"P*Õô—¿¤âùçè¼J¡PãÊ•&­Ã3 Ã8::¢©iàw ê,:?¿õ;66¬\yOÏÿéé×ôêBu8TW_ÇÌ™ßà…&Ó[oÍÔçMˆˆÒÒ®âµ×Žê%ùù ˜2ÅMëðvvv=.öûàÐå@§ƒƒ>ý4®Ç°¯¼r”ŒE RiðÙg¿á«¯²‘D7Ï89Y€Ãa˜÷ hPTÔŒÔÔrìÙ“‹kõi);›ZZZ¢¦fà³Z ==|}}1nÜ8­ûW¯¶jtÌ!•*±kWvíÊX[ `eeB*•--2(•†qUÃvFÕÇǧçrþÐJDD™™™ …7Nû5ò±°áS_\¿.ÇõërƒÇSWÇn3‡‡ãáá1às­:7/VâóÙ-Þ~ÇÍ]†D¢_›j%FµZÝËý›6ttþ‹ø³¡ïZF+(•JkÈåw†ccBß6ÕJ&&&Xºt)ìííYý¸±Ÿø1 …¦pr²€úêììW‘V@>ŸÏ„††²N,Ÿo—’ùøØbùò nôÞ?úèìï„…9#>>ÐÔ$Å–-ƒïÊqq±ÄÓO߃¸8?L˜à KKp¹F­ÖTªD~~#RRÄøê«lÔ×ëÞ9fkS™L†¢¢"ÄÅÅõûÜ ó&&Æq-¡¯¯=Þy'–n\˦ÂÃ{Þ¹r¥‰ÀúõS°qãý°°è»üÊår++bbÜãŽ×_ŸJkÖü„}ûtÛ#!°³©Z­þO:úß~nÐOÔÞÞÌ?oü÷OŦMq½ Ÿˆ¨µUFõõ$“){í ²¶0IIñ˜6ÍC§øììØÙT¡P€aðxý 箆»»5þþ÷Øž£XׯË饗RÈÕõ#ØÙ½W×`añ±u뺹»ˆÇã2o¿=C§8ííÍY…—Édàñxv൮O’’’(88‘‘‘Zwi<ŸØXîdØÚšâí·g`Õª‰º}½Ik«Œlmuw9k;gõõõ`7=Ÿª›7Ï×ÐQŒ^^B¤¦®€··m'™]‹[PZÚ‚+Wqþ| 𛥸ý÷uŽ­-«ªªàìì<à$0ðó³cBB© @û͌Ɨ;x÷ˆÃaðý÷Ëz ŸˆèìÙ*lÝzÇ—¡¡¡«?[èœ??;;²z§²²îîîƒ6?¬f•J%ååå‘L&c5|Y¶,DçŒCu^cc½0y²[a?þø,¦Oÿ»våõ[øÃeéÒV^Ȉlmmáë;x­ÁJÉÉÉ(+cwRuùò æ•€#ÎPîa¦O÷ìù["‘Ò_þ’:¤‡pG·™w†–/cùÃ$$$0þþþú;*www”–²;¢äãc‹ØX/2¯oÌÍùC.©ÚÙ™ ÙÞ:;[ôü]ZÚ¢Õ&ÐðpÝÆð11¬«ma-ÉÀÀ@C¥R±rXðâ‹S ’mP(þ8‚maaÂÄĸþ¯½––ƒŸ¬moÿck–‡‡Í5œ‹‹%6nœ­Sú×­›l°»‹Ywƒ‚‚pôèQ”——Ãßß_ë÷. €ŸŸ=Äbv—ŸËüóŸs(>~ß Pê|óVššzÅ ›1cÆ×øòˇ(:Ú½_Ã47Kéí·S±mÛ%XZš %ELÀÀŽœ~ýµsç~‹ÄÄ)8رßßlhè¤>:‹Ï>û …7fà‹/ mÚôg³*|ÈÏÏÃ0 Ñnè=â΢‰ˆæÏßÅÚé‘>‰ŒtÅÌ™^ðô‚Ïç ¹YŠK—êpìX™N§™9S§ºcÚ4¸¹YƒaÔ×wàüù¤¥]ísïá¬Y"ÌŸï KKTUµcÿþ+}ÎüÝwŸ'ÒÒV²êüi4JLL„H$‚ smÜ­477“\.‡››+•––¶Pxø–;æè¸¾15å!;{ ‚‚YÙµ­­’’’ðøãÃÞÞ^«w‡µ'0==GŽaµD ¾¾vÌ{ïÍÒ¿åîþ÷g².| …̺uë´.|`˜˜>}:êëëQTÄÞ‡Îúõ÷bî\½ìNbæL/¼þzŒÎ層xGGG&,, iii¬k.—ÃìÜ77«aìNÂÅÅII uQ;ÃÞ‹ÖÖV²_ówq±döïX§Í‘w&&\ìÛ·´ÏQ:;;Y{o½É°`kkˬ^½ÁÁºÍVEG»3_½H¯ççÆ"Û¶-Ä}÷iwÅî­twwÓÖ­[‘““ÃöUz:âììÌúª’[yì±0æ£æê#)c’÷Þ›+Âuz755tþãô&€—_ŽðRÅ;™·ÞšŽ7ßœ¦ÓbOee%]¼xqqq055ÕéÔ»T*ÉårÖíÃ0ÌÛoÏÀûï߯ï$-+wߥSák4úé§Ÿ ó×`&pïÞ½$¯Sƈˆ¶oÏÁ /1˜£¥Ñ†Çã`Ó¦8¬];iX˼555$ aa1´»ºÐ{ pï½÷"??_çN Ã0̳ÏNd~þyùy¸T(4ÅáÃá…&«ßnnnÌp 0€¼½½™ûüò jkku®^æÌñaΟ‘‘†½¹k$ wÆùó«ñÀ~F3æ1H'pÆŒðööÆ/¿ü2,WëÞÞ¶Lfæ*¼þúÔ1·§ðVxé¥(de= ??í§io§««‹Z[[õÚfl5°»»›är9lllôRrgÏVÑsÏý„‚‚¡¯X1&°mÛƒ˜1ƒýÿV”J%íܹ\.+W²[%ŒQ¹;XWär}ñÅy¼ûîé^{òŒ++¼õÖ lØp/ÌÌøÃ*,µZMßÿ=ª««ñÌ3ÏÀÎÎNoÕá˜ÀMššºèÃ3‘˜xÁ订37çcÍšIxã©pvf·e®?4 ±±"¬\yâãƒ`jÊnû–¶‘V[ÈtaD›€ºº:JJJ‚½½=}ôÑaM` Ds³”Ž)FJJ)Nž¬Ð»¿b{{3ÄÆŠç‹ ÐêÎcfÄû‰„öìÙƒÀÀ@Ì™3Ç ÆS©4TRÒŒ¬¬jäå5à÷ßQ^ÞŠššëCÎ2òù¸¹YC$"4Ô &¸ *j<ÀãnL*‘H¨¶¶aaa#"¬QéJ¥R211g˜*s(”J5µµu£¹Y ™LÕsG°@Àƒ™ööæ MµÚî­OŠ‹‹éÇ„³³3V¬X¡³O6ŒÉQÀ†Z­¦´´4dff"22óçϱÃ(–ƒ‰ˆNŸ>MJ5–””àÂ… X¼x1,X0¢5£QÔJ¥’víÚ…êêjLŸ>Ó¦Mµæa4 "êìì›+ùô…Q¸1áqñâE¤¦¦ÂÚÚ=ôÜÝÝï8Éår7pè£ÙÉáp˜)S¦ €Ž; {G•¦¦&:yò$ZZZ°f͉NÞPM 07W 5!bH$ ¥§§#??ÎÎΘ;w.¼¼¼Œ"/FS ENNŠŠŠMÆbŸ„„„Àßß_o+ž†fÌ  ?Äb1x<q¹\¬_¿¾×W+‘H˜˜033ƒP(ìwÿ½H$s…~+wT  -UUUÔÑѹ\•J•J…¨¨¨^µJ¥"‰Dkkk˜ššUÏ]Ÿü)p—?0ŠÅ »Œwð'ç®þäü?¯k¡¹jb LtEXtComment Image generated by GPL Ghostscript SVN PRE-RELEASE (device=pnmraw) Žœ=8IEND®B`‚lua-wsapi-1.6.1/rockspec/000077500000000000000000000000001231271307300152315ustar00rootroot00000000000000lua-wsapi-1.6.1/rockspec/wsapi-1.0-1.rockspec000066400000000000000000000016051231271307300205430ustar00rootroot00000000000000package = "WSAPI" version = "1.0-1" source = { url = "http://luaforge.net/frs/download.php/3382/wsapi-1.0.0.tar.gz", } description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock contains the base WSAPI libraries plus the CGI and Xavante adapters. ]], license = "MIT/X11", homepage = "http://wsapi.luaforge.net" } dependencies = { } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_BIN = "$(LUA)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" }, platforms = { win32 = { build_pass = true, build_target = "cgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib" } } } } lua-wsapi-1.6.1/rockspec/wsapi-1.0-2.rockspec000066400000000000000000000016051231271307300205440ustar00rootroot00000000000000package = "WSAPI" version = "1.0-2" source = { url = "http://luaforge.net/frs/download.php/3382/wsapi-1.0.0.tar.gz", } description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock contains the base WSAPI libraries plus the CGI and Xavante adapters. ]], license = "MIT/X11", homepage = "http://wsapi.luaforge.net" } dependencies = { } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_BIN = "$(LUA)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" }, platforms = { win32 = { build_pass = true, build_target = "cgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib" } } } } lua-wsapi-1.6.1/rockspec/wsapi-1.0rc1-1.rockspec000066400000000000000000000017151231271307300211530ustar00rootroot00000000000000package = "WSAPI" version = "1.0rc1-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock contains the base WSAPI libraries plus the CGI and Xavante adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem 1.4.1rc1", "rings 1.2.1rc1", "coxpcall 1.12.0rc1" } source = { url = "http://wsapi.luaforge.net/wsapi-1.0rc1.tar.gz", } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_BIN = "/usr/bin/env lua", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" }, platforms = { win32 = { build_pass = true, build_target = "cgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib" } } } } lua-wsapi-1.6.1/rockspec/wsapi-1.1-1.rockspec000066400000000000000000000026771231271307300205560ustar00rootroot00000000000000package = "WSAPI" version = "1.1-1" source = { url = "http://luaforge.net/frs/download.php/3935/wsapi-1.1.0.tar.gz", } description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock contains the base WSAPI libraries plus the CGI and Xavante adapters. ]], license = "MIT/X11", homepage = "http://wsapi.luaforge.net" } dependencies = { } build = { platforms = { unix = { type = "module", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, copy_directories = { "samples", "doc" }, install = { bin = { "src/launcher/wsapi.cgi" } } }, win32 = { type = "make", build_pass = true, build_target = "cgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib" }, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_BIN = "/usr/bin/env lua", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" }, } } } lua-wsapi-1.6.1/rockspec/wsapi-1.1-2.rockspec000066400000000000000000000027301231271307300205450ustar00rootroot00000000000000package = "WSAPI" version = "1.1-2" source = { url = "http://luaforge.net/frs/download.php/3935/wsapi-1.1.0.tar.gz", } description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock contains the base WSAPI libraries plus the CGI and Xavante adapters. ]], license = "MIT/X11", homepage = "http://wsapi.luaforge.net" } dependencies = { "luafilesystem >= 1.4.2" } build = { platforms = { unix = { type = "module", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, copy_directories = { "samples", "doc" }, install = { bin = { "src/launcher/wsapi.cgi" } } }, win32 = { type = "make", build_pass = true, build_target = "cgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib" }, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_BIN = "/usr/bin/env lua", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" }, } } } lua-wsapi-1.6.1/rockspec/wsapi-1.2-1.rockspec000066400000000000000000000026151231271307300205470ustar00rootroot00000000000000package = "WSAPI" version = "1.2-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.4.2" } source = { url = "http://cloud.github.com/downloads/keplerproject/wsapi/wsapi-1.2.tar.gz" } build = { platforms = { unix = { type = "module", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } }, win32 = { type = "make", build_pass = true, build_target = "cgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib" }, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_BIN = "/usr/bin/env lua", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" }, } } } lua-wsapi-1.6.1/rockspec/wsapi-1.2-2.rockspec000066400000000000000000000016661231271307300205550ustar00rootroot00000000000000package = "WSAPI" version = "1.2-2" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.2.tar.gz" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.3-1.rockspec000066400000000000000000000016731231271307300205530ustar00rootroot00000000000000package = "WSAPI" version = "1.3-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.tar.gz" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.3.1-1.rockspec000066400000000000000000000016771231271307300207160ustar00rootroot00000000000000package = "WSAPI" version = "1.3.1-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.1.tar.gz" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.3.2-1.rockspec000066400000000000000000000016771231271307300207170ustar00rootroot00000000000000package = "WSAPI" version = "1.3.2-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.2.tar.gz" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.3.3-1.rockspec000066400000000000000000000016771231271307300207200ustar00rootroot00000000000000package = "WSAPI" version = "1.3.3-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.3.tar.gz" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.3.4-1.rockspec000066400000000000000000000016771231271307300207210ustar00rootroot00000000000000package = "WSAPI" version = "1.3.4-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.4.tar.gz" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.4-1.rockspec000066400000000000000000000017541231271307300205540ustar00rootroot00000000000000package = "WSAPI" version = "1.4-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "http://cloud.github.com/downloads/keplerproject/wsapi/wsapi-1.4.tar.gz" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", ["wsapi.mock"] = "src/wsapi/mock.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.5-1.rockspec000066400000000000000000000017541231271307300205550ustar00rootroot00000000000000package = "WSAPI" version = "1.5-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "http://cloud.github.com/downloads/keplerproject/wsapi/wsapi-1.5.tar.gz" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", ["wsapi.mock"] = "src/wsapi/mock.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.6-1.rockspec000066400000000000000000000017721231271307300205560ustar00rootroot00000000000000package = "WSAPI" version = "1.6-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.6.2" } source = { url = "http://www.keplerproject.org/files/wsapi-1.6.tar.gz" } build = { type = "builtin", modules = { ["wsapi"] = "src/wsapi.lua", ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", ["wsapi.mock"] = "src/wsapi/mock.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-1.6.1-1.rockspec000066400000000000000000000017761231271307300207210ustar00rootroot00000000000000package = "WSAPI" version = "1.6.1-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.6.2" } source = { url = "http://www.keplerproject.org/files/wsapi-1.6.1.tar.gz" } build = { type = "builtin", modules = { ["wsapi"] = "src/wsapi.lua", ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", ["wsapi.mock"] = "src/wsapi/mock.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-cvs-1.rockspec000066400000000000000000000017251231271307300210430ustar00rootroot00000000000000package = "WSAPI" version = "cvs-1" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock contains the base WSAPI libraries plus the CGI and Xavante adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem cvs", "rings cvs", "coxpcall cvs" } source = { url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/wsapi", cvs_tag = "HEAD", } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_BIN = "/usr/bin/env lua", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" }, platforms = { win32 = { build_pass = true, build_target = "cgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib" } } } } lua-wsapi-1.6.1/rockspec/wsapi-cvs-2.rockspec000066400000000000000000000016441231271307300210440ustar00rootroot00000000000000package = "WSAPI" version = "cvs-2" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock contains the base WSAPI libraries plus the CGI and Xavante adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { } source = { url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/wsapi", cvs_tag = "HEAD", } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_BIN = "/usr/bin/env lua", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" }, platforms = { win32 = { build_pass = true, build_target = "cgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib" } } } } lua-wsapi-1.6.1/rockspec/wsapi-cvs-3.rockspec000066400000000000000000000016431231271307300210440ustar00rootroot00000000000000package = "WSAPI" version = "cvs-3" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.5.0" } source = { url = "git://github.com/keplerproject/wsapi.git" } build = { type = "builtin", modules = { ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-cvs-4.rockspec000066400000000000000000000017571231271307300210530ustar00rootroot00000000000000package = "WSAPI" version = "cvs-4" description = { summary = "Lua Web Server API", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the base WSAPI libraries plus the CGI adapters. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "luafilesystem >= 1.6.2" } source = { url = "git://github.com/keplerproject/wsapi.git" } build = { type = "builtin", modules = { ["wsapi"] = "src/wsapi.lua", ["wsapi.common"] = "src/wsapi/common.lua", ["wsapi.request"] = "src/wsapi/request.lua", ["wsapi.response"] = "src/wsapi/response.lua", ["wsapi.util"] = "src/wsapi/util.lua", ["wsapi.cgi"] = "src/wsapi/cgi.lua", ["wsapi.sapi"] = "src/wsapi/sapi.lua", ["wsapi.ringer"] = "src/wsapi/ringer.lua", ["wsapi.mock"] = "src/wsapi/mock.lua", }, copy_directories = { "samples", "doc", "tests" }, install = { bin = { "src/launcher/wsapi.cgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.0-1.rockspec000066400000000000000000000026241231271307300214530ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.0-1" source = { url = "http://luaforge.net/frs/download.php/3382/wsapi-1.0.0.tar.gz" } description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://wsapi.luaforge.net" } dependencies = { 'wsapi >= 1.0', 'rings >= 1.2.1', } external_dependencies = { FASTCGI = { header = "fcgi_stdio.h" } } build = { platforms = { unix = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LIB_OPTION = "$(LIBFLAG) -L$(FASTCGI_LIBDIR)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR) -I$(FASTCGI_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)" } }, win32 = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LIB_OPTION = "$(LUA_LIBDIR)\\lua5.1.lib $(FASTCGI_LIB)", CFLAGS = "$(CFLAGS) /I$(LUA_INCDIR) /I$(FASTCGI_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", BIN_DIR = "$(BINDIR)", } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.0-2.rockspec000066400000000000000000000026241231271307300214540ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.0-2" source = { url = "http://luaforge.net/frs/download.php/3382/wsapi-1.0.0.tar.gz" } description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://wsapi.luaforge.net" } dependencies = { 'wsapi >= 1.0', 'rings >= 1.2.1', } external_dependencies = { FASTCGI = { header = "fcgi_stdio.h" } } build = { platforms = { unix = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LIB_OPTION = "$(LIBFLAG) -L$(FASTCGI_LIBDIR)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR) -I$(FASTCGI_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)" } }, win32 = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LIB_OPTION = "$(LUA_LIBDIR)\\lua5.1.lib $(FASTCGI_LIB)", CFLAGS = "$(CFLAGS) /I$(LUA_INCDIR) /I$(FASTCGI_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", BIN_DIR = "$(BINDIR)", } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.0rc1-1.rockspec000066400000000000000000000024631231271307300220620ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.0rc1-1" source = { url = "http://wsapi.luaforge.net/wsapi-1.0rc1.tar.gz", } description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi 1.0rc1" } external_dependencies = { FASTCGI = { header = "fcgi_stdio.h" } } build = { platforms = { unix = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LIB_OPTION = "$(LIBFLAG) -L$(FASTCGI_LIBDIR)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR) -I$(FASTCGI_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)" } }, win32 = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LIB_OPTION = "$(LUA_LIBDIR)\\lua5.1.lib $(FASTCGI_LIB)", CFLAGS = "$(CFLAGS) /I$(FASTCGI_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", BIN_DIR = "$(BINDIR)" } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.1-1.rockspec000066400000000000000000000031461231271307300214540ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.1-1" source = { url = "http://luaforge.net/frs/download.php/3935/wsapi-1.1.0.tar.gz" } description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.1" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/wsapi", cvs_tag = "HEAD", } build = { platforms = { unix = { type = "module", modules = { lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, win32 = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", LIB_OPTION = "$(LUA_LIBDIR)\\lua5.1.lib $(FASTCGI_DIR)\\libfcgi\\Release\\fcgi_stdio.obj $(FASTCGI_DIR)\\libfcgi\\Release\\os_win32.obj $(FASTCGI_DIR)\\libfcgi\\Release\\fcgiapp.obj", CFLAGS = "$(CFLAGS) /I$(FASTCGI_DIR)\\include", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", BIN_DIR = "$(BINDIR)" } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.1-2.rockspec000066400000000000000000000027751231271307300214640ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.1-2" source = { url = "http://luaforge.net/frs/download.php/3935/wsapi-1.1.0.tar.gz" } description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.1" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } build = { platforms = { unix = { type = "module", modules = { lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, win32 = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", LIB_OPTION = "$(LUA_LIBDIR)\\lua5.1.lib $(FASTCGI_DIR)\\libfcgi\\Release\\fcgi_stdio.obj $(FASTCGI_DIR)\\libfcgi\\Release\\os_win32.obj $(FASTCGI_DIR)\\libfcgi\\Release\\fcgiapp.obj", CFLAGS = "$(CFLAGS) /I$(FASTCGI_DIR)\\include", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", BIN_DIR = "$(BINDIR)" } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.1-3.rockspec000066400000000000000000000030431231271307300214520ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.1-3" source = { url = "http://luaforge.net/frs/download.php/3935/wsapi-1.1.0.tar.gz" } description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.1", "rings >= 1.2.2", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } build = { platforms = { unix = { type = "module", modules = { lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, win32 = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", LIB_OPTION = "$(LUA_LIBDIR)\\lua5.1.lib $(FASTCGI_DIR)\\libfcgi\\Release\\fcgi_stdio.obj $(FASTCGI_DIR)\\libfcgi\\Release\\os_win32.obj $(FASTCGI_DIR)\\libfcgi\\Release\\fcgiapp.obj", CFLAGS = "$(CFLAGS) /I$(FASTCGI_DIR)\\include", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", BIN_DIR = "$(BINDIR)" } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.2-1.rockspec000066400000000000000000000031271231271307300214540ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.2-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.2", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.2.tar.gz" } build = { platforms = { unix = { type = "module", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, win32 = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LUA_INCLUDE = "$(LUA_INCDIR)", LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", LIB_OPTION = "$(LUA_LIBDIR)\\lua5.1.lib $(FASTCGI_DIR)\\libfcgi\\Release\\fcgi_stdio.obj $(FASTCGI_DIR)\\libfcgi\\Release\\os_win32.obj $(FASTCGI_DIR)\\libfcgi\\Release\\fcgiapp.obj", CFLAGS = "$(CFLAGS) /I$(FASTCGI_DIR)\\include", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", BIN_DIR = "$(BINDIR)" } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.3-1.rockspec000066400000000000000000000017061231271307300214560ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.3-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.tar.gz" } build = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.3.1-1.rockspec000066400000000000000000000017121231271307300216120ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.3.1-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.1.tar.gz" } build = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.3.2-1.rockspec000066400000000000000000000017141231271307300216150ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.3.2-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3.2", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.2.tar.gz" } build = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.3.3-1.rockspec000066400000000000000000000017141231271307300216160ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.3.3-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3.3", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.3.tar.gz" } build = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.3.4-1.rockspec000066400000000000000000000025311231271307300216150ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.3.4-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3.4", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.4.tar.gz" } build = { platforms = { unix = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, windows = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = { "libfcgi", "ws2_32" }, incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.4-1.rockspec000066400000000000000000000025311231271307300214540ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.4-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.4", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://cloud.github.com/downloads/keplerproject/wsapi/wsapi-1.4.tar.gz" } build = { platforms = { unix = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, windows = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = { "libfcgi", "ws2_32" }, incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.5-1.rockspec000066400000000000000000000025311231271307300214550ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.5-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.5", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://cloud.github.com/downloads/keplerproject/wsapi/wsapi-1.5.tar.gz" } build = { platforms = { unix = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, windows = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = { "libfcgi", "ws2_32" }, incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.6-1.rockspec000066400000000000000000000025061231271307300214600ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.6-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.6", "rings >= 1.3.0", "coxpcall >= 1.14" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://www.keplerproject.org/files/wsapi-1.6.tar.gz" } build = { platforms = { unix = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, windows = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = { "libfcgi", "ws2_32" }, incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-1.6.1-1.rockspec000066400000000000000000000025661231271307300216250ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "1.6.1-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.6.1", "rings >= 1.3.0", "coxpcall >= 1.14" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "http://www.keplerproject.org/files/wsapi-1.6.1.tar.gz" } build = { platforms = { unix = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } }, windows = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = { "libfcgi", "ws2_32" }, incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-cvs-1.rockspec000066400000000000000000000026011231271307300217430ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "cvs-1" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi cvs" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/wsapi", cvs_tag = "HEAD", } build = { platforms = { unix = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LIB_OPTION = "$(LIBFLAG) -L$(FASTCGI_LIBDIR)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR) -I$(FASTCGI_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)" } }, win32 = { type = "make", install_target = "install-fcgi", build_pass = true, build_target = "fcgi", build_variables = { LIB_OPTION = "$(LUA_LIBDIR)\\lua5.1.lib $(FASTCGI_LIB)", CFLAGS = "$(CFLAGS) /I$(FASTCGI_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", BIN_DIR = "$(BINDIR)" } } } } lua-wsapi-1.6.1/rockspec/wsapi-fcgi-cvs-2.rockspec000066400000000000000000000016611231271307300217510ustar00rootroot00000000000000package = "WSAPI-FCGI" version = "cvs-2" description = { summary = "Lua Web Server API FastCGI Adapter", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the FCGI module lfcgi. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi cvs", "rings >= 1.2.3", "coxpcall >= 1.13" } external_dependencies = { platforms = { unix = { FASTCGI = { header = "fcgi_stdio.h" } } } } source = { url = "git://github.com/keplerproject/wsapi.git", } build = { type = "builtin", modules = { ["wsapi.fastcgi"] = "src/wsapi/fastcgi.lua", lfcgi = { sources = "src/fastcgi/lfcgi.c", libraries = "fcgi", incdirs = "$(FASTCGI_INCDIR)", libdirs = "$(FASTCGI_LIBDIR)" } }, install = { bin = { "src/launcher/wsapi.fcgi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.2-1.rockspec000066400000000000000000000012641231271307300222120ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.2-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.2", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.1.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.2.tar.gz" } build = { type = "module", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.3-1.rockspec000066400000000000000000000012651231271307300222140ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.3-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.1.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.3.1-1.rockspec000066400000000000000000000012711231271307300223500ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.3.1-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.1.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.1.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.3.2-1.rockspec000066400000000000000000000012731231271307300223530ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.3.2-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3.2", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.1.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.2.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.3.3-1.rockspec000066400000000000000000000012731231271307300223540ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.3.3-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3.3", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.2.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.3.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.3.4-1.rockspec000066400000000000000000000012731231271307300223550ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.3.4-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.3.4", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.2.0" } source = { url = "http://github.com/downloads/keplerproject/wsapi/wsapi-1.3.4.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.4-1.rockspec000066400000000000000000000012731231271307300222140ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.4-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.4", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.2.0" } source = { url = "http://cloud.github.com/downloads/keplerproject/wsapi/wsapi-1.4.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.5-1.rockspec000066400000000000000000000012731231271307300222150ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.5-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.5", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.2.0" } source = { url = "http://cloud.github.com/downloads/keplerproject/wsapi/wsapi-1.5.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.6-1.rockspec000066400000000000000000000012501231271307300222110ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.6-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.6", "rings >= 1.3.0", "coxpcall >= 1.14", "xavante >= 2.3.0" } source = { url = "http://www.keplerproject.org/files/wsapi-1.6.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-1.6.1-1.rockspec000066400000000000000000000012471231271307300223560ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "1.6.1-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi >= 1.6.1", "rings >= 1.3.0", "coxpcall >= 1.14", "xavante >= 2.3.0" } source = { url = "http://www.keplerproject.org/files/wsapi-1.6.1.tar.gz" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/rockspec/wsapi-xavante-cvs-1.rockspec000066400000000000000000000012321231271307300225000ustar00rootroot00000000000000package = "WSAPI-Xavante" version = "cvs-1" description = { summary = "Lua Web Server API - Xavante Handler", detailed = [[ WSAPI is an API that abstracts the web server from Lua web applications. This is the rock that contains the Xavante adapter and launcher. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/wsapi" } dependencies = { "wsapi cvs", "rings >= 1.2.3", "coxpcall >= 1.13", "xavante >= 2.2.0" } source = { url = "git://github.com/keplerproject/wsapi.git" } build = { type = "builtin", modules = { ["wsapi.xavante"] = "src/wsapi/xavante.lua" }, install = { bin = { "src/launcher/wsapi" } } } lua-wsapi-1.6.1/samples/000077500000000000000000000000001231271307300150645ustar00rootroot00000000000000lua-wsapi-1.6.1/samples/cgi-example.lua000077500000000000000000000004731231271307300177710ustar00rootroot00000000000000#!/usr/bin/env lua -- Example of script that uses the cgi launcher to launch an Orbit application local cgi = require"wsapi.cgi" -- require'ing the application. It should be in your package.path local app = require"app" -- Calls the launcher, app.run is the WSAPI run method of the application cgi.run(app.run) lua-wsapi-1.6.1/samples/fastcgi-example.lua000077500000000000000000000005131231271307300206420ustar00rootroot00000000000000#!/usr/bin/env lua -- Example of script that uses the fastcgi launcher to launch an Orbit application local fastcgi = require"wsapi.fastcgi" -- require'ing the application. It should be in your package.path local app = require"app" -- Calls the launcher, app.run is the WSAPI run method of the application fastcgi.run(app.run) lua-wsapi-1.6.1/samples/hello.lua000066400000000000000000000007471231271307300167020ustar00rootroot00000000000000#!/usr/bin/env wsapi.cgi local _M = {} function _M.run(wsapi_env) local headers = { ["Content-type"] = "text/html" } local function hello_text() coroutine.yield("") coroutine.yield("

Hello Wsapi!

") coroutine.yield("

PATH_INFO: " .. wsapi_env.PATH_INFO .. "

") coroutine.yield("

SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "

") coroutine.yield("") end return 200, headers, coroutine.wrap(hello_text) end return _M lua-wsapi-1.6.1/samples/hello_config.lua000066400000000000000000000003251231271307300202170ustar00rootroot00000000000000isolated = false local app = dofile(docroot .. "/hello.lua") local wsx = require "wsapi.xavante" rules = { { match = { "^/app$", "^/app/" }, with = wsx.makeHandler(app, "/app", docroot, docroot) }, } lua-wsapi-1.6.1/samples/xavante-example.lua000066400000000000000000000021161231271307300206660ustar00rootroot00000000000000------------------------------------------------------------------------------- -- Sample Xavante configuration file for launching WSAPI applications. ------------------------------------------------------------------------------ local xavante = require "xavante" local filehandler = require "xavante.filehandler" local wsx = require "wsapi.xavante" -- Define here where Xavante HTTP documents scripts are located local webDir = "/var/www" local simplerules = { { -- WSAPI application will be mounted under /app match = { "%.lua$", "%.lua/" }, with = wsx.makeGenericHandler(webDir) }, { -- filehandler match = ".", with = filehandler, params = {baseDir = webDir} }, } -- Displays a message in the console with the used ports xavante.start_message(function (ports) local date = os.date("[%Y-%m-%d %H:%M:%S]") print(string.format("%s Xavante started on port(s) %s", date, table.concat(ports, ", "))) end) xavante.HTTP{ server = {host = "*", port = 8080}, defaultHost = { rules = simplerules }, } xavante.start() lua-wsapi-1.6.1/src/000077500000000000000000000000001231271307300142075ustar00rootroot00000000000000lua-wsapi-1.6.1/src/fastcgi/000077500000000000000000000000001231271307300156275ustar00rootroot00000000000000lua-wsapi-1.6.1/src/fastcgi/lfcgi.c000066400000000000000000000376411231271307300170720ustar00rootroot00000000000000/* ** FastCGI Input/Output library. ** ** $Id: lfcgi.c,v 1.6 2008/04/24 02:58:43 mascarenhas Exp $ */ #include "fcgi_stdio.h" #include #include #include #include #include #include #define lfcgiio_c #include "lua.h" #include "lauxlib.h" #include "lualib.h" #ifdef _WIN32 #include #else #include #endif #include "lfcgi.h" #if LUA_VERSION_NUM < 502 # define luaL_setfuncs(L,l,n) luaL_openlib(L,NULL,l,n) #else # define lua_strlen(L,i) lua_rawlen(L, (i)) #endif /* ** by default, gcc does not get `tmpname' */ #ifndef USE_TMPNAME #ifdef __GNUC__ #define USE_TMPNAME 0 #else #define USE_TMPNAME 1 #endif #endif /* ** by default, posix systems get `popen' */ #ifndef USE_POPEN #ifdef _POSIX_C_SOURCE #if _POSIX_C_SOURCE >= 2 #define USE_POPEN 1 #endif #endif #endif #ifndef USE_POPEN #define USE_POPEN 0 #endif /* ** {====================================================== ** FILE Operations ** ======================================================= */ #if !USE_POPEN #define pclose(f) (-1) #endif #define FILEHANDLE "FCGI_FILE*" #define IO_INPUT "_input" #define IO_OUTPUT "_output" #ifndef _WIN32 extern char **environ; #endif static char **old_env; static char **old_envp; static int pushresult (lua_State *L, int i, const char *filename) { if (i) { lua_pushboolean(L, 1); return 1; } else { lua_pushnil(L); if (filename) lua_pushfstring(L, "%s: %s", filename, strerror(errno)); else lua_pushfstring(L, "%s", strerror(errno)); lua_pushnumber(L, errno); return 3; } } static FILE **topfile (lua_State *L, int findex) { FILE **f = (FILE **)luaL_checkudata(L, findex, FILEHANDLE); if (f == NULL) luaL_argerror(L, findex, "bad file"); return f; } static int io_type (lua_State *L) { FILE **f = (FILE **)luaL_checkudata(L, 1, FILEHANDLE); if (f == NULL) lua_pushnil(L); else if (*f == NULL) lua_pushliteral(L, "closed file"); else lua_pushliteral(L, "file"); return 1; } static FILE *tofile (lua_State *L, int findex) { FILE **f = topfile(L, findex); if (*f == NULL) luaL_error(L, "attempt to use a closed file"); return *f; } /* ** When creating file handles, always creates a `closed' file handle ** before opening the actual file; so, if there is a memory error, the ** file is not left opened. */ static FILE **newfile (lua_State *L) { FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); *pf = NULL; /* file handle is currently `closed' */ luaL_getmetatable(L, FILEHANDLE); lua_setmetatable(L, -2); return pf; } /* ** assumes that top of the stack is the `io' library, and next is ** the `io' metatable */ static void registerfile (lua_State *L, FILE *f, const char *name, const char *impname) { lua_pushstring(L, name); *newfile(L) = f; if (impname) { lua_pushstring(L, impname); lua_pushvalue(L, -2); lua_settable(L, -6); /* metatable[impname] = file */ } lua_settable(L, -3); /* io[name] = file */ } static int aux_close (lua_State *L) { FILE *f = tofile(L, 1); if (f == stdin || f == stdout || f == stderr) return 0; /* file cannot be closed */ else { int ok = (pclose(f) != -1) || (fclose(f) == 0); if (ok) *(FILE **)lua_touserdata(L, 1) = NULL; /* mark file as closed */ return ok; } } static int io_close (lua_State *L) { if (lua_isnone(L, 1) && lua_type(L, lua_upvalueindex(1)) == LUA_TTABLE) { lua_pushstring(L, IO_OUTPUT); lua_rawget(L, lua_upvalueindex(1)); } return pushresult(L, aux_close(L), NULL); } static int io_gc (lua_State *L) { FILE **f = topfile(L, 1); if (*f != NULL) /* ignore closed files */ aux_close(L); return 0; } static int io_tostring (lua_State *L) { char buff[128]; FILE **f = topfile(L, 1); if (*f == NULL) strcpy(buff, "closed"); else sprintf(buff, "%p", lua_touserdata(L, 1)); lua_pushfstring(L, "file (%s)", buff); return 1; } static int io_open (lua_State *L) { const char *filename = luaL_checkstring(L, 1); const char *mode = luaL_optstring(L, 2, "r"); FILE **pf = newfile(L); *pf = fopen(filename, mode); return (*pf == NULL) ? pushresult(L, 0, filename) : 1; } static int io_popen (lua_State *L) { #if !USE_POPEN luaL_error(L, "`popen' not supported"); return 0; #else const char *filename = luaL_checkstring(L, 1); const char *mode = luaL_optstring(L, 2, "r"); FILE **pf = newfile(L); *pf = popen(filename, mode); return (*pf == NULL) ? pushresult(L, 0, filename) : 1; #endif } static int io_tmpfile (lua_State *L) { FILE **pf = newfile(L); *pf = tmpfile(); return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; } static FILE *getiofile (lua_State *L, const char *name) { lua_pushstring(L, name); lua_rawget(L, lua_upvalueindex(1)); return tofile(L, -1); } static int g_iofile (lua_State *L, const char *name, const char *mode) { if (!lua_isnoneornil(L, 1)) { const char *filename = luaL_checkstring(L, 1); lua_pushstring(L, name); if (filename) { FILE **pf = newfile(L); *pf = fopen(filename, mode); if (*pf == NULL) { lua_pushfstring(L, "%s: %s", filename, strerror(errno)); luaL_argerror(L, 1, lua_tostring(L, -1)); } } else { tofile(L, 1); /* check if it is a valid file handle */ lua_pushvalue(L, 1); } lua_rawset(L, lua_upvalueindex(1)); } /* return current value */ lua_pushstring(L, name); lua_rawget(L, lua_upvalueindex(1)); return 1; } static int io_input (lua_State *L) { return g_iofile(L, IO_INPUT, "r"); } static int io_output (lua_State *L) { return g_iofile(L, IO_OUTPUT, "w"); } static int io_readline (lua_State *L); static void aux_lines (lua_State *L, int idx, int close_it) { lua_pushliteral(L, FILEHANDLE); lua_rawget(L, LUA_REGISTRYINDEX); lua_pushvalue(L, idx); lua_pushboolean(L, close_it); /* close/not close file when finished */ lua_pushcclosure(L, io_readline, 3); } static int f_lines (lua_State *L) { tofile(L, 1); /* check if it is a valid file handle */ aux_lines(L, 1, 0); return 1; } static int io_lines (lua_State *L) { if (lua_isnoneornil(L, 1)) { /* no arguments? */ lua_pushstring(L, IO_INPUT); lua_rawget(L, lua_upvalueindex(1)); /* will iterate over default input */ return f_lines(L); } else { const char *filename = luaL_checkstring(L, 1); FILE **pf = newfile(L); *pf = fopen(filename, "r"); luaL_argcheck(L, *pf, 1, strerror(errno)); aux_lines(L, lua_gettop(L), 1); return 1; } } /* ** {====================================================== ** READ ** ======================================================= */ static int read_number (lua_State *L, FILE *f) { lua_Number d; /*if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {*/ char buf[32], ch; char *p = buf; for (;;) { ch = fgetc (f); if ((int)ch == EOF) break; if (strchr ("0123456789-.", ch)) break; *p++ = ch; } *p = '\0'; if (p != buf) { d = strtod (buf, NULL); lua_pushnumber(L, d); return 1; } else return 0; /* read fails */ } static int test_eof (lua_State *L, FILE *f) { int c = getc(f); ungetc(c, f); lua_pushlstring(L, NULL, 0); return (c != EOF); } static int read_line (lua_State *L, FILE *f) { luaL_Buffer b; luaL_buffinit(L, &b); for (;;) { size_t l; char *p = luaL_prepbuffer(&b); if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ luaL_pushresult(&b); /* close buffer */ return (lua_strlen(L, -1) > 0); /* check whether read something */ } l = strlen(p); if (p[l-1] != '\n') luaL_addsize(&b, l); else { luaL_addsize(&b, l - 1); /* do not include `eol' */ luaL_pushresult(&b); /* close buffer */ return 1; /* read at least an `eol' */ } } } static int read_chars (lua_State *L, FILE *f, size_t n) { size_t rlen; /* how much to read */ size_t nr; /* number of chars actually read */ luaL_Buffer b; luaL_buffinit(L, &b); rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ do { char *p = luaL_prepbuffer(&b); if (rlen > n) rlen = n; /* cannot read more than asked */ nr = fread(p, sizeof(char), rlen, f); luaL_addsize(&b, nr); n -= nr; /* still have to read `n' chars */ } while (n > 0 && nr == rlen); /* until end of count or eof */ luaL_pushresult(&b); /* close buffer */ return (n == 0 || lua_strlen(L, -1) > 0); } static int g_read (lua_State *L, FILE *f, int first) { int nargs = lua_gettop(L) - 1; int success; int n; if (nargs == 0) { /* no arguments? */ success = read_line(L, f); n = first+1; /* to return 1 result */ } else { /* ensure stack space for all results and for auxlib's buffer */ luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); success = 1; for (n = first; nargs-- && success; n++) { if (lua_type(L, n) == LUA_TNUMBER) { size_t l = (size_t)lua_tonumber(L, n); success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); } else { const char *p = lua_tostring(L, n); luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); switch (p[1]) { case 'n': /* number */ success = read_number(L, f); break; case 'l': /* line */ success = read_line(L, f); break; case 'a': /* file */ read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ success = 1; /* always success */ break; case 'w': /* word */ return luaL_error(L, "obsolete option `*w' to `read'"); default: return luaL_argerror(L, n, "invalid format"); } } } } if (!success) { lua_pop(L, 1); /* remove last result */ lua_pushnil(L); /* push nil instead */ } return n - first; } static int io_read (lua_State *L) { return g_read(L, getiofile(L, IO_INPUT), 1); } static int f_read (lua_State *L) { return g_read(L, tofile(L, 1), 2); } static int io_readline (lua_State *L) { FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(2)); if (f == NULL) /* file is already closed? */ luaL_error(L, "file is already closed"); if (read_line(L, f)) return 1; else { /* EOF */ if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ lua_settop(L, 0); lua_pushvalue(L, lua_upvalueindex(2)); aux_close(L); /* close it */ } return 0; } } /* }====================================================== */ static int g_write (lua_State *L, FILE *f, int arg) { int nargs = lua_gettop(L) - 1; int status = 1; for (; nargs--; arg++) { if (lua_type(L, arg) == LUA_TNUMBER) { /* optimization: could be done exactly as for strings */ status = status && fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; } else { size_t l; const char *s = luaL_checklstring(L, arg, &l); /*status = status && (fwrite(s, sizeof(char), l, f) == l);*/ status = status && (fwrite((void *)s, sizeof(char), l, f) == l); } } return pushresult(L, status, NULL); } static int io_write (lua_State *L) { return g_write(L, getiofile(L, IO_OUTPUT), 1); } static int f_write (lua_State *L) { return g_write(L, tofile(L, 1), 2); } static int f_seek (lua_State *L) { static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; static const char *const modenames[] = {"set", "cur", "end", NULL}; FILE *f = tofile(L, 1); int op = luaL_checkoption(L, 2, "cur", modenames); long offset = luaL_optlong(L, 3, 0); luaL_argcheck(L, op != -1, 2, "invalid mode"); op = fseek(f, offset, mode[op]); if (op) return pushresult(L, 0, NULL); /* error */ else { lua_pushnumber(L, ftell(f)); return 1; } } static int io_flush (lua_State *L) { return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); } static int f_flush (lua_State *L) { return pushresult(L, fflush(tofile(L, 1)) == 0, NULL); } /* ** {====================================================== ** environ ** ======================================================= */ static char *lf_getenv(char **env, const char *name) { char **ep; size_t len; if (name == NULL || *name == '\0') return NULL; len = strlen(name); for (ep = env; *ep != NULL; ep++) { if (strncmp(*ep, name, len) == 0 && (*ep)[len] == '=') { return &(*ep)[len+1]; } } return NULL; } static char **lf_copy_environ() { char **env = NULL; char **ep; size_t i = 0; /* Get the total number of elements in the array. */ for (ep = environ; *ep != NULL; ep++) { i++; } if (i == 0) return NULL; /* Allocate the space to hold the elements. */ env = malloc((i+1)*sizeof(*env)); /* Copy the elements into the new array. */ i = 0; for (ep = environ; *ep != NULL; ep++) { env[i++] = strdup(*ep); } env[i] = NULL; return env; } /* ** {====================================================== ** lfcgi ** ======================================================= */ static int lfcgi_accept (lua_State *L) { lua_pushnumber( L, FCGI_Accept() ); return 1; } /* * Do not use anything from the lfcgi module except accept() * after you called this function. Including io.* stuff * if you replaced originals. */ static int lfcgi_finish (lua_State *L) { FCGI_Finish(); return 0; } static int lfcgi_getenv (lua_State *L) { const char *envVar = luaL_checkstring(L, 1); char *val = getenv(envVar); if (val == NULL) { val = lf_getenv(old_env, envVar); } if (val != NULL) { lua_pushstring(L, val); } else { lua_pushnil(L); } return 1; } static int lfcgi_environ(lua_State *L) { char **envp; int i=1; lua_newtable(L); for ( envp = old_env; *envp != NULL; envp++, i++) { lua_pushnumber(L, i); lua_pushstring(L, *envp); lua_settable(L, -3); } if (old_envp != environ) { for ( envp = environ; *envp != NULL; envp++, i++) { lua_pushnumber(L, i); lua_pushstring(L, *envp); lua_settable(L, -3); } } return 1; } static int lfcgi_iscgi(lua_State *L) { lua_pushboolean(L, FCGX_IsCGI()); return 1; } static int lfcgi_getpid(lua_State *L) { lua_pushnumber(L, getpid()); return 1; } static const luaL_Reg iolib[] = { {"input", io_input}, {"output", io_output}, {"lines", io_lines}, {"close", io_close}, {"flush", io_flush}, {"open", io_open}, {"popen", io_popen}, {"read", io_read}, {"tmpfile", io_tmpfile}, {"type", io_type}, {"write", io_write}, {"accept", lfcgi_accept}, {"finish", lfcgi_finish}, {"getenv", lfcgi_getenv}, {"getpid", lfcgi_getpid}, {"environ", lfcgi_environ}, {"iscgi", lfcgi_iscgi}, {NULL, NULL} }; static const luaL_Reg flib[] = { {"flush", f_flush}, {"read", f_read}, {"lines", f_lines}, {"seek", f_seek}, {"write", f_write}, {"close", io_close}, {"__gc", io_gc}, {"__tostring", io_tostring}, {NULL, NULL} }; static void createmeta (lua_State *L) { luaL_newmetatable(L, FILEHANDLE); /* create new metatable for file handles */ /* file methods */ lua_pushliteral(L, "__index"); lua_pushvalue(L, -2); /* push metatable */ lua_rawset(L, -3); /* metatable.__index = metatable */ luaL_setfuncs(L, flib, 0); } /* }====================================================== */ LUALIB_API int luaopen_lfcgi (lua_State *L) { old_envp = environ; old_env = lf_copy_environ(); createmeta(L); lua_pushvalue(L, -1); lua_newtable(L); lua_pushvalue(L, -1); lua_setglobal(L, "lfcgi"); lua_insert(L, -2); luaL_setfuncs(L, iolib, 1); /* put predefined file handles into `io' table */ registerfile(L, FCGI_stdin, "stdin", IO_INPUT); registerfile(L, FCGI_stdout, "stdout", IO_OUTPUT); registerfile(L, FCGI_stderr, "stderr", NULL); return 1; } lua-wsapi-1.6.1/src/fastcgi/lfcgi.def000066400000000000000000000000501231271307300173660ustar00rootroot00000000000000LIBRARY "lfcgi" EXPORTS luaopen_lfcgi lua-wsapi-1.6.1/src/fastcgi/lfcgi.h000066400000000000000000000001541231271307300170640ustar00rootroot00000000000000/* $Id: lfcgi.h,v 1.1 2007/10/30 23:44:45 mascarenhas Exp $ */ LUALIB_API int luaopen_lfcgi (lua_State *L); lua-wsapi-1.6.1/src/launcher/000077500000000000000000000000001231271307300160105ustar00rootroot00000000000000lua-wsapi-1.6.1/src/launcher/launcher.c000066400000000000000000000040161231271307300177560ustar00rootroot00000000000000 /* ** Simple Lua interpreter. ** This program is used to run a Lua file with the same name but the ** extension (that should be .lua). ** It creates a Lua state, opens all its standard libraries, and run ** the Lua file in a protected environment just to redirect the error ** messages to stdout and stderr. ** ** $Id: launcher.c,v 1.4 2007/12/20 18:15:48 mascarenhas Exp $ */ #include #include #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include #include #include /* ** Report error message. ** Assumes that the error message is on top of the stack. */ static int report (lua_State *L) { fprintf (stderr, "lua: fatal error: `%s'\n", lua_tostring (L, -1)); fflush (stderr); printf ("Content-type: text/plain\n\nConfiguration fatal error: see error log!\n"); printf ("%s", lua_tostring(L, -1)); return 1; } static int runlua (lua_State *L, char *name) { int err_func; lua_pushliteral(L, "debug"); lua_rawget(L, LUA_GLOBALSINDEX); /* get traceback function */ lua_pushliteral(L, "traceback"); lua_gettable(L, -2); err_func = lua_gettop (L); return (luaL_loadfile (L, name)) || (lua_pcall (L, 0, 0, err_func)); } static DWORD GetModulePath( HINSTANCE hInst, LPTSTR pszBuffer, DWORD dwSize ) // // Return the size of the path in bytes. { DWORD dwLength = GetModuleFileName( hInst, pszBuffer, dwSize ); if( dwLength ) { while( dwLength && pszBuffer[ dwLength ] != '.' ) { dwLength--; } if( dwLength ) pszBuffer[ dwLength ] = '\000'; } return dwLength; } /* ** MAIN */ int main (int argc, char *argv[]) { char name[ MAX_PATH ]; DWORD dwLength; lua_State *L = lua_open(); (void)argc; /* avoid "unused parameter" warning */ dwLength = GetModulePath( NULL, name, MAX_PATH ); if(dwLength) { luaL_openlibs(L); _setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stdout), _O_BINARY); strcat(name, ".cgi"); if (runlua (L, name)) { report (L); lua_close (L); return EXIT_FAILURE; } } lua_close (L); return EXIT_SUCCESS; } lua-wsapi-1.6.1/src/launcher/make_rc.lua000066400000000000000000000004611231271307300201150ustar00rootroot00000000000000 io.write("#define IDS_WSAPI 1\r\n") io.write("STRINGTABLE\r\nBEGIN\r\n") io.write("IDS_WSAPI \"") for line in io.lines((...)) do if not line:match("^#!") then line = line:gsub("\\", "\\\\"):gsub('"', '""'):gsub("[\r\n]+", "") io.write(line .. "\\n\\\r\n") end end io.write("\"\r\nEND\r\n") lua-wsapi-1.6.1/src/launcher/wsapi000077500000000000000000000110151231271307300170570ustar00rootroot00000000000000#!/usr/bin/env lua local lfs = require "lfs" local util = require "wsapi.util" local wsx = require "wsapi.xavante" local xavante = require "xavante" local filehandler = require "xavante.filehandler" local redirecthandler = require "xavante.redirecthandler" local usage = [[ Usage: wsapi [options] [document root] Starts a Xavante instance to serve static files and WSAPI applications. Treats .lua and .ws files as WSAPI applications, and everything else as static (but see the --cgilua and --op options, below). The default document root is the current path. Options: -c, --config= Runs the specified file for additional configuration before starting the server -l, --log= Logs all output to the file (default stdout and stderr) -p, --port= Binds to the specified port (default 8080) --cgilua Adds .lp and .cgi rules for CGILua pages and scripts --op Adds an .op rule that for Orbit pages -r, --reload Reloads applications on every request -h, --help Shows this help screen ]] local config = {} local opts, args = util.getopt({ ... }, "clp") if opts.h or opts.help then print(usage) os.exit() end local config = { docroot = args[1] or lfs.currentdir(), logfile = opts.l or opts.log, port = tonumber(opts.p or opts.port) or 8080, start_message = function (ports) local date = os.date("[%Y-%m-%d %H:%M:%S]") print(string.format("%s Xavante started on port(s) %s", date, table.concat(ports, ", "))) end, rules = {}, is_finished = function() return false end, reload = opts.r or opts.reload, isolated = true } local config_file = opts.c or opts.config if config_file then local f, err = util.loadfile(config_file, setmetatable(config, { __index = _G })) if not f then io.stderr:write("Cannot load config file " .. config_file .. ":\n\n" .. err .. "\n") os.exit() end local res, err = pcall(f) if not res then io.stderr:write("Error in config file:\n\n" .. err .. "\n") os.exit() end setmetatable(config, nil) end if config.logfile then local tostring = tostring local log = io.open(config.logfile, "a+") if not log then error("Could not open log file. Please check the write permissions for: " .. config.logfile) end io.stdout = log io.stderr = log print = function (...) local nargs = select('#', ...) for i = 1, nargs-1 do log:write(tostring((select(i, ...)))) log:write("\t") end log:write(tostring(select(nargs, ...))) log:write("\n") end end local ONE_HOUR = 60 * 60 local ONE_DAY = 24 * ONE_HOUR local launcher_params = { isolated = config.isolated, reload = config.reload, period = config.period or ONE_HOUR, ttl = config.ttl or ONE_DAY } config.rules = config.rules or {} local function addrule(rule) config.rules[#config.rules+1] = rule end addrule{ -- URI remapping example match = "^/$", with = redirecthandler, params = {"index.html"} } addrule{ -- wsapihandler example match = {"%.lua$", "%.lua/" }, with = wsx.makeGenericHandler (config.docroot, launcher_params) } addrule{ -- wsapihandler example match = {"%.ws$", "%.ws/" }, with = wsx.makeGenericHandler (config.docroot, launcher_params) } if opts.cgilua then local hcgi = require "xavante.cgiluahandler" addrule{ match = {"%.lp$", "%.lp/.*$", "%.cgi$", "%.cgi/.*$" }, with = hcgi.makeHandler (config.docroot, launcher_params) } end if opts.op then local hop = require "orbit.ophandler" addrule{ match = {"%.op$", "%.op/.*$" }, with = hop.makeHandler (config.docroot, launcher_params) } end addrule{ -- filehandler example match = ".", with = filehandler, params = { baseDir = config.docroot } } -- Displays a message in the console with the used ports xavante.start_message(config.start_message) io.stdout:write("[Xavante launcher] Starting Xavante...\n") xavante.HTTP{ server = {host = "*", port = config.port}, defaultHost = { rules = config.rules }, } res, err = pcall(xavante.start, function (...) io.stdout:flush() io.stderr:flush() return config.is_finished(...) end, config.timeout) if not res then io.stderr:write(err .. "\n") else io.stderr:write("[Xavante launcher] Xavante stopped\n") end lua-wsapi-1.6.1/src/launcher/wsapi.c000066400000000000000000000046631231271307300173100ustar00rootroot00000000000000 /* ** Simple Lua interpreter. ** This program is used to run a Lua file embedded as a resource. ** It creates a Lua state, opens all its standard libraries, and run ** the Lua file in a protected environment just to redirect the error ** messages to stdout and stderr. ** ** $Id: wsapi.c,v 1.2 2008/01/23 18:29:15 mascarenhas Exp $ */ #include #include #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include #include #include /* ** Report error message. ** Assumes that the error message is on top of the stack. */ static int report (lua_State *L) { fprintf (stderr, "lua: fatal error: `%s'\n", lua_tostring (L, -1)); fflush (stderr); printf ("Content-type: text/plain\n\nConfiguration fatal error: see error log!\n"); printf ("%s", lua_tostring(L, -1)); return 1; } static int runlua (lua_State *L, LPTSTR lua_string) { int err_func; lua_pushliteral(L, "debug"); lua_rawget(L, LUA_GLOBALSINDEX); /* get traceback function */ lua_pushliteral(L, "traceback"); lua_gettable(L, -2); err_func = lua_gettop (L); return (luaL_loadstring (L, lua_string)) || (lua_pcall (L, 0, LUA_MULTRET, err_func)); } static DWORD GetModulePath( HINSTANCE hInst, LPTSTR pszBuffer, DWORD dwSize ) // // Return the size of the path in bytes. { DWORD dwLength = GetModuleFileName( hInst, pszBuffer, dwSize ); if( dwLength ) { while( dwLength && pszBuffer[ dwLength ] != '.' ) { dwLength--; } if( dwLength ) pszBuffer[ dwLength ] = '\000'; } return dwLength; } /* ** MAIN */ int main (int argc, char *argv[]) { char name[ MAX_PATH ]; DWORD dwLength; int size; TCHAR lua_string[10000]; lua_State *L = lua_open(); (void)argc; /* avoid "unused parameter" warning */ luaL_openlibs(L); dwLength = GetModulePath( NULL, name, MAX_PATH ); if(dwLength) { /* Optional bootstrap */ strcat(name, ".lua"); if(!luaL_loadfile (L, name)) { if(lua_pcall (L, 0, LUA_MULTRET, 0)) { report (L); lua_close (L); return EXIT_FAILURE; } } } size = LoadString(GetModuleHandle(NULL), 1, lua_string, sizeof(lua_string)/sizeof(TCHAR)); if(size) { if (runlua (L, lua_string)) { report (L); lua_close (L); return EXIT_FAILURE; } } else { lua_close(L); fprintf(stderr, "could not load Lua resource\n"); printf ("Content-type: text/plain\n\nConfiguration fatal error: see error log!\n"); } lua_close (L); return EXIT_SUCCESS; } lua-wsapi-1.6.1/src/launcher/wsapi.cgi000077500000000000000000000013541231271307300176250ustar00rootroot00000000000000#!/usr/bin/lua -- Generic WSAPI CGI launcher, extracts application to launch -- either from the command line (use #!wsapi in the script) -- or from SCRIPT_FILENAME/PATH_TRANSLATED local wsapi = require "wsapi" local common = require "wsapi.common" local cgi = require "wsapi.cgi" local arg_filename = (...) local function wsapi_loader(wsapi_env) local path, file, modname, ext = common.find_module(wsapi_env, arg_filename, "wsapi.cgi", { "SCRIPT_FILENAME", "PATH_TRANSLATED" }) if not path then error({ 404, "Resource " .. wsapi_env.SCRIPT_NAME .. " not found" }) end wsapi.app_path = path local app = common.load_wsapi(path, file, modname, ext) wsapi_env.APP_PATH = path return app(wsapi_env) end cgi.run(wsapi_loader) lua-wsapi-1.6.1/src/launcher/wsapi.fcgi000077500000000000000000000017731231271307300200000ustar00rootroot00000000000000#!/usr/bin/lua -- Generic WSAPI FastCGI launcher, extracts application to launch -- from SCRIPT_FILENAME/PATH_TRANSLATED, each application (defined -- by its script entry point) gets an isolated Lua VM; sequential -- requests to the same application go to the same VM local common = require "wsapi.common" local fastcgi = require "wsapi.fastcgi" local ONE_HOUR = 60 * 60 local ONE_DAY = 24 * ONE_HOUR local wsapi_loader = common.make_loader{ isolated = true, -- isolate each script in its own Lua state filename = nil, -- if you want to force the launch of a single script launcher = "wsapi.fcgi", -- the name of this script reload = false, -- if you want to reload the application on every request period = ONE_HOUR, -- frequency of Lua state staleness checks ttl = ONE_DAY, -- time-to-live for Lua states vars = -- order of checking for the path of the script { "SCRIPT_FILENAME", "PATH_TRANSLATED" } } fastcgi.run(wsapi_loader) lua-wsapi-1.6.1/src/wsapi.lua000066400000000000000000000001601231271307300160320ustar00rootroot00000000000000 -- Dummy module to store variables that need to be shared between other WSAPI modules local _M = {} return _Mlua-wsapi-1.6.1/src/wsapi/000077500000000000000000000000001231271307300153325ustar00rootroot00000000000000lua-wsapi-1.6.1/src/wsapi/cgi.lua000066400000000000000000000010621231271307300165760ustar00rootroot00000000000000----------------------------------------------------------------------------- -- CGI WSAPI handler -- -- Author: Fabio Mascarenhas -- Copyright (c) 2007 Kepler Project -- ----------------------------------------------------------------------------- local os = require"os" local io = require"io" local common = require"wsapi.common" common.setmode() local _M = {} -- Runs an WSAPI application for this CGI request function _M.run(app_run) common.run(app_run, { input = io.stdin, output = io.stdout, error = io.stderr, env = os.getenv }) end return _Mlua-wsapi-1.6.1/src/wsapi/common.lua000066400000000000000000000633611231271307300173360ustar00rootroot00000000000000----------------------------------------------------------------------------- -- wsapi.common - common functionality for adapters and launchers -- -- Author: Fabio Mascarenhas -- Copyright (c) 2007 Kepler Project -- ----------------------------------------------------------------------------- local os = require "os" local string = require "string" local io = require "io" local table = require "table" local debug = require "debug" local wsapi = require "wsapi" local lfs = require "lfs" local tostring, tonumber, pairs, ipairs, error, type, pcall, xpcall, setmetatable, dofile, rawget, rawset, assert, loadfile = tostring, tonumber, pairs, ipairs, error, type, pcall, xpcall, setmetatable, dofile, rawget, rawset, assert, loadfile if _VERSION < "Lua 5.2" then local coxpcall = require "coxpcall" pcall = coxpcall.pcall xpcall = coxpcall.xpcall end local package = package local _, ringer = pcall(require, "wsapi.ringer") local _M = {} -- HTTP status codes _M.status_codes = { [100] = "Continue", [101] = "Switching Protocols", [200] = "OK", [201] = "Created", [202] = "Accepted", [203] = "Non-Authoritative Information", [204] = "No Content", [205] = "Reset Content", [206] = "Partial Content", [300] = "Multiple Choices", [301] = "Moved Permanently", [302] = "Found", [303] = "See Other", [304] = "Not Modified", [305] = "Use Proxy", [307] = "Temporary Redirect", [400] = "Bad Request", [401] = "Unauthorized", [402] = "Payment Required", [403] = "Forbidden", [404] = "Not Found", [405] = "Method Not Allowed", [406] = "Not Acceptable", [407] = "Proxy Authentication Required", [408] = "Request Time-out", [409] = "Conflict", [410] = "Gone", [411] = "Length Required", [412] = "Precondition Failed", [413] = "Request Entity Too Large", [414] = "Request-URI Too Large", [415] = "Unsupported Media Type", [416] = "Requested range not satisfiable", [417] = "Expectation Failed", [500] = "Internal Server Error", [501] = "Not Implemented", [502] = "Bad Gateway", [503] = "Service Unavailable", [504] = "Gateway Time-out", [505] = "HTTP Version not supported", } -- Makes an index metamethod for the environment, from -- a function that returns the value of a server variable -- a metamethod lets us do "on-demand" loading of the WSAPI -- environment, and provides the invariant the the WSAPI -- environment returns the empty string instead of nil for -- variables that do not exist function _M.sv_index(func) if type(func) == "table" then return function (env, n) local v = func[n] env[n] = v or "" return v or "" end else return function (env, n) local v = func(n) env[n] = v or "" return v or "" end end end -- Makes an wsapi_env.input object from a low-level input -- object and the name of the method to read from this object function _M.input_maker(obj, read_method) local input = {} local read = obj[read_method or "read"] function input:read(n) n = n or self.length or 0 if n > 0 then return read(obj, n) end end return input end -- Windows only: sets stdin and stdout to binary mode so -- sending and receiving binary data works with CGI function _M.setmode() pcall(lfs.setmode, io.stdin, "binary") pcall(lfs.setmode, io.stdout, "binary") end -- Returns the actual WSAPI handler (a function) for the -- WSAPI application, whether it is a table, the name of a Lua -- module, a Lua script, or the function itself function _M.normalize_app(app_run, is_file) local t = type(app_run) if t == "function" then return app_run elseif t == "table" then return app_run.run elseif t == "string" then if is_file then return _M.normalize_app(dofile(app_run)) else return _M.normalize_app(require(app_run)) end else error("not a valid WSAPI application") end end -- Sends the respose body through the "out" pipe, using -- the provided write method. Gets the body from the -- response iterator function _M.send_content(out, res_iter, write_method) local write = out[write_method or "write"] local flush = out.flush local ok, res = xpcall(res_iter, debug.traceback) while ok and res do write(out, res) if flush then flush(out) end ok, res = xpcall(res_iter, debug.traceback) end if not ok then write(out, "======== WSAPI ERROR DURING RESPONSE PROCESSING: \n
" ..
              tostring(res) .. "\n
") end end -- Sends the complete response through the "out" pipe, -- using the provided write method function _M.send_output(out, status, headers, res_iter, write_method, res_line) local write = out[write_method or "write"] if type(status) == "number" or status:match("^%d+$") then status = status .. " " .. _M.status_codes[tonumber(status)] end if res_line then write(out, "HTTP/1.1 " .. (status or "500 Internal Server Error") .. "\r\n") else write(out, "Status: " .. (status or "500 Internal Server Error") .. "\r\n") end for h, v in pairs(headers or {}) do if type(v) ~= "table" then write(out, h .. ": " .. tostring(v) .. "\r\n") else for _, v in ipairs(v) do write(out, h .. ": " .. tostring(v) .. "\r\n") end end end write(out, "\r\n") _M.send_content(out, res_iter, write_method) end -- Formats the standard error message for WSAPI applications function _M.error_html(msg) return string.format([[ WSAPI Error in Application

There was an error in the specified application. The full error message follows:

%s
]], tostring(msg)) end -- Body for a 500 response function _M.status_500_html(msg) return _M.error_html(msg) end -- Body for a 404 response function _M.status_404_html(msg) return string.format([[ Resource not found

%s

]], tostring(msg)) end function _M.status_200_html(msg) return string.format([[ Resource not found

%s

]], tostring(msg)) end local function make_iterator(msg) local sent = false return function () if sent then return nil else sent = true return msg end end end -- Sends an error response through the "out" pipe, replicated -- to the "err" pipe (for logging, for example) -- msg is the error message function _M.send_error(out, err, msg, out_method, err_method, http_response) local write = out[out_method or "write"] local write_err = err[err_method or "write"] write_err(err, "WSAPI error in application: " .. tostring(msg) .. "\n") local msg = _M.error_html(msg) local status, headers, res_iter = "500 Internal Server Error", { ["Content-Type"] = "text/html", ["Content-Length"] = #msg }, make_iterator(msg) _M.send_output(out, status, headers, res_iter, out_method, http_response) return status, headers end -- Sends a 404 response to the "out" pipe, "msg" is the error -- message function _M.send_404(out, msg, out_method, http_response) local write = out[out_method or "write"] local msg = _M.status_404_html(msg) local status, headers, res_iter = "404 Not Found", { ["Content-Type"] = "text/html", ["Content-Length"] = #msg }, make_iterator(msg) _M.send_output(out, status, headers, res_iter, out_method, http_response) return status, headers end -- Runs the application in the provided WSAPI environment, catching errors and -- returning the appropriate error repsonses function _M.run_app(app, env) return xpcall(function () return (_M.normalize_app(app))(env) end, function (msg) if type(msg) == "table" then env.STATUS = msg[1] return _M["status_" .. msg[1] .. "_html"](msg[2]) else return debug.traceback(msg, 2) end end) end -- Builds an WSAPI environment from the configuration table "t" function _M.wsapi_env(t) local env = {} setmetatable(env, { __index = _M.sv_index(t.env) }) env.input = _M.input_maker(t.input, t.read_method) env.error = t.error env.input.length = tonumber(env.CONTENT_LENGTH) or 0 if env.PATH_INFO == "" then env.PATH_INFO = "/" end return env end -- Runs an application with data from the configuration table "t", -- sending the WSAPI error/not found responses in case of errors function _M.run(app, t) local env = _M.wsapi_env(t) local ok, status, headers, res_iter = _M.run_app(app, env) if ok then if not headers["Content-Length"] then if t.http_response then headers["Transfer-Encoding"] = "chunked" local unchunked = res_iter res_iter = function () local msg = unchunked() if msg then return string.format("%x\r\n%s\r\n", #msg, msg) end end end end _M.send_output(t.output, status, headers, res_iter, t.write_method, t.http_response) else if env.STATUS == 404 then return _M.send_404(t.output, status, t.write_method, t.http_response) else return _M.send_error(t.output, t.error, status, t.write_method, t.err_method, t.http_response) end end return status, headers end function _M.splitpath(filename) local path, file = string.match(filename, "^(.*)[/\\]([^/\\]*)$") return path, file end function _M.splitext(filename) local modname, ext = string.match(filename, "^(.+)%.([^%.]+)$") if not modname then modname, ext = filename, "" end return modname, ext end -- Gets the data for file or directory "filename" if it exists: -- path, actual file name, file name without extension, extension, -- and modification time. If "filename" is a directory it assumes -- that the actual file is a .lua file in this directory with -- the same name as the directory (for example, "/foo/bar/bar.lua") function _M.find_file(filename) local mode = assert(lfs.attributes(filename, "mode")) local path, file, modname, ext if mode == "directory" then path, modname = _M.splitpath(filename) path = path .. "/" .. modname file = modname .. ".lua" ext = "lua" elseif mode == "file" then path, file = _M.splitpath(filename) modname, ext = _M.splitext(file) else return nil end local mtime = assert(lfs.attributes(path .. "/" .. file, "modification")) return path, file, modname, ext, mtime end -- IIS appends the PATH_INFO to PATH_TRANSLATED, this function -- corrects for that function _M.adjust_iis_path(wsapi_env, filename) local script_name, ext = wsapi_env.SCRIPT_NAME:match("([^/%.]+)%.([^%.]+)$") if script_name then local path = filename:match("^(.+)" .. script_name .. "%." .. ext .. "[/\\]") if path then return path .. script_name .. "." .. ext else return filename end else return filename end end -- IIS appends the PATH_INFO to the DOCUMENT_ROOT, this corrects -- for that and for virtual directories local function not_compatible(wsapi_env, filename) local script_name = wsapi_env.SCRIPT_NAME if not filename:gsub("\\","/"):find(script_name, 1, true) then -- more IIS madness, down into the rabbit hole... local path_info = wsapi_env.PATH_INFO:gsub("/", "\\") wsapi_env.DOCUMENT_ROOT = filename:sub(1, #filename-#path_info) return true end end -- Find the actual script file in case of non-wrapped launchers -- (http://server/cgi-bin/wsapi.cgi/bar/baz.lua/foo) and for IIS, -- as IIS provides a wrong PATH_TRANSLATED variable -- Corrects PATH_INFO and SCRIPT_NAME, so SCRIPT_NAME will be -- /cgi-bin/wsapi.cgi/bar/baz.lua and PATH_INFO will be /foo -- for the previous example function _M.adjust_non_wrapped(wsapi_env, filename, launcher) if filename == "" or not_compatible(wsapi_env, filename) or (launcher and filename:match(launcher:gsub("%.", ".") .. "$")) then local path_info = wsapi_env.PATH_INFO local docroot = wsapi_env.DOCUMENT_ROOT if docroot:sub(#docroot) ~= "/" and docroot:sub(#docroot) ~= "\\" then docroot = docroot .. "/" end local s, e = path_info:find("[^/%.]+%.[^/%.]+", 1) while s do local filepath = path_info:sub(2, e) local filename if docroot:find("\\", 1, true) then filename = docroot .. filepath:gsub("/","\\") else filename = docroot .. filepath end local mode = lfs.attributes(filename, "mode") if not mode then error({ 404, "Resource " .. wsapi_env.SCRIPT_NAME .. "/" .. filepath .. " not found!" }, 0) elseif lfs.attributes(filename, "mode") == "file" then wsapi_env.PATH_INFO = path_info:sub(e + 1) if wsapi_env.PATH_INFO == "" then wsapi_env.PATH_INFO = "/" end wsapi_env.SCRIPT_NAME = wsapi_env.SCRIPT_NAME .. "/" .. filepath return filename end s, e = path_info:find("[^/%.]+%.[^/%.]+", e + 1) end error("could not find a filename to load, check your configuration or URL") else return filename end end -- Tries to guess the correct path for the WSAPI application script, -- correcting for misbehaving web servers (IIS), non-wrapped launchers -- and (http://server/cgi-bin/wsapi.cgi/bar/baz.lua/foo) function _M.normalize_paths(wsapi_env, filename, launcher, vars) vars = vars or { "SCRIPT_FILENAME", "PATH_TRANSLATED" } if not filename or filename == "" then for _, var in ipairs(vars) do filename = wsapi_env[var] if filename ~= "" then break end end filename = _M.adjust_non_wrapped(wsapi_env, filename, launcher) filename = _M.adjust_iis_path(wsapi_env, filename) wsapi_env.PATH_TRANSLATED = filename wsapi_env.SCRIPT_FILENAME = filename else wsapi_env.PATH_TRANSLATED = filename wsapi_env.SCRIPT_FILENAME = filename end local s, e = wsapi_env.PATH_INFO:find(wsapi_env.SCRIPT_NAME, 1, true) if s == 1 then wsapi_env.PATH_INFO = wsapi_env.PATH_INFO:sub(e+1) if wsapi_env.PATH_INFO == "" then wsapi_env.PATH_INFO = "/" end end end -- Tries to find the correct script to launch for the WSAPI application function _M.find_module(wsapi_env, filename, launcher, vars) _M.normalize_paths(wsapi_env, filename or "", launcher, vars) return _M.find_file(wsapi_env.PATH_TRANSLATED) end -- Version of require skips searching package.path function _M.require_file(filename, modname) package.loaded[modname] = true local res = loadfile(filename)(modname) if res then package.loaded[modname] = res end return package.loaded[modname] end -- Loads the script for a WSAPI application (require'ing in case of -- a .lua script and dofile'ing it in case of other extensions), -- returning the WSAPI handler function for this application -- also moves the current directory to the application's path function _M.load_wsapi(path, file, modname, ext) lfs.chdir(path) local app if ext == "lua" then app = _M.require_file(file, modname) else app = dofile(file) end return _M.normalize_app(app) end -- Local state and helper functions for the loader if isolated applications, -- used in the FastCGI and Xavante WSAPI launchers do local app_states = {} local last_collection = os.time() setmetatable(app_states, { __index = function (tab, app) tab[app] = { states = {} } return tab[app] end }) -- Bootstraps a Lua state (using rings) with the provided WSAPI application local function bootstrap_app(path, file, modname, ext) local bootstrap = [=[ _, package.path = remotedostring("return package.path") _, package.cpath = remotedostring("return package.cpath") pcall(require, "luarocks.require") wsapi = {} wsapi.app_path = [[]=] .. path .. [=[]] ]=] if ext == "lua" then return ringer.new(modname, bootstrap) else return ringer.new(file, bootstrap, true) end end -- "Garbage-collect" stale Lua states local function collect_states(period, ttl) if period and (last_collection + period < os.time()) then for app, app_state in pairs(app_states) do local new_states = {} for _, state in ipairs(app_state.states) do if ttl and (rawget(state.data, "created_at") + ttl > os.time()) then table.insert(new_states, state) else if not rawget(state.data, "status") then state.app("close") else rawset(state.data, "cleanup", true) end end end app_state.states = new_states end last_collection = os.time() end end -- Helper for the isolated launchers: find the application path and script, -- loads it in an isolated Lua state (reusing an existing state if one is free) -- and runs the application in the provided WSAPI environment local function wsapi_loader_isolated_helper(wsapi_env, params) local path, file, modname, ext, mtime = _M.find_module(wsapi_env, params.filename, params.launcher, params.vars) if params.reload then mtime = nil end if not path then error({ 404, "Resource " .. wsapi_env.SCRIPT_NAME .. " not found"}) end local app = _M.load_wsapi_isolated(path, file, modname, ext, mtime) wsapi_env.APP_PATH = path return app(wsapi_env) end -- Loads a WSAPI application isolated in its own Lua state and returns -- the application handler (reusing an existing state if one is free) function _M.load_wsapi_isolated(path, file, modname, ext, mtime) local filename = path .. "/" .. file lfs.chdir(path) local app, data local app_state = app_states[filename] if mtime and app_state.mtime == mtime then for i, state in ipairs(app_state.states) do if not rawget(state.data, "status") then return state.app end end app, data = bootstrap_app(path, file, modname, ext) table.insert(app_state.states, { app = app, data = data }) else for _, state in ipairs(app_state.states) do if not rawget(state.data, "status") then state.app("close") else rawset(state.data, "cleanup", true) end end app, data = bootstrap_app(path, file, modname, ext) if mtime then app_states[filename] = { states = { { app = app, data = data } }, mtime = mtime } end end return app end -- Makes an WSAPI application that launches isolated WSAPI applications -- scripts with the provided parameters - see wsapi.fcgi for the -- parameters and their descriptions function _M.make_isolated_loader(params) params = params or {} return function (wsapi_env) collect_states(params.period, params.ttl) return wsapi_loader_isolated_helper(wsapi_env, params) end end function _M.wsapi_loader_isolated(wsapi_env) return wsapi_loader_isolated_helper(wsapi_env, {}) end function _M.wsapi_loader_isolated_reload(wsapi_env) return wsapi_loader_isolated_helper(wsapi_env, { reload = true }) end end -- Local state and helper functions for the loader if isolated dedicated -- launchers, used in the CGILua and Orbit pages launchers do local app_states = {} local last_collection = os.time() setmetatable(app_states, { __index = function (tab, app) tab[app] = { states = {} } return tab[app] end }) -- "Garbage-collect" stale Lua states local function collect_states(period, ttl) if period and (last_collection + period < os.time()) then for app, app_state in pairs(app_states) do local new_states = {} for _, state in ipairs(app_state.states) do if ttl and (rawget(state.data, "created_at") + ttl > os.time()) then table.insert(new_states, state) else if not rawget(state.data, "status") then state.app("close") else rawset(state.data, "cleanup", true) end end end app_state.states = new_states end last_collection = os.time() end end -- Bootstraps a Lua state (using rings) with the provided launcher local function bootstrap_app(path, app_modname, extra) local bootstrap = [=[ _, package.path = remotedostring("return package.path") _, package.cpath = remotedostring("return package.cpath") pcall(require, "luarocks.require") wsapi = {} wsapi.app_path = [[]=] .. path .. [=[]] ]=] .. (extra or "") return ringer.new(app_modname, bootstrap) end -- Loads a WSAPI application isolated in its own Lua state and returns -- the application handler (reusing an existing state if one is free) function _M.load_isolated_launcher(filename, app_modname, bootstrap, reload) local app, data local app_state = app_states[filename] local path, _ = _M.splitpath(filename) local mtime = lfs.attributes(filename, "modification") if not reload and app_state.mtime == mtime then for _, state in ipairs(app_state.states) do if not rawget(state.data, "status") then return state.app end end app, data = bootstrap_app(path, app_modname, bootstrap) table.insert(app_state.states, { app = app, data = data }) else for _, state in ipairs(app_state.states) do if not rawget(state.data, "status") then state.app("close") else rawset(state.data, "cleanup", true) end end app, data = bootstrap_app(path, app_modname, bootstrap) app_states[filename] = { states = { { app = app, data = data } }, mtime = mtime } end return app end -- Makes an WSAPI application that launches an isolated WSAPI launcher -- with the provided parameters - see op.fcgi in the Orbit sources for the -- parameters and their descriptions function _M.make_isolated_launcher(params) params = params or {} return function (wsapi_env) collect_states(params.period, params.ttl) _M.normalize_paths(wsapi_env, params.filename, params.launcher, params.vars) local app = _M.load_isolated_launcher(wsapi_env.PATH_TRANSLATED, params.modname, params.bootstrap, params.reload) return app(wsapi_env) end end end -- Local state and helper functions for the loader of persistent applications, -- used in the FastCGI and Xavante WSAPI launchers do local apps = {} local last_collection = os.time() setmetatable(apps, { __index = function (tab, app) tab[app] = { created_at = os.time() } return tab[app] end }) -- Bootstraps a Lua state (using rings) with the provided WSAPI application local function bootstrap_app(path, file, modname, ext) return _M.load_wsapi(path, file, modname, ext) end -- "Garbage-collect" stale Lua states local function collect_states(period, ttl) if period and (last_collection + period < os.time()) then for app_name, app_data in pairs(apps) do local new_data = { created_at = os.time() } if ttl and app_data.created_at + ttl > os.time() then new_data.app = app_data.app end apps[app_name] = new_data end last_collection = os.time() end end -- Loads a persistent WSAPI application Lua state and returns -- the application handler (reusing an existing state if one is free) local function load_wsapi_persistent(path, file, modname, ext, mtime) local filename = path .. "/" .. file lfs.chdir(path) local app local app_data = apps[filename] if mtime and app_data.mtime == mtime then return app_data.app else app = bootstrap_app(path, file, modname, ext) if mtime then apps[filename].app = app apps[filename].mtime = mtime end return app end end -- Helper for the persistent launchers: find the application path and script, -- loads and runs the application in the provided WSAPI environment local function wsapi_loader_persistent_helper(wsapi_env, params) local path, file, modname, ext, mtime = _M.find_module(wsapi_env, params.filename, params.launcher, params.vars) if params.reload then mtime = nil end if not path then error({ 404, "Resource " .. wsapi_env.SCRIPT_NAME .. " not found"}) end local app = load_wsapi_persistent(path, file, modname, ext, mtime) wsapi_env.APP_PATH = path return app(wsapi_env) end -- Makes an WSAPI application that launches persistent WSAPI applications -- scripts with the provided parameters - see wsapi.fcgi for the -- parameters and their descriptions function _M.make_persistent_loader(params) params = params or {} return function (wsapi_env) collect_states(params.period, params.ttl) return wsapi_loader_persistent_helper(wsapi_env, params) end end end function _M.make_loader(params) params = params or { isolated = true } if params.isolated then return _M.make_isolated_loader(params) else return _M.make_persistent_loader(params) end end return _M lua-wsapi-1.6.1/src/wsapi/fastcgi.lua000066400000000000000000000023671231271307300174650ustar00rootroot00000000000000----------------------------------------------------------------------------- -- Fastcgi WSAPI handler -- -- Author: Fabio Mascarenhas -- Copyright (c) 2007 Kepler Project -- ----------------------------------------------------------------------------- local lfcgi = require"lfcgi" local os = require"os" local io = require"io" local common = require"wsapi.common" local ipairs = ipairs local _M = {} io.stdout = lfcgi.stdout io.stderr = lfcgi.stderr io.stdin = lfcgi.stdin -- Runs an WSAPI application for each FastCGI request that comes -- from the FastCGI pipeline function _M.run(app_run) while lfcgi.accept() >= 0 do local headers local function getenv(n) if n == "headers" then if headers then return headers end local env_vars = lfcgi.environ() headers = {} for _, s in ipairs(env_vars) do local name, val = s:match("^([^=]+)=(.*)$") headers[name] = val end return headers else return lfcgi.getenv(n) or os.getenv(n) end end common.run(app_run, { input = lfcgi.stdin, output = lfcgi.stdout, error = lfcgi.stderr, env = getenv }) end end return _Mlua-wsapi-1.6.1/src/wsapi/mock.lua000066400000000000000000000113421231271307300167670ustar00rootroot00000000000000----------------------------------------------------------------------------- -- Mock WSAPI handler for Unit testing -- -- Author: Norman Clarke -- Copyright (c) 2010 Kepler Project -- ----------------------------------------------------------------------------- local _M = {} local common = require "wsapi.common" local request = require "wsapi.request" -- Build a request that looks like something that would come from a real web -- browser. local function build_request(method, path, headers) local req = { GATEWAY_INTERFACE = "CGI/1.1", HTTP_ACCEPT = "application/xml,application/xhtml+xml,text/html;q=0.9," .. "text/plain;q=0.8,image/png,*/*;q=0.5", HTTP_ACCEPT_CHARSET = "ISO-8859-1,utf-8;q=0.7,*;q=0.3", HTTP_ACCEPT_ENCODING = "gzip,deflate,sdch", HTTP_ACCEPT_LANGUAGE = "en-US,en;q=0.8", HTTP_CACHE_CONTROL = "max-age=0", HTTP_CONNECTION = "keep-alive", HTTP_HOST = "127.0.0.1:80", HTTP_USER_AGENT = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X " .. "10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) " .. "Chrome/6.0.472.55", HTTP_VERSION = "HTTP/1.1", REMOTE_ADDR = "127.0.0.1", REMOTE_HOST = "localhost", SCRIPT_NAME = "wsapi_test", SERVER_NAME = "localhost", SERVER_PORT = "80", SERVER_PROTOCOL = "HTTP/1.1" } req.PATH_INFO = path req.REQUEST_METHOD = method:upper() req.METHOD = req.REQUEST_METHOD req.REQUEST_PATH = "/" if req.PATH_INFO == "" then req.PATH_INFO = "/" end for k, v in pairs(headers or {}) do req[k] = v end -- allow case-insensitive table key access setmetatable(req, {__index = function(t, k) return rawget(t, string.upper(k)) end}) return req end -- Override common's output handler to avoid writing headers -- in the reponse body. function common.send_output(out, status, headers, res_iter, write_method,res_line) common.send_content(out, res_iter, "write") end -- Mock IO objects local function make_io_object(content) local receiver = { buffer = { content }, bytes_read = 0 } function receiver:write(content) self.buffer[#self.buffer + 1] = content return true end function receiver:read(len) -- first read will turn the buffer into a string if type(self.buffer) == "table" then self.buffer = table.concat(self.buffer) end len = len or (#self.buffer - self.bytes_read) if self.bytes_read >= #self.buffer then return nil end local s = self.buffer:sub(self.bytes_read + 1, self.bytes_read + len) self.bytes_read = self.bytes_read + len if self.bytes_read > #self.buffer then self.bytes_read = #self.buffer end return s end function receiver:clear() self.buffer = {} self.bytes_read = 0 end function receiver:reset() self.bytes_read = 0 end return receiver end -- Build a GET request local function build_get(path, params, headers) local req = build_request("GET", path, headers) req.QUERY_STRING = request.methods.qs_encode(nil, params) req.REQUEST_URI = "http://" .. req.HTTP_HOST .. req.PATH_INFO .. req.QUERY_STRING return { env = req, input = make_io_object(), output = make_io_object(), error = make_io_object() } end local function build_post(path, params, headers) local req = build_request("POST", path, headers) req.REQUEST_URI = "http://" .. req.HTTP_HOST .. req.PATH_INFO local body if headers["Content-Type"] then body = params else body = request.methods.qs_encode(nil, params):gsub("^?", "") req.CONTENT_TYPE = "x-www-form-urlencoded" end -- if the path includes a query string, store it in the appropiate header local qs = path:match("?(.+)$") if qs then req.QUERY_STRING = qs end req.CONTENT_LENGTH = headers["Content-Length"] or #body return { env = req, input = make_io_object(body), output = make_io_object(), error = make_io_object() } end local function make_request(request_builder, app, path, params, headers) local wsapi_env = request_builder(path, params, headers) local response = {} response.code, response.headers = common.run(app, wsapi_env) response.body = wsapi_env.output:read() response.wsapi_errors = wsapi_env.error:read() return response, wsapi_env.env end local function get(self, path, params, headers) return make_request(build_get, self.app, path, params, headers) end local function post(self, path, params, headers) return make_request(build_post, self.app, path, params, headers) end --- Creates a WSAPI handler for testing. -- @param app The WSAPI application you want to test. function _M.make_handler(app) return { app = app, get = get, post = post } end return _M lua-wsapi-1.6.1/src/wsapi/request.lua000066400000000000000000000160521231271307300175310ustar00rootroot00000000000000local util = require"wsapi.util" local _M = {} local function split_filename(path) local name_patt = "[/\\]?([^/\\]+)$" return (string.match(path, name_patt)) end local function insert_field (tab, name, value, overwrite) if overwrite or not tab[name] then tab[name] = value else local t = type (tab[name]) if t == "table" then table.insert (tab[name], value) else tab[name] = { tab[name], value } end end end local function parse_qs(qs, tab, overwrite) tab = tab or {} if type(qs) == "string" then local url_decode = util.url_decode for key, val in string.gmatch(qs, "([^&=]+)=([^&=]*)&?") do insert_field(tab, url_decode(key), url_decode(val), overwrite) end elseif qs then error("WSAPI Request error: invalid query string") end return tab end local function get_boundary(content_type) local boundary = string.match(content_type, "boundary%=(.-)$") return "--" .. tostring(boundary) end local function break_headers(header_data) local headers = {} for type, val in string.gmatch(header_data, '([^%c%s:]+):%s+([^\n]+)') do type = string.lower(type) headers[type] = val end return headers end local function read_field_headers(input, pos) local EOH = "\r\n\r\n" local s, e = string.find(input, EOH, pos, true) if s then return break_headers(string.sub(input, pos, s-1)), e+1 else return nil, pos end end local function get_field_names(headers) local disp_header = headers["content-disposition"] or "" local attrs = {} for attr, val in string.gmatch(disp_header, ';%s*([^%s=]+)="(.-)"') do attrs[attr] = val end return attrs.name, attrs.filename and split_filename(attrs.filename) end local function read_field_contents(input, boundary, pos) local boundaryline = "\r\n" .. boundary local s, e = string.find(input, boundaryline, pos, true) if s then return string.sub(input, pos, s-1), s-pos, e+1 else return nil, 0, pos end end local function file_value(file_contents, file_name, file_size, headers) local value = { contents = file_contents, name = file_name, size = file_size } for h, v in pairs(headers) do if h ~= "content-disposition" then value[h] = v end end return value end local function fields(input, boundary) local state, _ = { } _, state.pos = string.find(input, boundary, 1, true) state.pos = state.pos + 1 return function (state, _) local headers, name, file_name, value, size headers, state.pos = read_field_headers(input, state.pos) if headers then name, file_name = get_field_names(headers) if file_name then value, size, state.pos = read_field_contents(input, boundary, state.pos) value = file_value(value, file_name, size, headers) else value, size, state.pos = read_field_contents(input, boundary, state.pos) end end return name, value end, state end local function parse_multipart_data(input, input_type, tab, overwrite) tab = tab or {} local boundary = get_boundary(input_type) for name, value in fields(input, boundary) do insert_field(tab, name, value, overwrite) end return tab end local function parse_post_data(wsapi_env, tab, overwrite) tab = tab or {} local input_type = wsapi_env.CONTENT_TYPE if string.find(input_type, "x-www-form-urlencoded", 1, true) then local length = tonumber(wsapi_env.CONTENT_LENGTH) or 0 parse_qs(wsapi_env.input:read(length) or "", tab, overwrite) elseif string.find(input_type, "multipart/form-data", 1, true) then local length = tonumber(wsapi_env.CONTENT_LENGTH) or 0 if length > 0 then parse_multipart_data(wsapi_env.input:read(length) or "", input_type, tab, overwrite) end else local length = tonumber(wsapi_env.CONTENT_LENGTH) or 0 tab.post_data = wsapi_env.input:read(length) or "" end return tab end _M.methods = {} local methods = _M.methods function methods.__index(tab, name) local func if methods[name] then func = methods[name] else local route_name = name:match("link_([%w_]+)") if route_name then func = function (self, query, ...) return tab:route_link(route_name, query, ...) end end end tab[name] = func return func end function methods:qs_encode(query, url) local parts = {} for k, v in pairs(query or {}) do parts[#parts+1] = k .. "=" .. util.url_encode(v) end if #parts > 0 then return (url and (url .. "?") or "") .. table.concat(parts, "&") else return (url and url or "") end end function methods:route_link(route, query, ...) local builder = self.mk_app["link_" .. route] if builder then local uri = builder(self.mk_app, self.env, ...) local qs = self:qs_encode(query) return uri .. (qs ~= "" and ("?"..qs) or "") else error("there is no route named " .. route) end end function methods:link(url, query) local prefix = (self.mk_app and self.mk_app.prefix) or self.script_name local uri = prefix .. url local qs = self:qs_encode(query) return prefix .. url .. (qs ~= "" and ("?"..qs) or "") end function methods:absolute_link(url, query) local qs = self:qs_encode(query) return url .. (qs ~= "" and ("?"..qs) or "") end function methods:static_link(url) local prefix = (self.mk_app and self.mk_app.prefix) or self.script_name local is_script = prefix:match("(%.%w+)$") if not is_script then return self:link(url) end local vpath = prefix:match("(.*)/") or "" return vpath .. url end function methods:empty(s) return not s or string.match(s, "^%s*$") end function methods:empty_param(param) return self:empty(self.params[param]) end function _M.new(wsapi_env, options) options = options or {} local req = { GET = {}, POST = {}, method = wsapi_env.REQUEST_METHOD, path_info = wsapi_env.PATH_INFO, query_string = wsapi_env.QUERY_STRING, script_name = wsapi_env.SCRIPT_NAME, env = wsapi_env, mk_app = options.mk_app, doc_root = wsapi_env.DOCUMENT_ROOT, app_path = wsapi_env.APP_PATH } parse_qs(wsapi_env.QUERY_STRING, req.GET, options.overwrite) if options.delay_post then req.parse_post = function (self) parse_post_data(wsapi_env, self.POST, options.overwrite) self.parse_post = function () return nil, "postdata already parsed" end return self.POST end else parse_post_data(wsapi_env, req.POST, options.overwrite) req.parse_post = function () return nil, "postdata already parsed" end end req.params = {} setmetatable(req.params, { __index = function (tab, name) local var = req.GET[name] or req.POST[name] rawset(tab, name, var) return var end}) req.cookies = {} local cookies = string.gsub(";" .. (wsapi_env.HTTP_COOKIE or "") .. ";", "%s*;%s*", ";") setmetatable(req.cookies, { __index = function (tab, name) name = name local pattern = ";" .. name .. "=(.-);" local cookie = string.match(cookies, pattern) cookie = util.url_decode(cookie) rawset(tab, name, cookie) return cookie end}) return setmetatable(req, methods) end return _M lua-wsapi-1.6.1/src/wsapi/response.lua000066400000000000000000000053461231271307300177030ustar00rootroot00000000000000local util = require "wsapi.util" local date = os.date local format = string.format local _M = {} local methods = {} methods.__index = methods _M.methods = methods local unpack = table.unpack or unpack function methods:write(...) for _, s in ipairs{ ... } do if type(s) == "table" then self:write(unpack(s)) elseif s then local s = tostring(s) self.body[#self.body+1] = s self.length = self.length + #s end end end function methods:forward(url) self.env.PATH_INFO = url or self.env.PATH_INFO return "MK_FORWARD" end function methods:finish() self.headers["Content-Length"] = self.length return self.status, self.headers, coroutine.wrap(function () for _, s in ipairs(self.body) do coroutine.yield(s) end end) end local function optional (what, name) if name ~= nil and name ~= "" then return format("; %s=%s", what, name) else return "" end end local function optional_flag(what, isset) if isset then return format("; %s", what) end return "" end local function make_cookie(name, value) local options = {} local t if type(value) == "table" then options = value value = value.value end local cookie = name .. "=" .. util.url_encode(value) if options.expires then t = date("!%A, %d-%b-%Y %H:%M:%S GMT", options.expires) cookie = cookie .. optional("expires", t) end if options.max_age then t = date("!%A, %d-%b-%Y %H:%M:%S GMT", options.max_age) cookie = cookie .. optional("Max-Age", t) end cookie = cookie .. optional("path", options.path) cookie = cookie .. optional("domain", options.domain) cookie = cookie .. optional_flag("secure", options.secure) cookie = cookie .. optional_flag("HttpOnly", options.httponly) return cookie end function methods:set_cookie(name, value) local cookie = self.headers["Set-Cookie"] if type(cookie) == "table" then table.insert(self.headers["Set-Cookie"], make_cookie(name, value)) elseif type(cookie) == "string" then self.headers["Set-Cookie"] = { cookie, make_cookie(name, value) } else self.headers["Set-Cookie"] = make_cookie(name, value) end end function methods:delete_cookie(name, path, domain) self:set_cookie(name, { value = "xxx", expires = 1, path = path, domain = domain }) end function methods:redirect(url) self.status = 302 self.headers["Location"] = url self.body = {} return self:finish() end function methods:content_type(type) self.headers["Content-Type"] = type end function _M.new(status, headers) status = status or 200 headers = headers or {} if not headers["Content-Type"] then headers["Content-Type"] = "text/html" end return setmetatable({ status = status, headers = headers, body = {}, length = 0 }, methods) end return _M lua-wsapi-1.6.1/src/wsapi/ringer.lua000066400000000000000000000123071231271307300173260ustar00rootroot00000000000000-- Rings application for WSAPI local rings = require "rings" local _M = {} local init = [==[ local app_name, bootstrap_code, is_file = ... if bootstrap_code then local bootstrap, err if string.match(bootstrap_code, "%w%.lua$") then bootstrap, err = loadfile(bootstrap_code) else bootstrap, err = loadstring(bootstrap_code) end if bootstrap then bootstrap() else error("could not load " .. bootstrap_code .. ": " .. err) end else _, package.path = remotedostring("return package.path") _, package.cpath = remotedostring("return package.cpath") end local common = require"wsapi.common" local coxpcall = require "coxpcall" pcall = coxpcall.pcall xpcall = coxpcall.xpcall local wsapi_error = { write = function (self, err) remotedostring("env.error:write(...)", err) end } local wsapi_input = { read = function (self, n) return coroutine.yield("RECEIVE", n) end } local wsapi_meta = { __index = function (tab, k) if k == "headers" then local headers local _, all_headers = remotedostring([[ if env.headers then local out = {} for k, v in pairs(env.headers) do table.insert(out, "[" .. string.format("%q", k) .. "]=" .. string.format("%q", v)) end return "return {" .. table.concat(out, ",") .. "}" end ]]) if all_headers then local v = loadstring(all_headers)() rawset(tab, k, v) return v end else local _, v = remotedostring("return env[(...)]", k) rawset(tab, k, v) return v end end, __newindex = function (tab, k, v) rawset(tab, k, v) remotedostring("local k, v = ...; env[k] = v", k, v) end } local app = common.normalize_app(app_name, is_file) main_func = function () local wsapi_env = { error = wsapi_error, input = wsapi_input } setmetatable(wsapi_env, wsapi_meta) local ok, status, headers, res = common.run_app(app, wsapi_env) if not ok then local msg = status headers = { ["Content-Type"] = "text/html" } if wsapi_env.STATUS ~= "" then status = wsapi_env.STATUS res = coroutine.wrap(function () coroutine.yield(msg) end) else status = 500 res = coroutine.wrap(function () coroutine.yield(common.error_html(msg)) end) end end remotedostring("status = ...", status) for k, v in pairs(headers) do if type(v) == "table" then remotedostring("headers[(...)] = {}", k) for _, val in ipairs(v) do remotedostring("local k, v = ...; table.insert(headers[k], v)", k, val) end else remotedostring("local k, v = ...; headers[k] = v", k, v) end end local s, v = res() while s do if s == "RECEIVE" and v then s, v = res(coroutine.yield(s, v)) else coroutine.yield("SEND", s) end s, v = res() end return "SEND", nil end ]==] -- Returns a WSAPI application that runs the provided WSAPI application -- in an isolated Lua environment function _M.new(app_name, bootstrap, is_file) local data = { created_at = os.time() } setmetatable(data, { __index = _G }) local state = rings.new(data) assert(state:dostring(init, app_name, bootstrap, is_file)) local error = function (msg) data.status, data.headers, data.env = nil error(msg) end return function (wsapi_env) if state and wsapi_env == "close" then state:close() state = nil end if not state then return nil end if rawget(data, "status") then error("this state is already in use") end data.status = 500 data.headers = {} data.env = wsapi_env local ok, flag, s = state:dostring([[ main_coro = coroutine.wrap(main_func) return main_coro(...) ]]) repeat if not ok then error(flag) end if flag == "RECEIVE" then ok, flag, s = state:dostring("return main_coro(...)", wsapi_env.input:read(s)) elseif flag == "SEND" then break else error("Invalid command: " .. tostring(flag)) end until flag == "SEND" local res if not s then res = function () return nil end else res = function () if s then local res = s s = nil return res end local ok, flag, s = state:dostring("return main_coro()") while ok and flag and s do if flag == "RECEIVE" then ok, flag, s = state:dostring("return main_coro(...)", wsapi_env.input:read(s)) elseif flag == "SEND" then return s else error("Invalid command: " .. tostring(flag)) end end data.status, data.headers, data.env = nil if data.cleanup then state:close() state = nil end if not ok then error(flag) end end end return data.status, data.headers, res end, data end return _M lua-wsapi-1.6.1/src/wsapi/sapi.lua000066400000000000000000000030121231271307300167650ustar00rootroot00000000000000 local response = require "wsapi.response" local _M = {} function _M.run(wsapi_env) _G.CGILUA_APPS = _G.CGILUA_APPS or wsapi_env.DOCUMENT_ROOT .. "/cgilua" _G.CGILUA_CONF = _G.CGILUA_CONF or wsapi_env.DOCUMENT_ROOT .. "/cgilua" _G.CGILUA_TMP = _G.CGILUA_TMP or os.getenv("TMP") or os.getenv("TEMP") or "/tmp" _G.CGILUA_ISDIRECT = true local res = response.new() _G.SAPI = { Info = { _COPYRIGHT = "Copyright (C) 2007 Kepler Project", _DESCRIPTION = "WSAPI SAPI implementation", _VERSION = "WSAPI SAPI 1.0", ispersistent = false, }, Request = { servervariable = function (name) return wsapi_env[name] end, getpostdata = function (n) return wsapi_env.input:read(n) end }, Response = { contenttype = function (header) res:content_type(header) end, errorlog = function (msg, errlevel) wsapi_env.error:write (msg) end, header = function (header, value) if res.headers[header] then if type(res.headers[header]) == "table" then table.insert(res.headers[header], value) else res.headers[header] = { res.headers[header], value } end else res.headers[header] = value end end, redirect = function (url) res.status = 302 res.headers["Location"] = url end, write = function (...) res:write({...}) end, }, } local cgilua = require "cgilua" cgilua.main() return res:finish() end return _Mlua-wsapi-1.6.1/src/wsapi/util.lua000066400000000000000000000137241231271307300170210ustar00rootroot00000000000000 local _M = {} ---------------------------------------------------------------------------- -- Decode an URL-encoded string (see RFC 2396) ---------------------------------------------------------------------------- function _M.url_decode(str) if not str then return nil end str = string.gsub (str, "+", " ") str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end) str = string.gsub (str, "\r\n", "\n") return str end ---------------------------------------------------------------------------- -- URL-encode a string (see RFC 2396) ---------------------------------------------------------------------------- function _M.url_encode(str) if not str then return nil end str = string.gsub (str, "\n", "\r\n") str = string.gsub (str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") return str end ---------------------------------------------------------------------------- -- Sanitizes all HTML tags ---------------------------------------------------------------------------- function _M.sanitize(text) return text:gsub(">", ">"):gsub("<", "<") end ---------------------------------------------------------------------------- -- Checks whether s is not nil or the empty string ---------------------------------------------------------------------------- function _M.not_empty(s) if s and s ~= "" then return s else return nil end end ---------------------------------------------------------------------------- -- Wraps the WSAPI environment to make the input rewindable, so you -- can parse postdata more than once, call wsapi_env.input:rewind() ---------------------------------------------------------------------------- function _M.make_rewindable(wsapi_env) local new_env = { input = { position = 1, contents = "" } } function new_env.input:read(size) local left = #self.contents - self.position + 1 local s if left < size then self.contents = self.contents .. wsapi_env.input:read(size - left) s = self.contents:sub(self.position) self.position = #self.contents + 1 else s = self.contents:sub(self.position, self.position + size) self.position = self.position + size end if s == "" then return nil else return s end end function new_env.input:rewind() self.position = 1 end return setmetatable(new_env, { __index = wsapi_env, __newindex = wsapi_env }) end ---------------------------------------------------------------------------- -- getopt, POSIX style command line argument parser -- param arg contains the command line arguments in a standard table. -- param options is a string with the letters that expect string values. -- returns a table where associated keys are true, nil, or a string value. -- The following example styles are supported -- -a one ==> opts["a"]=="one" -- -bone ==> opts["b"]=="one" -- -c ==> opts["c"]==true -- --c=one ==> opts["c"]=="one" -- -cdaone ==> opts["c"]==true opts["d"]==true opts["a"]=="one" -- note POSIX demands the parser ends at the first non option -- this behavior isn't implemented. ---------------------------------------------------------------------------- function _M.getopt( arg, options ) local tab, args = {}, {} local k = 1 while k <= #arg do local v = arg[k] if string.sub( v, 1, 2) == "--" then local x = string.find( v, "=", 1, true ) if x then tab[ string.sub( v, 3, x-1 ) ] = string.sub( v, x+1 ) else tab[ string.sub( v, 3 ) ] = true end k = k + 1 elseif string.sub( v, 1, 1 ) == "-" then local y = 2 local l = #v local jopt local next = 1 while ( y <= l ) do jopt = string.sub( v, y, y ) if string.find( options, jopt, 1, true ) then if y < l then tab[ jopt ] = string.sub( v, y+1 ) y = l else tab[ jopt ] = arg[ k + 1 ] next = 2 end else tab[ jopt ] = true end y = y + 1 end k = k + next else args[#args + 1] = v k = k + 1 end end return tab, args end ---------------------------------------------------------------------------- -- Makes a mock WSAPI environment with GET method and the provided -- query string ---------------------------------------------------------------------------- function _M.make_env_get(qs) return { REQUEST_METHOD = "GET", QUERY_STRING = qs or "", CONTENT_LENGTH = 0, PATH_INFO = "/", SCRIPT_NAME = "", CONTENT_TYPE = "x-www-form-urlencoded", input = { read = function () return nil end }, error = { messages = {}, write = function (self, msg) self.messages[#self.messages+1] = msg end } } end ---------------------------------------------------------------------------- -- Makes a mock WSAPI environment with POST method and the provided -- postdata, type (x-www-form-urlenconded default) and query string ---------------------------------------------------------------------------- function _M.make_env_post(pd, type, qs) pd = pd or "" return { REQUEST_METHOD = "POST", QUERY_STRING = qs or "", CONTENT_LENGTH = #pd, PATH_INFO = "/", CONTENT_TYPE = type or "x-www-form-urlencoded", SCRIPT_NAME = "", input = { post_data = pd, current = 1, read = function (self, len) if self.current > #self.post_data then return nil end local s = self.post_data:sub(self.current, len) self.current = self.current + len return s end }, error = { messages = {}, write = function (self, msg) self.messages[#self.messages+1] = msg end } } end function _M.loadfile(filename, env) if _VERSION == "Lua 5.2" then return loadfile(filename, "bt", env) else local f, err = loadfile(filename) if not f then return nil, err end setfenv(f, env) return f end end return _M lua-wsapi-1.6.1/src/wsapi/xavante.lua000066400000000000000000000101251231271307300175020ustar00rootroot00000000000000----------------------------------------------------------------------------- -- Xavante WSAPI handler -- -- Author: Fabio Mascarenhas -- Copyright (c) 2007 Kepler Project -- ----------------------------------------------------------------------------- local coxpcall = require "coxpcall" pcall = coxpcall.pcall xpcall = coxpcall.xpcall local common = require"wsapi.common" local _M = {} ------------------------------------------------------------------------------- -- Implements WSAPI ------------------------------------------------------------------------------- local function set_cgivars (req, diskpath, path_info_pat, script_name_pat, extra_vars) diskpath = diskpath or req.diskpath or "" req.cgivars = { SERVER_SOFTWARE = req.serversoftware, SERVER_NAME = req.parsed_url.host, GATEWAY_INTERFACE = "CGI/1.1", SERVER_PROTOCOL = "HTTP/1.1", SERVER_PORT = req.parsed_url.port, REQUEST_METHOD = req.cmd_mth, DOCUMENT_ROOT = diskpath, PATH_INFO = string.match(req.parsed_url.path, path_info_pat) or "", PATH_TRANSLATED = script_name_pat and (diskpath .. script_name_pat), SCRIPT_NAME = script_name_pat, QUERY_STRING = req.parsed_url.query or "", REMOTE_ADDR = string.gsub (req.rawskt:getpeername (), ":%d*$", ""), CONTENT_TYPE = req.headers ["content-type"], CONTENT_LENGTH = req.headers ["content-length"], } if req.cgivars.PATH_INFO == "" then req.cgivars.PATH_INFO = "/" end for n,v in pairs(extra_vars or {}) do req.cgivars[n] = v end for n,v in pairs (req.headers) do req.cgivars ["HTTP_"..string.gsub (string.upper (n), "-", "_")] = v end end local function wsapihandler (req, res, wsapi_run, app_prefix, docroot, app_path, extra_vars) local path_info_pat = "^" .. (app_prefix or "") .. "(.*)" set_cgivars(req, docroot, path_info_pat, app_prefix, extra_vars) local get_cgi_var = function (var) return req.cgivars[var] or "" end local wsapi_env = common.wsapi_env { input = req.socket, read_method = "receive", error = io.stderr, env = get_cgi_var } wsapi_env.APP_PATH = app_path local function set_status(status) if type(status) == "number" or status:match("^%d+$") then status = status .. " " .. common.status_codes[tonumber(status)] end res.statusline = "HTTP/1.1 " .. (status or "500 Internal Server Error") end local function send_headers(headers) for h, v in pairs(headers) do if h == "Status" or h == "Content-Type" then res.headers[h] = v elseif type(v) == "string" then res:add_header(h, v) elseif type(v) == "table" then for _, v in ipairs(v) do res:add_header(h, tostring(v)) end else res:add_header(h, tostring(v)) end end res:send_headers() end local ok, status, headers, res_iter = common.run_app(wsapi_run, wsapi_env) if ok then set_status(status or 500) send_headers(headers or {}) common.send_content(res, res_iter, "send_data") else if wsapi_env.STATUS == 404 then res.statusline = "HTTP/1.1 404" send_headers({ ["Content-Type"] = "text/html", ["Content-Length"] = (status and #status) or 0 }) res:send_data(status) else local content = common.error_html(status) res.statusline = "HTTP/1.1 500" send_headers({ ["Content-Type"] = "text/html", ["Content-Length"] = #content}) res:send_data(content) end end end -- Makes a WSAPI handler for a single WSAPI application function _M.makeHandler (app_func, app_prefix, docroot, app_path, extra_vars) return function (req, res) return wsapihandler(req, res, app_func, app_prefix, docroot, app_path, extra_vars) end end -- Makes a generic WSAPI handler, that launches WSAPI application scripts -- See the wsapi script for the possible values of the "params" table function _M.makeGenericHandler(docroot, params, extra_vars) params = params or { isolated = true } return function (req, res) return wsapihandler(req, res, common.make_loader(params), nil, docroot, nil, extra_vars) end end return _M lua-wsapi-1.6.1/tests/000077500000000000000000000000001231271307300145625ustar00rootroot00000000000000lua-wsapi-1.6.1/tests/mock_test.lua000066400000000000000000000012421231271307300172540ustar00rootroot00000000000000 local connector = require "wsapi.mock" function hello(wsapi_env) local headers = { ["Content-type"] = "text/html" } local function hello_text() coroutine.yield("hello world!") end return 200, headers, coroutine.wrap(hello_text) end do print("Test successful request") local app = connector.make_handler(hello) local response, request = app:get("/", {hello = "world"}) assert(response.code == 200) assert(request.request_method == "GET") assert(request.query_string == "hello=world") assert(response.headers["Content-type"] == "text/html") assert(response.body == "hello world!") end lua-wsapi-1.6.1/tests/test_request.lua000066400000000000000000000141201231271307300200120ustar00rootroot00000000000000 local request = require "wsapi.request" local function make_env_get(qs) return { REQUEST_METHOD = "GET", QUERY_STRING = qs or "", CONTENT_LENGTH = 0, PATH_INFO = "/", SCRIPT_NAME = "", CONTENT_TYPE = "x-www-form-urlencoded", input = { read = function () return nil end } } end local function make_env_post(pd, type, qs) pd = pd or "" return { REQUEST_METHOD = "POST", QUERY_STRING = qs or "", CONTENT_LENGTH = #pd, PATH_INFO = "/", CONTENT_TYPE = type or "x-www-form-urlencoded", SCRIPT_NAME = "", input = { post_data = pd, current = 1, read = function (self, len) if self.current > #self.post_data then return nil end local s = self.post_data:sub(self.current, len) self.current = self.current + len return s end } } end local function encode_multipart(boundary, fields) local parts = { "--" .. boundary } for _, t in ipairs(fields) do parts[#parts+1] = '\r\nContent-Disposition: form-data; name="' .. t[1] .. '"\r\n\r\n' .. t[2] .. '\r\n--' .. boundary end return table.concat(parts) end local function is_empty_table(t) for k, v in pairs(t) do return false, k, v end return true end print("Test empty GET") local env = make_env_get() local req = request.new(env) assert(req.path_info == env.PATH_INFO) assert(req.method == env.REQUEST_METHOD) assert(req.script_name == env.SCRIPT_NAME) assert(req.query_string == env.QUERY_STRING) assert(is_empty_table(req.GET)) assert(is_empty_table(req.POST)) print("Test one-parameter GET") local env = make_env_get("foo=bar") local req = request.new(env) assert(req.GET["foo"] == "bar") assert(req.params["foo"] == "bar") assert(is_empty_table(req.POST)) print("Test one-parameter POST") local env = make_env_post("foo=bar") local req = request.new(env) assert(is_empty_table(req.GET)) assert(req.POST["foo"] == "bar") assert(req.params["foo"] == "bar") print("Test empty POST that is not form-encoded") local env = make_env_post(nil, "application/json") local req = request.new(env) assert(is_empty_table(req.GET)) assert(req.POST["post_data"] == "") assert(req.params["post_data"] == "") print("Test POST with content that is not form-encoded") local env = make_env_post("{ foo: bar }", "application/json") local req = request.new(env) assert(is_empty_table(req.GET)) assert(req.POST["post_data"] == "{ foo: bar }") assert(req.params["post_data"] == "{ foo: bar }") print("Test two-parameter GET") local env = make_env_get("foo=bar&baz=boo") local req = request.new(env) assert(req.GET["foo"] == "bar") assert(req.GET["baz"] == "boo") assert(req.params["foo"] == "bar") assert(req.params["baz"] == "boo") assert(is_empty_table(req.POST)) print("Test two-parameter POST") local env = make_env_post("foo=bar&baz=boo") local req = request.new(env) assert(is_empty_table(req.GET)) assert(req.POST["foo"] == "bar") assert(req.POST["baz"] == "boo") assert(req.params["foo"] == "bar") assert(req.params["baz"] == "boo") assert(not req:parse_post()) print("Test POST with GET") local env = make_env_post("baz=boo", nil, "foo=bar") local req = request.new(env) assert(req.GET["foo"] == "bar") assert(req.POST["baz"] == "boo") assert(req.params["foo"] == "bar") assert(req.params["baz"] == "boo") print("Test one-parameter POST") local env = make_env_post("foo=bar") local req = request.new(env) assert(is_empty_table(req.GET)) assert(req.POST["foo"] == "bar") assert(req.params["foo"] == "bar") print("Test multipart/form-data") local boundary = "hello" local env = make_env_post(encode_multipart(boundary, { { "foo", "bar\nbar" }, { "baz", "boo" } }), "multipart/form-data; boundary=" .. boundary) local req = request.new(env) assert(is_empty_table(req.GET)) assert(req.POST["foo"] == "bar\nbar") assert(req.POST["baz"] == "boo") assert(req.params["foo"] == "bar\nbar") assert(req.params["baz"] == "boo") print("Test POST with repeat parameters") local env = make_env_post("foo=bar&foo=boo") local req = request.new(env) assert(is_empty_table(req.GET)) assert(#req.POST["foo"] == 2) assert(req.POST["foo"][1] == "bar") assert(req.POST["foo"][2] == "boo") print("Test GET with repeat parameters") local env = make_env_get("foo=bar&foo=boo") local req = request.new(env) assert(is_empty_table(req.POST)) assert(#req.GET["foo"] == 2) assert(req.GET["foo"][1] == "bar") assert(req.GET["foo"][2] == "boo") print("Test POST with repeat parameters and overwrite enabled") local env = make_env_post("foo=bar&foo=boo") local req = request.new(env, { overwrite = true }) assert(is_empty_table(req.GET)) assert(req.POST["foo"] == "boo") print("Test GET with repeat parameters and overwrite enabled") local env = make_env_get("foo=bar&foo=boo") local req = request.new(env, { overwrite = true }) assert(is_empty_table(req.POST)) assert(req.GET["foo"] == "boo") print("Test multipart/form-data with repeat parameters") local boundary = "hello" local env = make_env_post(encode_multipart(boundary, { { "foo", "bar\nbar" }, { "foo", "boo" } }), "multipart/form-data; boundary=" .. boundary) local req = request.new(env) assert(is_empty_table(req.GET)) assert(#req.POST["foo"] == 2) assert(req.POST["foo"][1] == "bar\nbar") assert(req.POST["foo"][2] == "boo") print("Test multipart/form-data with repeat parameters and overwrite") local boundary = "hello" local env = make_env_post(encode_multipart(boundary, { { "foo", "bar\nbar" }, { "foo", "boo" } }), "multipart/form-data; boundary=" .. boundary) local req = request.new(env, { overwrite = true }) assert(is_empty_table(req.GET)) assert(req.POST["foo"] == "boo") print("Test delayed POST") local env = make_env_post("foo=bar&baz=boo") local req = request.new(env, { delay_post = true }) assert(is_empty_table(req.GET)) assert(is_empty_table(req.POST)) assert(req:parse_post()) assert(req.POST["foo"] == "bar") assert(req.POST["baz"] == "boo") assert(req.params["foo"] == "bar") assert(req.params["baz"] == "boo") assert(not req:parse_post()) lua-wsapi-1.6.1/wsapi-install000077500000000000000000000346511231271307300161460ustar00rootroot00000000000000#!/bin/bash # Generic AIO installation script. # Platform pushd `dirname $0` WGET="wget -c -t0" if [ "`echo ${OSTYPE%%[0-9]*}`" = "darwin" ] then WGET="curl -O --retry 10" fi SOURCE_DIR=`pwd` # Defaults PREFIX="/usr/local" TMP="/tmp" LUA_SUFFIX="" BUILD_LUA="yes" INSTALL_LUA="yes" USE_READLINE="yes" NCURSES_DIR="/usr" READLINE_DIR="/usr" LUA_DIR="/usr" LUA_INCDIR="/usr/include" LUA_LIBDIR="/usr/lib" LUA_BINDIR="/usr/bin" SKIP_PACKAGE=no SKIP_LR=no BOOTSTRAP=no UNAME="`uname`" if ! [ "$UNAME" = "Linux" -o "$UNAME" = "Darwin" -o "$UNAME" = "FreeBSD" ] then USE_READLINE=no fi # Installer parameters LUA_VERSION=5.1.4 PACKAGE=WSAPI PACKAGE_OPT=wsapi PACKAGE_ROCK=wsapi-xavante INSTALLER_VERSION=0.6 PACKAGE_VERSION=1.4 LUAROCKS_REPO=http://luarocks.org/repositories/rocks LUAROCKS_URL=http://www.luarocks.org/releases/luarocks-2.0.3.tar.gz LUAROCKS_VERSION=2.0.3 # Help show_help() { cat < Makefile # This file was automatically generated by the configure script. # Run "./configure --help" for details. BUILD_LUA=$BUILD_LUA INSTALL_LUA=$INSTALL_LUA USE_READLINE=$USE_READLINE PREFIX=$PREFIX INCLUDEDIR=$INCLUDEDIR LUA_SUFFIX=$LUA_SUFFIX READLINE_DIR=$READLINE_DIR NCURSES_DIR=$NCURSES_DIR LUA_DIR=$LUA_DIR LUA_INCDIR=$LUA_INCDIR LUA_LIBDIR=$LUA_LIBDIR LUA_BINDIR=$LUA_BINDIR LUA_URL=http://www.lua.org/ftp READLINE_LIBDIR=\$(READLINE_DIR)/lib READLINE_INCLUDEDIR=\$(READLINE_DIR)/include NCURSES_LIBDIR=\$(NCURSES_DIR)/lib NCURSES_INCLUDEDIR=\$(NCURSES_DIR)/include LUA_VERSION=$LUA_VERSION PLATFORM_CFLAGS=-Wl,-E PLATFORM_LDFLAGS=-lm -ldl LIB_FLAG=-shared ifeq (\$(shell uname -m | sed 's/i.86/i386/'),i386) FPIC= else FPIC=-fpic endif LUA_LIB=\$(LUA_LIBDIR)/liblua\$(LUA_SUFFIX).a LUA_DEFPATH=-DLUA_ROOT=\\\\\\"\$(LUA_DIR)\\\\\\" ifeq (\$(USE_READLINE), yes) LUA_READLINE_CFLAGS=-DLUA_USE_READLINE -I\$(READLINE_INCLUDEDIR) LUA_READLINE_LIBS=-lreadline -lhistory -lncurses -L\$(READLINE_LIBDIR) -L\$(NCURSES_LIBDIR) else LUA_READLINE_CFLAGS= LUA_READLINE_LIBS= endif LUA_MYCFLAGS=-DLUA_USE_POSIX -DLUA_USE_DLOPEN \$(LUA_READLINE_CFLAGS) LUA_MYLIBS=\$(PLATFORM_CFLAGS) -ldl \$(LUA_READLINE_LIBS) WGET=wget -c -t0 PLATFORM_BUILD=build ifeq (\$(shell bash -c 'echo ${OSTYPE%%[0-9]*}'),darwin) WGET=curl -O --retry 10 PLATFORM_BUILD=OSX-build ifneq (\$(LUA_READLINE_LIBS),) LUA_READLINE_LIBS=-lreadline -L\$(READLINE_LIBDIR) endif endif ifeq (\$(shell uname -s),FreeBSD) PLATFORM_BUILD=FreeBSD-build endif platform: \$(PLATFORM_BUILD) OSX-build: MACOSX_DEPLOYMENT_TARGET=10.3 \$(MAKE) \\ LUA_MYCFLAGS="-DLUA_USE_MACOSX \$(LUA_READLINE_CFLAGS)" \\ LUA_MYLIBS="\$(LUA_READLINE_LIBS)" \\ PLATFORM_CFLAGS="-dynamic" \\ PLATFORM_LDFLAGS="-lm -ldl" \\ LIB_FLAG="-bundle -undefined dynamic_lookup -all_load" \\ build FreeBSD-build: \$(MAKE) \\ LUA_MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" \\ LUA_MYLIBS="-Wl,-E" \\ PLATFORM_LDFLAGS="-lm" \\ build LUA_TESTFILE=lua-\$(LUA_VERSION)/src/lua\$(LUA_SUFFIX) fetch: lua-\$(LUA_VERSION) lua-\$(LUA_VERSION).tar.gz: \$(WGET) \$(LUA_URL)/\$@ lua-\$(LUA_VERSION): \$(MAKE) lua-\$(LUA_VERSION).tar.gz test -d \$@ || tar zxvpf lua-\$(LUA_VERSION).tar.gz cd lua-\$(LUA_VERSION) && patch -p1 < ../lua-\$(LUA_VERSION)-easylua.diff build: \$(LUA_TESTFILE) \$(LUA_TESTFILE): lua-\$(LUA_VERSION) cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ INSTALL_INC="\$(LUA_INCDIR)" \\ MYCFLAGS="\$(LUA_DEFPATH) \$(LUA_MYCFLAGS)" \\ MYLIBS="\$(LUA_MYLIBS)" \\ CC="\$(CC)" \\ generic install: build cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ INSTALL_INC="\$(LUA_INCDIR)" \\ INSTALL_TOP="\$(LUA_DIR)" \\ MYCFLAGS="\$(LUA_MYCFLAGS)" \\ MYLIBS="\$(LUA_MYLIBS)" \\ INSTALL_EXEC="install -p -m 0755" \\ INSTALL_DATA="install -p -m 0644" \\ STRIP="true" \\ install clean: if [ -d lua-\$(LUA_VERSION) ]; then \\ cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ clean; \\ fi klean: rm -f lua-\$(LUA_VERSION).tar.gz rm -rf lua-\$(LUA_VERSION) rm -f Makefile rm -f lua-\$(LUA_VERSION)-easylua.diff EOF cat < lua-5.1.4-easylua.diff diff -Naur lua-5.1.4-orig/Makefile lua-5.1.4/Makefile --- lua-5.1.4-orig/Makefile 2007-03-25 11:44:39.000000000 -0300 +++ lua-5.1.4/Makefile 2007-05-11 16:08:02.000000000 -0300 @@ -41,10 +41,10 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris # What to install. -TO_BIN= lua luac +TO_BIN= lua\$(LUA_SUFFIX) luac\$(LUA_SUFFIX) TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp -TO_LIB= liblua.a -TO_MAN= lua.1 luac.1 +TO_LIB= liblua\$(LUA_SUFFIX).a +TO_MAN= lua\$(LUA_SUFFIX).1 luac\$(LUA_SUFFIX).1 # Lua version and release. V= 5.1 @@ -56,11 +56,15 @@ cd src && \$(MAKE) \$@ test: dummy - src/lua test/hello.lua + src/lua\$(LUA_SUFFIX) test/hello.lua install: dummy - cd src && \$(MKDIR) \$(INSTALL_BIN) \$(INSTALL_INC) \$(INSTALL_LIB) \$(INSTALL_MAN) \$(INSTALL_LMOD) \$(INSTALL_CMOD) + cd src && \$(MKDIR) -p \$(INSTALL_BIN) \$(INSTALL_INC) \$(INSTALL_LIB) \$(INSTALL_MAN) \$(INSTALL_LMOD) \$(INSTALL_CMOD) cd src && \$(INSTALL_EXEC) \$(TO_BIN) \$(INSTALL_BIN) cd src && \$(INSTALL_DATA) \$(TO_INC) \$(INSTALL_INC) cd src && \$(INSTALL_DATA) \$(TO_LIB) \$(INSTALL_LIB) + cp doc/lua.1 doc/t_lua.1 + cp doc/luac.1 doc/t_luac.1 + mv doc/t_lua.1 doc/lua\$(LUA_SUFFIX).1 + mv doc/t_luac.1 doc/luac\$(LUA_SUFFIX).1 cd doc && \$(INSTALL_DATA) \$(TO_MAN) \$(INSTALL_MAN) diff -Naur lua-5.1.4-orig/src/luaconf.h lua-5.1.4/src/luaconf.h --- lua-5.1.4-orig/src/luaconf.h 2007-03-24 00:01:55.000000000 -0300 +++ lua-5.1.4/src/luaconf.h 2007-05-11 16:12:55.000000000 -0300 @@ -94,9 +94,11 @@ ".\\\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" #else -#define LUA_ROOT "/usr/local/" -#define LUA_LDIR LUA_ROOT "share/lua/5.1/" -#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#ifndef LUA_ROOT +#define LUA_ROOT "/usr/local" +#endif +#define LUA_LDIR LUA_ROOT "/share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "/lib/lua/5.1/" #define LUA_PATH_DEFAULT \\ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \\ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" diff -Naur lua-5.1.4-orig/src/Makefile lua-5.1.4/src/Makefile --- lua-5.1.4-orig/src/Makefile 2007-03-25 11:49:23.000000000 -0300 +++ lua-5.1.4/src/Makefile 2007-05-11 16:08:02.000000000 -0300 @@ -22,17 +22,17 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris -LUA_A= liblua.a +LUA_A= liblua\$(LUA_SUFFIX).a CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \\ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \\ lundump.o lvm.o lzio.o LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \\ lstrlib.o loadlib.o linit.o -LUA_T= lua +LUA_T= lua\$(LUA_SUFFIX) LUA_O= lua.o -LUAC_T= luac +LUAC_T= luac\$(LUA_SUFFIX) LUAC_O= luac.o print.o ALL_O= \$(CORE_O) \$(LIB_O) \$(LUA_O) \$(LUAC_O) @@ -93,7 +93,7 @@ \$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" generic: - \$(MAKE) all MYCFLAGS= + \$(MAKE) all linux: \$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" EOF echo echo echo "=========================================================" echo "Installing Lua $LUA_VERSION on $PREFIX" echo "=========================================================" echo echo if [ "`uname -s`" = "FreeBSD" ] then MAKE=gmake else MAKE=make fi cleanup() { echo echo "Cleaning up..." echo if [ -d /tmp/$PACKAGE_OPT-$PACKAGE_VERSION ]; then popd && rm -rf /tmp/$PACKAGE_OPT-$PACKAGE_VERSION fi } $MAKE clean > /dev/null 2> /dev/null $MAKE || (echo "Failed compiling Lua. Exiting..."; cleanup; exit 1) $MAKE install || (echo "Failed installing Lua. Exiting..."; cleanup; exit 1) echo echo "Done. Lua is installed on $PREFIX." echo if ! [ $SKIP_LR = "yes" ] then echo echo echo "=========================================================" echo "Now installing LuaRocks $LUAROCKS_VERSION in $PREFIX." echo "=========================================================" echo echo if [ $LUAROCKS_URL != "" ] then if [ ! -f luarocks-$LUAROCKS_VERSION.tar.gz ]; then $WGET $LUAROCKS_URL fi tar zxvf luarocks-$LUAROCKS_VERSION.tar.gz cd luarocks-$LUAROCKS_VERSION else cvs -d:pserver:anonymous@cvs.luaforge.net:/cvsroot/luarocks export -r HEAD luarocks cd luarocks fi sh configure --prefix=$PREFIX --with-lua=$PREFIX \ --with-lua-include=$LUA_INCDIR && make && make install || (echo "Failed installing LuaRocks. Exiting..."; cleanup; exit 1) cd .. fi if ! [ $SKIP_PACKAGE = "yes" ] then echo echo echo "=========================================================" echo "Now installing $PACKAGE in $PREFIX." echo "=========================================================" echo if [ -d rocks ]; then $PREFIX/bin/luarocks install $PACKAGE_ROCK --only-from=`pwd`/rocks $PACKAGE_VERSION else $PREFIX/bin/luarocks install --from=$LUAROCKS_REPO $PACKAGE_ROCK $PACKAGE_VERSION fi fi if [ $BOOTSTRAP = "yes" ] then cat < /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/pack_tree.lua #!/usr/bin/env lua require "luarocks.require" require "lfs" local prefix, tree, target = ... rockspecs = io.popen('find "' .. tree .. '" -name "*.rockspec"') if lfs.attributes(target, "mode") ~= "d" then lfs.mkdir(target) end lfs.chdir(target) for rockspec in rockspecs:lines() do os.execute('"' .. prefix .. '/bin/luarocks" pack "' .. rockspec .. '"') end os.execute('"' .. prefix .. '/bin/luarocks-admin" make_manifest "' .. target .. '"') EOF cp /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/lua-$LUA_VERSION.tar.gz "$SOURCE_DIR/" cp /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/luarocks-$LUAROCKS_VERSION.tar.gz "$SOURCE_DIR/" "$PREFIX/bin/lua" /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/pack_tree.lua "$PREFIX" "$PREFIX/lib/luarocks/rocks" "$SOURCE_DIR/rocks" fi cleanup lua-wsapi-1.6.1/wsapi-install-1.6000077500000000000000000000346341231271307300164510ustar00rootroot00000000000000#!/bin/bash # Generic AIO installation script. # Platform pushd `dirname $0` WGET="wget -c -t0" if [ "`echo ${OSTYPE%%[0-9]*}`" = "darwin" ] then WGET="curl -O --retry 10" fi SOURCE_DIR=`pwd` # Defaults PREFIX="/usr/local" TMP="/tmp" LUA_SUFFIX="" BUILD_LUA="yes" INSTALL_LUA="yes" USE_READLINE="yes" NCURSES_DIR="/usr" READLINE_DIR="/usr" LUA_DIR="/usr" LUA_INCDIR="/usr/include" LUA_LIBDIR="/usr/lib" LUA_BINDIR="/usr/bin" SKIP_PACKAGE=no SKIP_LR=no BOOTSTRAP=no UNAME="`uname`" if ! [ "$UNAME" = "Linux" -o "$UNAME" = "Darwin" -o "$UNAME" = "FreeBSD" ] then USE_READLINE=no fi # Installer parameters LUA_VERSION=5.2.1 PACKAGE=WSAPI PACKAGE_OPT=wsapi PACKAGE_ROCK=wsapi-xavante INSTALLER_VERSION=0.7 PACKAGE_VERSION=1.6 LUAROCKS_REPO=http://luarocks.org/repositories/rocks LUAROCKS_URL=http://www.luarocks.org/releases/luarocks-2.0.12.tar.gz LUAROCKS_VERSION=2.0.12 # Help show_help() { cat < Makefile # This file was automatically generated by the configure script. # Run "./configure --help" for details. BUILD_LUA=$BUILD_LUA INSTALL_LUA=$INSTALL_LUA USE_READLINE=$USE_READLINE PREFIX=$PREFIX INCLUDEDIR=$INCLUDEDIR LUA_SUFFIX=$LUA_SUFFIX READLINE_DIR=$READLINE_DIR NCURSES_DIR=$NCURSES_DIR LUA_DIR=$LUA_DIR LUA_INCDIR=$LUA_INCDIR LUA_LIBDIR=$LUA_LIBDIR LUA_BINDIR=$LUA_BINDIR LUA_URL=http://www.lua.org/ftp READLINE_LIBDIR=\$(READLINE_DIR)/lib READLINE_INCLUDEDIR=\$(READLINE_DIR)/include NCURSES_LIBDIR=\$(NCURSES_DIR)/lib NCURSES_INCLUDEDIR=\$(NCURSES_DIR)/include LUA_VERSION=$LUA_VERSION PLATFORM_CFLAGS=-Wl,-E PLATFORM_LDFLAGS=-lm -ldl LIB_FLAG=-shared ifeq (\$(shell uname -m | sed 's/i.86/i386/'),i386) FPIC= else FPIC=-fpic endif LUA_LIB=\$(LUA_LIBDIR)/liblua\$(LUA_SUFFIX).a LUA_DEFPATH=-DLUA_ROOT=\\\\\\"\$(LUA_DIR)\\\\\\" ifeq (\$(USE_READLINE), yes) LUA_READLINE_CFLAGS=-DLUA_USE_READLINE -I\$(READLINE_INCLUDEDIR) LUA_READLINE_LIBS=-lreadline -lhistory -lncurses -L\$(READLINE_LIBDIR) -L\$(NCURSES_LIBDIR) else LUA_READLINE_CFLAGS= LUA_READLINE_LIBS= endif LUA_MYCFLAGS=-DLUA_USE_POSIX -DLUA_USE_DLOPEN \$(LUA_READLINE_CFLAGS) LUA_MYLIBS=\$(PLATFORM_CFLAGS) -ldl \$(LUA_READLINE_LIBS) WGET=wget -c -t0 PLATFORM_BUILD=build ifeq (\$(shell bash -c 'echo ${OSTYPE%%[0-9]*}'),darwin) WGET=curl -O --retry 10 PLATFORM_BUILD=OSX-build ifneq (\$(LUA_READLINE_LIBS),) LUA_READLINE_LIBS=-lreadline -L\$(READLINE_LIBDIR) endif endif ifeq (\$(shell uname -s),FreeBSD) PLATFORM_BUILD=FreeBSD-build endif platform: \$(PLATFORM_BUILD) OSX-build: MACOSX_DEPLOYMENT_TARGET=10.3 \$(MAKE) \\ LUA_MYCFLAGS="-DLUA_USE_MACOSX \$(LUA_READLINE_CFLAGS)" \\ LUA_MYLIBS="\$(LUA_READLINE_LIBS)" \\ PLATFORM_CFLAGS="-dynamic" \\ PLATFORM_LDFLAGS="-lm -ldl" \\ LIB_FLAG="-bundle -undefined dynamic_lookup -all_load" \\ build FreeBSD-build: \$(MAKE) \\ LUA_MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" \\ LUA_MYLIBS="-Wl,-E" \\ PLATFORM_LDFLAGS="-lm" \\ build LUA_TESTFILE=lua-\$(LUA_VERSION)/src/lua\$(LUA_SUFFIX) fetch: lua-\$(LUA_VERSION) lua-\$(LUA_VERSION).tar.gz: \$(WGET) \$(LUA_URL)/\$@ lua-\$(LUA_VERSION): \$(MAKE) lua-\$(LUA_VERSION).tar.gz test -d \$@ || tar zxvpf lua-\$(LUA_VERSION).tar.gz cd lua-\$(LUA_VERSION) && patch -p1 < ../lua-\$(LUA_VERSION)-easylua.diff build: \$(LUA_TESTFILE) \$(LUA_TESTFILE): lua-\$(LUA_VERSION) cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ INSTALL_INC="\$(LUA_INCDIR)" \\ MYCFLAGS="\$(LUA_DEFPATH) \$(LUA_MYCFLAGS)" \\ MYLIBS="\$(LUA_MYLIBS)" \\ CC="\$(CC)" \\ generic install: build cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ INSTALL_INC="\$(LUA_INCDIR)" \\ INSTALL_TOP="\$(LUA_DIR)" \\ MYCFLAGS="\$(LUA_MYCFLAGS)" \\ MYLIBS="\$(LUA_MYLIBS)" \\ INSTALL_EXEC="install -p -m 0755" \\ INSTALL_DATA="install -p -m 0644" \\ STRIP="true" \\ install clean: if [ -d lua-\$(LUA_VERSION) ]; then \\ cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ clean; \\ fi klean: rm -f lua-\$(LUA_VERSION).tar.gz rm -rf lua-\$(LUA_VERSION) rm -f Makefile rm -f lua-\$(LUA_VERSION)-easylua.diff EOF cat < lua-5.1.4-easylua.diff diff -Naur lua-5.1.4-orig/Makefile lua-5.1.4/Makefile --- lua-5.1.4-orig/Makefile 2007-03-25 11:44:39.000000000 -0300 +++ lua-5.1.4/Makefile 2007-05-11 16:08:02.000000000 -0300 @@ -41,10 +41,10 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris # What to install. -TO_BIN= lua luac +TO_BIN= lua\$(LUA_SUFFIX) luac\$(LUA_SUFFIX) TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp -TO_LIB= liblua.a -TO_MAN= lua.1 luac.1 +TO_LIB= liblua\$(LUA_SUFFIX).a +TO_MAN= lua\$(LUA_SUFFIX).1 luac\$(LUA_SUFFIX).1 # Lua version and release. V= 5.1 @@ -56,11 +56,15 @@ cd src && \$(MAKE) \$@ test: dummy - src/lua test/hello.lua + src/lua\$(LUA_SUFFIX) test/hello.lua install: dummy - cd src && \$(MKDIR) \$(INSTALL_BIN) \$(INSTALL_INC) \$(INSTALL_LIB) \$(INSTALL_MAN) \$(INSTALL_LMOD) \$(INSTALL_CMOD) + cd src && \$(MKDIR) -p \$(INSTALL_BIN) \$(INSTALL_INC) \$(INSTALL_LIB) \$(INSTALL_MAN) \$(INSTALL_LMOD) \$(INSTALL_CMOD) cd src && \$(INSTALL_EXEC) \$(TO_BIN) \$(INSTALL_BIN) cd src && \$(INSTALL_DATA) \$(TO_INC) \$(INSTALL_INC) cd src && \$(INSTALL_DATA) \$(TO_LIB) \$(INSTALL_LIB) + cp doc/lua.1 doc/t_lua.1 + cp doc/luac.1 doc/t_luac.1 + mv doc/t_lua.1 doc/lua\$(LUA_SUFFIX).1 + mv doc/t_luac.1 doc/luac\$(LUA_SUFFIX).1 cd doc && \$(INSTALL_DATA) \$(TO_MAN) \$(INSTALL_MAN) diff -Naur lua-5.1.4-orig/src/luaconf.h lua-5.1.4/src/luaconf.h --- lua-5.1.4-orig/src/luaconf.h 2007-03-24 00:01:55.000000000 -0300 +++ lua-5.1.4/src/luaconf.h 2007-05-11 16:12:55.000000000 -0300 @@ -94,9 +94,11 @@ ".\\\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" #else -#define LUA_ROOT "/usr/local/" -#define LUA_LDIR LUA_ROOT "share/lua/5.1/" -#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#ifndef LUA_ROOT +#define LUA_ROOT "/usr/local" +#endif +#define LUA_LDIR LUA_ROOT "/share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "/lib/lua/5.1/" #define LUA_PATH_DEFAULT \\ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \\ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" diff -Naur lua-5.1.4-orig/src/Makefile lua-5.1.4/src/Makefile --- lua-5.1.4-orig/src/Makefile 2007-03-25 11:49:23.000000000 -0300 +++ lua-5.1.4/src/Makefile 2007-05-11 16:08:02.000000000 -0300 @@ -22,17 +22,17 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris -LUA_A= liblua.a +LUA_A= liblua\$(LUA_SUFFIX).a CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \\ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \\ lundump.o lvm.o lzio.o LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \\ lstrlib.o loadlib.o linit.o -LUA_T= lua +LUA_T= lua\$(LUA_SUFFIX) LUA_O= lua.o -LUAC_T= luac +LUAC_T= luac\$(LUA_SUFFIX) LUAC_O= luac.o print.o ALL_O= \$(CORE_O) \$(LIB_O) \$(LUA_O) \$(LUAC_O) @@ -93,7 +93,7 @@ \$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" generic: - \$(MAKE) all MYCFLAGS= + \$(MAKE) all linux: \$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" EOF echo echo echo "=========================================================" echo "Installing Lua $LUA_VERSION on $PREFIX" echo "=========================================================" echo echo if [ "`uname -s`" = "FreeBSD" ] then MAKE=gmake else MAKE=make fi cleanup() { echo echo "Cleaning up..." echo if [ -d /tmp/$PACKAGE_OPT-$PACKAGE_VERSION ]; then popd && rm -rf /tmp/$PACKAGE_OPT-$PACKAGE_VERSION fi } $MAKE clean > /dev/null 2> /dev/null $MAKE || (echo "Failed compiling Lua. Exiting..."; cleanup; exit 1) $MAKE install || (echo "Failed installing Lua. Exiting..."; cleanup; exit 1) echo echo "Done. Lua is installed on $PREFIX." echo if ! [ $SKIP_LR = "yes" ] then echo echo echo "=========================================================" echo "Now installing LuaRocks $LUAROCKS_VERSION in $PREFIX." echo "=========================================================" echo echo if [ $LUAROCKS_URL != "" ] then if [ ! -f luarocks-$LUAROCKS_VERSION.tar.gz ]; then $WGET $LUAROCKS_URL fi tar zxvf luarocks-$LUAROCKS_VERSION.tar.gz cd luarocks-$LUAROCKS_VERSION else cvs -d:pserver:anonymous@cvs.luaforge.net:/cvsroot/luarocks export -r HEAD luarocks cd luarocks fi sh configure --prefix=$PREFIX --with-lua=$PREFIX \ --with-lua-include=$LUA_INCDIR && make && make install || (echo "Failed installing LuaRocks. Exiting..."; cleanup; exit 1) cd .. fi if ! [ $SKIP_PACKAGE = "yes" ] then echo echo echo "=========================================================" echo "Now installing $PACKAGE in $PREFIX." echo "=========================================================" echo if [ -d rocks ]; then $PREFIX/bin/luarocks install $PACKAGE_ROCK --only-from=`pwd`/rocks $PACKAGE_VERSION else $PREFIX/bin/luarocks install --from=$LUAROCKS_REPO $PACKAGE_ROCK $PACKAGE_VERSION fi fi if [ $BOOTSTRAP = "yes" ] then cat < /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/pack_tree.lua #!/usr/bin/env lua local lfs = require "lfs" local prefix, tree, target = ... rockspecs = io.popen('find "' .. tree .. '" -name "*.rockspec"') if lfs.attributes(target, "mode") ~= "d" then lfs.mkdir(target) end lfs.chdir(target) for rockspec in rockspecs:lines() do os.execute('"' .. prefix .. '/bin/luarocks" pack "' .. rockspec .. '"') end os.execute('"' .. prefix .. '/bin/luarocks-admin" make_manifest "' .. target .. '"') EOF cp /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/lua-$LUA_VERSION.tar.gz "$SOURCE_DIR/" cp /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/luarocks-$LUAROCKS_VERSION.tar.gz "$SOURCE_DIR/" "$PREFIX/bin/lua" /tmp/$PACKAGE_OPT-$PACKAGE_VERSION/pack_tree.lua "$PREFIX" "$PREFIX/lib/luarocks/rocks" "$SOURCE_DIR/rocks" fi cleanup