mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 14:28:21 +01:00
Decent makefiles!
This commit is contained in:
parent
d1a72435d5
commit
bce60be30f
26
NEW
26
NEW
@ -2,13 +2,19 @@ What's New
|
|||||||
|
|
||||||
This is just a bug-fix/update release.
|
This is just a bug-fix/update release.
|
||||||
|
|
||||||
* Improved: http.request() now supports deprecated HTTP/0.9
|
* Fixed: manual links to home.html changed to index.html (Robert Hahn)
|
||||||
servers (Florian Berger)
|
* Fixed: mime.unb64() returns empty string on results that start
|
||||||
* Fixed: could return "timedout" instead of "timeout" (Leo Leo)
|
with a null character (Robert Raschke)
|
||||||
* Fixed: crash when reading '*a' on closed socket (Paul Ducklin);
|
* Fixed: HTTP now automatically redirecting on 303 and 307 (Jonathan Gray)
|
||||||
* Fixed: return values are consistent when reading from closed sockets;
|
* Fixed: sleep(-1) could sleep forever wasting CPU. Now it
|
||||||
* Fixed: case sensitivity in headers of multipart messages in
|
returns immediately (MPB);
|
||||||
smtp.message() (Graham Henstridge);
|
|
||||||
* Fixed a couple instances of error() being called instead of base.error(). These would cause an error when an error was reported. :) (Ketmar Dark);
|
* Improved: FTP commands are now sent in upper case to
|
||||||
* Fixed: test script now uses pairs() iterator instead of the old
|
help buggy servers (Anders Eurenius)
|
||||||
Lua syntax (Robert Dodier).
|
* Improved: known headers now sent in canonic
|
||||||
|
capitalization to help buggy servers (Joseph Stewart);
|
||||||
|
* Improved: Clarified tcp:receive() in the manual (MPB);
|
||||||
|
|
||||||
|
* Fixed: multicast didn't work on Windows (Herbert Leuwer, Adrian Sietsma)
|
||||||
|
* Fixed: select() reports an error when called with more
|
||||||
|
sockets than FD_SETSIZE (Lorenzo Leonini)
|
||||||
|
60
config
60
config
@ -1,60 +0,0 @@
|
|||||||
#------
|
|
||||||
# LuaSocket makefile configuration
|
|
||||||
#
|
|
||||||
|
|
||||||
#------
|
|
||||||
# Output file names
|
|
||||||
#
|
|
||||||
EXT=so
|
|
||||||
SOCKET_V=2.0.2
|
|
||||||
MIME_V=1.0.2
|
|
||||||
SOCKET_SO=socket.$(EXT).$(SOCKET_V)
|
|
||||||
MIME_SO=mime.$(EXT).$(MIME_V)
|
|
||||||
UNIX_SO=unix.$(EXT)
|
|
||||||
|
|
||||||
#------
|
|
||||||
# Lua includes and libraries
|
|
||||||
#
|
|
||||||
#LUAINC=-I/usr/local/include/lua50
|
|
||||||
#LUAINC=-I/usr/local/include/lua5.1
|
|
||||||
#LUAINC=-Ilua-5.1.1/src
|
|
||||||
|
|
||||||
#------
|
|
||||||
# Compat-5.1 directory
|
|
||||||
#
|
|
||||||
#COMPAT=compat-5.1r5
|
|
||||||
|
|
||||||
#------
|
|
||||||
# Top of your Lua installation
|
|
||||||
# Relative paths will be inside the src tree
|
|
||||||
#
|
|
||||||
#INSTALL_TOP_SHARE=/usr/local/share/lua/5.0
|
|
||||||
#INSTALL_TOP_LIB=/usr/local/lib/lua/5.0
|
|
||||||
INSTALL_TOP_SHARE=/usr/local/share/lua/5.1
|
|
||||||
INSTALL_TOP_LIB=/usr/local/lib/lua/5.1
|
|
||||||
|
|
||||||
INSTALL_DATA=cp
|
|
||||||
INSTALL_EXEC=cp
|
|
||||||
|
|
||||||
#------
|
|
||||||
# Compiler and linker settings
|
|
||||||
# for Mac OS X
|
|
||||||
#
|
|
||||||
#CC=gcc
|
|
||||||
#DEF= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN
|
|
||||||
#CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common
|
|
||||||
#LDFLAGS=-bundle -undefined dynamic_lookup
|
|
||||||
#LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
|
|
||||||
|
|
||||||
#------
|
|
||||||
# Compiler and linker settings
|
|
||||||
# for Linux
|
|
||||||
CC=gcc
|
|
||||||
DEF=-DLUASOCKET_DEBUG
|
|
||||||
CFLAGS= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic
|
|
||||||
LDFLAGS=-O -shared -fpic
|
|
||||||
LD=gcc
|
|
||||||
|
|
||||||
#------
|
|
||||||
# End of makefile configuration
|
|
||||||
#
|
|
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -113,8 +113,8 @@ message.
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -270,8 +270,8 @@ f, e = ftp.put{
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -314,8 +314,8 @@ r, c = http.request {
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -87,7 +87,7 @@ Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a>
|
|||||||
<h2 id=download>Download</h2>
|
<h2 id=download>Download</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
LuaSocket version 2.0.2 is now available for download! It is
|
LuaSocket version 2.0.3 is now available for download! It is
|
||||||
compatible with Lua 5.1, and has
|
compatible with Lua 5.1, and has
|
||||||
been tested on Windows XP, Linux, and Mac OS X. Chances
|
been tested on Windows XP, Linux, and Mac OS X. Chances
|
||||||
are it works well on most UNIX distributions and Windows flavors.
|
are it works well on most UNIX distributions and Windows flavors.
|
||||||
@ -118,14 +118,15 @@ manual to find out how to properly install the library.
|
|||||||
<h2 id=thanks>Special thanks</h2>
|
<h2 id=thanks>Special thanks</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Throughout LuaSocket's history, many people gave suggestions that helped
|
Throughout LuaSocket's history, many people gave suggestions
|
||||||
improve it. For that, I thank the Lua community.
|
that helped improve it. For that, I thank the Lua community.
|
||||||
Special thanks go to
|
Special thanks go to David Burgess, who has helped push the
|
||||||
David Burgess, who has helped push the library to a new level of quality and
|
library to a new level of quality and from whom I have
|
||||||
from whom I have learned a lot of stuff that doesn't show up in RFCs.
|
learned a lot of stuff that doesn't show up in RFCs.
|
||||||
Special thanks also to Carlos Cassino, who played a big part in the
|
Special thanks also to Carlos Cassino, who played a big part
|
||||||
extensible design seen in the C core of LuaSocket 2.0. Mike Pall
|
in the extensible design seen in the C core of LuaSocket
|
||||||
has been helping a lot too! Thanks to you all!
|
2.0. Mike Pall has been helping a lot too! Thanks to you
|
||||||
|
all!
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
@ -133,44 +134,26 @@ has been helping a lot too! Thanks to you all!
|
|||||||
<h2 id=new>What's New</h2>
|
<h2 id=new>What's New</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
2.0.2 is just a bug-fix/update release.
|
2.0.3 is just a bug-fix/update release.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li> Improved: http.request() now supports deprecated
|
<li> Fixed: multicast didn't work on Windows, or anywhere
|
||||||
HTTP/0.9 servers (Florian Berger);
|
else for that matter (Herbert Leuwer, Adrian Sietsma)
|
||||||
<li> Fixed: could return "timedout" instead of "timeout" (Leo Leo);
|
<li> Fixed: select() now reports an error when called with more
|
||||||
<li> Fixed: crash when reading '*a' on closed socket (Paul Ducklin);
|
sockets than FD_SETSIZE (Lorenzo Leonini)
|
||||||
<li> Fixed: return values are consistent when reading from closed sockets;
|
<li> Fixed: manual links to home.html changed to index.html (Robert Hahn)
|
||||||
<li> Fixed: case sensitivity in headers of multipart
|
<li> Fixed: mime.unb64() would return an empty string on results that started
|
||||||
messages in smtp.message() (Graham Henstridge);
|
with a null character (Robert Raschke)
|
||||||
<li> Fixed a couple instances of error() being called instead of
|
<li> Fixed: HTTP now automatically redirects on 303 and 307 (Jonathan Gray)
|
||||||
base.error(). These would cause an error when an error was
|
<li> Fixed: calling sleep() with negative numbers could
|
||||||
reported :) (Ketmar Dark);
|
block forever, wasting CPU. Now it returns immediately (MPB);
|
||||||
<li> Fixed: test script now uses pairs() iterator instead
|
<li> Improved: FTP commands are now sent in upper case to
|
||||||
of the old Lua syntax (Robert Dodier).
|
help buggy servers (Anders Eurenius)
|
||||||
</ul>
|
<li> Improved: known headers now sent in canonic
|
||||||
|
capitalization to help buggy servers (Joseph Stewart);
|
||||||
<p>
|
<li> Improved: Clarified tcp:receive() in the manual (MPB);
|
||||||
2.0.1 is just a bug-fix/update release.
|
<li> Improved: Decent makefiles (LHF).
|
||||||
</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li> Updated: now using <tt>compat-5.1r5</tt>;
|
|
||||||
<li> Improved: <tt>http.request</tt> is more robust to
|
|
||||||
malformed URLs (Adrian Sietsma);
|
|
||||||
<li> Improved: the simple <tt>http.request</tt> interface sends a
|
|
||||||
"<tt>Content-type: application/x-www-form-urlencoded</tt>"
|
|
||||||
header (William Trenker);
|
|
||||||
<li> Improved: <tt>http.request</tt> is robust to evil
|
|
||||||
servers that send inappropriate 100-continue messages
|
|
||||||
(David Burgess);
|
|
||||||
<li> Fixed: <tt>http.request</tt> was using the old host header during
|
|
||||||
redirects (Florian Berger);
|
|
||||||
<li> Fixed: sample <tt>unix.c</tt> had fallen through the
|
|
||||||
cracks during development (Matthew Percival);
|
|
||||||
<li> Fixed: error code was not being propagated correctly in
|
|
||||||
ftp.lua (David Burgess).
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
@ -190,7 +173,7 @@ still available for those that have compatibility issues.
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -25,8 +25,8 @@ Installation">
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -144,8 +144,8 @@ Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -25,8 +25,8 @@ Library, Support">
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -314,8 +314,8 @@ and many others are covered by the <a href=reference.html>reference manual</a>.
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -25,8 +25,8 @@ Pump, Support, Library">
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -411,8 +411,8 @@ Creates and returns a source that produces the contents of a
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -457,8 +457,8 @@ marker.
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -25,8 +25,8 @@ Support, Manual">
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -151,6 +151,7 @@ Support, Manual">
|
|||||||
<a href="socket.html#sink">sink</a>,
|
<a href="socket.html#sink">sink</a>,
|
||||||
<a href="socket.html#skip">skip</a>,
|
<a href="socket.html#skip">skip</a>,
|
||||||
<a href="socket.html#sleep">sleep</a>,
|
<a href="socket.html#sleep">sleep</a>,
|
||||||
|
<a href="socket.html#setsize">_SETSIZE</a>,
|
||||||
<a href="socket.html#source">source</a>,
|
<a href="socket.html#source">source</a>,
|
||||||
<a href="tcp.html#tcp">tcp</a>,
|
<a href="tcp.html#tcp">tcp</a>,
|
||||||
<a href="socket.html#try">try</a>,
|
<a href="socket.html#try">try</a>,
|
||||||
@ -220,8 +221,8 @@ Support, Manual">
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -25,8 +25,8 @@ Library, Support">
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -398,8 +398,8 @@ r, e = smtp.send{
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -94,6 +94,24 @@ This constant is set to <tt><b>true</b></tt> if the library was compiled
|
|||||||
with debug support.
|
with debug support.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<!-- get time +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
|
<p class=name id=gettime>
|
||||||
|
socket.<b>gettime()</b>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class=description>
|
||||||
|
Returns the time in seconds, relative to the origin of the
|
||||||
|
universe. You should subtract the values returned by this function
|
||||||
|
to get meaningful values.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre class=example>
|
||||||
|
t = socket.gettime()
|
||||||
|
-- do stuff
|
||||||
|
print(socket.gettime() - t .. " seconds elapsed")
|
||||||
|
</pre>
|
||||||
|
|
||||||
<!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
<p class=name id=newtry>
|
<p class=name id=newtry>
|
||||||
@ -199,6 +217,15 @@ themselves, to simplify the test if a specific socket has
|
|||||||
changed status.
|
changed status.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p class=note>
|
||||||
|
<b>Note: </b>: <tt>select</tt> can monitor a limited number
|
||||||
|
of sockets, as defined by the constant <tt>socket._SETSIZE</tt>. This
|
||||||
|
number may be as high as 1024 or as low as 64 by default,
|
||||||
|
depending on the system. It is usually possible to change this
|
||||||
|
at compile time. Invoking <tt>select</tt> with a larger
|
||||||
|
number of sockets will raise an error.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p class=note>
|
<p class=note>
|
||||||
<b>Important note</b>: a known bug in WinSock causes <tt>select</tt> to fail
|
<b>Important note</b>: a known bug in WinSock causes <tt>select</tt> to fail
|
||||||
on non-blocking TCP sockets. The function may return a socket as
|
on non-blocking TCP sockets. The function may return a socket as
|
||||||
@ -288,8 +315,8 @@ Freezes the program execution during a given amount of time.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class=parameters>
|
<p class=parameters>
|
||||||
<tt>Time</tt> is the number of seconds to sleep for.
|
<tt>Time</tt> is the number of seconds to sleep for. If
|
||||||
The function truncates <tt>time</tt> down to the nearest integer.
|
<tt>time</tt> is negative, the function returns immediately.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
@ -324,24 +351,17 @@ side closes the connection.
|
|||||||
The function returns a source with the appropriate behavior.
|
The function returns a source with the appropriate behavior.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- time ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- setsize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
<p class=name id=gettime>
|
<p class=name id=setsize>
|
||||||
socket.<b>gettime()</b>
|
socket.<b>_SETSIZE</b>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class=description>
|
<p class=description>
|
||||||
Returns the time in seconds, relative to the origin of the
|
The maximum number of sockets that the <a
|
||||||
universe. You should subtract the values returned by this function
|
href=#select><tt>select</tt></a> function can handle.
|
||||||
to get meaningful values.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class=example>
|
|
||||||
t = socket.gettime()
|
|
||||||
-- do stuff
|
|
||||||
print(socket.gettime() - t .. " seconds elapsed")
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
<p class=name id=try>
|
<p class=name id=try>
|
||||||
@ -386,8 +406,8 @@ This constant has a string describing the current LuaSocket version.
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
16
doc/tcp.html
16
doc/tcp.html
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -297,12 +297,12 @@ of any received data before return.
|
|||||||
|
|
||||||
<p class=return>
|
<p class=return>
|
||||||
If successful, the method returns the received pattern. In case of error,
|
If successful, the method returns the received pattern. In case of error,
|
||||||
the method returns <tt><b>nil</b></tt> followed by an error message which
|
the method returns <tt><b>nil</b></tt> followed by an error
|
||||||
can be the string '<tt>closed</tt>' in case the connection was
|
message, followed by a (possibly empty) string containing
|
||||||
|
the partial that was received. The error message can be
|
||||||
|
the string '<tt>closed</tt>' in case the connection was
|
||||||
closed before the transmission was completed or the string
|
closed before the transmission was completed or the string
|
||||||
'<tt>timeout</tt>' in case there was a timeout during the operation.
|
'<tt>timeout</tt>' in case there was a timeout during the operation.
|
||||||
Also, after the error message, the function returns the partial result of
|
|
||||||
the transmission.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class=note>
|
<p class=note>
|
||||||
@ -514,8 +514,8 @@ This function returns 1.
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -397,8 +397,8 @@ imperative nature obvious.
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#download">download</a> ·
|
<a href="index.html#download">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
@ -310,8 +310,8 @@ The function returns the decoded string.
|
|||||||
<hr>
|
<hr>
|
||||||
<center>
|
<center>
|
||||||
<p class=bar>
|
<p class=bar>
|
||||||
<a href="home.html">home</a> ·
|
<a href="index.html">home</a> ·
|
||||||
<a href="home.html#down">download</a> ·
|
<a href="index.html#down">download</a> ·
|
||||||
<a href="installation.html">installation</a> ·
|
<a href="installation.html">installation</a> ·
|
||||||
<a href="introduction.html">introduction</a> ·
|
<a href="introduction.html">introduction</a> ·
|
||||||
<a href="reference.html">reference</a>
|
<a href="reference.html">reference</a>
|
||||||
|
@ -54,7 +54,7 @@ function socket.protect(f)
|
|||||||
local results = {coroutine.resume(co, base.unpack(arg))}
|
local results = {coroutine.resume(co, base.unpack(arg))}
|
||||||
local status = table.remove(results, 1)
|
local status = table.remove(results, 1)
|
||||||
if not status then
|
if not status then
|
||||||
if type(results[1]) == 'table' then
|
if base.type(results[1]) == 'table' then
|
||||||
return nil, results[1][1]
|
return nil, results[1][1]
|
||||||
else base.error(results[1]) end
|
else base.error(results[1]) end
|
||||||
end
|
end
|
||||||
|
@ -1,37 +1,25 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "socket", "socket.vcproj", "{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "socket", "socket.vcproj", "{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mime", "mime.vcproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mime", "mime.vcproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libluasocket", "libluasocket.vcproj", "{599EAD40-60EE-4043-9C14-AE090A8A092D}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug = Debug
|
Debug|Win32 = Debug|Win32
|
||||||
Release = Release
|
Release|Win32 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfiguration) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Debug.ActiveCfg = Debug|Win32
|
{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Debug.Build.0 = Debug|Win32
|
{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Release.ActiveCfg = Release|Win32
|
{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Release.Build.0 = Release|Win32
|
{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Release|Win32.Build.0 = Release|Win32
|
||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.ActiveCfg = Debug|Win32
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.Build.0 = Debug|Win32
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.ActiveCfg = Release|Win32
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.Build.0 = Release|Win32
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release|Win32.Build.0 = Release|Win32
|
||||||
{599EAD40-60EE-4043-9C14-AE090A8A092D}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{599EAD40-60EE-4043-9C14-AE090A8A092D}.Debug.Build.0 = Debug|Win32
|
|
||||||
{599EAD40-60EE-4043-9C14-AE090A8A092D}.Release.ActiveCfg = Release|Win32
|
|
||||||
{599EAD40-60EE-4043-9C14-AE090A8A092D}.Release.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
EndGlobalSection
|
HideSolutionNode = FALSE
|
||||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
56
makefile
56
makefile
@ -1,51 +1,23 @@
|
|||||||
#------
|
PLAT= none
|
||||||
# Load configuration
|
PLATS= macosx linux
|
||||||
#
|
|
||||||
include config
|
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# Hopefully no need to change anything below this line
|
# Hopefully no need to change anything below this line
|
||||||
#
|
#
|
||||||
INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket
|
all: $(PLAT)
|
||||||
INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket
|
|
||||||
INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime
|
|
||||||
INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime
|
|
||||||
|
|
||||||
all clean:
|
none:
|
||||||
|
@echo "Please run"
|
||||||
|
@echo " make PLATFORM"
|
||||||
|
@echo "where PLATFORM is one of these:"
|
||||||
|
@echo " $(PLATS)"
|
||||||
|
|
||||||
|
$(PLATS) install local clean:
|
||||||
cd src; $(MAKE) $@
|
cd src; $(MAKE) $@
|
||||||
|
|
||||||
#------
|
dummy:
|
||||||
# Files to install
|
|
||||||
#
|
|
||||||
TO_SOCKET_SHARE:= \
|
|
||||||
http.lua \
|
|
||||||
url.lua \
|
|
||||||
tp.lua \
|
|
||||||
ftp.lua \
|
|
||||||
smtp.lua
|
|
||||||
|
|
||||||
TO_TOP_SHARE:= \
|
test: dummy
|
||||||
ltn12.lua \
|
lua test/hello.lua
|
||||||
socket.lua \
|
|
||||||
mime.lua
|
|
||||||
|
|
||||||
TO_MIME_SHARE:=
|
.PHONY: dummy
|
||||||
|
|
||||||
#------
|
|
||||||
# Install LuaSocket according to recommendation
|
|
||||||
#
|
|
||||||
install: all
|
|
||||||
cd src; mkdir -p $(INSTALL_TOP_SHARE)
|
|
||||||
cd src; $(INSTALL_DATA) $(TO_TOP_SHARE) $(INSTALL_TOP_SHARE)
|
|
||||||
cd src; mkdir -p $(INSTALL_SOCKET_SHARE)
|
|
||||||
cd src; $(INSTALL_DATA) $(TO_SOCKET_SHARE) $(INSTALL_SOCKET_SHARE)
|
|
||||||
cd src; mkdir -p $(INSTALL_SOCKET_LIB)
|
|
||||||
cd src; $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_LIB)/core.$(EXT)
|
|
||||||
#cd src; mkdir -p $(INSTALL_MIME_SHARE)
|
|
||||||
#cd src; $(INSTALL_DATA) $(TO_MIME_SHARE) $(INSTALL_MIME_SHARE)
|
|
||||||
cd src; mkdir -p $(INSTALL_MIME_LIB)
|
|
||||||
cd src; $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(EXT)
|
|
||||||
|
|
||||||
#------
|
|
||||||
# End of makefile
|
|
||||||
#
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
# Distribution makefile
|
# Distribution makefile
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
DIST = luasocket-2.0.2
|
DIST = luasocket-2.0.3
|
||||||
|
|
||||||
TEST = \
|
TEST = \
|
||||||
test/README \
|
test/README \
|
||||||
|
test/hello.lua \
|
||||||
test/testclnt.lua \
|
test/testclnt.lua \
|
||||||
test/testsrvr.lua \
|
test/testsrvr.lua \
|
||||||
test/testsupport.lua
|
test/testsupport.lua
|
||||||
@ -15,6 +16,8 @@ SAMPLES = \
|
|||||||
samples/daytimeclnt.lua \
|
samples/daytimeclnt.lua \
|
||||||
samples/echoclnt.lua \
|
samples/echoclnt.lua \
|
||||||
samples/echosrvr.lua \
|
samples/echosrvr.lua \
|
||||||
|
samples/mclisten.lua \
|
||||||
|
samples/mcsend.lua \
|
||||||
samples/listener.lua \
|
samples/listener.lua \
|
||||||
samples/lpr.lua \
|
samples/lpr.lua \
|
||||||
samples/talker.lua \
|
samples/talker.lua \
|
||||||
@ -73,12 +76,12 @@ SRC = \
|
|||||||
src/mime.lua \
|
src/mime.lua \
|
||||||
src/smtp.lua \
|
src/smtp.lua \
|
||||||
src/socket.lua \
|
src/socket.lua \
|
||||||
|
src/headers.lua \
|
||||||
src/tp.lua \
|
src/tp.lua \
|
||||||
src/url.lua
|
src/url.lua
|
||||||
|
|
||||||
MAKE = \
|
MAKE = \
|
||||||
makefile \
|
makefile \
|
||||||
config \
|
|
||||||
luasocket.sln \
|
luasocket.sln \
|
||||||
socket.vcproj \
|
socket.vcproj \
|
||||||
mime.vcproj
|
mime.vcproj
|
||||||
|
176
mime.vcproj
176
mime.vcproj
@ -1,114 +1,179 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="7.10"
|
Version="9.00"
|
||||||
Name="mime"
|
Name="mime"
|
||||||
ProjectGUID="{128E8BD0-174A-48F0-8771-92B1E8D18713}"
|
ProjectGUID="{128E8BD0-174A-48F0-8771-92B1E8D18713}"
|
||||||
Keyword="Win32Proj">
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"/>
|
Name="Win32"
|
||||||
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="src"
|
OutputDirectory="src"
|
||||||
IntermediateDirectory="src"
|
IntermediateDirectory="src"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
CharacterSet="2">
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="h:\include\lua5.1"
|
AdditionalIncludeDirectories="..\lua-5.1.4\src"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport)"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="false"
|
||||||
DebugInformationFormat="4"/>
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="lua5.1.lib"
|
||||||
OutputFile="$(OutDir)/mime.dll"
|
OutputFile="$(OutDir)/mime.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
AdditionalLibraryDirectories="h:\lib"
|
AdditionalLibraryDirectories="..\lua-5.1.4"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(OutDir)/mime.pdb"
|
ProgramDatabaseFile="$(OutDir)/mime.pdb"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
ImportLibrary="$(OutDir)/mime.lib"
|
ImportLibrary="$(OutDir)/mime.lib"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCPostBuildEventTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="src"
|
OutputDirectory="src"
|
||||||
IntermediateDirectory="src"
|
IntermediateDirectory="src"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
CharacterSet="2">
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="h:\include\lua5.1"
|
AdditionalIncludeDirectories="..\lua-5.1.4\src"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="false"
|
||||||
DebugInformationFormat="0"/>
|
DebugInformationFormat="0"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="lua5.1.lib"
|
||||||
OutputFile="$(OutDir)/mime.dll"
|
OutputFile="$(OutDir)/mime.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories="h:\lib"
|
AdditionalLibraryDirectories="..\lua-5.1.4"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
ImportLibrary="$(OutDir)/mime.lib"
|
ImportLibrary="$(OutDir)/mime.lib"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCPostBuildEventTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
@ -117,24 +182,25 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\mime.c">
|
RelativePath="src\mime.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
<File
|
|
||||||
RelativePath="..\..\lib\lua5.1.dll.lib">
|
|
||||||
</File>
|
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
@ -32,7 +32,7 @@ end
|
|||||||
local host = socket.dns.gethostname()
|
local host = socket.dns.gethostname()
|
||||||
local query = "%s?cmd=cddb+read+%s+%s&hello=LuaSocket+%s+LuaSocket+2.0&proto=6"
|
local query = "%s?cmd=cddb+read+%s+%s&hello=LuaSocket+%s+LuaSocket+2.0&proto=6"
|
||||||
local url = string.format(query, server, arg[1], arg[2], host)
|
local url = string.format(query, server, arg[1], arg[2], host)
|
||||||
local body, headers, code = http.get(url)
|
local body, headers, code = http.request(url)
|
||||||
|
|
||||||
if code == 200 then
|
if code == 200 then
|
||||||
local data, code, error = parse(body)
|
local data, code, error = parse(body)
|
||||||
|
217
socket.vcproj
217
socket.vcproj
@ -1,116 +1,179 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="7.10"
|
Version="9.00"
|
||||||
Name="socket"
|
Name="socket"
|
||||||
ProjectGUID="{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}"
|
ProjectGUID="{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}"
|
||||||
Keyword="Win32Proj">
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"/>
|
Name="Win32"
|
||||||
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="src"
|
OutputDirectory="src"
|
||||||
IntermediateDirectory="src"
|
IntermediateDirectory="src"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
CharacterSet="2">
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="h:\include\lua5.1"
|
AdditionalIncludeDirectories="..\lua-5.1.4\src"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport)"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="false"
|
||||||
DebugInformationFormat="4"/>
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="ws2_32.lib"
|
AdditionalDependencies="ws2_32.lib lua5.1.lib"
|
||||||
OutputFile="$(OutDir)/socket.dll"
|
OutputFile="$(OutDir)/socket.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
AdditionalLibraryDirectories="h:\lib"
|
AdditionalLibraryDirectories="..\lua-5.1.4"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(OutDir)/socket.pdb"
|
ProgramDatabaseFile="$(OutDir)/socket.pdb"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
ImportLibrary="$(OutDir)/socket.lib"
|
ImportLibrary="$(OutDir)/socket.lib"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCPostBuildEventTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="./src"
|
OutputDirectory="./src"
|
||||||
IntermediateDirectory="./src"
|
IntermediateDirectory="./src"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
CharacterSet="2">
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="h:\include\lua5.1"
|
AdditionalIncludeDirectories="..\lua-5.1.4\src"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG; _CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="false"
|
||||||
DebugInformationFormat="0"/>
|
DebugInformationFormat="0"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="ws2_32.lib"
|
AdditionalDependencies="ws2_32.lib lua5.1.lib"
|
||||||
OutputFile="$(OutDir)/socket.dll"
|
OutputFile="$(OutDir)/socket.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories="h:\lib"
|
AdditionalLibraryDirectories="..\lua-5.1.4"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
ImportLibrary="$(OutDir)/socket.lib"
|
ImportLibrary="$(OutDir)/socket.lib"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCPostBuildEventTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
@ -119,63 +182,77 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\auxiliar.c">
|
RelativePath="src\auxiliar.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\buffer.c">
|
RelativePath="src\buffer.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\except.c">
|
RelativePath="src\except.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\inet.c">
|
RelativePath="src\inet.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\io.c">
|
RelativePath="src\io.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\luasocket.c">
|
RelativePath="src\luasocket.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\options.c">
|
RelativePath="src\options.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\select.c">
|
RelativePath="src\select.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\tcp.c">
|
RelativePath="src\tcp.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\timeout.c">
|
RelativePath="src\timeout.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\udp.c">
|
RelativePath="src\udp.c"
|
||||||
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="src\wsocket.c">
|
RelativePath="src\wsocket.c"
|
||||||
|
>
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
Name="Release|Win32">
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
GeneratePreprocessedFile="0"/>
|
GeneratePreprocessedFile="0"
|
||||||
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
<File
|
|
||||||
RelativePath="..\..\lib\lua5.1.dll.lib">
|
|
||||||
</File>
|
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
*
|
*
|
||||||
* The mapping from class name to the corresponding metatable and the
|
* The mapping from class name to the corresponding metatable and the
|
||||||
* reverse mapping are done using lauxlib.
|
* reverse mapping are done using lauxlib.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
@ -166,7 +166,7 @@ static int sendraw(p_buffer buf, const char *data, size_t count, size_t *sent) {
|
|||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
int err = IO_DONE;
|
int err = IO_DONE;
|
||||||
while (total < count && err == IO_DONE) {
|
while (total < count && err == IO_DONE) {
|
||||||
size_t done;
|
size_t done = 0;
|
||||||
size_t step = (count-total <= STEPSIZE)? count-total: STEPSIZE;
|
size_t step = (count-total <= STEPSIZE)? count-total: STEPSIZE;
|
||||||
err = io->send(io->ctx, data+total, step, &done, tm);
|
err = io->send(io->ctx, data+total, step, &done, tm);
|
||||||
total += done;
|
total += done;
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
*
|
*
|
||||||
* The module is built on top of the I/O abstraction defined in io.h and the
|
* The module is built on top of the I/O abstraction defined in io.h and the
|
||||||
* timeout management is done with the timeout.h interface.
|
* timeout management is done with the timeout.h interface.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
*
|
*
|
||||||
* With these two function, it's easy to write functions that throw
|
* With these two function, it's easy to write functions that throw
|
||||||
* exceptions on error, but that don't interrupt the user script.
|
* exceptions on error, but that don't interrupt the user script.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
10
src/http.lua
10
src/http.lua
@ -13,6 +13,7 @@ local url = require("socket.url")
|
|||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
local mime = require("mime")
|
local mime = require("mime")
|
||||||
local string = require("string")
|
local string = require("string")
|
||||||
|
local headers = require("socket.headers")
|
||||||
local base = _G
|
local base = _G
|
||||||
local table = require("table")
|
local table = require("table")
|
||||||
module("socket.http")
|
module("socket.http")
|
||||||
@ -123,10 +124,11 @@ function metat.__index:sendrequestline(method, uri)
|
|||||||
return self.try(self.c:send(reqline))
|
return self.try(self.c:send(reqline))
|
||||||
end
|
end
|
||||||
|
|
||||||
function metat.__index:sendheaders(headers)
|
function metat.__index:sendheaders(tosend)
|
||||||
|
local canonic = headers.canonic
|
||||||
local h = "\r\n"
|
local h = "\r\n"
|
||||||
for i, v in base.pairs(headers) do
|
for f, v in base.pairs(tosend) do
|
||||||
h = i .. ": " .. v .. "\r\n" .. h
|
h = (canonic[f] or f) .. ": " .. v .. "\r\n" .. h
|
||||||
end
|
end
|
||||||
self.try(self.c:send(h))
|
self.try(self.c:send(h))
|
||||||
return 1
|
return 1
|
||||||
@ -254,7 +256,7 @@ local function shouldredirect(reqt, code, headers)
|
|||||||
return headers.location and
|
return headers.location and
|
||||||
string.gsub(headers.location, "%s", "") ~= "" and
|
string.gsub(headers.location, "%s", "") ~= "" and
|
||||||
(reqt.redirect ~= false) and
|
(reqt.redirect ~= false) and
|
||||||
(code == 301 or code == 302) and
|
(code == 301 or code == 302 or code == 303 or code == 307) and
|
||||||
(not reqt.method or reqt.method == "GET" or reqt.method == "HEAD")
|
(not reqt.method or reqt.method == "GET" or reqt.method == "HEAD")
|
||||||
and (not reqt.nredirects or reqt.nredirects < 5)
|
and (not reqt.nredirects or reqt.nredirects < 5)
|
||||||
end
|
end
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
* getpeername and getsockname functions as seen by Lua programs.
|
* getpeername and getsockname functions as seen by Lua programs.
|
||||||
*
|
*
|
||||||
* The Lua functions toip and tohostname are also implemented here.
|
* The Lua functions toip and tohostname are also implemented here.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
2
src/io.h
2
src/io.h
@ -11,8 +11,6 @@
|
|||||||
*
|
*
|
||||||
* The module socket.h implements this interface, and thus the module tcp.h
|
* The module socket.h implements this interface, and thus the module tcp.h
|
||||||
* is very simple.
|
* is very simple.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
* involved in setting up both client and server connections. The provided
|
* involved in setting up both client and server connections. The provided
|
||||||
* IO routines, however, follow the Lua style, being very similar to the
|
* IO routines, however, follow the Lua style, being very similar to the
|
||||||
* standard Lua read and write functions.
|
* standard Lua read and write functions.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
|
@ -5,16 +5,14 @@
|
|||||||
* Networking support for the Lua language
|
* Networking support for the Lua language
|
||||||
* Diego Nehab
|
* Diego Nehab
|
||||||
* 9/11/1999
|
* 9/11/1999
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Current socket library version
|
* Current socket library version
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
#define LUASOCKET_VERSION "LuaSocket 2.0.2"
|
#define LUASOCKET_VERSION "LuaSocket 2.0.3"
|
||||||
#define LUASOCKET_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab"
|
#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2009 Diego Nehab"
|
||||||
#define LUASOCKET_AUTHORS "Diego Nehab"
|
#define LUASOCKET_AUTHORS "Diego Nehab"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
|
154
src/makefile
154
src/makefile
@ -1,19 +1,68 @@
|
|||||||
#------
|
PLAT = none
|
||||||
# Load configuration
|
INSTALL_DATA=cp
|
||||||
#
|
INSTALL_EXEC=cp
|
||||||
include ../config
|
INSTALL_TOP= /opt/local
|
||||||
|
LUAINC= $(LUAINC_$(PLAT))
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# Hopefully no need to change anything below this line
|
# Install directories
|
||||||
#
|
#
|
||||||
|
INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/5.1
|
||||||
|
INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/5.1
|
||||||
|
INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket
|
||||||
|
INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket
|
||||||
|
INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime
|
||||||
|
INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime
|
||||||
|
|
||||||
|
#------
|
||||||
|
# Output file names
|
||||||
|
#
|
||||||
|
EXT=so
|
||||||
|
SOCKET_V=2.0.3
|
||||||
|
MIME_V=1.0.3
|
||||||
|
SOCKET_SO=socket.$(EXT).$(SOCKET_V)
|
||||||
|
MIME_SO=mime.$(EXT).$(MIME_V)
|
||||||
|
UNIX_SO=unix.$(EXT)
|
||||||
|
|
||||||
|
#------
|
||||||
|
# Compiler and linker settings
|
||||||
|
# for Mac OS X
|
||||||
|
LUAINC_macosx= -I/opt/local/include
|
||||||
|
CC_macosx=gcc
|
||||||
|
DEF_macosx= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN \
|
||||||
|
-DLUASOCKET_API='__attribute__((visibility("default")))' \
|
||||||
|
-DMIME_API='__attribute__((visibility("default")))'
|
||||||
|
CFLAGS_macosx= $(LUAINC) $(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common \
|
||||||
|
-fvisibility=hidden
|
||||||
|
LDFLAGS_macosx= -bundle -undefined dynamic_lookup
|
||||||
|
LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
|
||||||
|
|
||||||
|
#------
|
||||||
|
# Compiler and linker settings
|
||||||
|
# for Linux
|
||||||
|
LUAINC_linux= -I/usr/local/include/lua5.1
|
||||||
|
CC_linux=gcc
|
||||||
|
DEF_linux=-DLUASOCKET_DEBUG \
|
||||||
|
-DLUASOCKET_API='__attribute__((visibility("default")))' \
|
||||||
|
-DMIME_API='__attribute__((visibility("default")))'
|
||||||
|
CFLAGS_linux= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic \
|
||||||
|
-fvisibility=hidden
|
||||||
|
LDFLAGS_linux=-O -shared -fpic
|
||||||
|
LD_linux= gcc
|
||||||
|
|
||||||
|
#------
|
||||||
|
# Settings selected for platform
|
||||||
|
#
|
||||||
|
CC=$(CC_$(PLAT))
|
||||||
|
DEF=$(DEF_$(PLAT))
|
||||||
|
CFLAGS=$(CFLAGS_$(PLAT))
|
||||||
|
LDFLAGS=$(LDFLAGS_$(PLAT))
|
||||||
|
LD=$(LD_$(PLAT))
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# Modules belonging to socket-core
|
# Modules belonging to socket-core
|
||||||
#
|
#
|
||||||
|
SOCKET_OBJS= \
|
||||||
#$(COMPAT)/compat-5.1.o \
|
|
||||||
|
|
||||||
SOCKET_OBJS:= \
|
|
||||||
luasocket.o \
|
luasocket.o \
|
||||||
timeout.o \
|
timeout.o \
|
||||||
buffer.o \
|
buffer.o \
|
||||||
@ -21,18 +70,16 @@ SOCKET_OBJS:= \
|
|||||||
auxiliar.o \
|
auxiliar.o \
|
||||||
options.o \
|
options.o \
|
||||||
inet.o \
|
inet.o \
|
||||||
tcp.o \
|
usocket.o \
|
||||||
udp.o \
|
|
||||||
except.o \
|
except.o \
|
||||||
select.o \
|
select.o \
|
||||||
usocket.o
|
tcp.o \
|
||||||
|
udp.o
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# Modules belonging mime-core
|
# Modules belonging mime-core
|
||||||
#
|
#
|
||||||
#$(COMPAT)/compat-5.1.o \
|
MIME_OBJS= \
|
||||||
|
|
||||||
MIME_OBJS:=\
|
|
||||||
mime.o
|
mime.o
|
||||||
|
|
||||||
#------
|
#------
|
||||||
@ -47,6 +94,34 @@ UNIX_OBJS:=\
|
|||||||
usocket.o \
|
usocket.o \
|
||||||
unix.o
|
unix.o
|
||||||
|
|
||||||
|
#------
|
||||||
|
# Files to install
|
||||||
|
#
|
||||||
|
TO_SOCKET_SHARE:= \
|
||||||
|
http.lua \
|
||||||
|
url.lua \
|
||||||
|
tp.lua \
|
||||||
|
ftp.lua \
|
||||||
|
headers.lua \
|
||||||
|
smtp.lua
|
||||||
|
|
||||||
|
TO_TOP_SHARE:= \
|
||||||
|
ltn12.lua \
|
||||||
|
socket.lua \
|
||||||
|
mime.lua
|
||||||
|
|
||||||
|
default: $(PLAT)
|
||||||
|
|
||||||
|
macosx:
|
||||||
|
$(MAKE) all PLAT=macosx
|
||||||
|
|
||||||
|
linux:
|
||||||
|
$(MAKE) all PLAT=linux
|
||||||
|
|
||||||
|
none:
|
||||||
|
@echo "Please choose a platform:"
|
||||||
|
@echo " $(PLATS)"
|
||||||
|
|
||||||
all: $(SOCKET_SO) $(MIME_SO)
|
all: $(SOCKET_SO) $(MIME_SO)
|
||||||
|
|
||||||
$(SOCKET_SO): $(SOCKET_OBJS)
|
$(SOCKET_SO): $(SOCKET_OBJS)
|
||||||
@ -58,6 +133,25 @@ $(MIME_SO): $(MIME_OBJS)
|
|||||||
$(UNIX_SO): $(UNIX_OBJS)
|
$(UNIX_SO): $(UNIX_OBJS)
|
||||||
$(LD) $(LDFLAGS) -o $@ $(UNIX_OBJS)
|
$(LD) $(LDFLAGS) -o $@ $(UNIX_OBJS)
|
||||||
|
|
||||||
|
install:
|
||||||
|
mkdir -p $(INSTALL_TOP_SHARE)
|
||||||
|
$(INSTALL_DATA) $(TO_TOP_SHARE) $(INSTALL_TOP_SHARE)
|
||||||
|
mkdir -p $(INSTALL_SOCKET_SHARE)
|
||||||
|
$(INSTALL_DATA) $(TO_SOCKET_SHARE) $(INSTALL_SOCKET_SHARE)
|
||||||
|
mkdir -p $(INSTALL_SOCKET_LIB)
|
||||||
|
$(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_LIB)/core.$(EXT)
|
||||||
|
mkdir -p $(INSTALL_MIME_LIB)
|
||||||
|
$(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(EXT)
|
||||||
|
|
||||||
|
local:
|
||||||
|
$(MAKE) install INSTALL_TOP_LIB=.. INSTALL_TOP_SHARE=..
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(SOCKET_SO) $(SOCKET_OBJS)
|
||||||
|
rm -f $(MIME_SO) $(UNIX_SO) $(MIME_OBJS) $(UNIX_OBJS)
|
||||||
|
|
||||||
|
.PHONY: all $(PLATS) default clean echo none
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# List of dependencies
|
# List of dependencies
|
||||||
#
|
#
|
||||||
@ -66,25 +160,19 @@ buffer.o: buffer.c buffer.h io.h timeout.h
|
|||||||
except.o: except.c except.h
|
except.o: except.c except.h
|
||||||
inet.o: inet.c inet.h socket.h io.h timeout.h usocket.h
|
inet.o: inet.c inet.h socket.h io.h timeout.h usocket.h
|
||||||
io.o: io.c io.h timeout.h
|
io.o: io.c io.h timeout.h
|
||||||
luasocket.o: luasocket.c luasocket.h auxiliar.h except.h timeout.h \
|
luasocket.o: luasocket.c luasocket.h auxiliar.h except.h \
|
||||||
buffer.h io.h inet.h socket.h usocket.h tcp.h udp.h select.h
|
timeout.h buffer.h io.h inet.h socket.h usocket.h tcp.h \
|
||||||
|
udp.h select.h
|
||||||
mime.o: mime.c mime.h
|
mime.o: mime.c mime.h
|
||||||
options.o: options.c auxiliar.h options.h socket.h io.h timeout.h \
|
options.o: options.c auxiliar.h options.h socket.h io.h \
|
||||||
usocket.h inet.h
|
timeout.h usocket.h inet.h
|
||||||
select.o: select.c socket.h io.h timeout.h usocket.h select.h
|
select.o: select.c socket.h io.h timeout.h usocket.h select.h
|
||||||
tcp.o: tcp.c auxiliar.h socket.h io.h timeout.h usocket.h inet.h \
|
tcp.o: tcp.c auxiliar.h socket.h io.h timeout.h usocket.h \
|
||||||
options.h tcp.h buffer.h
|
inet.h options.h tcp.h buffer.h
|
||||||
timeout.o: timeout.c auxiliar.h timeout.h
|
timeout.o: timeout.c auxiliar.h timeout.h
|
||||||
udp.o: udp.c auxiliar.h socket.h io.h timeout.h usocket.h inet.h \
|
udp.o: udp.c auxiliar.h socket.h io.h timeout.h usocket.h \
|
||||||
options.h udp.h
|
inet.h options.h udp.h
|
||||||
unix.o: unix.c auxiliar.h socket.h io.h timeout.h usocket.h options.h \
|
unix.o: unix.c auxiliar.h socket.h io.h timeout.h usocket.h \
|
||||||
unix.h buffer.h
|
options.h unix.h buffer.h
|
||||||
usocket.o: usocket.c socket.h io.h timeout.h usocket.h
|
usocket.o: usocket.c socket.h io.h timeout.h usocket.h
|
||||||
|
wsocket.o: wsocket.c socket.h io.h timeout.h usocket.h
|
||||||
clean:
|
|
||||||
rm -f $(SOCKET_SO) $(SOCKET_OBJS)
|
|
||||||
rm -f $(MIME_SO) $(UNIX_SO) $(MIME_OBJS) $(UNIX_OBJS)
|
|
||||||
|
|
||||||
#------
|
|
||||||
# End of makefile configuration
|
|
||||||
#
|
|
||||||
|
10
src/mime.c
10
src/mime.c
@ -272,9 +272,12 @@ static int mime_global_b64(lua_State *L)
|
|||||||
input = (UC *) luaL_optlstring(L, 2, NULL, &isize);
|
input = (UC *) luaL_optlstring(L, 2, NULL, &isize);
|
||||||
/* if second part is nil, we are done */
|
/* if second part is nil, we are done */
|
||||||
if (!input) {
|
if (!input) {
|
||||||
|
size_t osize = 0;
|
||||||
asize = b64pad(atom, asize, &buffer);
|
asize = b64pad(atom, asize, &buffer);
|
||||||
luaL_pushresult(&buffer);
|
luaL_pushresult(&buffer);
|
||||||
if (!(*lua_tostring(L, -1))) lua_pushnil(L);
|
/* if the output is empty and the input is nil, return nil */
|
||||||
|
lua_tolstring(L, -1, &osize);
|
||||||
|
if (osize == 0) lua_pushnil(L);
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@ -313,8 +316,11 @@ static int mime_global_unb64(lua_State *L)
|
|||||||
input = (UC *) luaL_optlstring(L, 2, NULL, &isize);
|
input = (UC *) luaL_optlstring(L, 2, NULL, &isize);
|
||||||
/* if second is nil, we are done */
|
/* if second is nil, we are done */
|
||||||
if (!input) {
|
if (!input) {
|
||||||
|
size_t osize = 0;
|
||||||
luaL_pushresult(&buffer);
|
luaL_pushresult(&buffer);
|
||||||
if (!(*lua_tostring(L, -1))) lua_pushnil(L);
|
/* if the output is empty and the input is nil, return nil */
|
||||||
|
lua_tolstring(L, -1, &osize);
|
||||||
|
if (osize == 0) lua_pushnil(L);
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,14 @@
|
|||||||
* This module provides functions to implement transfer content encodings
|
* This module provides functions to implement transfer content encodings
|
||||||
* and formatting conforming to RFC 2045. It is used by mime.lua, which
|
* and formatting conforming to RFC 2045. It is used by mime.lua, which
|
||||||
* provide a higher level interface to this functionality.
|
* provide a higher level interface to this functionality.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Current MIME library version
|
* Current MIME library version
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
#define MIME_VERSION "MIME 1.0.2"
|
#define MIME_VERSION "MIME 1.0.3"
|
||||||
#define MIME_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab"
|
#define MIME_COPYRIGHT "Copyright (C) 2004-2009 Diego Nehab"
|
||||||
#define MIME_AUTHORS "Diego Nehab"
|
#define MIME_AUTHORS "Diego Nehab"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "inet.h"
|
#include "inet.h"
|
||||||
|
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Internal functions prototypes
|
* Internal functions prototypes
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
static int opt_setmembership(lua_State *L, p_socket ps, int level, int name);
|
static int opt_setmembership(lua_State *L, p_socket ps, int level, int name);
|
||||||
static int opt_setboolean(lua_State *L, p_socket ps, int level, int name);
|
static int opt_setboolean(lua_State *L, p_socket ps, int level, int name);
|
||||||
|
static int opt_getboolean(lua_State *L, p_socket ps, int level, int name);
|
||||||
static int opt_set(lua_State *L, p_socket ps, int level, int name,
|
static int opt_set(lua_State *L, p_socket ps, int level, int name,
|
||||||
void *val, int len);
|
void *val, int len);
|
||||||
|
|
||||||
@ -40,39 +40,63 @@ int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps)
|
|||||||
return opt->func(L, ps);
|
return opt->func(L, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps)
|
||||||
|
{
|
||||||
|
const char *name = luaL_checkstring(L, 2); /* obj, name, ... */
|
||||||
|
while (opt->name && strcmp(name, opt->name))
|
||||||
|
opt++;
|
||||||
|
if (!opt->func) {
|
||||||
|
char msg[45];
|
||||||
|
sprintf(msg, "unsupported option `%.35s'", name);
|
||||||
|
luaL_argerror(L, 2, msg);
|
||||||
|
}
|
||||||
|
return opt->func(L, ps);
|
||||||
|
}
|
||||||
|
|
||||||
/* enables reuse of local address */
|
/* enables reuse of local address */
|
||||||
int opt_reuseaddr(lua_State *L, p_socket ps)
|
int opt_set_reuseaddr(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
|
return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* enables reuse of local port */
|
||||||
|
int opt_set_reuseport(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEPORT);
|
||||||
|
}
|
||||||
|
|
||||||
/* disables the Naggle algorithm */
|
/* disables the Naggle algorithm */
|
||||||
int opt_tcp_nodelay(lua_State *L, p_socket ps)
|
int opt_set_tcp_nodelay(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY);
|
return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_keepalive(lua_State *L, p_socket ps)
|
int opt_set_keepalive(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE);
|
return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_dontroute(lua_State *L, p_socket ps)
|
int opt_set_dontroute(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE);
|
return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_broadcast(lua_State *L, p_socket ps)
|
int opt_set_broadcast(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
|
return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_ip_multicast_loop(lua_State *L, p_socket ps)
|
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
|
return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_linger(lua_State *L, p_socket ps)
|
int opt_get_ip_multicast_loop(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_getboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_set_linger(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
struct linger li; /* obj, name, table */
|
struct linger li; /* obj, name, table */
|
||||||
if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE));
|
if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE));
|
||||||
@ -89,18 +113,43 @@ int opt_linger(lua_State *L, p_socket ps)
|
|||||||
return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li));
|
return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li));
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_ip_multicast_ttl(lua_State *L, p_socket ps)
|
int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
int val = (int) luaL_checknumber(L, 3); /* obj, name, int */
|
int val = (int) luaL_checknumber(L, 3); /* obj, name, int */
|
||||||
return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &val, sizeof(val));
|
return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_TTL,
|
||||||
|
(char *) &val, sizeof(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_ip_add_membership(lua_State *L, p_socket ps)
|
int opt_set_ip_multicast_if(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
const char *address = luaL_checkstring(L, 3); /* obj, name, ip */
|
||||||
|
struct in_addr val;
|
||||||
|
val.s_addr = htonl(INADDR_ANY);
|
||||||
|
if (strcmp(address, "*") && !inet_aton(address, &val))
|
||||||
|
luaL_argerror(L, 3, "ip expected");
|
||||||
|
return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_IF,
|
||||||
|
(char *) &val, sizeof(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_get_ip_multicast_if(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
struct in_addr val;
|
||||||
|
socklen_t len = sizeof(val);
|
||||||
|
if (getsockopt(*ps, IPPROTO_IP, IP_MULTICAST_IF, (char *) &val, &len) < 0) {
|
||||||
|
lua_pushnil(L);
|
||||||
|
lua_pushstring(L, "getsockopt failed");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
lua_pushstring(L, inet_ntoa(val));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_set_ip_add_membership(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP);
|
return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_ip_drop_membersip(lua_State *L, p_socket ps)
|
int opt_set_ip_drop_membersip(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP);
|
return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP);
|
||||||
}
|
}
|
||||||
@ -141,6 +190,19 @@ int opt_set(lua_State *L, p_socket ps, int level, int name, void *val, int len)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int opt_getboolean(lua_State *L, p_socket ps, int level, int name)
|
||||||
|
{
|
||||||
|
int val = 0;
|
||||||
|
socklen_t len = sizeof(val);
|
||||||
|
if (getsockopt(*ps, level, name, (char *) &val, &len) < 0) {
|
||||||
|
lua_pushnil(L);
|
||||||
|
lua_pushstring(L, "getsockopt failed");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
lua_pushboolean(L, val);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int opt_setboolean(lua_State *L, p_socket ps, int level, int name)
|
static int opt_setboolean(lua_State *L, p_socket ps, int level, int name)
|
||||||
{
|
{
|
||||||
int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */
|
int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
*
|
*
|
||||||
* This module provides a common interface to socket options, used mainly by
|
* This module provides a common interface to socket options, used mainly by
|
||||||
* modules UDP and TCP.
|
* modules UDP and TCP.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
@ -20,20 +18,28 @@ typedef struct t_opt {
|
|||||||
} t_opt;
|
} t_opt;
|
||||||
typedef t_opt *p_opt;
|
typedef t_opt *p_opt;
|
||||||
|
|
||||||
/* supported options */
|
/* supported options for setoption */
|
||||||
int opt_dontroute(lua_State *L, p_socket ps);
|
int opt_set_dontroute(lua_State *L, p_socket ps);
|
||||||
int opt_broadcast(lua_State *L, p_socket ps);
|
int opt_set_broadcast(lua_State *L, p_socket ps);
|
||||||
int opt_reuseaddr(lua_State *L, p_socket ps);
|
int opt_set_reuseaddr(lua_State *L, p_socket ps);
|
||||||
int opt_tcp_nodelay(lua_State *L, p_socket ps);
|
int opt_set_tcp_nodelay(lua_State *L, p_socket ps);
|
||||||
int opt_keepalive(lua_State *L, p_socket ps);
|
int opt_set_keepalive(lua_State *L, p_socket ps);
|
||||||
int opt_linger(lua_State *L, p_socket ps);
|
int opt_set_linger(lua_State *L, p_socket ps);
|
||||||
int opt_reuseaddr(lua_State *L, p_socket ps);
|
int opt_set_reuseaddr(lua_State *L, p_socket ps);
|
||||||
int opt_ip_multicast_ttl(lua_State *L, p_socket ps);
|
int opt_set_reuseport(lua_State *L, p_socket ps);
|
||||||
int opt_ip_multicast_loop(lua_State *L, p_socket ps);
|
int opt_set_ip_multicast_if(lua_State *L, p_socket ps);
|
||||||
int opt_ip_add_membership(lua_State *L, p_socket ps);
|
int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps);
|
||||||
int opt_ip_drop_membersip(lua_State *L, p_socket ps);
|
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps);
|
||||||
|
int opt_set_ip_add_membership(lua_State *L, p_socket ps);
|
||||||
|
int opt_set_ip_drop_membersip(lua_State *L, p_socket ps);
|
||||||
/* invokes the appropriate option handler */
|
/* invokes the appropriate option handler */
|
||||||
int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps);
|
int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps);
|
||||||
|
|
||||||
|
/* supported options for getoption */
|
||||||
|
int opt_get_ip_multicast_loop(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_ip_multicast_if(lua_State *L, p_socket ps);
|
||||||
|
/* invokes the appropriate option handler */
|
||||||
|
int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
39
src/select.c
39
src/select.c
@ -18,8 +18,8 @@
|
|||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
static t_socket getfd(lua_State *L);
|
static t_socket getfd(lua_State *L);
|
||||||
static int dirty(lua_State *L);
|
static int dirty(lua_State *L);
|
||||||
static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
|
static void collect_fd(lua_State *L, int tab, int itab,
|
||||||
int itab, fd_set *set);
|
fd_set *set, t_socket *max_fd);
|
||||||
static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set);
|
static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set);
|
||||||
static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
|
static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
|
||||||
int itab, int tab, int start);
|
int itab, int tab, int start);
|
||||||
@ -39,6 +39,9 @@ static luaL_reg func[] = {
|
|||||||
* Initializes module
|
* Initializes module
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
int select_open(lua_State *L) {
|
int select_open(lua_State *L) {
|
||||||
|
lua_pushstring(L, "_SETSIZE");
|
||||||
|
lua_pushnumber(L, FD_SETSIZE);
|
||||||
|
lua_rawset(L, -3);
|
||||||
luaL_openlib(L, NULL, func, 0);
|
luaL_openlib(L, NULL, func, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -51,7 +54,7 @@ int select_open(lua_State *L) {
|
|||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int global_select(lua_State *L) {
|
static int global_select(lua_State *L) {
|
||||||
int rtab, wtab, itab, ret, ndirty;
|
int rtab, wtab, itab, ret, ndirty;
|
||||||
t_socket max_fd;
|
t_socket max_fd = SOCKET_INVALID;
|
||||||
fd_set rset, wset;
|
fd_set rset, wset;
|
||||||
t_timeout tm;
|
t_timeout tm;
|
||||||
double t = luaL_optnumber(L, 3, -1);
|
double t = luaL_optnumber(L, 3, -1);
|
||||||
@ -60,12 +63,12 @@ static int global_select(lua_State *L) {
|
|||||||
lua_newtable(L); itab = lua_gettop(L);
|
lua_newtable(L); itab = lua_gettop(L);
|
||||||
lua_newtable(L); rtab = lua_gettop(L);
|
lua_newtable(L); rtab = lua_gettop(L);
|
||||||
lua_newtable(L); wtab = lua_gettop(L);
|
lua_newtable(L); wtab = lua_gettop(L);
|
||||||
max_fd = collect_fd(L, 1, SOCKET_INVALID, itab, &rset);
|
collect_fd(L, 1, itab, &rset, &max_fd);
|
||||||
|
collect_fd(L, 2, itab, &wset, &max_fd);
|
||||||
ndirty = check_dirty(L, 1, rtab, &rset);
|
ndirty = check_dirty(L, 1, rtab, &rset);
|
||||||
t = ndirty > 0? 0.0: t;
|
t = ndirty > 0? 0.0: t;
|
||||||
timeout_init(&tm, t, -1);
|
timeout_init(&tm, t, -1);
|
||||||
timeout_markstart(&tm);
|
timeout_markstart(&tm);
|
||||||
max_fd = collect_fd(L, 2, max_fd, itab, &wset);
|
|
||||||
ret = socket_select(max_fd+1, &rset, &wset, NULL, &tm);
|
ret = socket_select(max_fd+1, &rset, &wset, NULL, &tm);
|
||||||
if (ret > 0 || ndirty > 0) {
|
if (ret > 0 || ndirty > 0) {
|
||||||
return_fd(L, &rset, max_fd+1, itab, rtab, ndirty);
|
return_fd(L, &rset, max_fd+1, itab, rtab, ndirty);
|
||||||
@ -77,7 +80,7 @@ static int global_select(lua_State *L) {
|
|||||||
lua_pushstring(L, "timeout");
|
lua_pushstring(L, "timeout");
|
||||||
return 3;
|
return 3;
|
||||||
} else {
|
} else {
|
||||||
lua_pushstring(L, "error");
|
luaL_error(L, "select failed");
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,11 +115,13 @@ static int dirty(lua_State *L) {
|
|||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
|
static void collect_fd(lua_State *L, int tab, int itab,
|
||||||
int itab, fd_set *set) {
|
fd_set *set, t_socket *max_fd) {
|
||||||
int i = 1;
|
int i = 1, n = 0;
|
||||||
if (lua_isnil(L, tab))
|
/* nil is the same as an empty table */
|
||||||
return max_fd;
|
if (lua_isnil(L, tab)) return;
|
||||||
|
/* otherwise we need it to be a table */
|
||||||
|
luaL_checktype(L, tab, LUA_TTABLE);
|
||||||
while (1) {
|
while (1) {
|
||||||
t_socket fd;
|
t_socket fd;
|
||||||
lua_pushnumber(L, i);
|
lua_pushnumber(L, i);
|
||||||
@ -125,11 +130,18 @@ static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* getfd figures out if this is a socket */
|
||||||
fd = getfd(L);
|
fd = getfd(L);
|
||||||
if (fd != SOCKET_INVALID) {
|
if (fd != SOCKET_INVALID) {
|
||||||
|
/* make sure we don't overflow the fd_set */
|
||||||
|
if (n >= FD_SETSIZE)
|
||||||
|
luaL_argerror(L, tab, "too many sockets");
|
||||||
FD_SET(fd, set);
|
FD_SET(fd, set);
|
||||||
if (max_fd == SOCKET_INVALID || max_fd < fd)
|
n++;
|
||||||
max_fd = fd;
|
/* keep track of the largest descriptor so far */
|
||||||
|
if (*max_fd == SOCKET_INVALID || *max_fd < fd)
|
||||||
|
*max_fd = fd;
|
||||||
|
/* make sure we can map back from descriptor to the object */
|
||||||
lua_pushnumber(L, fd);
|
lua_pushnumber(L, fd);
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
lua_settable(L, itab);
|
lua_settable(L, itab);
|
||||||
@ -137,7 +149,6 @@ static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
return max_fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) {
|
static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) {
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
* method getfd() which returns the descriptor to be passed to the
|
* method getfd() which returns the descriptor to be passed to the
|
||||||
* underlying select function. Another method, dirty(), should return
|
* underlying select function. Another method, dirty(), should return
|
||||||
* true if there is data ready for reading (required for buffered input).
|
* true if there is data ready for reading (required for buffered input).
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
int select_open(lua_State *L);
|
int select_open(lua_State *L);
|
||||||
|
@ -16,6 +16,7 @@ local os = require("os")
|
|||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
local tp = require("socket.tp")
|
local tp = require("socket.tp")
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
|
local headers = require("socket.headers")
|
||||||
local mime = require("mime")
|
local mime = require("mime")
|
||||||
module("socket.smtp")
|
module("socket.smtp")
|
||||||
|
|
||||||
@ -146,10 +147,11 @@ end
|
|||||||
local send_message
|
local send_message
|
||||||
|
|
||||||
-- yield the headers all at once, it's faster
|
-- yield the headers all at once, it's faster
|
||||||
local function send_headers(headers)
|
local function send_headers(tosend)
|
||||||
|
local canonic = headers.canonic
|
||||||
local h = "\r\n"
|
local h = "\r\n"
|
||||||
for i,v in base.pairs(headers) do
|
for f,v in base.pairs(tosend) do
|
||||||
h = i .. ': ' .. v .. "\r\n" .. h
|
h = (canonic[f] or f) .. ': ' .. v .. "\r\n" .. h
|
||||||
end
|
end
|
||||||
coroutine.yield(h)
|
coroutine.yield(h)
|
||||||
end
|
end
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
* differences. Also, not all *nix platforms behave the same. This module
|
* differences. Also, not all *nix platforms behave the same. This module
|
||||||
* (and the associated usocket.h and wsocket.h) factor these differences and
|
* (and the associated usocket.h and wsocket.h) factor these differences and
|
||||||
* creates a interface compatible with the io.h module.
|
* creates a interface compatible with the io.h module.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
|
12
src/tcp.c
12
src/tcp.c
@ -64,11 +64,11 @@ static luaL_reg tcp[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* socket option handlers */
|
/* socket option handlers */
|
||||||
static t_opt opt[] = {
|
static t_opt optset[] = {
|
||||||
{"keepalive", opt_keepalive},
|
{"keepalive", opt_set_keepalive},
|
||||||
{"reuseaddr", opt_reuseaddr},
|
{"reuseaddr", opt_set_reuseaddr},
|
||||||
{"tcp-nodelay", opt_tcp_nodelay},
|
{"tcp-nodelay", opt_set_tcp_nodelay},
|
||||||
{"linger", opt_linger},
|
{"linger", opt_set_linger},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ static int meth_setstats(lua_State *L) {
|
|||||||
static int meth_setoption(lua_State *L)
|
static int meth_setoption(lua_State *L)
|
||||||
{
|
{
|
||||||
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
|
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
|
||||||
return opt_meth_setoption(L, opt, &tcp->sock);
|
return opt_meth_setoption(L, optset, &tcp->sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
* objects are tcp objects bound to some local address. Client objects are
|
* objects are tcp objects bound to some local address. Client objects are
|
||||||
* tcp objects either connected to some address or returned by the accept
|
* tcp objects either connected to some address or returned by the accept
|
||||||
* method of a server object.
|
* method of a server object.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
* RCS ID: $Id$
|
* RCS ID: $Id$
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
@ -187,13 +189,23 @@ static int timeout_lua_gettime(lua_State *L)
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Sleep for n seconds.
|
* Sleep for n seconds.
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
|
#ifdef _WIN32
|
||||||
int timeout_lua_sleep(lua_State *L)
|
int timeout_lua_sleep(lua_State *L)
|
||||||
{
|
{
|
||||||
double n = luaL_checknumber(L, 1);
|
double n = luaL_checknumber(L, 1);
|
||||||
#ifdef _WIN32
|
if (n < 0.0) n = 0.0;
|
||||||
Sleep((int)(n*1000));
|
if (n < DBL_MAX/1000.0) n *= 1000.0;
|
||||||
|
if (n > INT_MAX) n = INT_MAX;
|
||||||
|
Sleep((int)n);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
int timeout_lua_sleep(lua_State *L)
|
||||||
|
{
|
||||||
|
double n = luaL_checknumber(L, 1);
|
||||||
struct timespec t, r;
|
struct timespec t, r;
|
||||||
|
if (n < 0.0) n = 0.0;
|
||||||
|
if (n > INT_MAX) n = INT_MAX;
|
||||||
t.tv_sec = (int) n;
|
t.tv_sec = (int) n;
|
||||||
n -= t.tv_sec;
|
n -= t.tv_sec;
|
||||||
t.tv_nsec = (int) (n * 1000000000);
|
t.tv_nsec = (int) (n * 1000000000);
|
||||||
@ -202,6 +214,6 @@ int timeout_lua_sleep(lua_State *L)
|
|||||||
t.tv_sec = r.tv_sec;
|
t.tv_sec = r.tv_sec;
|
||||||
t.tv_nsec = r.tv_nsec;
|
t.tv_nsec = r.tv_nsec;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Timeout management functions
|
* Timeout management functions
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ function metat.__index:check(ok)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function metat.__index:command(cmd, arg)
|
function metat.__index:command(cmd, arg)
|
||||||
|
cmd = string.upper(cmd)
|
||||||
if arg then
|
if arg then
|
||||||
return self.c:send(cmd .. " " .. arg.. "\r\n")
|
return self.c:send(cmd .. " " .. arg.. "\r\n")
|
||||||
else
|
else
|
||||||
|
39
src/udp.c
39
src/udp.c
@ -37,6 +37,7 @@ static int meth_setsockname(lua_State *L);
|
|||||||
static int meth_setpeername(lua_State *L);
|
static int meth_setpeername(lua_State *L);
|
||||||
static int meth_close(lua_State *L);
|
static int meth_close(lua_State *L);
|
||||||
static int meth_setoption(lua_State *L);
|
static int meth_setoption(lua_State *L);
|
||||||
|
static int meth_getoption(lua_State *L);
|
||||||
static int meth_settimeout(lua_State *L);
|
static int meth_settimeout(lua_State *L);
|
||||||
static int meth_getfd(lua_State *L);
|
static int meth_getfd(lua_State *L);
|
||||||
static int meth_setfd(lua_State *L);
|
static int meth_setfd(lua_State *L);
|
||||||
@ -57,21 +58,31 @@ static luaL_reg udp[] = {
|
|||||||
{"sendto", meth_sendto},
|
{"sendto", meth_sendto},
|
||||||
{"setfd", meth_setfd},
|
{"setfd", meth_setfd},
|
||||||
{"setoption", meth_setoption},
|
{"setoption", meth_setoption},
|
||||||
|
{"getoption", meth_getoption},
|
||||||
{"setpeername", meth_setpeername},
|
{"setpeername", meth_setpeername},
|
||||||
{"setsockname", meth_setsockname},
|
{"setsockname", meth_setsockname},
|
||||||
{"settimeout", meth_settimeout},
|
{"settimeout", meth_settimeout},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* socket options */
|
/* socket options for setoption */
|
||||||
static t_opt opt[] = {
|
static t_opt optset[] = {
|
||||||
{"dontroute", opt_dontroute},
|
{"dontroute", opt_set_dontroute},
|
||||||
{"broadcast", opt_broadcast},
|
{"broadcast", opt_set_broadcast},
|
||||||
{"reuseaddr", opt_reuseaddr},
|
{"reuseaddr", opt_set_reuseaddr},
|
||||||
{"ip-multicast-ttl", opt_ip_multicast_ttl},
|
{"reuseport", opt_set_reuseport},
|
||||||
{"ip-multicast-loop", opt_ip_multicast_loop},
|
{"ip-multicast-if", opt_set_ip_multicast_if},
|
||||||
{"ip-add-membership", opt_ip_add_membership},
|
{"ip-multicast-ttl", opt_set_ip_multicast_ttl},
|
||||||
{"ip-drop-membership", opt_ip_drop_membersip},
|
{"ip-multicast-loop", opt_set_ip_multicast_loop},
|
||||||
|
{"ip-add-membership", opt_set_ip_add_membership},
|
||||||
|
{"ip-drop-membership", opt_set_ip_drop_membersip},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* socket options for getoption */
|
||||||
|
static t_opt optget[] = {
|
||||||
|
{"ip-multicast-if", opt_get_ip_multicast_if},
|
||||||
|
{"ip-multicast-loop", opt_get_ip_multicast_loop},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -247,7 +258,15 @@ static int meth_getsockname(lua_State *L) {
|
|||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int meth_setoption(lua_State *L) {
|
static int meth_setoption(lua_State *L) {
|
||||||
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
|
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
|
||||||
return opt_meth_setoption(L, opt, &udp->sock);
|
return opt_meth_setoption(L, optset, &udp->sock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*\
|
||||||
|
* Just call option handler
|
||||||
|
\*-------------------------------------------------------------------------*/
|
||||||
|
static int meth_getoption(lua_State *L) {
|
||||||
|
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
|
||||||
|
return opt_meth_getoption(L, optget, &udp->sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
* originally unconnected. They can be "connected" to a given address
|
* originally unconnected. They can be "connected" to a given address
|
||||||
* with a call to the setpeername function. The same function can be used to
|
* with a call to the setpeername function. The same function can be used to
|
||||||
* break the connection.
|
* break the connection.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
|
10
src/unix.c
10
src/unix.c
@ -63,10 +63,10 @@ static luaL_reg un[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* socket option handlers */
|
/* socket option handlers */
|
||||||
static t_opt opt[] = {
|
static t_opt optset[] = {
|
||||||
{"keepalive", opt_keepalive},
|
{"keepalive", opt_set_keepalive},
|
||||||
{"reuseaddr", opt_reuseaddr},
|
{"reuseaddr", opt_set_reuseaddr},
|
||||||
{"linger", opt_linger},
|
{"linger", opt_set_linger},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ static int meth_setstats(lua_State *L) {
|
|||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int meth_setoption(lua_State *L) {
|
static int meth_setoption(lua_State *L) {
|
||||||
p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
|
p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
|
||||||
return opt_meth_setoption(L, opt, &un->sock);
|
return opt_meth_setoption(L, optset, &un->sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
*
|
*
|
||||||
* This module is just an example of how to extend LuaSocket with a new
|
* This module is just an example of how to extend LuaSocket with a new
|
||||||
* domain.
|
* domain.
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
@ -23,6 +21,6 @@ typedef struct t_unix_ {
|
|||||||
} t_unix;
|
} t_unix;
|
||||||
typedef t_unix *p_unix;
|
typedef t_unix *p_unix;
|
||||||
|
|
||||||
int luaopen_socketunix(lua_State *L);
|
int luaopen_socket_unix(lua_State *L);
|
||||||
|
|
||||||
#endif /* UNIX_H */
|
#endif /* UNIX_H */
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Socket compatibilization module for Unix
|
* Socket compatibilization module for Unix
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
@ -32,6 +30,10 @@
|
|||||||
/* TCP options (nagle algorithm disable) */
|
/* TCP options (nagle algorithm disable) */
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
|
|
||||||
|
#ifndef SO_REUSEPORT
|
||||||
|
#define SO_REUSEPORT SO_REUSEADDR
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int t_socket;
|
typedef int t_socket;
|
||||||
typedef t_socket *p_socket;
|
typedef t_socket *p_socket;
|
||||||
|
|
||||||
|
@ -3,14 +3,13 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Socket compatibilization module for Win32
|
* Socket compatibilization module for Win32
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id$
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* WinSock include files
|
* WinSock include files
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <winsock.h>
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
typedef SOCKET t_socket;
|
typedef SOCKET t_socket;
|
||||||
@ -18,4 +17,8 @@ typedef t_socket *p_socket;
|
|||||||
|
|
||||||
#define SOCKET_INVALID (INVALID_SOCKET)
|
#define SOCKET_INVALID (INVALID_SOCKET)
|
||||||
|
|
||||||
|
#ifndef SO_REUSEPORT
|
||||||
|
#define SO_REUSEPORT SO_REUSEADDR
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* WSOCKET_H */
|
#endif /* WSOCKET_H */
|
||||||
|
@ -8,5 +8,7 @@ The files provided are:
|
|||||||
|
|
||||||
To run these tests, just run lua on the server and then on the client.
|
To run these tests, just run lua on the server and then on the client.
|
||||||
|
|
||||||
|
hello.lua -- run to verify if installation worked
|
||||||
|
|
||||||
Good luck,
|
Good luck,
|
||||||
Diego.
|
Diego.
|
||||||
|
3
test/hello.lua
Normal file
3
test/hello.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
require"socket"
|
||||||
|
require"mime"
|
||||||
|
print("Hello from " .. socket._VERSION .. " and " .. mime._VERSION .. "!")
|
@ -420,17 +420,17 @@ print("ok")
|
|||||||
io.write("testing HEAD method: ")
|
io.write("testing HEAD method: ")
|
||||||
local r, c, h = http.request {
|
local r, c, h = http.request {
|
||||||
method = "HEAD",
|
method = "HEAD",
|
||||||
url = "http://www.cs.princeton.edu/~diego/"
|
url = "http://www.tecgraf.puc-rio.br/~diego/"
|
||||||
}
|
}
|
||||||
assert(r and h and (c == 200), c)
|
assert(r and h and (c == 200), c)
|
||||||
print("ok")
|
print("ok")
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
io.write("testing host not found: ")
|
io.write("testing host not found: ")
|
||||||
local c, e = socket.connect("wronghost", 80)
|
local c, e = socket.connect("example.invalid", 80)
|
||||||
local r, re = http.request{url = "http://wronghost/does/not/exist"}
|
local r, re = http.request{url = "http://example.invalid/does/not/exist"}
|
||||||
assert(r == nil and e == re)
|
assert(r == nil and e == re, tostring(r) .. " " .. tostring(re))
|
||||||
r, re = http.request("http://wronghost/does/not/exist")
|
r, re = http.request("http://example.invalid/does/not/exist")
|
||||||
assert(r == nil and e == re)
|
assert(r == nil and e == re)
|
||||||
print("ok")
|
print("ok")
|
||||||
|
|
||||||
|
@ -251,6 +251,28 @@ io.write("testing b64 padding: ")
|
|||||||
print("ok")
|
print("ok")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function test_b64lowlevel()
|
||||||
|
io.write("testing b64 low-level: ")
|
||||||
|
local a, b
|
||||||
|
a, b = mime.b64("", "")
|
||||||
|
assert(a == "" and b == "")
|
||||||
|
a, b = mime.b64(nil, "blablabla")
|
||||||
|
assert(a == nil and b == nil)
|
||||||
|
a, b = mime.b64("", nil)
|
||||||
|
assert(a == nil and b == nil)
|
||||||
|
a, b = mime.unb64("", "")
|
||||||
|
assert(a == "" and b == "")
|
||||||
|
a, b = mime.unb64(nil, "blablabla")
|
||||||
|
assert(a == nil and b == nil)
|
||||||
|
a, b = mime.unb64("", nil)
|
||||||
|
assert(a == nil and b == nil)
|
||||||
|
local binary=string.char(0x00,0x44,0x1D,0x14,0x0F,0xF4,0xDA,0x11,0xA9,0x78,0x00,0x14,0x38,0x50,0x60,0xCE)
|
||||||
|
local encoded = mime.b64(binary)
|
||||||
|
local decoded=mime.unb64(encoded)
|
||||||
|
assert(binary == decoded)
|
||||||
|
print("ok")
|
||||||
|
end
|
||||||
|
|
||||||
local t = socket.gettime()
|
local t = socket.gettime()
|
||||||
|
|
||||||
create_b64test()
|
create_b64test()
|
||||||
@ -260,6 +282,7 @@ decode_b64test()
|
|||||||
compare_b64test()
|
compare_b64test()
|
||||||
cleanup_b64test()
|
cleanup_b64test()
|
||||||
padding_b64test()
|
padding_b64test()
|
||||||
|
test_b64lowlevel()
|
||||||
|
|
||||||
create_qptest()
|
create_qptest()
|
||||||
encode_qptest()
|
encode_qptest()
|
||||||
@ -270,4 +293,5 @@ decode_qptest()
|
|||||||
compare_qptest()
|
compare_qptest()
|
||||||
cleanup_qptest()
|
cleanup_qptest()
|
||||||
|
|
||||||
|
|
||||||
print(string.format("done in %.2fs", socket.gettime() - t))
|
print(string.format("done in %.2fs", socket.gettime() - t))
|
||||||
|
@ -342,6 +342,7 @@ end
|
|||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
function test_selectbugs()
|
function test_selectbugs()
|
||||||
local r, s, e = socket.select(nil, nil, 0.1)
|
local r, s, e = socket.select(nil, nil, 0.1)
|
||||||
|
print(r, s, e)
|
||||||
assert(type(r) == "table" and type(s) == "table" and
|
assert(type(r) == "table" and type(s) == "table" and
|
||||||
(e == "timeout" or e == "error"))
|
(e == "timeout" or e == "error"))
|
||||||
pass("both nil: ok")
|
pass("both nil: ok")
|
||||||
@ -352,10 +353,23 @@ function test_selectbugs()
|
|||||||
(e == "timeout" or e == "error"))
|
(e == "timeout" or e == "error"))
|
||||||
pass("closed sockets: ok")
|
pass("closed sockets: ok")
|
||||||
e = pcall(socket.select, "wrong", 1, 0.1)
|
e = pcall(socket.select, "wrong", 1, 0.1)
|
||||||
assert(e == false)
|
assert(e == false, tostring(e))
|
||||||
e = pcall(socket.select, {}, 1, 0.1)
|
e = pcall(socket.select, {}, 1, 0.1)
|
||||||
assert(e == false)
|
assert(e == false, tostring(e))
|
||||||
pass("invalid input: ok")
|
pass("invalid input: ok")
|
||||||
|
local toomany = {}
|
||||||
|
for i = 1, socket._SETSIZE+1 do
|
||||||
|
toomany[#toomany+1] = socket.udp()
|
||||||
|
end
|
||||||
|
if #toomany > socket._SETSIZE then
|
||||||
|
local e = pcall(socket.select, toomany, nil, 0.1)
|
||||||
|
assert(e == false, tostring(e))
|
||||||
|
pass("too many sockets (" .. #toomany .. "): ok")
|
||||||
|
else
|
||||||
|
pass("unable to create enough sockets (max was "..#toomany..")")
|
||||||
|
pass("try using ulimit")
|
||||||
|
end
|
||||||
|
for _, c in ipairs(toomany) do c:close() end
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
@ -555,6 +569,25 @@ function test_readafterclose()
|
|||||||
print("ok")
|
print("ok")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
function test_writeafterclose()
|
||||||
|
local str = 'little string'
|
||||||
|
reconnect()
|
||||||
|
remote (string.format ([[
|
||||||
|
data:close()
|
||||||
|
data = nil
|
||||||
|
]]))
|
||||||
|
local sent, err, errsent
|
||||||
|
while not err do
|
||||||
|
sent, err, errsent, time = data:send(str)
|
||||||
|
end
|
||||||
|
print(sent, err, errsent, time)
|
||||||
|
print("ok")
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
--test_writeafterclose()
|
||||||
|
|
||||||
test("method registration")
|
test("method registration")
|
||||||
test_methods(socket.tcp(), {
|
test_methods(socket.tcp(), {
|
||||||
"accept",
|
"accept",
|
||||||
@ -596,12 +629,12 @@ test_methods(socket.udp(), {
|
|||||||
"settimeout"
|
"settimeout"
|
||||||
})
|
})
|
||||||
|
|
||||||
test("testing read after close")
|
|
||||||
test_readafterclose()
|
|
||||||
|
|
||||||
test("select function")
|
test("select function")
|
||||||
test_selectbugs()
|
test_selectbugs()
|
||||||
|
|
||||||
|
test("testing read after close")
|
||||||
|
test_readafterclose()
|
||||||
|
|
||||||
test("connect function")
|
test("connect function")
|
||||||
connect_timeout()
|
connect_timeout()
|
||||||
empty_connect()
|
empty_connect()
|
||||||
|
@ -32,6 +32,8 @@ r, e = smtp.send{
|
|||||||
port = 2525
|
port = 2525
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print(r, e)
|
||||||
|
|
||||||
-- creates a source to send a message with two parts. The first part is
|
-- creates a source to send a message with two parts. The first part is
|
||||||
-- plain text, the second part is a PNG image, encoded as base64.
|
-- plain text, the second part is a PNG image, encoded as base64.
|
||||||
source = smtp.message{
|
source = smtp.message{
|
||||||
|
Loading…
Reference in New Issue
Block a user