diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2009-05-27 09:31:38 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2009-05-27 09:31:38 +0000 |
| commit | bce60be30fe8e9c1b0eb33128c23c93d7bca5303 (patch) | |
| tree | 3927343c777fcb7764a0f2f89754a0ceab141c21 | |
| parent | d1a72435d5bd3528f3c334cd4d1da16dcead47bf (diff) | |
| download | luasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.tar.gz luasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.tar.bz2 luasocket-bce60be30fe8e9c1b0eb33128c23c93d7bca5303.zip | |
Decent makefiles!
58 files changed, 850 insertions, 544 deletions
| @@ -2,13 +2,19 @@ What's New | |||
| 2 | 2 | ||
| 3 | This is just a bug-fix/update release. | 3 | This is just a bug-fix/update release. |
| 4 | 4 | ||
| 5 | * Improved: http.request() now supports deprecated HTTP/0.9 | 5 | * Fixed: manual links to home.html changed to index.html (Robert Hahn) |
| 6 | servers (Florian Berger) | 6 | * Fixed: mime.unb64() returns empty string on results that start |
| 7 | * Fixed: could return "timedout" instead of "timeout" (Leo Leo) | 7 | with a null character (Robert Raschke) |
| 8 | * Fixed: crash when reading '*a' on closed socket (Paul Ducklin); | 8 | * Fixed: HTTP now automatically redirecting on 303 and 307 (Jonathan Gray) |
| 9 | * Fixed: return values are consistent when reading from closed sockets; | 9 | * Fixed: sleep(-1) could sleep forever wasting CPU. Now it |
| 10 | * Fixed: case sensitivity in headers of multipart messages in | 10 | returns immediately (MPB); |
| 11 | smtp.message() (Graham Henstridge); | 11 | |
| 12 | * Fixed a couple instances of error() being called instead of base.error(). These would cause an error when an error was reported. :) (Ketmar Dark); | 12 | * Improved: FTP commands are now sent in upper case to |
| 13 | * Fixed: test script now uses pairs() iterator instead of the old | 13 | help buggy servers (Anders Eurenius) |
| 14 | Lua syntax (Robert Dodier). | 14 | * Improved: known headers now sent in canonic |
| 15 | capitalization to help buggy servers (Joseph Stewart); | ||
| 16 | * Improved: Clarified tcp:receive() in the manual (MPB); | ||
| 17 | |||
| 18 | * Fixed: multicast didn't work on Windows (Herbert Leuwer, Adrian Sietsma) | ||
| 19 | * Fixed: select() reports an error when called with more | ||
| 20 | sockets than FD_SETSIZE (Lorenzo Leonini) | ||
| @@ -1,60 +0,0 @@ | |||
| 1 | #------ | ||
| 2 | # LuaSocket makefile configuration | ||
| 3 | # | ||
| 4 | |||
| 5 | #------ | ||
| 6 | # Output file names | ||
| 7 | # | ||
| 8 | EXT=so | ||
| 9 | SOCKET_V=2.0.2 | ||
| 10 | MIME_V=1.0.2 | ||
| 11 | SOCKET_SO=socket.$(EXT).$(SOCKET_V) | ||
| 12 | MIME_SO=mime.$(EXT).$(MIME_V) | ||
| 13 | UNIX_SO=unix.$(EXT) | ||
| 14 | |||
| 15 | #------ | ||
| 16 | # Lua includes and libraries | ||
| 17 | # | ||
| 18 | #LUAINC=-I/usr/local/include/lua50 | ||
| 19 | #LUAINC=-I/usr/local/include/lua5.1 | ||
| 20 | #LUAINC=-Ilua-5.1.1/src | ||
| 21 | |||
| 22 | #------ | ||
| 23 | # Compat-5.1 directory | ||
| 24 | # | ||
| 25 | #COMPAT=compat-5.1r5 | ||
| 26 | |||
| 27 | #------ | ||
| 28 | # Top of your Lua installation | ||
| 29 | # Relative paths will be inside the src tree | ||
| 30 | # | ||
| 31 | #INSTALL_TOP_SHARE=/usr/local/share/lua/5.0 | ||
| 32 | #INSTALL_TOP_LIB=/usr/local/lib/lua/5.0 | ||
| 33 | INSTALL_TOP_SHARE=/usr/local/share/lua/5.1 | ||
| 34 | INSTALL_TOP_LIB=/usr/local/lib/lua/5.1 | ||
| 35 | |||
| 36 | INSTALL_DATA=cp | ||
| 37 | INSTALL_EXEC=cp | ||
| 38 | |||
| 39 | #------ | ||
| 40 | # Compiler and linker settings | ||
| 41 | # for Mac OS X | ||
| 42 | # | ||
| 43 | #CC=gcc | ||
| 44 | #DEF= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN | ||
| 45 | #CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common | ||
| 46 | #LDFLAGS=-bundle -undefined dynamic_lookup | ||
| 47 | #LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc | ||
| 48 | |||
| 49 | #------ | ||
| 50 | # Compiler and linker settings | ||
| 51 | # for Linux | ||
| 52 | CC=gcc | ||
| 53 | DEF=-DLUASOCKET_DEBUG | ||
| 54 | CFLAGS= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic | ||
| 55 | LDFLAGS=-O -shared -fpic | ||
| 56 | LD=gcc | ||
| 57 | |||
| 58 | #------ | ||
| 59 | # End of makefile configuration | ||
| 60 | # | ||
diff --git a/doc/dns.html b/doc/dns.html index f4c3b07..a38e368 100644 --- a/doc/dns.html +++ b/doc/dns.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| @@ -113,8 +113,8 @@ message. | |||
| 113 | <hr> | 113 | <hr> |
| 114 | <center> | 114 | <center> |
| 115 | <p class=bar> | 115 | <p class=bar> |
| 116 | <a href="home.html">home</a> · | 116 | <a href="index.html">home</a> · |
| 117 | <a href="home.html#down">download</a> · | 117 | <a href="index.html#down">download</a> · |
| 118 | <a href="installation.html">installation</a> · | 118 | <a href="installation.html">installation</a> · |
| 119 | <a href="introduction.html">introduction</a> · | 119 | <a href="introduction.html">introduction</a> · |
| 120 | <a href="reference.html">reference</a> | 120 | <a href="reference.html">reference</a> |
diff --git a/doc/ftp.html b/doc/ftp.html index 9884f31..1f6335e 100644 --- a/doc/ftp.html +++ b/doc/ftp.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| @@ -270,8 +270,8 @@ f, e = ftp.put{ | |||
| 270 | <hr> | 270 | <hr> |
| 271 | <center> | 271 | <center> |
| 272 | <p class=bar> | 272 | <p class=bar> |
| 273 | <a href="home.html">home</a> · | 273 | <a href="index.html">home</a> · |
| 274 | <a href="home.html#download">download</a> · | 274 | <a href="index.html#download">download</a> · |
| 275 | <a href="installation.html">installation</a> · | 275 | <a href="installation.html">installation</a> · |
| 276 | <a href="introduction.html">introduction</a> · | 276 | <a href="introduction.html">introduction</a> · |
| 277 | <a href="reference.html">reference</a> | 277 | <a href="reference.html">reference</a> |
diff --git a/doc/http.html b/doc/http.html index 0acac13..a274aef 100644 --- a/doc/http.html +++ b/doc/http.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="introduction.html">introduction</a> · | 29 | <a href="introduction.html">introduction</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| @@ -314,8 +314,8 @@ r, c = http.request { | |||
| 314 | <hr> | 314 | <hr> |
| 315 | <center> | 315 | <center> |
| 316 | <p class=bar> | 316 | <p class=bar> |
| 317 | <a href="home.html">home</a> · | 317 | <a href="index.html">home</a> · |
| 318 | <a href="home.html#download">download</a> · | 318 | <a href="index.html#download">download</a> · |
| 319 | <a href="installation.html">installation</a> · | 319 | <a href="installation.html">installation</a> · |
| 320 | <a href="introduction.html">introduction</a> · | 320 | <a href="introduction.html">introduction</a> · |
| 321 | <a href="reference.html">reference</a> | 321 | <a href="reference.html">reference</a> |
diff --git a/doc/index.html b/doc/index.html index 57a7907..5b54c59 100644 --- a/doc/index.html +++ b/doc/index.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| @@ -87,7 +87,7 @@ Author: <A href="http://www.cs.princeton.edu/~diego">Diego Nehab</a> | |||
| 87 | <h2 id=download>Download</h2> | 87 | <h2 id=download>Download</h2> |
| 88 | 88 | ||
| 89 | <p> | 89 | <p> |
| 90 | LuaSocket version 2.0.2 is now available for download! It is | 90 | LuaSocket version 2.0.3 is now available for download! It is |
| 91 | compatible with Lua 5.1, and has | 91 | compatible with Lua 5.1, and has |
| 92 | been tested on Windows XP, Linux, and Mac OS X. Chances | 92 | been tested on Windows XP, Linux, and Mac OS X. Chances |
| 93 | are it works well on most UNIX distributions and Windows flavors. | 93 | 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. | |||
| 118 | <h2 id=thanks>Special thanks</h2> | 118 | <h2 id=thanks>Special thanks</h2> |
| 119 | 119 | ||
| 120 | <p> | 120 | <p> |
| 121 | Throughout LuaSocket's history, many people gave suggestions that helped | 121 | Throughout LuaSocket's history, many people gave suggestions |
| 122 | improve it. For that, I thank the Lua community. | 122 | that helped improve it. For that, I thank the Lua community. |
| 123 | Special thanks go to | 123 | Special thanks go to David Burgess, who has helped push the |
| 124 | David Burgess, who has helped push the library to a new level of quality and | 124 | library to a new level of quality and from whom I have |
| 125 | from whom I have learned a lot of stuff that doesn't show up in RFCs. | 125 | learned a lot of stuff that doesn't show up in RFCs. |
| 126 | Special thanks also to Carlos Cassino, who played a big part in the | 126 | Special thanks also to Carlos Cassino, who played a big part |
| 127 | extensible design seen in the C core of LuaSocket 2.0. Mike Pall | 127 | in the extensible design seen in the C core of LuaSocket |
| 128 | has been helping a lot too! Thanks to you all! | 128 | 2.0. Mike Pall has been helping a lot too! Thanks to you |
| 129 | all! | ||
| 129 | </p> | 130 | </p> |
| 130 | 131 | ||
| 131 | <!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 132 | <!-- whatsnew +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -133,44 +134,26 @@ has been helping a lot too! Thanks to you all! | |||
| 133 | <h2 id=new>What's New</h2> | 134 | <h2 id=new>What's New</h2> |
| 134 | 135 | ||
| 135 | <p> | 136 | <p> |
| 136 | 2.0.2 is just a bug-fix/update release. | 137 | 2.0.3 is just a bug-fix/update release. |
| 137 | </p> | 138 | </p> |
| 138 | 139 | ||
| 139 | <ul> | 140 | <ul> |
| 140 | <li> Improved: http.request() now supports deprecated | 141 | <li> Fixed: multicast didn't work on Windows, or anywhere |
| 141 | HTTP/0.9 servers (Florian Berger); | 142 | else for that matter (Herbert Leuwer, Adrian Sietsma) |
| 142 | <li> Fixed: could return "timedout" instead of "timeout" (Leo Leo); | 143 | <li> Fixed: select() now reports an error when called with more |
| 143 | <li> Fixed: crash when reading '*a' on closed socket (Paul Ducklin); | 144 | sockets than FD_SETSIZE (Lorenzo Leonini) |
| 144 | <li> Fixed: return values are consistent when reading from closed sockets; | 145 | <li> Fixed: manual links to home.html changed to index.html (Robert Hahn) |
| 145 | <li> Fixed: case sensitivity in headers of multipart | 146 | <li> Fixed: mime.unb64() would return an empty string on results that started |
| 146 | messages in smtp.message() (Graham Henstridge); | 147 | with a null character (Robert Raschke) |
| 147 | <li> Fixed a couple instances of error() being called instead of | 148 | <li> Fixed: HTTP now automatically redirects on 303 and 307 (Jonathan Gray) |
| 148 | base.error(). These would cause an error when an error was | 149 | <li> Fixed: calling sleep() with negative numbers could |
| 149 | reported :) (Ketmar Dark); | 150 | block forever, wasting CPU. Now it returns immediately (MPB); |
| 150 | <li> Fixed: test script now uses pairs() iterator instead | 151 | <li> Improved: FTP commands are now sent in upper case to |
| 151 | of the old Lua syntax (Robert Dodier). | 152 | help buggy servers (Anders Eurenius) |
| 152 | </ul> | 153 | <li> Improved: known headers now sent in canonic |
| 153 | 154 | capitalization to help buggy servers (Joseph Stewart); | |
| 154 | <p> | 155 | <li> Improved: Clarified tcp:receive() in the manual (MPB); |
| 155 | 2.0.1 is just a bug-fix/update release. | 156 | <li> Improved: Decent makefiles (LHF). |
| 156 | </p> | ||
| 157 | |||
| 158 | <ul> | ||
| 159 | <li> Updated: now using <tt>compat-5.1r5</tt>; | ||
| 160 | <li> Improved: <tt>http.request</tt> is more robust to | ||
| 161 | malformed URLs (Adrian Sietsma); | ||
| 162 | <li> Improved: the simple <tt>http.request</tt> interface sends a | ||
| 163 | "<tt>Content-type: application/x-www-form-urlencoded</tt>" | ||
| 164 | header (William Trenker); | ||
| 165 | <li> Improved: <tt>http.request</tt> is robust to evil | ||
| 166 | servers that send inappropriate 100-continue messages | ||
| 167 | (David Burgess); | ||
| 168 | <li> Fixed: <tt>http.request</tt> was using the old host header during | ||
| 169 | redirects (Florian Berger); | ||
| 170 | <li> Fixed: sample <tt>unix.c</tt> had fallen through the | ||
| 171 | cracks during development (Matthew Percival); | ||
| 172 | <li> Fixed: error code was not being propagated correctly in | ||
| 173 | ftp.lua (David Burgess). | ||
| 174 | </ul> | 157 | </ul> |
| 175 | 158 | ||
| 176 | <!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 159 | <!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -190,7 +173,7 @@ still available for those that have compatibility issues. | |||
| 190 | <hr> | 173 | <hr> |
| 191 | <center> | 174 | <center> |
| 192 | <p class=bar> | 175 | <p class=bar> |
| 193 | <a href="home.html#download">download</a> · | 176 | <a href="index.html#download">download</a> · |
| 194 | <a href="installation.html">installation</a> · | 177 | <a href="installation.html">installation</a> · |
| 195 | <a href="introduction.html">introduction</a> · | 178 | <a href="introduction.html">introduction</a> · |
| 196 | <a href="reference.html">reference</a> | 179 | <a href="reference.html">reference</a> |
diff --git a/doc/installation.html b/doc/installation.html index 0288f4a..bb9a5bb 100644 --- a/doc/installation.html +++ b/doc/installation.html | |||
| @@ -25,8 +25,8 @@ Installation"> | |||
| 25 | </td></tr> | 25 | </td></tr> |
| 26 | </table> | 26 | </table> |
| 27 | <p class=bar> | 27 | <p class=bar> |
| 28 | <a href="home.html">home</a> · | 28 | <a href="index.html">home</a> · |
| 29 | <a href="home.html#download">download</a> · | 29 | <a href="index.html#download">download</a> · |
| 30 | <a href="installation.html">installation</a> · | 30 | <a href="installation.html">installation</a> · |
| 31 | <a href="introduction.html">introduction</a> · | 31 | <a href="introduction.html">introduction</a> · |
| 32 | <a href="reference.html">reference</a> | 32 | <a href="reference.html">reference</a> |
| @@ -144,8 +144,8 @@ Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio | |||
| 144 | <hr> | 144 | <hr> |
| 145 | <center> | 145 | <center> |
| 146 | <p class=bar> | 146 | <p class=bar> |
| 147 | <a href="home.html">home</a> · | 147 | <a href="index.html">home</a> · |
| 148 | <a href="home.html#down">download</a> · | 148 | <a href="index.html#down">download</a> · |
| 149 | <a href="installation.html">installation</a> · | 149 | <a href="installation.html">installation</a> · |
| 150 | <a href="introduction.html">introduction</a> · | 150 | <a href="introduction.html">introduction</a> · |
| 151 | <a href="reference.html">reference</a> | 151 | <a href="reference.html">reference</a> |
diff --git a/doc/introduction.html b/doc/introduction.html index eff6367..fd22f48 100644 --- a/doc/introduction.html +++ b/doc/introduction.html | |||
| @@ -25,8 +25,8 @@ Library, Support"> | |||
| 25 | </td></tr> | 25 | </td></tr> |
| 26 | </table> | 26 | </table> |
| 27 | <p class=bar> | 27 | <p class=bar> |
| 28 | <a href="home.html">home</a> · | 28 | <a href="index.html">home</a> · |
| 29 | <a href="home.html#download">download</a> · | 29 | <a href="index.html#download">download</a> · |
| 30 | <a href="installation.html">installation</a> · | 30 | <a href="installation.html">installation</a> · |
| 31 | <a href="introduction.html">introduction</a> · | 31 | <a href="introduction.html">introduction</a> · |
| 32 | <a href="reference.html">reference</a> | 32 | <a href="reference.html">reference</a> |
| @@ -314,8 +314,8 @@ and many others are covered by the <a href=reference.html>reference manual</a>. | |||
| 314 | <hr> | 314 | <hr> |
| 315 | <center> | 315 | <center> |
| 316 | <p class=bar> | 316 | <p class=bar> |
| 317 | <a href="home.html">home</a> · | 317 | <a href="index.html">home</a> · |
| 318 | <a href="home.html#down">download</a> · | 318 | <a href="index.html#down">download</a> · |
| 319 | <a href="installation.html">installation</a> · | 319 | <a href="installation.html">installation</a> · |
| 320 | <a href="introduction.html">introduction</a> · | 320 | <a href="introduction.html">introduction</a> · |
| 321 | <a href="reference.html">reference</a> | 321 | <a href="reference.html">reference</a> |
diff --git a/doc/ltn12.html b/doc/ltn12.html index 0013950..7e2f49a 100644 --- a/doc/ltn12.html +++ b/doc/ltn12.html | |||
| @@ -25,8 +25,8 @@ Pump, Support, Library"> | |||
| 25 | </td></tr> | 25 | </td></tr> |
| 26 | </table> | 26 | </table> |
| 27 | <p class=bar> | 27 | <p class=bar> |
| 28 | <a href="home.html">home</a> · | 28 | <a href="index.html">home</a> · |
| 29 | <a href="home.html#download">download</a> · | 29 | <a href="index.html#download">download</a> · |
| 30 | <a href="installation.html">installation</a> · | 30 | <a href="installation.html">installation</a> · |
| 31 | <a href="introduction.html">introduction</a> · | 31 | <a href="introduction.html">introduction</a> · |
| 32 | <a href="reference.html">reference</a> | 32 | <a href="reference.html">reference</a> |
| @@ -411,8 +411,8 @@ Creates and returns a source that produces the contents of a | |||
| 411 | <hr> | 411 | <hr> |
| 412 | <center> | 412 | <center> |
| 413 | <p class=bar> | 413 | <p class=bar> |
| 414 | <a href="home.html">home</a> · | 414 | <a href="index.html">home</a> · |
| 415 | <a href="home.html#down">download</a> · | 415 | <a href="index.html#down">download</a> · |
| 416 | <a href="installation.html">installation</a> · | 416 | <a href="installation.html">installation</a> · |
| 417 | <a href="introduction.html">introduction</a> · | 417 | <a href="introduction.html">introduction</a> · |
| 418 | <a href="reference.html">reference</a> | 418 | <a href="reference.html">reference</a> |
diff --git a/doc/mime.html b/doc/mime.html index d7faf52..9844744 100644 --- a/doc/mime.html +++ b/doc/mime.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| @@ -457,8 +457,8 @@ marker. | |||
| 457 | <hr> | 457 | <hr> |
| 458 | <center> | 458 | <center> |
| 459 | <p class=bar> | 459 | <p class=bar> |
| 460 | <a href="home.html">home</a> · | 460 | <a href="index.html">home</a> · |
| 461 | <a href="home.html#down">download</a> · | 461 | <a href="index.html#down">download</a> · |
| 462 | <a href="installation.html">installation</a> · | 462 | <a href="installation.html">installation</a> · |
| 463 | <a href="introduction.html">introduction</a> · | 463 | <a href="introduction.html">introduction</a> · |
| 464 | <a href="reference.html">reference</a> | 464 | <a href="reference.html">reference</a> |
diff --git a/doc/reference.html b/doc/reference.html index b329f57..31f6ecf 100644 --- a/doc/reference.html +++ b/doc/reference.html | |||
| @@ -25,8 +25,8 @@ Support, Manual"> | |||
| 25 | </td></tr> | 25 | </td></tr> |
| 26 | </table> | 26 | </table> |
| 27 | <p class=bar> | 27 | <p class=bar> |
| 28 | <a href="home.html">home</a> · | 28 | <a href="index.html">home</a> · |
| 29 | <a href="home.html#download">download</a> · | 29 | <a href="index.html#download">download</a> · |
| 30 | <a href="installation.html">installation</a> · | 30 | <a href="installation.html">installation</a> · |
| 31 | <a href="introduction.html">introduction</a> · | 31 | <a href="introduction.html">introduction</a> · |
| 32 | <a href="reference.html">reference</a> | 32 | <a href="reference.html">reference</a> |
| @@ -151,6 +151,7 @@ Support, Manual"> | |||
| 151 | <a href="socket.html#sink">sink</a>, | 151 | <a href="socket.html#sink">sink</a>, |
| 152 | <a href="socket.html#skip">skip</a>, | 152 | <a href="socket.html#skip">skip</a>, |
| 153 | <a href="socket.html#sleep">sleep</a>, | 153 | <a href="socket.html#sleep">sleep</a>, |
| 154 | <a href="socket.html#setsize">_SETSIZE</a>, | ||
| 154 | <a href="socket.html#source">source</a>, | 155 | <a href="socket.html#source">source</a>, |
| 155 | <a href="tcp.html#tcp">tcp</a>, | 156 | <a href="tcp.html#tcp">tcp</a>, |
| 156 | <a href="socket.html#try">try</a>, | 157 | <a href="socket.html#try">try</a>, |
| @@ -220,8 +221,8 @@ Support, Manual"> | |||
| 220 | <hr> | 221 | <hr> |
| 221 | <center> | 222 | <center> |
| 222 | <p class=bar> | 223 | <p class=bar> |
| 223 | <a href="home.html">home</a> · | 224 | <a href="index.html">home</a> · |
| 224 | <a href="home.html#down">download</a> · | 225 | <a href="index.html#down">download</a> · |
| 225 | <a href="installation.html">installation</a> · | 226 | <a href="installation.html">installation</a> · |
| 226 | <a href="introduction.html">introduction</a> · | 227 | <a href="introduction.html">introduction</a> · |
| 227 | <a href="reference.html">reference</a> | 228 | <a href="reference.html">reference</a> |
diff --git a/doc/smtp.html b/doc/smtp.html index 27dd473..980b821 100644 --- a/doc/smtp.html +++ b/doc/smtp.html | |||
| @@ -25,8 +25,8 @@ Library, Support"> | |||
| 25 | </td></tr> | 25 | </td></tr> |
| 26 | </table> | 26 | </table> |
| 27 | <p class=bar> | 27 | <p class=bar> |
| 28 | <a href="home.html">home</a> · | 28 | <a href="index.html">home</a> · |
| 29 | <a href="home.html#download">download</a> · | 29 | <a href="index.html#download">download</a> · |
| 30 | <a href="installation.html">installation</a> · | 30 | <a href="installation.html">installation</a> · |
| 31 | <a href="introduction.html">introduction</a> · | 31 | <a href="introduction.html">introduction</a> · |
| 32 | <a href="reference.html">reference</a> | 32 | <a href="reference.html">reference</a> |
| @@ -398,8 +398,8 @@ r, e = smtp.send{ | |||
| 398 | <hr> | 398 | <hr> |
| 399 | <center> | 399 | <center> |
| 400 | <p class=bar> | 400 | <p class=bar> |
| 401 | <a href="home.html">home</a> · | 401 | <a href="index.html">home</a> · |
| 402 | <a href="home.html#down">download</a> · | 402 | <a href="index.html#down">download</a> · |
| 403 | <a href="installation.html">installation</a> · | 403 | <a href="installation.html">installation</a> · |
| 404 | <a href="introduction.html">introduction</a> · | 404 | <a href="introduction.html">introduction</a> · |
| 405 | <a href="reference.html">reference</a> | 405 | <a href="reference.html">reference</a> |
diff --git a/doc/socket.html b/doc/socket.html index f096e4b..490ab50 100644 --- a/doc/socket.html +++ b/doc/socket.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <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 | |||
| 94 | with debug support. | 94 | with debug support. |
| 95 | </p> | 95 | </p> |
| 96 | 96 | ||
| 97 | <!-- get time +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 98 | |||
| 99 | <p class=name id=gettime> | ||
| 100 | socket.<b>gettime()</b> | ||
| 101 | </p> | ||
| 102 | |||
| 103 | <p class=description> | ||
| 104 | Returns the time in seconds, relative to the origin of the | ||
| 105 | universe. You should subtract the values returned by this function | ||
| 106 | to get meaningful values. | ||
| 107 | </p> | ||
| 108 | |||
| 109 | <pre class=example> | ||
| 110 | t = socket.gettime() | ||
| 111 | -- do stuff | ||
| 112 | print(socket.gettime() - t .. " seconds elapsed") | ||
| 113 | </pre> | ||
| 114 | |||
| 97 | <!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 115 | <!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 98 | 116 | ||
| 99 | <p class=name id=newtry> | 117 | <p class=name id=newtry> |
| @@ -200,6 +218,15 @@ changed status. | |||
| 200 | </p> | 218 | </p> |
| 201 | 219 | ||
| 202 | <p class=note> | 220 | <p class=note> |
| 221 | <b>Note: </b>: <tt>select</tt> can monitor a limited number | ||
| 222 | of sockets, as defined by the constant <tt>socket._SETSIZE</tt>. This | ||
| 223 | number may be as high as 1024 or as low as 64 by default, | ||
| 224 | depending on the system. It is usually possible to change this | ||
| 225 | at compile time. Invoking <tt>select</tt> with a larger | ||
| 226 | number of sockets will raise an error. | ||
| 227 | </p> | ||
| 228 | |||
| 229 | <p class=note> | ||
| 203 | <b>Important note</b>: a known bug in WinSock causes <tt>select</tt> to fail | 230 | <b>Important note</b>: a known bug in WinSock causes <tt>select</tt> to fail |
| 204 | on non-blocking TCP sockets. The function may return a socket as | 231 | on non-blocking TCP sockets. The function may return a socket as |
| 205 | writable even though the socket is <em>not</em> ready for sending. | 232 | writable even though the socket is <em>not</em> ready for sending. |
| @@ -288,8 +315,8 @@ Freezes the program execution during a given amount of time. | |||
| 288 | </p> | 315 | </p> |
| 289 | 316 | ||
| 290 | <p class=parameters> | 317 | <p class=parameters> |
| 291 | <tt>Time</tt> is the number of seconds to sleep for. | 318 | <tt>Time</tt> is the number of seconds to sleep for. If |
| 292 | The function truncates <tt>time</tt> down to the nearest integer. | 319 | <tt>time</tt> is negative, the function returns immediately. |
| 293 | </p> | 320 | </p> |
| 294 | 321 | ||
| 295 | <!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 322 | <!-- source +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -324,24 +351,17 @@ side closes the connection. | |||
| 324 | The function returns a source with the appropriate behavior. | 351 | The function returns a source with the appropriate behavior. |
| 325 | </p> | 352 | </p> |
| 326 | 353 | ||
| 327 | <!-- time ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 354 | <!-- setsize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 328 | 355 | ||
| 329 | <p class=name id=gettime> | 356 | <p class=name id=setsize> |
| 330 | socket.<b>gettime()</b> | 357 | socket.<b>_SETSIZE</b> |
| 331 | </p> | 358 | </p> |
| 332 | 359 | ||
| 333 | <p class=description> | 360 | <p class=description> |
| 334 | Returns the time in seconds, relative to the origin of the | 361 | The maximum number of sockets that the <a |
| 335 | universe. You should subtract the values returned by this function | 362 | href=#select><tt>select</tt></a> function can handle. |
| 336 | to get meaningful values. | ||
| 337 | </p> | 363 | </p> |
| 338 | 364 | ||
| 339 | <pre class=example> | ||
| 340 | t = socket.gettime() | ||
| 341 | -- do stuff | ||
| 342 | print(socket.gettime() - t .. " seconds elapsed") | ||
| 343 | </pre> | ||
| 344 | |||
| 345 | <!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 365 | <!-- try ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 346 | 366 | ||
| 347 | <p class=name id=try> | 367 | <p class=name id=try> |
| @@ -386,8 +406,8 @@ This constant has a string describing the current LuaSocket version. | |||
| 386 | <hr> | 406 | <hr> |
| 387 | <center> | 407 | <center> |
| 388 | <p class=bar> | 408 | <p class=bar> |
| 389 | <a href="home.html">home</a> · | 409 | <a href="index.html">home</a> · |
| 390 | <a href="home.html#down">download</a> · | 410 | <a href="index.html#down">download</a> · |
| 391 | <a href="installation.html">installation</a> · | 411 | <a href="installation.html">installation</a> · |
| 392 | <a href="introduction.html">introduction</a> · | 412 | <a href="introduction.html">introduction</a> · |
| 393 | <a href="reference.html">reference</a> | 413 | <a href="reference.html">reference</a> |
diff --git a/doc/tcp.html b/doc/tcp.html index a16a09e..d1d2154 100644 --- a/doc/tcp.html +++ b/doc/tcp.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| @@ -297,12 +297,12 @@ of any received data before return. | |||
| 297 | 297 | ||
| 298 | <p class=return> | 298 | <p class=return> |
| 299 | If successful, the method returns the received pattern. In case of error, | 299 | If successful, the method returns the received pattern. In case of error, |
| 300 | the method returns <tt><b>nil</b></tt> followed by an error message which | 300 | the method returns <tt><b>nil</b></tt> followed by an error |
| 301 | can be the string '<tt>closed</tt>' in case the connection was | 301 | message, followed by a (possibly empty) string containing |
| 302 | the partial that was received. The error message can be | ||
| 303 | the string '<tt>closed</tt>' in case the connection was | ||
| 302 | closed before the transmission was completed or the string | 304 | closed before the transmission was completed or the string |
| 303 | '<tt>timeout</tt>' in case there was a timeout during the operation. | 305 | '<tt>timeout</tt>' in case there was a timeout during the operation. |
| 304 | Also, after the error message, the function returns the partial result of | ||
| 305 | the transmission. | ||
| 306 | </p> | 306 | </p> |
| 307 | 307 | ||
| 308 | <p class=note> | 308 | <p class=note> |
| @@ -514,8 +514,8 @@ This function returns 1. | |||
| 514 | <hr> | 514 | <hr> |
| 515 | <center> | 515 | <center> |
| 516 | <p class=bar> | 516 | <p class=bar> |
| 517 | <a href="home.html">home</a> · | 517 | <a href="index.html">home</a> · |
| 518 | <a href="home.html#down">download</a> · | 518 | <a href="index.html#down">download</a> · |
| 519 | <a href="installation.html">installation</a> · | 519 | <a href="installation.html">installation</a> · |
| 520 | <a href="introduction.html">introduction</a> · | 520 | <a href="introduction.html">introduction</a> · |
| 521 | <a href="reference.html">reference</a> | 521 | <a href="reference.html">reference</a> |
diff --git a/doc/udp.html b/doc/udp.html index 688649d..eca881d 100644 --- a/doc/udp.html +++ b/doc/udp.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| @@ -397,8 +397,8 @@ imperative nature obvious. | |||
| 397 | <hr> | 397 | <hr> |
| 398 | <center> | 398 | <center> |
| 399 | <p class=bar> | 399 | <p class=bar> |
| 400 | <a href="home.html">home</a> · | 400 | <a href="index.html">home</a> · |
| 401 | <a href="home.html#download">download</a> · | 401 | <a href="index.html#download">download</a> · |
| 402 | <a href="installation.html">installation</a> · | 402 | <a href="installation.html">installation</a> · |
| 403 | <a href="introduction.html">introduction</a> · | 403 | <a href="introduction.html">introduction</a> · |
| 404 | <a href="reference.html">reference</a> | 404 | <a href="reference.html">reference</a> |
diff --git a/doc/url.html b/doc/url.html index e87126f..303e05d 100644 --- a/doc/url.html +++ b/doc/url.html | |||
| @@ -24,8 +24,8 @@ | |||
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class=bar> |
| 27 | <a href="home.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="home.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| @@ -310,8 +310,8 @@ The function returns the decoded string. | |||
| 310 | <hr> | 310 | <hr> |
| 311 | <center> | 311 | <center> |
| 312 | <p class=bar> | 312 | <p class=bar> |
| 313 | <a href="home.html">home</a> · | 313 | <a href="index.html">home</a> · |
| 314 | <a href="home.html#down">download</a> · | 314 | <a href="index.html#down">download</a> · |
| 315 | <a href="installation.html">installation</a> · | 315 | <a href="installation.html">installation</a> · |
| 316 | <a href="introduction.html">introduction</a> · | 316 | <a href="introduction.html">introduction</a> · |
| 317 | <a href="reference.html">reference</a> | 317 | <a href="reference.html">reference</a> |
diff --git a/etc/dispatch.lua b/etc/dispatch.lua index 3ef1e72..5236f3d 100644 --- a/etc/dispatch.lua +++ b/etc/dispatch.lua | |||
| @@ -54,7 +54,7 @@ function socket.protect(f) | |||
| 54 | local results = {coroutine.resume(co, base.unpack(arg))} | 54 | local results = {coroutine.resume(co, base.unpack(arg))} |
| 55 | local status = table.remove(results, 1) | 55 | local status = table.remove(results, 1) |
| 56 | if not status then | 56 | if not status then |
| 57 | if type(results[1]) == 'table' then | 57 | if base.type(results[1]) == 'table' then |
| 58 | return nil, results[1][1] | 58 | return nil, results[1][1] |
| 59 | else base.error(results[1]) end | 59 | else base.error(results[1]) end |
| 60 | end | 60 | end |
diff --git a/luasocket.sln b/luasocket.sln index a674c33..76b175b 100644 --- a/luasocket.sln +++ b/luasocket.sln | |||
| @@ -1,37 +1,25 @@ | |||
| 1 | Microsoft Visual Studio Solution File, Format Version 8.00 | 1 | Microsoft Visual Studio Solution File, Format Version 10.00 |
| 2 | # Visual Studio 2008 | ||
| 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "socket", "socket.vcproj", "{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}" | 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "socket", "socket.vcproj", "{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}" |
| 3 | ProjectSection(ProjectDependencies) = postProject | ||
| 4 | EndProjectSection | ||
| 5 | EndProject | 4 | EndProject |
| 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mime", "mime.vcproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}" | 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mime", "mime.vcproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}" |
| 7 | ProjectSection(ProjectDependencies) = postProject | ||
| 8 | EndProjectSection | ||
| 9 | EndProject | ||
| 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libluasocket", "libluasocket.vcproj", "{599EAD40-60EE-4043-9C14-AE090A8A092D}" | ||
| 11 | ProjectSection(ProjectDependencies) = postProject | ||
| 12 | EndProjectSection | ||
| 13 | EndProject | 6 | EndProject |
| 14 | Global | 7 | Global |
| 15 | GlobalSection(SolutionConfiguration) = preSolution | 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
| 16 | Debug = Debug | 9 | Debug|Win32 = Debug|Win32 |
| 17 | Release = Release | 10 | Release|Win32 = Release|Win32 |
| 18 | EndGlobalSection | ||
| 19 | GlobalSection(ProjectConfiguration) = postSolution | ||
| 20 | {66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Debug.ActiveCfg = Debug|Win32 | ||
| 21 | {66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Debug.Build.0 = Debug|Win32 | ||
| 22 | {66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Release.ActiveCfg = Release|Win32 | ||
| 23 | {66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Release.Build.0 = Release|Win32 | ||
| 24 | {128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.ActiveCfg = Debug|Win32 | ||
| 25 | {128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.Build.0 = Debug|Win32 | ||
| 26 | {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.ActiveCfg = Release|Win32 | ||
| 27 | {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.Build.0 = Release|Win32 | ||
| 28 | {599EAD40-60EE-4043-9C14-AE090A8A092D}.Debug.ActiveCfg = Debug|Win32 | ||
| 29 | {599EAD40-60EE-4043-9C14-AE090A8A092D}.Debug.Build.0 = Debug|Win32 | ||
| 30 | {599EAD40-60EE-4043-9C14-AE090A8A092D}.Release.ActiveCfg = Release|Win32 | ||
| 31 | {599EAD40-60EE-4043-9C14-AE090A8A092D}.Release.Build.0 = Release|Win32 | ||
| 32 | EndGlobalSection | 11 | EndGlobalSection |
| 33 | GlobalSection(ExtensibilityGlobals) = postSolution | 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution |
| 13 | {66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
| 14 | {66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Debug|Win32.Build.0 = Debug|Win32 | ||
| 15 | {66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Release|Win32.ActiveCfg = Release|Win32 | ||
| 16 | {66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}.Release|Win32.Build.0 = Release|Win32 | ||
| 17 | {128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
| 18 | {128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug|Win32.Build.0 = Debug|Win32 | ||
| 19 | {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release|Win32.ActiveCfg = Release|Win32 | ||
| 20 | {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release|Win32.Build.0 = Release|Win32 | ||
| 34 | EndGlobalSection | 21 | EndGlobalSection |
| 35 | GlobalSection(ExtensibilityAddIns) = postSolution | 22 | GlobalSection(SolutionProperties) = preSolution |
| 23 | HideSolutionNode = FALSE | ||
| 36 | EndGlobalSection | 24 | EndGlobalSection |
| 37 | EndGlobal | 25 | EndGlobal |
| @@ -1,51 +1,23 @@ | |||
| 1 | #------ | 1 | PLAT= none |
| 2 | # Load configuration | 2 | PLATS= macosx linux |
| 3 | # | ||
| 4 | include config | ||
| 5 | 3 | ||
| 6 | #------ | 4 | #------ |
| 7 | # Hopefully no need to change anything below this line | 5 | # Hopefully no need to change anything below this line |
| 8 | # | 6 | # |
| 9 | INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket | 7 | all: $(PLAT) |
| 10 | INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket | ||
| 11 | INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime | ||
| 12 | INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime | ||
| 13 | |||
| 14 | all clean: | ||
| 15 | cd src; $(MAKE) $@ | ||
| 16 | 8 | ||
| 17 | #------ | 9 | none: |
| 18 | # Files to install | 10 | @echo "Please run" |
| 19 | # | 11 | @echo " make PLATFORM" |
| 20 | TO_SOCKET_SHARE:= \ | 12 | @echo "where PLATFORM is one of these:" |
| 21 | http.lua \ | 13 | @echo " $(PLATS)" |
| 22 | url.lua \ | ||
| 23 | tp.lua \ | ||
| 24 | ftp.lua \ | ||
| 25 | smtp.lua | ||
| 26 | 14 | ||
| 27 | TO_TOP_SHARE:= \ | 15 | $(PLATS) install local clean: |
| 28 | ltn12.lua \ | 16 | cd src; $(MAKE) $@ |
| 29 | socket.lua \ | ||
| 30 | mime.lua | ||
| 31 | 17 | ||
| 32 | TO_MIME_SHARE:= | 18 | dummy: |
| 33 | 19 | ||
| 34 | #------ | 20 | test: dummy |
| 35 | # Install LuaSocket according to recommendation | 21 | lua test/hello.lua |
| 36 | # | ||
| 37 | install: all | ||
| 38 | cd src; mkdir -p $(INSTALL_TOP_SHARE) | ||
| 39 | cd src; $(INSTALL_DATA) $(TO_TOP_SHARE) $(INSTALL_TOP_SHARE) | ||
| 40 | cd src; mkdir -p $(INSTALL_SOCKET_SHARE) | ||
| 41 | cd src; $(INSTALL_DATA) $(TO_SOCKET_SHARE) $(INSTALL_SOCKET_SHARE) | ||
| 42 | cd src; mkdir -p $(INSTALL_SOCKET_LIB) | ||
| 43 | cd src; $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_LIB)/core.$(EXT) | ||
| 44 | #cd src; mkdir -p $(INSTALL_MIME_SHARE) | ||
| 45 | #cd src; $(INSTALL_DATA) $(TO_MIME_SHARE) $(INSTALL_MIME_SHARE) | ||
| 46 | cd src; mkdir -p $(INSTALL_MIME_LIB) | ||
| 47 | cd src; $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(EXT) | ||
| 48 | 22 | ||
| 49 | #------ | 23 | .PHONY: dummy |
| 50 | # End of makefile | ||
| 51 | # | ||
diff --git a/makefile.dist b/makefile.dist index 876cf18..e4f8da8 100644 --- a/makefile.dist +++ b/makefile.dist | |||
| @@ -1,10 +1,11 @@ | |||
| 1 | #-------------------------------------------------------------------------- | 1 | #-------------------------------------------------------------------------- |
| 2 | # Distribution makefile | 2 | # Distribution makefile |
| 3 | #-------------------------------------------------------------------------- | 3 | #-------------------------------------------------------------------------- |
| 4 | DIST = luasocket-2.0.2 | 4 | DIST = luasocket-2.0.3 |
| 5 | 5 | ||
| 6 | TEST = \ | 6 | TEST = \ |
| 7 | test/README \ | 7 | test/README \ |
| 8 | test/hello.lua \ | ||
| 8 | test/testclnt.lua \ | 9 | test/testclnt.lua \ |
| 9 | test/testsrvr.lua \ | 10 | test/testsrvr.lua \ |
| 10 | test/testsupport.lua | 11 | test/testsupport.lua |
| @@ -15,6 +16,8 @@ SAMPLES = \ | |||
| 15 | samples/daytimeclnt.lua \ | 16 | samples/daytimeclnt.lua \ |
| 16 | samples/echoclnt.lua \ | 17 | samples/echoclnt.lua \ |
| 17 | samples/echosrvr.lua \ | 18 | samples/echosrvr.lua \ |
| 19 | samples/mclisten.lua \ | ||
| 20 | samples/mcsend.lua \ | ||
| 18 | samples/listener.lua \ | 21 | samples/listener.lua \ |
| 19 | samples/lpr.lua \ | 22 | samples/lpr.lua \ |
| 20 | samples/talker.lua \ | 23 | samples/talker.lua \ |
| @@ -73,12 +76,12 @@ SRC = \ | |||
| 73 | src/mime.lua \ | 76 | src/mime.lua \ |
| 74 | src/smtp.lua \ | 77 | src/smtp.lua \ |
| 75 | src/socket.lua \ | 78 | src/socket.lua \ |
| 79 | src/headers.lua \ | ||
| 76 | src/tp.lua \ | 80 | src/tp.lua \ |
| 77 | src/url.lua | 81 | src/url.lua |
| 78 | 82 | ||
| 79 | MAKE = \ | 83 | MAKE = \ |
| 80 | makefile \ | 84 | makefile \ |
| 81 | config \ | ||
| 82 | luasocket.sln \ | 85 | luasocket.sln \ |
| 83 | socket.vcproj \ | 86 | socket.vcproj \ |
| 84 | mime.vcproj | 87 | mime.vcproj |
diff --git a/mime.vcproj b/mime.vcproj index 8ad7900..313cdb1 100644 --- a/mime.vcproj +++ b/mime.vcproj | |||
| @@ -1,114 +1,179 @@ | |||
| 1 | <?xml version="1.0" encoding="Windows-1252"?> | 1 | <?xml version="1.0" encoding="Windows-1252"?> |
| 2 | <VisualStudioProject | 2 | <VisualStudioProject |
| 3 | ProjectType="Visual C++" | 3 | ProjectType="Visual C++" |
| 4 | Version="7.10" | 4 | Version="9.00" |
| 5 | Name="mime" | 5 | Name="mime" |
| 6 | ProjectGUID="{128E8BD0-174A-48F0-8771-92B1E8D18713}" | 6 | ProjectGUID="{128E8BD0-174A-48F0-8771-92B1E8D18713}" |
| 7 | Keyword="Win32Proj"> | 7 | Keyword="Win32Proj" |
| 8 | TargetFrameworkVersion="131072" | ||
| 9 | > | ||
| 8 | <Platforms> | 10 | <Platforms> |
| 9 | <Platform | 11 | <Platform |
| 10 | Name="Win32"/> | 12 | Name="Win32" |
| 13 | /> | ||
| 11 | </Platforms> | 14 | </Platforms> |
| 15 | <ToolFiles> | ||
| 16 | </ToolFiles> | ||
| 12 | <Configurations> | 17 | <Configurations> |
| 13 | <Configuration | 18 | <Configuration |
| 14 | Name="Debug|Win32" | 19 | Name="Debug|Win32" |
| 15 | OutputDirectory="src" | 20 | OutputDirectory="src" |
| 16 | IntermediateDirectory="src" | 21 | IntermediateDirectory="src" |
| 17 | ConfigurationType="2" | 22 | ConfigurationType="2" |
| 18 | CharacterSet="2"> | 23 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" |
| 24 | CharacterSet="2" | ||
| 25 | > | ||
| 26 | <Tool | ||
| 27 | Name="VCPreBuildEventTool" | ||
| 28 | /> | ||
| 29 | <Tool | ||
| 30 | Name="VCCustomBuildTool" | ||
| 31 | /> | ||
| 32 | <Tool | ||
| 33 | Name="VCXMLDataGeneratorTool" | ||
| 34 | /> | ||
| 35 | <Tool | ||
| 36 | Name="VCWebServiceProxyGeneratorTool" | ||
| 37 | /> | ||
| 38 | <Tool | ||
| 39 | Name="VCMIDLTool" | ||
| 40 | /> | ||
| 19 | <Tool | 41 | <Tool |
| 20 | Name="VCCLCompilerTool" | 42 | Name="VCCLCompilerTool" |
| 21 | Optimization="0" | 43 | Optimization="0" |
| 22 | AdditionalIncludeDirectories="h:\include\lua5.1" | 44 | AdditionalIncludeDirectories="..\lua-5.1.4\src" |
| 23 | PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport)" | 45 | PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS" |
| 24 | MinimalRebuild="TRUE" | 46 | MinimalRebuild="true" |
| 25 | BasicRuntimeChecks="3" | 47 | BasicRuntimeChecks="3" |
| 26 | RuntimeLibrary="3" | 48 | RuntimeLibrary="3" |
| 27 | UsePrecompiledHeader="0" | 49 | UsePrecompiledHeader="0" |
| 28 | WarningLevel="3" | 50 | WarningLevel="3" |
| 29 | Detect64BitPortabilityProblems="TRUE" | 51 | Detect64BitPortabilityProblems="false" |
| 30 | DebugInformationFormat="4"/> | 52 | DebugInformationFormat="4" |
| 53 | /> | ||
| 31 | <Tool | 54 | <Tool |
| 32 | Name="VCCustomBuildTool"/> | 55 | Name="VCManagedResourceCompilerTool" |
| 56 | /> | ||
| 57 | <Tool | ||
| 58 | Name="VCResourceCompilerTool" | ||
| 59 | /> | ||
| 60 | <Tool | ||
| 61 | Name="VCPreLinkEventTool" | ||
| 62 | /> | ||
| 33 | <Tool | 63 | <Tool |
| 34 | Name="VCLinkerTool" | 64 | Name="VCLinkerTool" |
| 65 | AdditionalDependencies="lua5.1.lib" | ||
| 35 | OutputFile="$(OutDir)/mime.dll" | 66 | OutputFile="$(OutDir)/mime.dll" |
| 36 | LinkIncremental="2" | 67 | LinkIncremental="2" |
| 37 | AdditionalLibraryDirectories="h:\lib" | 68 | AdditionalLibraryDirectories="..\lua-5.1.4" |
| 38 | GenerateDebugInformation="TRUE" | 69 | GenerateDebugInformation="true" |
| 39 | ProgramDatabaseFile="$(OutDir)/mime.pdb" | 70 | ProgramDatabaseFile="$(OutDir)/mime.pdb" |
| 40 | SubSystem="2" | 71 | SubSystem="2" |
| 72 | RandomizedBaseAddress="1" | ||
| 73 | DataExecutionPrevention="0" | ||
| 41 | ImportLibrary="$(OutDir)/mime.lib" | 74 | ImportLibrary="$(OutDir)/mime.lib" |
| 42 | TargetMachine="1"/> | 75 | TargetMachine="1" |
| 43 | <Tool | 76 | /> |
| 44 | Name="VCMIDLTool"/> | ||
| 45 | <Tool | ||
| 46 | Name="VCPostBuildEventTool"/> | ||
| 47 | <Tool | ||
| 48 | Name="VCPreBuildEventTool"/> | ||
| 49 | <Tool | 77 | <Tool |
| 50 | Name="VCPreLinkEventTool"/> | 78 | Name="VCALinkTool" |
| 79 | /> | ||
| 51 | <Tool | 80 | <Tool |
| 52 | Name="VCResourceCompilerTool"/> | 81 | Name="VCManifestTool" |
| 82 | /> | ||
| 53 | <Tool | 83 | <Tool |
| 54 | Name="VCWebServiceProxyGeneratorTool"/> | 84 | Name="VCXDCMakeTool" |
| 85 | /> | ||
| 55 | <Tool | 86 | <Tool |
| 56 | Name="VCXMLDataGeneratorTool"/> | 87 | Name="VCBscMakeTool" |
| 88 | /> | ||
| 57 | <Tool | 89 | <Tool |
| 58 | Name="VCWebDeploymentTool"/> | 90 | Name="VCFxCopTool" |
| 91 | /> | ||
| 59 | <Tool | 92 | <Tool |
| 60 | Name="VCManagedWrapperGeneratorTool"/> | 93 | Name="VCAppVerifierTool" |
| 94 | /> | ||
| 61 | <Tool | 95 | <Tool |
| 62 | Name="VCAuxiliaryManagedWrapperGeneratorTool"/> | 96 | Name="VCPostBuildEventTool" |
| 97 | /> | ||
| 63 | </Configuration> | 98 | </Configuration> |
| 64 | <Configuration | 99 | <Configuration |
| 65 | Name="Release|Win32" | 100 | Name="Release|Win32" |
| 66 | OutputDirectory="src" | 101 | OutputDirectory="src" |
| 67 | IntermediateDirectory="src" | 102 | IntermediateDirectory="src" |
| 68 | ConfigurationType="2" | 103 | ConfigurationType="2" |
| 69 | CharacterSet="2"> | 104 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" |
| 105 | CharacterSet="2" | ||
| 106 | > | ||
| 107 | <Tool | ||
| 108 | Name="VCPreBuildEventTool" | ||
| 109 | /> | ||
| 110 | <Tool | ||
| 111 | Name="VCCustomBuildTool" | ||
| 112 | /> | ||
| 113 | <Tool | ||
| 114 | Name="VCXMLDataGeneratorTool" | ||
| 115 | /> | ||
| 116 | <Tool | ||
| 117 | Name="VCWebServiceProxyGeneratorTool" | ||
| 118 | /> | ||
| 119 | <Tool | ||
| 120 | Name="VCMIDLTool" | ||
| 121 | /> | ||
| 70 | <Tool | 122 | <Tool |
| 71 | Name="VCCLCompilerTool" | 123 | Name="VCCLCompilerTool" |
| 72 | AdditionalIncludeDirectories="h:\include\lua5.1" | 124 | AdditionalIncludeDirectories="..\lua-5.1.4\src" |
| 73 | PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)" | 125 | PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS" |
| 74 | RuntimeLibrary="2" | 126 | RuntimeLibrary="2" |
| 75 | UsePrecompiledHeader="0" | 127 | UsePrecompiledHeader="0" |
| 76 | WarningLevel="4" | 128 | WarningLevel="4" |
| 77 | Detect64BitPortabilityProblems="TRUE" | 129 | Detect64BitPortabilityProblems="false" |
| 78 | DebugInformationFormat="0"/> | 130 | DebugInformationFormat="0" |
| 131 | /> | ||
| 79 | <Tool | 132 | <Tool |
| 80 | Name="VCCustomBuildTool"/> | 133 | Name="VCManagedResourceCompilerTool" |
| 134 | /> | ||
| 135 | <Tool | ||
| 136 | Name="VCResourceCompilerTool" | ||
| 137 | /> | ||
| 138 | <Tool | ||
| 139 | Name="VCPreLinkEventTool" | ||
| 140 | /> | ||
| 81 | <Tool | 141 | <Tool |
| 82 | Name="VCLinkerTool" | 142 | Name="VCLinkerTool" |
| 143 | AdditionalDependencies="lua5.1.lib" | ||
| 83 | OutputFile="$(OutDir)/mime.dll" | 144 | OutputFile="$(OutDir)/mime.dll" |
| 84 | LinkIncremental="1" | 145 | LinkIncremental="1" |
| 85 | AdditionalLibraryDirectories="h:\lib" | 146 | AdditionalLibraryDirectories="..\lua-5.1.4" |
| 86 | GenerateDebugInformation="TRUE" | 147 | GenerateDebugInformation="true" |
| 87 | SubSystem="2" | 148 | SubSystem="2" |
| 88 | OptimizeReferences="2" | 149 | OptimizeReferences="2" |
| 89 | EnableCOMDATFolding="2" | 150 | EnableCOMDATFolding="2" |
| 151 | RandomizedBaseAddress="1" | ||
| 152 | DataExecutionPrevention="0" | ||
| 90 | ImportLibrary="$(OutDir)/mime.lib" | 153 | ImportLibrary="$(OutDir)/mime.lib" |
| 91 | TargetMachine="1"/> | 154 | TargetMachine="1" |
| 92 | <Tool | 155 | /> |
| 93 | Name="VCMIDLTool"/> | ||
| 94 | <Tool | ||
| 95 | Name="VCPostBuildEventTool"/> | ||
| 96 | <Tool | ||
| 97 | Name="VCPreBuildEventTool"/> | ||
| 98 | <Tool | 156 | <Tool |
| 99 | Name="VCPreLinkEventTool"/> | 157 | Name="VCALinkTool" |
| 158 | /> | ||
| 100 | <Tool | 159 | <Tool |
| 101 | Name="VCResourceCompilerTool"/> | 160 | Name="VCManifestTool" |
| 161 | /> | ||
| 102 | <Tool | 162 | <Tool |
| 103 | Name="VCWebServiceProxyGeneratorTool"/> | 163 | Name="VCXDCMakeTool" |
| 164 | /> | ||
| 104 | <Tool | 165 | <Tool |
| 105 | Name="VCXMLDataGeneratorTool"/> | 166 | Name="VCBscMakeTool" |
| 167 | /> | ||
| 106 | <Tool | 168 | <Tool |
| 107 | Name="VCWebDeploymentTool"/> | 169 | Name="VCFxCopTool" |
| 170 | /> | ||
| 108 | <Tool | 171 | <Tool |
| 109 | Name="VCManagedWrapperGeneratorTool"/> | 172 | Name="VCAppVerifierTool" |
| 173 | /> | ||
| 110 | <Tool | 174 | <Tool |
| 111 | Name="VCAuxiliaryManagedWrapperGeneratorTool"/> | 175 | Name="VCPostBuildEventTool" |
| 176 | /> | ||
| 112 | </Configuration> | 177 | </Configuration> |
| 113 | </Configurations> | 178 | </Configurations> |
| 114 | <References> | 179 | <References> |
| @@ -117,24 +182,25 @@ | |||
| 117 | <Filter | 182 | <Filter |
| 118 | Name="Source Files" | 183 | Name="Source Files" |
| 119 | Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" | 184 | Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" |
| 120 | UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> | 185 | UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" |
| 186 | > | ||
| 121 | <File | 187 | <File |
| 122 | RelativePath="src\mime.c"> | 188 | RelativePath="src\mime.c" |
| 189 | > | ||
| 123 | </File> | 190 | </File> |
| 124 | </Filter> | 191 | </Filter> |
| 125 | <Filter | 192 | <Filter |
| 126 | Name="Header Files" | 193 | Name="Header Files" |
| 127 | Filter="h;hpp;hxx;hm;inl;inc;xsd" | 194 | Filter="h;hpp;hxx;hm;inl;inc;xsd" |
| 128 | UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> | 195 | UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" |
| 196 | > | ||
| 129 | </Filter> | 197 | </Filter> |
| 130 | <Filter | 198 | <Filter |
| 131 | Name="Resource Files" | 199 | Name="Resource Files" |
| 132 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" | 200 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" |
| 133 | UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> | 201 | UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" |
| 202 | > | ||
| 134 | </Filter> | 203 | </Filter> |
| 135 | <File | ||
| 136 | RelativePath="..\..\lib\lua5.1.dll.lib"> | ||
| 137 | </File> | ||
| 138 | </Files> | 204 | </Files> |
| 139 | <Globals> | 205 | <Globals> |
| 140 | </Globals> | 206 | </Globals> |
diff --git a/samples/cddb.lua b/samples/cddb.lua index 883730c..49a1871 100644 --- a/samples/cddb.lua +++ b/samples/cddb.lua | |||
| @@ -32,7 +32,7 @@ end | |||
| 32 | local host = socket.dns.gethostname() | 32 | local host = socket.dns.gethostname() |
| 33 | local query = "%s?cmd=cddb+read+%s+%s&hello=LuaSocket+%s+LuaSocket+2.0&proto=6" | 33 | local query = "%s?cmd=cddb+read+%s+%s&hello=LuaSocket+%s+LuaSocket+2.0&proto=6" |
| 34 | local url = string.format(query, server, arg[1], arg[2], host) | 34 | local url = string.format(query, server, arg[1], arg[2], host) |
| 35 | local body, headers, code = http.get(url) | 35 | local body, headers, code = http.request(url) |
| 36 | 36 | ||
| 37 | if code == 200 then | 37 | if code == 200 then |
| 38 | local data, code, error = parse(body) | 38 | local data, code, error = parse(body) |
diff --git a/socket.vcproj b/socket.vcproj index b7c4a08..195eb09 100644 --- a/socket.vcproj +++ b/socket.vcproj | |||
| @@ -1,116 +1,179 @@ | |||
| 1 | <?xml version="1.0" encoding="Windows-1252"?> | 1 | <?xml version="1.0" encoding="Windows-1252"?> |
| 2 | <VisualStudioProject | 2 | <VisualStudioProject |
| 3 | ProjectType="Visual C++" | 3 | ProjectType="Visual C++" |
| 4 | Version="7.10" | 4 | Version="9.00" |
| 5 | Name="socket" | 5 | Name="socket" |
| 6 | ProjectGUID="{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}" | 6 | ProjectGUID="{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}" |
| 7 | Keyword="Win32Proj"> | 7 | Keyword="Win32Proj" |
| 8 | TargetFrameworkVersion="131072" | ||
| 9 | > | ||
| 8 | <Platforms> | 10 | <Platforms> |
| 9 | <Platform | 11 | <Platform |
| 10 | Name="Win32"/> | 12 | Name="Win32" |
| 13 | /> | ||
| 11 | </Platforms> | 14 | </Platforms> |
| 15 | <ToolFiles> | ||
| 16 | </ToolFiles> | ||
| 12 | <Configurations> | 17 | <Configurations> |
| 13 | <Configuration | 18 | <Configuration |
| 14 | Name="Debug|Win32" | 19 | Name="Debug|Win32" |
| 15 | OutputDirectory="src" | 20 | OutputDirectory="src" |
| 16 | IntermediateDirectory="src" | 21 | IntermediateDirectory="src" |
| 17 | ConfigurationType="2" | 22 | ConfigurationType="2" |
| 18 | CharacterSet="2"> | 23 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" |
| 24 | CharacterSet="2" | ||
| 25 | > | ||
| 26 | <Tool | ||
| 27 | Name="VCPreBuildEventTool" | ||
| 28 | /> | ||
| 29 | <Tool | ||
| 30 | Name="VCCustomBuildTool" | ||
| 31 | /> | ||
| 32 | <Tool | ||
| 33 | Name="VCXMLDataGeneratorTool" | ||
| 34 | /> | ||
| 35 | <Tool | ||
| 36 | Name="VCWebServiceProxyGeneratorTool" | ||
| 37 | /> | ||
| 38 | <Tool | ||
| 39 | Name="VCMIDLTool" | ||
| 40 | /> | ||
| 19 | <Tool | 41 | <Tool |
| 20 | Name="VCCLCompilerTool" | 42 | Name="VCCLCompilerTool" |
| 21 | Optimization="0" | 43 | Optimization="0" |
| 22 | AdditionalIncludeDirectories="h:\include\lua5.1" | 44 | AdditionalIncludeDirectories="..\lua-5.1.4\src" |
| 23 | PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport)" | 45 | PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS" |
| 24 | MinimalRebuild="TRUE" | 46 | MinimalRebuild="true" |
| 25 | BasicRuntimeChecks="3" | 47 | BasicRuntimeChecks="3" |
| 26 | RuntimeLibrary="3" | 48 | RuntimeLibrary="3" |
| 27 | UsePrecompiledHeader="0" | 49 | UsePrecompiledHeader="0" |
| 28 | WarningLevel="3" | 50 | WarningLevel="3" |
| 29 | Detect64BitPortabilityProblems="TRUE" | 51 | Detect64BitPortabilityProblems="false" |
| 30 | DebugInformationFormat="4"/> | 52 | DebugInformationFormat="4" |
| 53 | /> | ||
| 31 | <Tool | 54 | <Tool |
| 32 | Name="VCCustomBuildTool"/> | 55 | Name="VCManagedResourceCompilerTool" |
| 56 | /> | ||
| 57 | <Tool | ||
| 58 | Name="VCResourceCompilerTool" | ||
| 59 | /> | ||
| 60 | <Tool | ||
| 61 | Name="VCPreLinkEventTool" | ||
| 62 | /> | ||
| 33 | <Tool | 63 | <Tool |
| 34 | Name="VCLinkerTool" | 64 | Name="VCLinkerTool" |
| 35 | AdditionalDependencies="ws2_32.lib" | 65 | AdditionalDependencies="ws2_32.lib lua5.1.lib" |
| 36 | OutputFile="$(OutDir)/socket.dll" | 66 | OutputFile="$(OutDir)/socket.dll" |
| 37 | LinkIncremental="2" | 67 | LinkIncremental="2" |
| 38 | AdditionalLibraryDirectories="h:\lib" | 68 | AdditionalLibraryDirectories="..\lua-5.1.4" |
| 39 | GenerateDebugInformation="TRUE" | 69 | GenerateDebugInformation="true" |
| 40 | ProgramDatabaseFile="$(OutDir)/socket.pdb" | 70 | ProgramDatabaseFile="$(OutDir)/socket.pdb" |
| 41 | SubSystem="2" | 71 | SubSystem="2" |
| 72 | RandomizedBaseAddress="1" | ||
| 73 | DataExecutionPrevention="0" | ||
| 42 | ImportLibrary="$(OutDir)/socket.lib" | 74 | ImportLibrary="$(OutDir)/socket.lib" |
| 43 | TargetMachine="1"/> | 75 | TargetMachine="1" |
| 44 | <Tool | 76 | /> |
| 45 | Name="VCMIDLTool"/> | ||
| 46 | <Tool | ||
| 47 | Name="VCPostBuildEventTool"/> | ||
| 48 | <Tool | ||
| 49 | Name="VCPreBuildEventTool"/> | ||
| 50 | <Tool | 77 | <Tool |
| 51 | Name="VCPreLinkEventTool"/> | 78 | Name="VCALinkTool" |
| 79 | /> | ||
| 52 | <Tool | 80 | <Tool |
| 53 | Name="VCResourceCompilerTool"/> | 81 | Name="VCManifestTool" |
| 82 | /> | ||
| 54 | <Tool | 83 | <Tool |
| 55 | Name="VCWebServiceProxyGeneratorTool"/> | 84 | Name="VCXDCMakeTool" |
| 85 | /> | ||
| 56 | <Tool | 86 | <Tool |
| 57 | Name="VCXMLDataGeneratorTool"/> | 87 | Name="VCBscMakeTool" |
| 88 | /> | ||
| 58 | <Tool | 89 | <Tool |
| 59 | Name="VCWebDeploymentTool"/> | 90 | Name="VCFxCopTool" |
| 91 | /> | ||
| 60 | <Tool | 92 | <Tool |
| 61 | Name="VCManagedWrapperGeneratorTool"/> | 93 | Name="VCAppVerifierTool" |
| 94 | /> | ||
| 62 | <Tool | 95 | <Tool |
| 63 | Name="VCAuxiliaryManagedWrapperGeneratorTool"/> | 96 | Name="VCPostBuildEventTool" |
| 97 | /> | ||
| 64 | </Configuration> | 98 | </Configuration> |
| 65 | <Configuration | 99 | <Configuration |
| 66 | Name="Release|Win32" | 100 | Name="Release|Win32" |
| 67 | OutputDirectory="./src" | 101 | OutputDirectory="./src" |
| 68 | IntermediateDirectory="./src" | 102 | IntermediateDirectory="./src" |
| 69 | ConfigurationType="2" | 103 | ConfigurationType="2" |
| 70 | CharacterSet="2"> | 104 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" |
| 105 | CharacterSet="2" | ||
| 106 | > | ||
| 107 | <Tool | ||
| 108 | Name="VCPreBuildEventTool" | ||
| 109 | /> | ||
| 110 | <Tool | ||
| 111 | Name="VCCustomBuildTool" | ||
| 112 | /> | ||
| 113 | <Tool | ||
| 114 | Name="VCXMLDataGeneratorTool" | ||
| 115 | /> | ||
| 116 | <Tool | ||
| 117 | Name="VCWebServiceProxyGeneratorTool" | ||
| 118 | /> | ||
| 119 | <Tool | ||
| 120 | Name="VCMIDLTool" | ||
| 121 | /> | ||
| 71 | <Tool | 122 | <Tool |
| 72 | Name="VCCLCompilerTool" | 123 | Name="VCCLCompilerTool" |
| 73 | AdditionalIncludeDirectories="h:\include\lua5.1" | 124 | AdditionalIncludeDirectories="..\lua-5.1.4\src" |
| 74 | PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG" | 125 | PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG; _CRT_SECURE_NO_WARNINGS" |
| 75 | RuntimeLibrary="2" | 126 | RuntimeLibrary="2" |
| 76 | UsePrecompiledHeader="0" | 127 | UsePrecompiledHeader="0" |
| 77 | WarningLevel="3" | 128 | WarningLevel="3" |
| 78 | Detect64BitPortabilityProblems="TRUE" | 129 | Detect64BitPortabilityProblems="false" |
| 79 | DebugInformationFormat="0"/> | 130 | DebugInformationFormat="0" |
| 131 | /> | ||
| 80 | <Tool | 132 | <Tool |
| 81 | Name="VCCustomBuildTool"/> | 133 | Name="VCManagedResourceCompilerTool" |
| 134 | /> | ||
| 135 | <Tool | ||
| 136 | Name="VCResourceCompilerTool" | ||
| 137 | /> | ||
| 138 | <Tool | ||
| 139 | Name="VCPreLinkEventTool" | ||
| 140 | /> | ||
| 82 | <Tool | 141 | <Tool |
| 83 | Name="VCLinkerTool" | 142 | Name="VCLinkerTool" |
| 84 | AdditionalDependencies="ws2_32.lib" | 143 | AdditionalDependencies="ws2_32.lib lua5.1.lib" |
| 85 | OutputFile="$(OutDir)/socket.dll" | 144 | OutputFile="$(OutDir)/socket.dll" |
| 86 | LinkIncremental="1" | 145 | LinkIncremental="1" |
| 87 | AdditionalLibraryDirectories="h:\lib" | 146 | AdditionalLibraryDirectories="..\lua-5.1.4" |
| 88 | GenerateDebugInformation="TRUE" | 147 | GenerateDebugInformation="true" |
| 89 | SubSystem="2" | 148 | SubSystem="2" |
| 90 | OptimizeReferences="2" | 149 | OptimizeReferences="2" |
| 91 | EnableCOMDATFolding="2" | 150 | EnableCOMDATFolding="2" |
| 151 | RandomizedBaseAddress="1" | ||
| 152 | DataExecutionPrevention="0" | ||
| 92 | ImportLibrary="$(OutDir)/socket.lib" | 153 | ImportLibrary="$(OutDir)/socket.lib" |
| 93 | TargetMachine="1"/> | 154 | TargetMachine="1" |
| 94 | <Tool | 155 | /> |
| 95 | Name="VCMIDLTool"/> | ||
| 96 | <Tool | ||
| 97 | Name="VCPostBuildEventTool"/> | ||
| 98 | <Tool | ||
| 99 | Name="VCPreBuildEventTool"/> | ||
| 100 | <Tool | 156 | <Tool |
| 101 | Name="VCPreLinkEventTool"/> | 157 | Name="VCALinkTool" |
| 158 | /> | ||
| 102 | <Tool | 159 | <Tool |
| 103 | Name="VCResourceCompilerTool"/> | 160 | Name="VCManifestTool" |
| 161 | /> | ||
| 104 | <Tool | 162 | <Tool |
| 105 | Name="VCWebServiceProxyGeneratorTool"/> | 163 | Name="VCXDCMakeTool" |
| 164 | /> | ||
| 106 | <Tool | 165 | <Tool |
| 107 | Name="VCXMLDataGeneratorTool"/> | 166 | Name="VCBscMakeTool" |
| 167 | /> | ||
| 108 | <Tool | 168 | <Tool |
| 109 | Name="VCWebDeploymentTool"/> | 169 | Name="VCFxCopTool" |
| 170 | /> | ||
| 110 | <Tool | 171 | <Tool |
| 111 | Name="VCManagedWrapperGeneratorTool"/> | 172 | Name="VCAppVerifierTool" |
| 173 | /> | ||
| 112 | <Tool | 174 | <Tool |
| 113 | Name="VCAuxiliaryManagedWrapperGeneratorTool"/> | 175 | Name="VCPostBuildEventTool" |
| 176 | /> | ||
| 114 | </Configuration> | 177 | </Configuration> |
| 115 | </Configurations> | 178 | </Configurations> |
| 116 | <References> | 179 | <References> |
| @@ -119,63 +182,77 @@ | |||
| 119 | <Filter | 182 | <Filter |
| 120 | Name="Source Files" | 183 | Name="Source Files" |
| 121 | Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" | 184 | Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" |
| 122 | UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> | 185 | UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" |
| 186 | > | ||
| 123 | <File | 187 | <File |
| 124 | RelativePath="src\auxiliar.c"> | 188 | RelativePath="src\auxiliar.c" |
| 189 | > | ||
| 125 | </File> | 190 | </File> |
| 126 | <File | 191 | <File |
| 127 | RelativePath="src\buffer.c"> | 192 | RelativePath="src\buffer.c" |
| 193 | > | ||
| 128 | </File> | 194 | </File> |
| 129 | <File | 195 | <File |
| 130 | RelativePath="src\except.c"> | 196 | RelativePath="src\except.c" |
| 197 | > | ||
| 131 | </File> | 198 | </File> |
| 132 | <File | 199 | <File |
| 133 | RelativePath="src\inet.c"> | 200 | RelativePath="src\inet.c" |
| 201 | > | ||
| 134 | </File> | 202 | </File> |
| 135 | <File | 203 | <File |
| 136 | RelativePath="src\io.c"> | 204 | RelativePath="src\io.c" |
| 205 | > | ||
| 137 | </File> | 206 | </File> |
| 138 | <File | 207 | <File |
| 139 | RelativePath="src\luasocket.c"> | 208 | RelativePath="src\luasocket.c" |
| 209 | > | ||
| 140 | </File> | 210 | </File> |
| 141 | <File | 211 | <File |
| 142 | RelativePath="src\options.c"> | 212 | RelativePath="src\options.c" |
| 213 | > | ||
| 143 | </File> | 214 | </File> |
| 144 | <File | 215 | <File |
| 145 | RelativePath="src\select.c"> | 216 | RelativePath="src\select.c" |
| 217 | > | ||
| 146 | </File> | 218 | </File> |
| 147 | <File | 219 | <File |
| 148 | RelativePath="src\tcp.c"> | 220 | RelativePath="src\tcp.c" |
| 221 | > | ||
| 149 | </File> | 222 | </File> |
| 150 | <File | 223 | <File |
| 151 | RelativePath="src\timeout.c"> | 224 | RelativePath="src\timeout.c" |
| 225 | > | ||
| 152 | </File> | 226 | </File> |
| 153 | <File | 227 | <File |
| 154 | RelativePath="src\udp.c"> | 228 | RelativePath="src\udp.c" |
| 229 | > | ||
| 155 | </File> | 230 | </File> |
| 156 | <File | 231 | <File |
| 157 | RelativePath="src\wsocket.c"> | 232 | RelativePath="src\wsocket.c" |
| 233 | > | ||
| 158 | <FileConfiguration | 234 | <FileConfiguration |
| 159 | Name="Release|Win32"> | 235 | Name="Release|Win32" |
| 236 | > | ||
| 160 | <Tool | 237 | <Tool |
| 161 | Name="VCCLCompilerTool" | 238 | Name="VCCLCompilerTool" |
| 162 | GeneratePreprocessedFile="0"/> | 239 | GeneratePreprocessedFile="0" |
| 240 | /> | ||
| 163 | </FileConfiguration> | 241 | </FileConfiguration> |
| 164 | </File> | 242 | </File> |
| 165 | </Filter> | 243 | </Filter> |
| 166 | <Filter | 244 | <Filter |
| 167 | Name="Header Files" | 245 | Name="Header Files" |
| 168 | Filter="h;hpp;hxx;hm;inl;inc;xsd" | 246 | Filter="h;hpp;hxx;hm;inl;inc;xsd" |
| 169 | UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> | 247 | UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" |
| 248 | > | ||
| 170 | </Filter> | 249 | </Filter> |
| 171 | <Filter | 250 | <Filter |
| 172 | Name="Resource Files" | 251 | Name="Resource Files" |
| 173 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" | 252 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" |
| 174 | UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> | 253 | UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" |
| 254 | > | ||
| 175 | </Filter> | 255 | </Filter> |
| 176 | <File | ||
| 177 | RelativePath="..\..\lib\lua5.1.dll.lib"> | ||
| 178 | </File> | ||
| 179 | </Files> | 256 | </Files> |
| 180 | <Globals> | 257 | <Globals> |
| 181 | </Globals> | 258 | </Globals> |
diff --git a/src/auxiliar.h b/src/auxiliar.h index 8a18bcf..57a2ecc 100644 --- a/src/auxiliar.h +++ b/src/auxiliar.h | |||
| @@ -27,8 +27,6 @@ | |||
| 27 | * | 27 | * |
| 28 | * The mapping from class name to the corresponding metatable and the | 28 | * The mapping from class name to the corresponding metatable and the |
| 29 | * reverse mapping are done using lauxlib. | 29 | * reverse mapping are done using lauxlib. |
| 30 | * | ||
| 31 | * RCS ID: $Id$ | ||
| 32 | \*=========================================================================*/ | 30 | \*=========================================================================*/ |
| 33 | 31 | ||
| 34 | #include "lua.h" | 32 | #include "lua.h" |
diff --git a/src/buffer.c b/src/buffer.c index de817b2..363da3d 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -166,7 +166,7 @@ static int sendraw(p_buffer buf, const char *data, size_t count, size_t *sent) { | |||
| 166 | size_t total = 0; | 166 | size_t total = 0; |
| 167 | int err = IO_DONE; | 167 | int err = IO_DONE; |
| 168 | while (total < count && err == IO_DONE) { | 168 | while (total < count && err == IO_DONE) { |
| 169 | size_t done; | 169 | size_t done = 0; |
| 170 | size_t step = (count-total <= STEPSIZE)? count-total: STEPSIZE; | 170 | size_t step = (count-total <= STEPSIZE)? count-total: STEPSIZE; |
| 171 | err = io->send(io->ctx, data+total, step, &done, tm); | 171 | err = io->send(io->ctx, data+total, step, &done, tm); |
| 172 | total += done; | 172 | total += done; |
diff --git a/src/buffer.h b/src/buffer.h index 0a4a335..58838d1 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -14,8 +14,6 @@ | |||
| 14 | * | 14 | * |
| 15 | * The module is built on top of the I/O abstraction defined in io.h and the | 15 | * The module is built on top of the I/O abstraction defined in io.h and the |
| 16 | * timeout management is done with the timeout.h interface. | 16 | * timeout management is done with the timeout.h interface. |
| 17 | * | ||
| 18 | * RCS ID: $Id$ | ||
| 19 | \*=========================================================================*/ | 17 | \*=========================================================================*/ |
| 20 | #include "lua.h" | 18 | #include "lua.h" |
| 21 | 19 | ||
diff --git a/src/except.h b/src/except.h index 03e417d..1e7a245 100644 --- a/src/except.h +++ b/src/except.h | |||
| @@ -24,8 +24,6 @@ | |||
| 24 | * | 24 | * |
| 25 | * With these two function, it's easy to write functions that throw | 25 | * With these two function, it's easy to write functions that throw |
| 26 | * exceptions on error, but that don't interrupt the user script. | 26 | * exceptions on error, but that don't interrupt the user script. |
| 27 | * | ||
| 28 | * RCS ID: $Id$ | ||
| 29 | \*=========================================================================*/ | 27 | \*=========================================================================*/ |
| 30 | 28 | ||
| 31 | #include "lua.h" | 29 | #include "lua.h" |
diff --git a/src/http.lua b/src/http.lua index 3a386a6..4c27149 100644 --- a/src/http.lua +++ b/src/http.lua | |||
| @@ -13,6 +13,7 @@ local url = require("socket.url") | |||
| 13 | local ltn12 = require("ltn12") | 13 | local ltn12 = require("ltn12") |
| 14 | local mime = require("mime") | 14 | local mime = require("mime") |
| 15 | local string = require("string") | 15 | local string = require("string") |
| 16 | local headers = require("socket.headers") | ||
| 16 | local base = _G | 17 | local base = _G |
| 17 | local table = require("table") | 18 | local table = require("table") |
| 18 | module("socket.http") | 19 | module("socket.http") |
| @@ -123,10 +124,11 @@ function metat.__index:sendrequestline(method, uri) | |||
| 123 | return self.try(self.c:send(reqline)) | 124 | return self.try(self.c:send(reqline)) |
| 124 | end | 125 | end |
| 125 | 126 | ||
| 126 | function metat.__index:sendheaders(headers) | 127 | function metat.__index:sendheaders(tosend) |
| 128 | local canonic = headers.canonic | ||
| 127 | local h = "\r\n" | 129 | local h = "\r\n" |
| 128 | for i, v in base.pairs(headers) do | 130 | for f, v in base.pairs(tosend) do |
| 129 | h = i .. ": " .. v .. "\r\n" .. h | 131 | h = (canonic[f] or f) .. ": " .. v .. "\r\n" .. h |
| 130 | end | 132 | end |
| 131 | self.try(self.c:send(h)) | 133 | self.try(self.c:send(h)) |
| 132 | return 1 | 134 | return 1 |
| @@ -254,7 +256,7 @@ local function shouldredirect(reqt, code, headers) | |||
| 254 | return headers.location and | 256 | return headers.location and |
| 255 | string.gsub(headers.location, "%s", "") ~= "" and | 257 | string.gsub(headers.location, "%s", "") ~= "" and |
| 256 | (reqt.redirect ~= false) and | 258 | (reqt.redirect ~= false) and |
| 257 | (code == 301 or code == 302) and | 259 | (code == 301 or code == 302 or code == 303 or code == 307) and |
| 258 | (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") | 260 | (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") |
| 259 | and (not reqt.nredirects or reqt.nredirects < 5) | 261 | and (not reqt.nredirects or reqt.nredirects < 5) |
| 260 | end | 262 | end |
| @@ -13,8 +13,6 @@ | |||
| 13 | * getpeername and getsockname functions as seen by Lua programs. | 13 | * getpeername and getsockname functions as seen by Lua programs. |
| 14 | * | 14 | * |
| 15 | * The Lua functions toip and tohostname are also implemented here. | 15 | * The Lua functions toip and tohostname are also implemented here. |
| 16 | * | ||
| 17 | * RCS ID: $Id$ | ||
| 18 | \*=========================================================================*/ | 16 | \*=========================================================================*/ |
| 19 | #include "lua.h" | 17 | #include "lua.h" |
| 20 | #include "socket.h" | 18 | #include "socket.h" |
| @@ -11,8 +11,6 @@ | |||
| 11 | * | 11 | * |
| 12 | * The module socket.h implements this interface, and thus the module tcp.h | 12 | * The module socket.h implements this interface, and thus the module tcp.h |
| 13 | * is very simple. | 13 | * is very simple. |
| 14 | * | ||
| 15 | * RCS ID: $Id$ | ||
| 16 | \*=========================================================================*/ | 14 | \*=========================================================================*/ |
| 17 | #include <stdio.h> | 15 | #include <stdio.h> |
| 18 | #include "lua.h" | 16 | #include "lua.h" |
diff --git a/src/luasocket.c b/src/luasocket.c index 142aa95..3b29e8e 100644 --- a/src/luasocket.c +++ b/src/luasocket.c | |||
| @@ -10,8 +10,6 @@ | |||
| 10 | * involved in setting up both client and server connections. The provided | 10 | * involved in setting up both client and server connections. The provided |
| 11 | * IO routines, however, follow the Lua style, being very similar to the | 11 | * IO routines, however, follow the Lua style, being very similar to the |
| 12 | * standard Lua read and write functions. | 12 | * standard Lua read and write functions. |
| 13 | * | ||
| 14 | * RCS ID: $Id$ | ||
| 15 | \*=========================================================================*/ | 13 | \*=========================================================================*/ |
| 16 | 14 | ||
| 17 | /*=========================================================================*\ | 15 | /*=========================================================================*\ |
diff --git a/src/luasocket.h b/src/luasocket.h index 13134cf..d7a78bb 100644 --- a/src/luasocket.h +++ b/src/luasocket.h | |||
| @@ -5,16 +5,14 @@ | |||
| 5 | * Networking support for the Lua language | 5 | * Networking support for the Lua language |
| 6 | * Diego Nehab | 6 | * Diego Nehab |
| 7 | * 9/11/1999 | 7 | * 9/11/1999 |
| 8 | * | ||
| 9 | * RCS ID: $Id$ | ||
| 10 | \*=========================================================================*/ | 8 | \*=========================================================================*/ |
| 11 | #include "lua.h" | 9 | #include "lua.h" |
| 12 | 10 | ||
| 13 | /*-------------------------------------------------------------------------*\ | 11 | /*-------------------------------------------------------------------------*\ |
| 14 | * Current socket library version | 12 | * Current socket library version |
| 15 | \*-------------------------------------------------------------------------*/ | 13 | \*-------------------------------------------------------------------------*/ |
| 16 | #define LUASOCKET_VERSION "LuaSocket 2.0.2" | 14 | #define LUASOCKET_VERSION "LuaSocket 2.0.3" |
| 17 | #define LUASOCKET_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab" | 15 | #define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2009 Diego Nehab" |
| 18 | #define LUASOCKET_AUTHORS "Diego Nehab" | 16 | #define LUASOCKET_AUTHORS "Diego Nehab" |
| 19 | 17 | ||
| 20 | /*-------------------------------------------------------------------------*\ | 18 | /*-------------------------------------------------------------------------*\ |
diff --git a/src/makefile b/src/makefile index b614f77..3351997 100644 --- a/src/makefile +++ b/src/makefile | |||
| @@ -1,39 +1,86 @@ | |||
| 1 | PLAT = none | ||
| 2 | INSTALL_DATA=cp | ||
| 3 | INSTALL_EXEC=cp | ||
| 4 | INSTALL_TOP= /opt/local | ||
| 5 | LUAINC= $(LUAINC_$(PLAT)) | ||
| 6 | |||
| 1 | #------ | 7 | #------ |
| 2 | # Load configuration | 8 | # Install directories |
| 3 | # | 9 | # |
| 4 | include ../config | 10 | INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/5.1 |
| 11 | INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/5.1 | ||
| 12 | INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket | ||
| 13 | INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket | ||
| 14 | INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime | ||
| 15 | INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime | ||
| 5 | 16 | ||
| 6 | #------ | 17 | #------ |
| 7 | # Hopefully no need to change anything below this line | 18 | # Output file names |
| 8 | # | 19 | # |
| 20 | EXT=so | ||
| 21 | SOCKET_V=2.0.3 | ||
| 22 | MIME_V=1.0.3 | ||
| 23 | SOCKET_SO=socket.$(EXT).$(SOCKET_V) | ||
| 24 | MIME_SO=mime.$(EXT).$(MIME_V) | ||
| 25 | UNIX_SO=unix.$(EXT) | ||
| 9 | 26 | ||
| 10 | #------ | 27 | #------ |
| 11 | # Modules belonging to socket-core | 28 | # Compiler and linker settings |
| 12 | # | 29 | # for Mac OS X |
| 30 | LUAINC_macosx= -I/opt/local/include | ||
| 31 | CC_macosx=gcc | ||
| 32 | DEF_macosx= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN \ | ||
| 33 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ | ||
| 34 | -DMIME_API='__attribute__((visibility("default")))' | ||
| 35 | CFLAGS_macosx= $(LUAINC) $(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common \ | ||
| 36 | -fvisibility=hidden | ||
| 37 | LDFLAGS_macosx= -bundle -undefined dynamic_lookup | ||
| 38 | LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc | ||
| 13 | 39 | ||
| 14 | #$(COMPAT)/compat-5.1.o \ | 40 | #------ |
| 41 | # Compiler and linker settings | ||
| 42 | # for Linux | ||
| 43 | LUAINC_linux= -I/usr/local/include/lua5.1 | ||
| 44 | CC_linux=gcc | ||
| 45 | DEF_linux=-DLUASOCKET_DEBUG \ | ||
| 46 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ | ||
| 47 | -DMIME_API='__attribute__((visibility("default")))' | ||
| 48 | CFLAGS_linux= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic \ | ||
| 49 | -fvisibility=hidden | ||
| 50 | LDFLAGS_linux=-O -shared -fpic | ||
| 51 | LD_linux= gcc | ||
| 15 | 52 | ||
| 16 | SOCKET_OBJS:= \ | 53 | #------ |
| 54 | # Settings selected for platform | ||
| 55 | # | ||
| 56 | CC=$(CC_$(PLAT)) | ||
| 57 | DEF=$(DEF_$(PLAT)) | ||
| 58 | CFLAGS=$(CFLAGS_$(PLAT)) | ||
| 59 | LDFLAGS=$(LDFLAGS_$(PLAT)) | ||
| 60 | LD=$(LD_$(PLAT)) | ||
| 61 | |||
| 62 | #------ | ||
| 63 | # Modules belonging to socket-core | ||
| 64 | # | ||
| 65 | SOCKET_OBJS= \ | ||
| 17 | luasocket.o \ | 66 | luasocket.o \ |
| 18 | timeout.o \ | 67 | timeout.o \ |
| 19 | buffer.o \ | 68 | buffer.o \ |
| 20 | io.o \ | 69 | io.o \ |
| 21 | auxiliar.o \ | 70 | auxiliar.o \ |
| 22 | options.o \ | 71 | options.o \ |
| 23 | inet.o \ | 72 | inet.o \ |
| 24 | tcp.o \ | 73 | usocket.o \ |
| 25 | udp.o \ | ||
| 26 | except.o \ | 74 | except.o \ |
| 27 | select.o \ | 75 | select.o \ |
| 28 | usocket.o | 76 | tcp.o \ |
| 77 | udp.o | ||
| 29 | 78 | ||
| 30 | #------ | 79 | #------ |
| 31 | # Modules belonging mime-core | 80 | # Modules belonging mime-core |
| 32 | # | 81 | # |
| 33 | #$(COMPAT)/compat-5.1.o \ | 82 | MIME_OBJS= \ |
| 34 | 83 | mime.o | |
| 35 | MIME_OBJS:=\ | ||
| 36 | mime.o | ||
| 37 | 84 | ||
| 38 | #------ | 85 | #------ |
| 39 | # Modules belonging unix (local domain sockets) | 86 | # Modules belonging unix (local domain sockets) |
| @@ -47,7 +94,35 @@ UNIX_OBJS:=\ | |||
| 47 | usocket.o \ | 94 | usocket.o \ |
| 48 | unix.o | 95 | unix.o |
| 49 | 96 | ||
| 50 | all: $(SOCKET_SO) $(MIME_SO) | 97 | #------ |
| 98 | # Files to install | ||
| 99 | # | ||
| 100 | TO_SOCKET_SHARE:= \ | ||
| 101 | http.lua \ | ||
| 102 | url.lua \ | ||
| 103 | tp.lua \ | ||
| 104 | ftp.lua \ | ||
| 105 | headers.lua \ | ||
| 106 | smtp.lua | ||
| 107 | |||
| 108 | TO_TOP_SHARE:= \ | ||
| 109 | ltn12.lua \ | ||
| 110 | socket.lua \ | ||
| 111 | mime.lua | ||
| 112 | |||
| 113 | default: $(PLAT) | ||
| 114 | |||
| 115 | macosx: | ||
| 116 | $(MAKE) all PLAT=macosx | ||
| 117 | |||
| 118 | linux: | ||
| 119 | $(MAKE) all PLAT=linux | ||
| 120 | |||
| 121 | none: | ||
| 122 | @echo "Please choose a platform:" | ||
| 123 | @echo " $(PLATS)" | ||
| 124 | |||
| 125 | all: $(SOCKET_SO) $(MIME_SO) | ||
| 51 | 126 | ||
| 52 | $(SOCKET_SO): $(SOCKET_OBJS) | 127 | $(SOCKET_SO): $(SOCKET_OBJS) |
| 53 | $(LD) $(LDFLAGS) -o $@ $(SOCKET_OBJS) | 128 | $(LD) $(LDFLAGS) -o $@ $(SOCKET_OBJS) |
| @@ -58,6 +133,25 @@ $(MIME_SO): $(MIME_OBJS) | |||
| 58 | $(UNIX_SO): $(UNIX_OBJS) | 133 | $(UNIX_SO): $(UNIX_OBJS) |
| 59 | $(LD) $(LDFLAGS) -o $@ $(UNIX_OBJS) | 134 | $(LD) $(LDFLAGS) -o $@ $(UNIX_OBJS) |
| 60 | 135 | ||
| 136 | install: | ||
| 137 | mkdir -p $(INSTALL_TOP_SHARE) | ||
| 138 | $(INSTALL_DATA) $(TO_TOP_SHARE) $(INSTALL_TOP_SHARE) | ||
| 139 | mkdir -p $(INSTALL_SOCKET_SHARE) | ||
| 140 | $(INSTALL_DATA) $(TO_SOCKET_SHARE) $(INSTALL_SOCKET_SHARE) | ||
| 141 | mkdir -p $(INSTALL_SOCKET_LIB) | ||
| 142 | $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_LIB)/core.$(EXT) | ||
| 143 | mkdir -p $(INSTALL_MIME_LIB) | ||
| 144 | $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(EXT) | ||
| 145 | |||
| 146 | local: | ||
| 147 | $(MAKE) install INSTALL_TOP_LIB=.. INSTALL_TOP_SHARE=.. | ||
| 148 | |||
| 149 | clean: | ||
| 150 | rm -f $(SOCKET_SO) $(SOCKET_OBJS) | ||
| 151 | rm -f $(MIME_SO) $(UNIX_SO) $(MIME_OBJS) $(UNIX_OBJS) | ||
| 152 | |||
| 153 | .PHONY: all $(PLATS) default clean echo none | ||
| 154 | |||
| 61 | #------ | 155 | #------ |
| 62 | # List of dependencies | 156 | # List of dependencies |
| 63 | # | 157 | # |
| @@ -66,25 +160,19 @@ buffer.o: buffer.c buffer.h io.h timeout.h | |||
| 66 | except.o: except.c except.h | 160 | except.o: except.c except.h |
| 67 | inet.o: inet.c inet.h socket.h io.h timeout.h usocket.h | 161 | inet.o: inet.c inet.h socket.h io.h timeout.h usocket.h |
| 68 | io.o: io.c io.h timeout.h | 162 | io.o: io.c io.h timeout.h |
| 69 | luasocket.o: luasocket.c luasocket.h auxiliar.h except.h timeout.h \ | 163 | luasocket.o: luasocket.c luasocket.h auxiliar.h except.h \ |
| 70 | buffer.h io.h inet.h socket.h usocket.h tcp.h udp.h select.h | 164 | timeout.h buffer.h io.h inet.h socket.h usocket.h tcp.h \ |
| 165 | udp.h select.h | ||
| 71 | mime.o: mime.c mime.h | 166 | mime.o: mime.c mime.h |
| 72 | options.o: options.c auxiliar.h options.h socket.h io.h timeout.h \ | 167 | options.o: options.c auxiliar.h options.h socket.h io.h \ |
| 73 | usocket.h inet.h | 168 | timeout.h usocket.h inet.h |
| 74 | select.o: select.c socket.h io.h timeout.h usocket.h select.h | 169 | select.o: select.c socket.h io.h timeout.h usocket.h select.h |
| 75 | tcp.o: tcp.c auxiliar.h socket.h io.h timeout.h usocket.h inet.h \ | 170 | tcp.o: tcp.c auxiliar.h socket.h io.h timeout.h usocket.h \ |
| 76 | options.h tcp.h buffer.h | 171 | inet.h options.h tcp.h buffer.h |
| 77 | timeout.o: timeout.c auxiliar.h timeout.h | 172 | timeout.o: timeout.c auxiliar.h timeout.h |
| 78 | udp.o: udp.c auxiliar.h socket.h io.h timeout.h usocket.h inet.h \ | 173 | udp.o: udp.c auxiliar.h socket.h io.h timeout.h usocket.h \ |
| 79 | options.h udp.h | 174 | inet.h options.h udp.h |
| 80 | unix.o: unix.c auxiliar.h socket.h io.h timeout.h usocket.h options.h \ | 175 | unix.o: unix.c auxiliar.h socket.h io.h timeout.h usocket.h \ |
| 81 | unix.h buffer.h | 176 | options.h unix.h buffer.h |
| 82 | usocket.o: usocket.c socket.h io.h timeout.h usocket.h | 177 | usocket.o: usocket.c socket.h io.h timeout.h usocket.h |
| 83 | 178 | wsocket.o: wsocket.c socket.h io.h timeout.h usocket.h | |
| 84 | clean: | ||
| 85 | rm -f $(SOCKET_SO) $(SOCKET_OBJS) | ||
| 86 | rm -f $(MIME_SO) $(UNIX_SO) $(MIME_OBJS) $(UNIX_OBJS) | ||
| 87 | |||
| 88 | #------ | ||
| 89 | # End of makefile configuration | ||
| 90 | # | ||
| @@ -272,9 +272,12 @@ static int mime_global_b64(lua_State *L) | |||
| 272 | input = (UC *) luaL_optlstring(L, 2, NULL, &isize); | 272 | input = (UC *) luaL_optlstring(L, 2, NULL, &isize); |
| 273 | /* if second part is nil, we are done */ | 273 | /* if second part is nil, we are done */ |
| 274 | if (!input) { | 274 | if (!input) { |
| 275 | size_t osize = 0; | ||
| 275 | asize = b64pad(atom, asize, &buffer); | 276 | asize = b64pad(atom, asize, &buffer); |
| 276 | luaL_pushresult(&buffer); | 277 | luaL_pushresult(&buffer); |
| 277 | if (!(*lua_tostring(L, -1))) lua_pushnil(L); | 278 | /* if the output is empty and the input is nil, return nil */ |
| 279 | lua_tolstring(L, -1, &osize); | ||
| 280 | if (osize == 0) lua_pushnil(L); | ||
| 278 | lua_pushnil(L); | 281 | lua_pushnil(L); |
| 279 | return 2; | 282 | return 2; |
| 280 | } | 283 | } |
| @@ -313,8 +316,11 @@ static int mime_global_unb64(lua_State *L) | |||
| 313 | input = (UC *) luaL_optlstring(L, 2, NULL, &isize); | 316 | input = (UC *) luaL_optlstring(L, 2, NULL, &isize); |
| 314 | /* if second is nil, we are done */ | 317 | /* if second is nil, we are done */ |
| 315 | if (!input) { | 318 | if (!input) { |
| 319 | size_t osize = 0; | ||
| 316 | luaL_pushresult(&buffer); | 320 | luaL_pushresult(&buffer); |
| 317 | if (!(*lua_tostring(L, -1))) lua_pushnil(L); | 321 | /* if the output is empty and the input is nil, return nil */ |
| 322 | lua_tolstring(L, -1, &osize); | ||
| 323 | if (osize == 0) lua_pushnil(L); | ||
| 318 | lua_pushnil(L); | 324 | lua_pushnil(L); |
| 319 | return 2; | 325 | return 2; |
| 320 | } | 326 | } |
| @@ -7,16 +7,14 @@ | |||
| 7 | * This module provides functions to implement transfer content encodings | 7 | * This module provides functions to implement transfer content encodings |
| 8 | * and formatting conforming to RFC 2045. It is used by mime.lua, which | 8 | * and formatting conforming to RFC 2045. It is used by mime.lua, which |
| 9 | * provide a higher level interface to this functionality. | 9 | * provide a higher level interface to this functionality. |
| 10 | * | ||
| 11 | * RCS ID: $Id$ | ||
| 12 | \*=========================================================================*/ | 10 | \*=========================================================================*/ |
| 13 | #include "lua.h" | 11 | #include "lua.h" |
| 14 | 12 | ||
| 15 | /*-------------------------------------------------------------------------*\ | 13 | /*-------------------------------------------------------------------------*\ |
| 16 | * Current MIME library version | 14 | * Current MIME library version |
| 17 | \*-------------------------------------------------------------------------*/ | 15 | \*-------------------------------------------------------------------------*/ |
| 18 | #define MIME_VERSION "MIME 1.0.2" | 16 | #define MIME_VERSION "MIME 1.0.3" |
| 19 | #define MIME_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab" | 17 | #define MIME_COPYRIGHT "Copyright (C) 2004-2009 Diego Nehab" |
| 20 | #define MIME_AUTHORS "Diego Nehab" | 18 | #define MIME_AUTHORS "Diego Nehab" |
| 21 | 19 | ||
| 22 | /*-------------------------------------------------------------------------*\ | 20 | /*-------------------------------------------------------------------------*\ |
diff --git a/src/options.c b/src/options.c index a464a4b..1d4c950 100644 --- a/src/options.c +++ b/src/options.c | |||
| @@ -12,12 +12,12 @@ | |||
| 12 | #include "options.h" | 12 | #include "options.h" |
| 13 | #include "inet.h" | 13 | #include "inet.h" |
| 14 | 14 | ||
| 15 | |||
| 16 | /*=========================================================================*\ | 15 | /*=========================================================================*\ |
| 17 | * Internal functions prototypes | 16 | * Internal functions prototypes |
| 18 | \*=========================================================================*/ | 17 | \*=========================================================================*/ |
| 19 | static int opt_setmembership(lua_State *L, p_socket ps, int level, int name); | 18 | static int opt_setmembership(lua_State *L, p_socket ps, int level, int name); |
| 20 | static int opt_setboolean(lua_State *L, p_socket ps, int level, int name); | 19 | static int opt_setboolean(lua_State *L, p_socket ps, int level, int name); |
| 20 | static int opt_getboolean(lua_State *L, p_socket ps, int level, int name); | ||
| 21 | static int opt_set(lua_State *L, p_socket ps, int level, int name, | 21 | static int opt_set(lua_State *L, p_socket ps, int level, int name, |
| 22 | void *val, int len); | 22 | void *val, int len); |
| 23 | 23 | ||
| @@ -40,39 +40,63 @@ int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps) | |||
| 40 | return opt->func(L, ps); | 40 | return opt->func(L, ps); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps) | ||
| 44 | { | ||
| 45 | const char *name = luaL_checkstring(L, 2); /* obj, name, ... */ | ||
| 46 | while (opt->name && strcmp(name, opt->name)) | ||
| 47 | opt++; | ||
| 48 | if (!opt->func) { | ||
| 49 | char msg[45]; | ||
| 50 | sprintf(msg, "unsupported option `%.35s'", name); | ||
| 51 | luaL_argerror(L, 2, msg); | ||
| 52 | } | ||
| 53 | return opt->func(L, ps); | ||
| 54 | } | ||
| 55 | |||
| 43 | /* enables reuse of local address */ | 56 | /* enables reuse of local address */ |
| 44 | int opt_reuseaddr(lua_State *L, p_socket ps) | 57 | int opt_set_reuseaddr(lua_State *L, p_socket ps) |
| 45 | { | 58 | { |
| 46 | return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR); | 59 | return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR); |
| 47 | } | 60 | } |
| 48 | 61 | ||
| 62 | /* enables reuse of local port */ | ||
| 63 | int opt_set_reuseport(lua_State *L, p_socket ps) | ||
| 64 | { | ||
| 65 | return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEPORT); | ||
| 66 | } | ||
| 67 | |||
| 49 | /* disables the Naggle algorithm */ | 68 | /* disables the Naggle algorithm */ |
| 50 | int opt_tcp_nodelay(lua_State *L, p_socket ps) | 69 | int opt_set_tcp_nodelay(lua_State *L, p_socket ps) |
| 51 | { | 70 | { |
| 52 | return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY); | 71 | return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY); |
| 53 | } | 72 | } |
| 54 | 73 | ||
| 55 | int opt_keepalive(lua_State *L, p_socket ps) | 74 | int opt_set_keepalive(lua_State *L, p_socket ps) |
| 56 | { | 75 | { |
| 57 | return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE); | 76 | return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE); |
| 58 | } | 77 | } |
| 59 | 78 | ||
| 60 | int opt_dontroute(lua_State *L, p_socket ps) | 79 | int opt_set_dontroute(lua_State *L, p_socket ps) |
| 61 | { | 80 | { |
| 62 | return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE); | 81 | return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE); |
| 63 | } | 82 | } |
| 64 | 83 | ||
| 65 | int opt_broadcast(lua_State *L, p_socket ps) | 84 | int opt_set_broadcast(lua_State *L, p_socket ps) |
| 66 | { | 85 | { |
| 67 | return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST); | 86 | return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST); |
| 68 | } | 87 | } |
| 69 | 88 | ||
| 70 | int opt_ip_multicast_loop(lua_State *L, p_socket ps) | 89 | int opt_set_ip_multicast_loop(lua_State *L, p_socket ps) |
| 71 | { | 90 | { |
| 72 | return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP); | 91 | return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP); |
| 73 | } | 92 | } |
| 74 | 93 | ||
| 75 | int opt_linger(lua_State *L, p_socket ps) | 94 | int opt_get_ip_multicast_loop(lua_State *L, p_socket ps) |
| 95 | { | ||
| 96 | return opt_getboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP); | ||
| 97 | } | ||
| 98 | |||
| 99 | int opt_set_linger(lua_State *L, p_socket ps) | ||
| 76 | { | 100 | { |
| 77 | struct linger li; /* obj, name, table */ | 101 | struct linger li; /* obj, name, table */ |
| 78 | if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE)); | 102 | 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) | |||
| 89 | return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li)); | 113 | return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li)); |
| 90 | } | 114 | } |
| 91 | 115 | ||
| 92 | int opt_ip_multicast_ttl(lua_State *L, p_socket ps) | 116 | int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps) |
| 93 | { | 117 | { |
| 94 | int val = (int) luaL_checknumber(L, 3); /* obj, name, int */ | 118 | int val = (int) luaL_checknumber(L, 3); /* obj, name, int */ |
| 95 | return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &val, sizeof(val)); | 119 | return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_TTL, |
| 120 | (char *) &val, sizeof(val)); | ||
| 121 | } | ||
| 122 | |||
| 123 | int opt_set_ip_multicast_if(lua_State *L, p_socket ps) | ||
| 124 | { | ||
| 125 | const char *address = luaL_checkstring(L, 3); /* obj, name, ip */ | ||
| 126 | struct in_addr val; | ||
| 127 | val.s_addr = htonl(INADDR_ANY); | ||
| 128 | if (strcmp(address, "*") && !inet_aton(address, &val)) | ||
| 129 | luaL_argerror(L, 3, "ip expected"); | ||
| 130 | return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_IF, | ||
| 131 | (char *) &val, sizeof(val)); | ||
| 132 | } | ||
| 133 | |||
| 134 | int opt_get_ip_multicast_if(lua_State *L, p_socket ps) | ||
| 135 | { | ||
| 136 | struct in_addr val; | ||
| 137 | socklen_t len = sizeof(val); | ||
| 138 | if (getsockopt(*ps, IPPROTO_IP, IP_MULTICAST_IF, (char *) &val, &len) < 0) { | ||
| 139 | lua_pushnil(L); | ||
| 140 | lua_pushstring(L, "getsockopt failed"); | ||
| 141 | return 2; | ||
| 142 | } | ||
| 143 | lua_pushstring(L, inet_ntoa(val)); | ||
| 144 | return 1; | ||
| 96 | } | 145 | } |
| 97 | 146 | ||
| 98 | int opt_ip_add_membership(lua_State *L, p_socket ps) | 147 | int opt_set_ip_add_membership(lua_State *L, p_socket ps) |
| 99 | { | 148 | { |
| 100 | return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP); | 149 | return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP); |
| 101 | } | 150 | } |
| 102 | 151 | ||
| 103 | int opt_ip_drop_membersip(lua_State *L, p_socket ps) | 152 | int opt_set_ip_drop_membersip(lua_State *L, p_socket ps) |
| 104 | { | 153 | { |
| 105 | return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP); | 154 | return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP); |
| 106 | } | 155 | } |
| @@ -141,6 +190,19 @@ int opt_set(lua_State *L, p_socket ps, int level, int name, void *val, int len) | |||
| 141 | return 1; | 190 | return 1; |
| 142 | } | 191 | } |
| 143 | 192 | ||
| 193 | static int opt_getboolean(lua_State *L, p_socket ps, int level, int name) | ||
| 194 | { | ||
| 195 | int val = 0; | ||
| 196 | socklen_t len = sizeof(val); | ||
| 197 | if (getsockopt(*ps, level, name, (char *) &val, &len) < 0) { | ||
| 198 | lua_pushnil(L); | ||
| 199 | lua_pushstring(L, "getsockopt failed"); | ||
| 200 | return 2; | ||
| 201 | } | ||
| 202 | lua_pushboolean(L, val); | ||
| 203 | return 1; | ||
| 204 | } | ||
| 205 | |||
| 144 | static int opt_setboolean(lua_State *L, p_socket ps, int level, int name) | 206 | static int opt_setboolean(lua_State *L, p_socket ps, int level, int name) |
| 145 | { | 207 | { |
| 146 | int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */ | 208 | int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */ |
diff --git a/src/options.h b/src/options.h index 900761e..aa43cab 100644 --- a/src/options.h +++ b/src/options.h | |||
| @@ -6,8 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * This module provides a common interface to socket options, used mainly by | 7 | * This module provides a common interface to socket options, used mainly by |
| 8 | * modules UDP and TCP. | 8 | * modules UDP and TCP. |
| 9 | * | ||
| 10 | * RCS ID: $Id$ | ||
| 11 | \*=========================================================================*/ | 9 | \*=========================================================================*/ |
| 12 | 10 | ||
| 13 | #include "lua.h" | 11 | #include "lua.h" |
| @@ -20,20 +18,28 @@ typedef struct t_opt { | |||
| 20 | } t_opt; | 18 | } t_opt; |
| 21 | typedef t_opt *p_opt; | 19 | typedef t_opt *p_opt; |
| 22 | 20 | ||
| 23 | /* supported options */ | 21 | /* supported options for setoption */ |
| 24 | int opt_dontroute(lua_State *L, p_socket ps); | 22 | int opt_set_dontroute(lua_State *L, p_socket ps); |
| 25 | int opt_broadcast(lua_State *L, p_socket ps); | 23 | int opt_set_broadcast(lua_State *L, p_socket ps); |
| 26 | int opt_reuseaddr(lua_State *L, p_socket ps); | 24 | int opt_set_reuseaddr(lua_State *L, p_socket ps); |
| 27 | int opt_tcp_nodelay(lua_State *L, p_socket ps); | 25 | int opt_set_tcp_nodelay(lua_State *L, p_socket ps); |
| 28 | int opt_keepalive(lua_State *L, p_socket ps); | 26 | int opt_set_keepalive(lua_State *L, p_socket ps); |
| 29 | int opt_linger(lua_State *L, p_socket ps); | 27 | int opt_set_linger(lua_State *L, p_socket ps); |
| 30 | int opt_reuseaddr(lua_State *L, p_socket ps); | 28 | int opt_set_reuseaddr(lua_State *L, p_socket ps); |
| 31 | int opt_ip_multicast_ttl(lua_State *L, p_socket ps); | 29 | int opt_set_reuseport(lua_State *L, p_socket ps); |
| 32 | int opt_ip_multicast_loop(lua_State *L, p_socket ps); | 30 | int opt_set_ip_multicast_if(lua_State *L, p_socket ps); |
| 33 | int opt_ip_add_membership(lua_State *L, p_socket ps); | 31 | int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps); |
| 34 | int opt_ip_drop_membersip(lua_State *L, p_socket ps); | 32 | int opt_set_ip_multicast_loop(lua_State *L, p_socket ps); |
| 35 | 33 | int opt_set_ip_add_membership(lua_State *L, p_socket ps); | |
| 34 | int opt_set_ip_drop_membersip(lua_State *L, p_socket ps); | ||
| 36 | /* invokes the appropriate option handler */ | 35 | /* invokes the appropriate option handler */ |
| 37 | int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); | 36 | int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); |
| 38 | 37 | ||
| 38 | /* supported options for getoption */ | ||
| 39 | int opt_get_ip_multicast_loop(lua_State *L, p_socket ps); | ||
| 40 | int opt_get_ip_multicast_if(lua_State *L, p_socket ps); | ||
| 41 | /* invokes the appropriate option handler */ | ||
| 42 | int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps); | ||
| 43 | |||
| 44 | |||
| 39 | #endif | 45 | #endif |
diff --git a/src/select.c b/src/select.c index 99b59f5..8e47d0e 100644 --- a/src/select.c +++ b/src/select.c | |||
| @@ -18,8 +18,8 @@ | |||
| 18 | \*=========================================================================*/ | 18 | \*=========================================================================*/ |
| 19 | static t_socket getfd(lua_State *L); | 19 | static t_socket getfd(lua_State *L); |
| 20 | static int dirty(lua_State *L); | 20 | static int dirty(lua_State *L); |
| 21 | static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd, | 21 | static void collect_fd(lua_State *L, int tab, int itab, |
| 22 | int itab, fd_set *set); | 22 | fd_set *set, t_socket *max_fd); |
| 23 | static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set); | 23 | static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set); |
| 24 | static void return_fd(lua_State *L, fd_set *set, t_socket max_fd, | 24 | static void return_fd(lua_State *L, fd_set *set, t_socket max_fd, |
| 25 | int itab, int tab, int start); | 25 | int itab, int tab, int start); |
| @@ -39,6 +39,9 @@ static luaL_reg func[] = { | |||
| 39 | * Initializes module | 39 | * Initializes module |
| 40 | \*-------------------------------------------------------------------------*/ | 40 | \*-------------------------------------------------------------------------*/ |
| 41 | int select_open(lua_State *L) { | 41 | int select_open(lua_State *L) { |
| 42 | lua_pushstring(L, "_SETSIZE"); | ||
| 43 | lua_pushnumber(L, FD_SETSIZE); | ||
| 44 | lua_rawset(L, -3); | ||
| 42 | luaL_openlib(L, NULL, func, 0); | 45 | luaL_openlib(L, NULL, func, 0); |
| 43 | return 0; | 46 | return 0; |
| 44 | } | 47 | } |
| @@ -51,7 +54,7 @@ int select_open(lua_State *L) { | |||
| 51 | \*-------------------------------------------------------------------------*/ | 54 | \*-------------------------------------------------------------------------*/ |
| 52 | static int global_select(lua_State *L) { | 55 | static int global_select(lua_State *L) { |
| 53 | int rtab, wtab, itab, ret, ndirty; | 56 | int rtab, wtab, itab, ret, ndirty; |
| 54 | t_socket max_fd; | 57 | t_socket max_fd = SOCKET_INVALID; |
| 55 | fd_set rset, wset; | 58 | fd_set rset, wset; |
| 56 | t_timeout tm; | 59 | t_timeout tm; |
| 57 | double t = luaL_optnumber(L, 3, -1); | 60 | double t = luaL_optnumber(L, 3, -1); |
| @@ -60,12 +63,12 @@ static int global_select(lua_State *L) { | |||
| 60 | lua_newtable(L); itab = lua_gettop(L); | 63 | lua_newtable(L); itab = lua_gettop(L); |
| 61 | lua_newtable(L); rtab = lua_gettop(L); | 64 | lua_newtable(L); rtab = lua_gettop(L); |
| 62 | lua_newtable(L); wtab = lua_gettop(L); | 65 | lua_newtable(L); wtab = lua_gettop(L); |
| 63 | max_fd = collect_fd(L, 1, SOCKET_INVALID, itab, &rset); | 66 | collect_fd(L, 1, itab, &rset, &max_fd); |
| 67 | collect_fd(L, 2, itab, &wset, &max_fd); | ||
| 64 | ndirty = check_dirty(L, 1, rtab, &rset); | 68 | ndirty = check_dirty(L, 1, rtab, &rset); |
| 65 | t = ndirty > 0? 0.0: t; | 69 | t = ndirty > 0? 0.0: t; |
| 66 | timeout_init(&tm, t, -1); | 70 | timeout_init(&tm, t, -1); |
| 67 | timeout_markstart(&tm); | 71 | timeout_markstart(&tm); |
| 68 | max_fd = collect_fd(L, 2, max_fd, itab, &wset); | ||
| 69 | ret = socket_select(max_fd+1, &rset, &wset, NULL, &tm); | 72 | ret = socket_select(max_fd+1, &rset, &wset, NULL, &tm); |
| 70 | if (ret > 0 || ndirty > 0) { | 73 | if (ret > 0 || ndirty > 0) { |
| 71 | return_fd(L, &rset, max_fd+1, itab, rtab, ndirty); | 74 | return_fd(L, &rset, max_fd+1, itab, rtab, ndirty); |
| @@ -77,7 +80,7 @@ static int global_select(lua_State *L) { | |||
| 77 | lua_pushstring(L, "timeout"); | 80 | lua_pushstring(L, "timeout"); |
| 78 | return 3; | 81 | return 3; |
| 79 | } else { | 82 | } else { |
| 80 | lua_pushstring(L, "error"); | 83 | luaL_error(L, "select failed"); |
| 81 | return 3; | 84 | return 3; |
| 82 | } | 85 | } |
| 83 | } | 86 | } |
| @@ -112,11 +115,13 @@ static int dirty(lua_State *L) { | |||
| 112 | return is; | 115 | return is; |
| 113 | } | 116 | } |
| 114 | 117 | ||
| 115 | static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd, | 118 | static void collect_fd(lua_State *L, int tab, int itab, |
| 116 | int itab, fd_set *set) { | 119 | fd_set *set, t_socket *max_fd) { |
| 117 | int i = 1; | 120 | int i = 1, n = 0; |
| 118 | if (lua_isnil(L, tab)) | 121 | /* nil is the same as an empty table */ |
| 119 | return max_fd; | 122 | if (lua_isnil(L, tab)) return; |
| 123 | /* otherwise we need it to be a table */ | ||
| 124 | luaL_checktype(L, tab, LUA_TTABLE); | ||
| 120 | while (1) { | 125 | while (1) { |
| 121 | t_socket fd; | 126 | t_socket fd; |
| 122 | lua_pushnumber(L, i); | 127 | lua_pushnumber(L, i); |
| @@ -125,11 +130,18 @@ static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd, | |||
| 125 | lua_pop(L, 1); | 130 | lua_pop(L, 1); |
| 126 | break; | 131 | break; |
| 127 | } | 132 | } |
| 133 | /* getfd figures out if this is a socket */ | ||
| 128 | fd = getfd(L); | 134 | fd = getfd(L); |
| 129 | if (fd != SOCKET_INVALID) { | 135 | if (fd != SOCKET_INVALID) { |
| 136 | /* make sure we don't overflow the fd_set */ | ||
| 137 | if (n >= FD_SETSIZE) | ||
| 138 | luaL_argerror(L, tab, "too many sockets"); | ||
| 130 | FD_SET(fd, set); | 139 | FD_SET(fd, set); |
| 131 | if (max_fd == SOCKET_INVALID || max_fd < fd) | 140 | n++; |
| 132 | max_fd = fd; | 141 | /* keep track of the largest descriptor so far */ |
| 142 | if (*max_fd == SOCKET_INVALID || *max_fd < fd) | ||
| 143 | *max_fd = fd; | ||
| 144 | /* make sure we can map back from descriptor to the object */ | ||
| 133 | lua_pushnumber(L, fd); | 145 | lua_pushnumber(L, fd); |
| 134 | lua_pushvalue(L, -2); | 146 | lua_pushvalue(L, -2); |
| 135 | lua_settable(L, itab); | 147 | lua_settable(L, itab); |
| @@ -137,7 +149,6 @@ static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd, | |||
| 137 | lua_pop(L, 1); | 149 | lua_pop(L, 1); |
| 138 | i = i + 1; | 150 | i = i + 1; |
| 139 | } | 151 | } |
| 140 | return max_fd; | ||
| 141 | } | 152 | } |
| 142 | 153 | ||
| 143 | static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) { | 154 | static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) { |
diff --git a/src/select.h b/src/select.h index f2d2cc2..8750200 100644 --- a/src/select.h +++ b/src/select.h | |||
| @@ -8,8 +8,6 @@ | |||
| 8 | * method getfd() which returns the descriptor to be passed to the | 8 | * method getfd() which returns the descriptor to be passed to the |
| 9 | * underlying select function. Another method, dirty(), should return | 9 | * underlying select function. Another method, dirty(), should return |
| 10 | * true if there is data ready for reading (required for buffered input). | 10 | * true if there is data ready for reading (required for buffered input). |
| 11 | * | ||
| 12 | * RCS ID: $Id$ | ||
| 13 | \*=========================================================================*/ | 11 | \*=========================================================================*/ |
| 14 | 12 | ||
| 15 | int select_open(lua_State *L); | 13 | int select_open(lua_State *L); |
diff --git a/src/smtp.lua b/src/smtp.lua index 9a204d8..b39f5d6 100644 --- a/src/smtp.lua +++ b/src/smtp.lua | |||
| @@ -16,6 +16,7 @@ local os = require("os") | |||
| 16 | local socket = require("socket") | 16 | local socket = require("socket") |
| 17 | local tp = require("socket.tp") | 17 | local tp = require("socket.tp") |
| 18 | local ltn12 = require("ltn12") | 18 | local ltn12 = require("ltn12") |
| 19 | local headers = require("socket.headers") | ||
| 19 | local mime = require("mime") | 20 | local mime = require("mime") |
| 20 | module("socket.smtp") | 21 | module("socket.smtp") |
| 21 | 22 | ||
| @@ -146,10 +147,11 @@ end | |||
| 146 | local send_message | 147 | local send_message |
| 147 | 148 | ||
| 148 | -- yield the headers all at once, it's faster | 149 | -- yield the headers all at once, it's faster |
| 149 | local function send_headers(headers) | 150 | local function send_headers(tosend) |
| 151 | local canonic = headers.canonic | ||
| 150 | local h = "\r\n" | 152 | local h = "\r\n" |
| 151 | for i,v in base.pairs(headers) do | 153 | for f,v in base.pairs(tosend) do |
| 152 | h = i .. ': ' .. v .. "\r\n" .. h | 154 | h = (canonic[f] or f) .. ': ' .. v .. "\r\n" .. h |
| 153 | end | 155 | end |
| 154 | coroutine.yield(h) | 156 | coroutine.yield(h) |
| 155 | end | 157 | end |
diff --git a/src/socket.h b/src/socket.h index de5d79f..425628d 100644 --- a/src/socket.h +++ b/src/socket.h | |||
| @@ -8,8 +8,6 @@ | |||
| 8 | * differences. Also, not all *nix platforms behave the same. This module | 8 | * differences. Also, not all *nix platforms behave the same. This module |
| 9 | * (and the associated usocket.h and wsocket.h) factor these differences and | 9 | * (and the associated usocket.h and wsocket.h) factor these differences and |
| 10 | * creates a interface compatible with the io.h module. | 10 | * creates a interface compatible with the io.h module. |
| 11 | * | ||
| 12 | * RCS ID: $Id$ | ||
| 13 | \*=========================================================================*/ | 11 | \*=========================================================================*/ |
| 14 | #include "io.h" | 12 | #include "io.h" |
| 15 | 13 | ||
| @@ -64,11 +64,11 @@ static luaL_reg tcp[] = { | |||
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | /* socket option handlers */ | 66 | /* socket option handlers */ |
| 67 | static t_opt opt[] = { | 67 | static t_opt optset[] = { |
| 68 | {"keepalive", opt_keepalive}, | 68 | {"keepalive", opt_set_keepalive}, |
| 69 | {"reuseaddr", opt_reuseaddr}, | 69 | {"reuseaddr", opt_set_reuseaddr}, |
| 70 | {"tcp-nodelay", opt_tcp_nodelay}, | 70 | {"tcp-nodelay", opt_set_tcp_nodelay}, |
| 71 | {"linger", opt_linger}, | 71 | {"linger", opt_set_linger}, |
| 72 | {NULL, NULL} | 72 | {NULL, NULL} |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| @@ -128,7 +128,7 @@ static int meth_setstats(lua_State *L) { | |||
| 128 | static int meth_setoption(lua_State *L) | 128 | static int meth_setoption(lua_State *L) |
| 129 | { | 129 | { |
| 130 | p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); | 130 | p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); |
| 131 | return opt_meth_setoption(L, opt, &tcp->sock); | 131 | return opt_meth_setoption(L, optset, &tcp->sock); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | /*-------------------------------------------------------------------------*\ | 134 | /*-------------------------------------------------------------------------*\ |
| @@ -13,8 +13,6 @@ | |||
| 13 | * objects are tcp objects bound to some local address. Client objects are | 13 | * objects are tcp objects bound to some local address. Client objects are |
| 14 | * tcp objects either connected to some address or returned by the accept | 14 | * tcp objects either connected to some address or returned by the accept |
| 15 | * method of a server object. | 15 | * method of a server object. |
| 16 | * | ||
| 17 | * RCS ID: $Id$ | ||
| 18 | \*=========================================================================*/ | 16 | \*=========================================================================*/ |
| 19 | #include "lua.h" | 17 | #include "lua.h" |
| 20 | 18 | ||
diff --git a/src/timeout.c b/src/timeout.c index 863546e..fb015f9 100644 --- a/src/timeout.c +++ b/src/timeout.c | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | * RCS ID: $Id$ | 5 | * RCS ID: $Id$ |
| 6 | \*=========================================================================*/ | 6 | \*=========================================================================*/ |
| 7 | #include <stdio.h> | 7 | #include <stdio.h> |
| 8 | #include <limits.h> | ||
| 9 | #include <float.h> | ||
| 8 | 10 | ||
| 9 | #include "lua.h" | 11 | #include "lua.h" |
| 10 | #include "lauxlib.h" | 12 | #include "lauxlib.h" |
| @@ -187,13 +189,23 @@ static int timeout_lua_gettime(lua_State *L) | |||
| 187 | /*-------------------------------------------------------------------------*\ | 189 | /*-------------------------------------------------------------------------*\ |
| 188 | * Sleep for n seconds. | 190 | * Sleep for n seconds. |
| 189 | \*-------------------------------------------------------------------------*/ | 191 | \*-------------------------------------------------------------------------*/ |
| 192 | #ifdef _WIN32 | ||
| 190 | int timeout_lua_sleep(lua_State *L) | 193 | int timeout_lua_sleep(lua_State *L) |
| 191 | { | 194 | { |
| 192 | double n = luaL_checknumber(L, 1); | 195 | double n = luaL_checknumber(L, 1); |
| 193 | #ifdef _WIN32 | 196 | if (n < 0.0) n = 0.0; |
| 194 | Sleep((int)(n*1000)); | 197 | if (n < DBL_MAX/1000.0) n *= 1000.0; |
| 198 | if (n > INT_MAX) n = INT_MAX; | ||
| 199 | Sleep((int)n); | ||
| 200 | return 0; | ||
| 201 | } | ||
| 195 | #else | 202 | #else |
| 203 | int timeout_lua_sleep(lua_State *L) | ||
| 204 | { | ||
| 205 | double n = luaL_checknumber(L, 1); | ||
| 196 | struct timespec t, r; | 206 | struct timespec t, r; |
| 207 | if (n < 0.0) n = 0.0; | ||
| 208 | if (n > INT_MAX) n = INT_MAX; | ||
| 197 | t.tv_sec = (int) n; | 209 | t.tv_sec = (int) n; |
| 198 | n -= t.tv_sec; | 210 | n -= t.tv_sec; |
| 199 | t.tv_nsec = (int) (n * 1000000000); | 211 | t.tv_nsec = (int) (n * 1000000000); |
| @@ -202,6 +214,6 @@ int timeout_lua_sleep(lua_State *L) | |||
| 202 | t.tv_sec = r.tv_sec; | 214 | t.tv_sec = r.tv_sec; |
| 203 | t.tv_nsec = r.tv_nsec; | 215 | t.tv_nsec = r.tv_nsec; |
| 204 | } | 216 | } |
| 205 | #endif | ||
| 206 | return 0; | 217 | return 0; |
| 207 | } | 218 | } |
| 219 | #endif | ||
diff --git a/src/timeout.h b/src/timeout.h index a328bcc..6715ca7 100644 --- a/src/timeout.h +++ b/src/timeout.h | |||
| @@ -3,8 +3,6 @@ | |||
| 3 | /*=========================================================================*\ | 3 | /*=========================================================================*\ |
| 4 | * Timeout management functions | 4 | * Timeout management functions |
| 5 | * LuaSocket toolkit | 5 | * LuaSocket toolkit |
| 6 | * | ||
| 7 | * RCS ID: $Id$ | ||
| 8 | \*=========================================================================*/ | 6 | \*=========================================================================*/ |
| 9 | #include "lua.h" | 7 | #include "lua.h" |
| 10 | 8 | ||
| @@ -64,6 +64,7 @@ function metat.__index:check(ok) | |||
| 64 | end | 64 | end |
| 65 | 65 | ||
| 66 | function metat.__index:command(cmd, arg) | 66 | function metat.__index:command(cmd, arg) |
| 67 | cmd = string.upper(cmd) | ||
| 67 | if arg then | 68 | if arg then |
| 68 | return self.c:send(cmd .. " " .. arg.. "\r\n") | 69 | return self.c:send(cmd .. " " .. arg.. "\r\n") |
| 69 | else | 70 | else |
| @@ -37,6 +37,7 @@ static int meth_setsockname(lua_State *L); | |||
| 37 | static int meth_setpeername(lua_State *L); | 37 | static int meth_setpeername(lua_State *L); |
| 38 | static int meth_close(lua_State *L); | 38 | static int meth_close(lua_State *L); |
| 39 | static int meth_setoption(lua_State *L); | 39 | static int meth_setoption(lua_State *L); |
| 40 | static int meth_getoption(lua_State *L); | ||
| 40 | static int meth_settimeout(lua_State *L); | 41 | static int meth_settimeout(lua_State *L); |
| 41 | static int meth_getfd(lua_State *L); | 42 | static int meth_getfd(lua_State *L); |
| 42 | static int meth_setfd(lua_State *L); | 43 | static int meth_setfd(lua_State *L); |
| @@ -57,22 +58,32 @@ static luaL_reg udp[] = { | |||
| 57 | {"sendto", meth_sendto}, | 58 | {"sendto", meth_sendto}, |
| 58 | {"setfd", meth_setfd}, | 59 | {"setfd", meth_setfd}, |
| 59 | {"setoption", meth_setoption}, | 60 | {"setoption", meth_setoption}, |
| 61 | {"getoption", meth_getoption}, | ||
| 60 | {"setpeername", meth_setpeername}, | 62 | {"setpeername", meth_setpeername}, |
| 61 | {"setsockname", meth_setsockname}, | 63 | {"setsockname", meth_setsockname}, |
| 62 | {"settimeout", meth_settimeout}, | 64 | {"settimeout", meth_settimeout}, |
| 63 | {NULL, NULL} | 65 | {NULL, NULL} |
| 64 | }; | 66 | }; |
| 65 | 67 | ||
| 66 | /* socket options */ | 68 | /* socket options for setoption */ |
| 67 | static t_opt opt[] = { | 69 | static t_opt optset[] = { |
| 68 | {"dontroute", opt_dontroute}, | 70 | {"dontroute", opt_set_dontroute}, |
| 69 | {"broadcast", opt_broadcast}, | 71 | {"broadcast", opt_set_broadcast}, |
| 70 | {"reuseaddr", opt_reuseaddr}, | 72 | {"reuseaddr", opt_set_reuseaddr}, |
| 71 | {"ip-multicast-ttl", opt_ip_multicast_ttl}, | 73 | {"reuseport", opt_set_reuseport}, |
| 72 | {"ip-multicast-loop", opt_ip_multicast_loop}, | 74 | {"ip-multicast-if", opt_set_ip_multicast_if}, |
| 73 | {"ip-add-membership", opt_ip_add_membership}, | 75 | {"ip-multicast-ttl", opt_set_ip_multicast_ttl}, |
| 74 | {"ip-drop-membership", opt_ip_drop_membersip}, | 76 | {"ip-multicast-loop", opt_set_ip_multicast_loop}, |
| 75 | {NULL, NULL} | 77 | {"ip-add-membership", opt_set_ip_add_membership}, |
| 78 | {"ip-drop-membership", opt_set_ip_drop_membersip}, | ||
| 79 | {NULL, NULL} | ||
| 80 | }; | ||
| 81 | |||
| 82 | /* socket options for getoption */ | ||
| 83 | static t_opt optget[] = { | ||
| 84 | {"ip-multicast-if", opt_get_ip_multicast_if}, | ||
| 85 | {"ip-multicast-loop", opt_get_ip_multicast_loop}, | ||
| 86 | {NULL, NULL} | ||
| 76 | }; | 87 | }; |
| 77 | 88 | ||
| 78 | /* functions in library namespace */ | 89 | /* functions in library namespace */ |
| @@ -247,7 +258,15 @@ static int meth_getsockname(lua_State *L) { | |||
| 247 | \*-------------------------------------------------------------------------*/ | 258 | \*-------------------------------------------------------------------------*/ |
| 248 | static int meth_setoption(lua_State *L) { | 259 | static int meth_setoption(lua_State *L) { |
| 249 | p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); | 260 | p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); |
| 250 | return opt_meth_setoption(L, opt, &udp->sock); | 261 | return opt_meth_setoption(L, optset, &udp->sock); |
| 262 | } | ||
| 263 | |||
| 264 | /*-------------------------------------------------------------------------*\ | ||
| 265 | * Just call option handler | ||
| 266 | \*-------------------------------------------------------------------------*/ | ||
| 267 | static int meth_getoption(lua_State *L) { | ||
| 268 | p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); | ||
| 269 | return opt_meth_getoption(L, optget, &udp->sock); | ||
| 251 | } | 270 | } |
| 252 | 271 | ||
| 253 | /*-------------------------------------------------------------------------*\ | 272 | /*-------------------------------------------------------------------------*\ |
| @@ -11,8 +11,6 @@ | |||
| 11 | * originally unconnected. They can be "connected" to a given address | 11 | * originally unconnected. They can be "connected" to a given address |
| 12 | * with a call to the setpeername function. The same function can be used to | 12 | * with a call to the setpeername function. The same function can be used to |
| 13 | * break the connection. | 13 | * break the connection. |
| 14 | * | ||
| 15 | * RCS ID: $Id$ | ||
| 16 | \*=========================================================================*/ | 14 | \*=========================================================================*/ |
| 17 | #include "lua.h" | 15 | #include "lua.h" |
| 18 | 16 | ||
| @@ -63,10 +63,10 @@ static luaL_reg un[] = { | |||
| 63 | }; | 63 | }; |
| 64 | 64 | ||
| 65 | /* socket option handlers */ | 65 | /* socket option handlers */ |
| 66 | static t_opt opt[] = { | 66 | static t_opt optset[] = { |
| 67 | {"keepalive", opt_keepalive}, | 67 | {"keepalive", opt_set_keepalive}, |
| 68 | {"reuseaddr", opt_reuseaddr}, | 68 | {"reuseaddr", opt_set_reuseaddr}, |
| 69 | {"linger", opt_linger}, | 69 | {"linger", opt_set_linger}, |
| 70 | {NULL, NULL} | 70 | {NULL, NULL} |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| @@ -128,7 +128,7 @@ static int meth_setstats(lua_State *L) { | |||
| 128 | \*-------------------------------------------------------------------------*/ | 128 | \*-------------------------------------------------------------------------*/ |
| 129 | static int meth_setoption(lua_State *L) { | 129 | static int meth_setoption(lua_State *L) { |
| 130 | p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); | 130 | p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); |
| 131 | return opt_meth_setoption(L, opt, &un->sock); | 131 | return opt_meth_setoption(L, optset, &un->sock); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | /*-------------------------------------------------------------------------*\ | 134 | /*-------------------------------------------------------------------------*\ |
| @@ -6,8 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * This module is just an example of how to extend LuaSocket with a new | 7 | * This module is just an example of how to extend LuaSocket with a new |
| 8 | * domain. | 8 | * domain. |
| 9 | * | ||
| 10 | * RCS ID: $Id$ | ||
| 11 | \*=========================================================================*/ | 9 | \*=========================================================================*/ |
| 12 | #include "lua.h" | 10 | #include "lua.h" |
| 13 | 11 | ||
| @@ -23,6 +21,6 @@ typedef struct t_unix_ { | |||
| 23 | } t_unix; | 21 | } t_unix; |
| 24 | typedef t_unix *p_unix; | 22 | typedef t_unix *p_unix; |
| 25 | 23 | ||
| 26 | int luaopen_socketunix(lua_State *L); | 24 | int luaopen_socket_unix(lua_State *L); |
| 27 | 25 | ||
| 28 | #endif /* UNIX_H */ | 26 | #endif /* UNIX_H */ |
diff --git a/src/usocket.h b/src/usocket.h index e1f7498..75bfe82 100644 --- a/src/usocket.h +++ b/src/usocket.h | |||
| @@ -3,8 +3,6 @@ | |||
| 3 | /*=========================================================================*\ | 3 | /*=========================================================================*\ |
| 4 | * Socket compatibilization module for Unix | 4 | * Socket compatibilization module for Unix |
| 5 | * LuaSocket toolkit | 5 | * LuaSocket toolkit |
| 6 | * | ||
| 7 | * RCS ID: $Id$ | ||
| 8 | \*=========================================================================*/ | 6 | \*=========================================================================*/ |
| 9 | 7 | ||
| 10 | /*=========================================================================*\ | 8 | /*=========================================================================*\ |
| @@ -32,6 +30,10 @@ | |||
| 32 | /* TCP options (nagle algorithm disable) */ | 30 | /* TCP options (nagle algorithm disable) */ |
| 33 | #include <netinet/tcp.h> | 31 | #include <netinet/tcp.h> |
| 34 | 32 | ||
| 33 | #ifndef SO_REUSEPORT | ||
| 34 | #define SO_REUSEPORT SO_REUSEADDR | ||
| 35 | #endif | ||
| 36 | |||
| 35 | typedef int t_socket; | 37 | typedef int t_socket; |
| 36 | typedef t_socket *p_socket; | 38 | typedef t_socket *p_socket; |
| 37 | 39 | ||
diff --git a/src/wsocket.h b/src/wsocket.h index e4f0e92..8e0f114 100644 --- a/src/wsocket.h +++ b/src/wsocket.h | |||
| @@ -3,14 +3,13 @@ | |||
| 3 | /*=========================================================================*\ | 3 | /*=========================================================================*\ |
| 4 | * Socket compatibilization module for Win32 | 4 | * Socket compatibilization module for Win32 |
| 5 | * LuaSocket toolkit | 5 | * LuaSocket toolkit |
| 6 | * | ||
| 7 | * RCS ID: $Id$ | ||
| 8 | \*=========================================================================*/ | 6 | \*=========================================================================*/ |
| 9 | 7 | ||
| 10 | /*=========================================================================*\ | 8 | /*=========================================================================*\ |
| 11 | * WinSock include files | 9 | * WinSock include files |
| 12 | \*=========================================================================*/ | 10 | \*=========================================================================*/ |
| 13 | #include <winsock.h> | 11 | #include <winsock2.h> |
| 12 | #include <ws2tcpip.h> | ||
| 14 | 13 | ||
| 15 | typedef int socklen_t; | 14 | typedef int socklen_t; |
| 16 | typedef SOCKET t_socket; | 15 | typedef SOCKET t_socket; |
| @@ -18,4 +17,8 @@ typedef t_socket *p_socket; | |||
| 18 | 17 | ||
| 19 | #define SOCKET_INVALID (INVALID_SOCKET) | 18 | #define SOCKET_INVALID (INVALID_SOCKET) |
| 20 | 19 | ||
| 20 | #ifndef SO_REUSEPORT | ||
| 21 | #define SO_REUSEPORT SO_REUSEADDR | ||
| 22 | #endif | ||
| 23 | |||
| 21 | #endif /* WSOCKET_H */ | 24 | #endif /* WSOCKET_H */ |
diff --git a/test/README b/test/README index 180fa27..27837e0 100644 --- a/test/README +++ b/test/README | |||
| @@ -8,5 +8,7 @@ The files provided are: | |||
| 8 | 8 | ||
| 9 | To run these tests, just run lua on the server and then on the client. | 9 | To run these tests, just run lua on the server and then on the client. |
| 10 | 10 | ||
| 11 | hello.lua -- run to verify if installation worked | ||
| 12 | |||
| 11 | Good luck, | 13 | Good luck, |
| 12 | Diego. | 14 | Diego. |
diff --git a/test/hello.lua b/test/hello.lua new file mode 100644 index 0000000..cfa5c82 --- /dev/null +++ b/test/hello.lua | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | require"socket" | ||
| 2 | require"mime" | ||
| 3 | print("Hello from " .. socket._VERSION .. " and " .. mime._VERSION .. "!") | ||
diff --git a/test/httptest.lua b/test/httptest.lua index dd53ec3..9d50a14 100644 --- a/test/httptest.lua +++ b/test/httptest.lua | |||
| @@ -420,17 +420,17 @@ print("ok") | |||
| 420 | io.write("testing HEAD method: ") | 420 | io.write("testing HEAD method: ") |
| 421 | local r, c, h = http.request { | 421 | local r, c, h = http.request { |
| 422 | method = "HEAD", | 422 | method = "HEAD", |
| 423 | url = "http://www.cs.princeton.edu/~diego/" | 423 | url = "http://www.tecgraf.puc-rio.br/~diego/" |
| 424 | } | 424 | } |
| 425 | assert(r and h and (c == 200), c) | 425 | assert(r and h and (c == 200), c) |
| 426 | print("ok") | 426 | print("ok") |
| 427 | 427 | ||
| 428 | ------------------------------------------------------------------------ | 428 | ------------------------------------------------------------------------ |
| 429 | io.write("testing host not found: ") | 429 | io.write("testing host not found: ") |
| 430 | local c, e = socket.connect("wronghost", 80) | 430 | local c, e = socket.connect("example.invalid", 80) |
| 431 | local r, re = http.request{url = "http://wronghost/does/not/exist"} | 431 | local r, re = http.request{url = "http://example.invalid/does/not/exist"} |
| 432 | assert(r == nil and e == re) | 432 | assert(r == nil and e == re, tostring(r) .. " " .. tostring(re)) |
| 433 | r, re = http.request("http://wronghost/does/not/exist") | 433 | r, re = http.request("http://example.invalid/does/not/exist") |
| 434 | assert(r == nil and e == re) | 434 | assert(r == nil and e == re) |
| 435 | print("ok") | 435 | print("ok") |
| 436 | 436 | ||
diff --git a/test/mimetest.lua b/test/mimetest.lua index f52a351..11c3f4f 100644 --- a/test/mimetest.lua +++ b/test/mimetest.lua | |||
| @@ -251,6 +251,28 @@ io.write("testing b64 padding: ") | |||
| 251 | print("ok") | 251 | print("ok") |
| 252 | end | 252 | end |
| 253 | 253 | ||
| 254 | local function test_b64lowlevel() | ||
| 255 | io.write("testing b64 low-level: ") | ||
| 256 | local a, b | ||
| 257 | a, b = mime.b64("", "") | ||
| 258 | assert(a == "" and b == "") | ||
| 259 | a, b = mime.b64(nil, "blablabla") | ||
| 260 | assert(a == nil and b == nil) | ||
| 261 | a, b = mime.b64("", nil) | ||
| 262 | assert(a == nil and b == nil) | ||
| 263 | a, b = mime.unb64("", "") | ||
| 264 | assert(a == "" and b == "") | ||
| 265 | a, b = mime.unb64(nil, "blablabla") | ||
| 266 | assert(a == nil and b == nil) | ||
| 267 | a, b = mime.unb64("", nil) | ||
| 268 | assert(a == nil and b == nil) | ||
| 269 | local binary=string.char(0x00,0x44,0x1D,0x14,0x0F,0xF4,0xDA,0x11,0xA9,0x78,0x00,0x14,0x38,0x50,0x60,0xCE) | ||
| 270 | local encoded = mime.b64(binary) | ||
| 271 | local decoded=mime.unb64(encoded) | ||
| 272 | assert(binary == decoded) | ||
| 273 | print("ok") | ||
| 274 | end | ||
| 275 | |||
| 254 | local t = socket.gettime() | 276 | local t = socket.gettime() |
| 255 | 277 | ||
| 256 | create_b64test() | 278 | create_b64test() |
| @@ -260,6 +282,7 @@ decode_b64test() | |||
| 260 | compare_b64test() | 282 | compare_b64test() |
| 261 | cleanup_b64test() | 283 | cleanup_b64test() |
| 262 | padding_b64test() | 284 | padding_b64test() |
| 285 | test_b64lowlevel() | ||
| 263 | 286 | ||
| 264 | create_qptest() | 287 | create_qptest() |
| 265 | encode_qptest() | 288 | encode_qptest() |
| @@ -270,4 +293,5 @@ decode_qptest() | |||
| 270 | compare_qptest() | 293 | compare_qptest() |
| 271 | cleanup_qptest() | 294 | cleanup_qptest() |
| 272 | 295 | ||
| 296 | |||
| 273 | print(string.format("done in %.2fs", socket.gettime() - t)) | 297 | print(string.format("done in %.2fs", socket.gettime() - t)) |
diff --git a/test/testclnt.lua b/test/testclnt.lua index a7ca1ba..1f03b10 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua | |||
| @@ -342,6 +342,7 @@ end | |||
| 342 | ------------------------------------------------------------------------ | 342 | ------------------------------------------------------------------------ |
| 343 | function test_selectbugs() | 343 | function test_selectbugs() |
| 344 | local r, s, e = socket.select(nil, nil, 0.1) | 344 | local r, s, e = socket.select(nil, nil, 0.1) |
| 345 | print(r, s, e) | ||
| 345 | assert(type(r) == "table" and type(s) == "table" and | 346 | assert(type(r) == "table" and type(s) == "table" and |
| 346 | (e == "timeout" or e == "error")) | 347 | (e == "timeout" or e == "error")) |
| 347 | pass("both nil: ok") | 348 | pass("both nil: ok") |
| @@ -352,10 +353,23 @@ function test_selectbugs() | |||
| 352 | (e == "timeout" or e == "error")) | 353 | (e == "timeout" or e == "error")) |
| 353 | pass("closed sockets: ok") | 354 | pass("closed sockets: ok") |
| 354 | e = pcall(socket.select, "wrong", 1, 0.1) | 355 | e = pcall(socket.select, "wrong", 1, 0.1) |
| 355 | assert(e == false) | 356 | assert(e == false, tostring(e)) |
| 356 | e = pcall(socket.select, {}, 1, 0.1) | 357 | e = pcall(socket.select, {}, 1, 0.1) |
| 357 | assert(e == false) | 358 | assert(e == false, tostring(e)) |
| 358 | pass("invalid input: ok") | 359 | pass("invalid input: ok") |
| 360 | local toomany = {} | ||
| 361 | for i = 1, socket._SETSIZE+1 do | ||
| 362 | toomany[#toomany+1] = socket.udp() | ||
| 363 | end | ||
| 364 | if #toomany > socket._SETSIZE then | ||
| 365 | local e = pcall(socket.select, toomany, nil, 0.1) | ||
| 366 | assert(e == false, tostring(e)) | ||
| 367 | pass("too many sockets (" .. #toomany .. "): ok") | ||
| 368 | else | ||
| 369 | pass("unable to create enough sockets (max was "..#toomany..")") | ||
| 370 | pass("try using ulimit") | ||
| 371 | end | ||
| 372 | for _, c in ipairs(toomany) do c:close() end | ||
| 359 | end | 373 | end |
| 360 | 374 | ||
| 361 | ------------------------------------------------------------------------ | 375 | ------------------------------------------------------------------------ |
| @@ -555,6 +569,25 @@ function test_readafterclose() | |||
| 555 | print("ok") | 569 | print("ok") |
| 556 | end | 570 | end |
| 557 | 571 | ||
| 572 | ------------------------------------------------------------------------ | ||
| 573 | function test_writeafterclose() | ||
| 574 | local str = 'little string' | ||
| 575 | reconnect() | ||
| 576 | remote (string.format ([[ | ||
| 577 | data:close() | ||
| 578 | data = nil | ||
| 579 | ]])) | ||
| 580 | local sent, err, errsent | ||
| 581 | while not err do | ||
| 582 | sent, err, errsent, time = data:send(str) | ||
| 583 | end | ||
| 584 | print(sent, err, errsent, time) | ||
| 585 | print("ok") | ||
| 586 | end | ||
| 587 | |||
| 588 | ------------------------------------------------------------------------ | ||
| 589 | --test_writeafterclose() | ||
| 590 | |||
| 558 | test("method registration") | 591 | test("method registration") |
| 559 | test_methods(socket.tcp(), { | 592 | test_methods(socket.tcp(), { |
| 560 | "accept", | 593 | "accept", |
| @@ -596,12 +629,12 @@ test_methods(socket.udp(), { | |||
| 596 | "settimeout" | 629 | "settimeout" |
| 597 | }) | 630 | }) |
| 598 | 631 | ||
| 599 | test("testing read after close") | ||
| 600 | test_readafterclose() | ||
| 601 | |||
| 602 | test("select function") | 632 | test("select function") |
| 603 | test_selectbugs() | 633 | test_selectbugs() |
| 604 | 634 | ||
| 635 | test("testing read after close") | ||
| 636 | test_readafterclose() | ||
| 637 | |||
| 605 | test("connect function") | 638 | test("connect function") |
| 606 | connect_timeout() | 639 | connect_timeout() |
| 607 | empty_connect() | 640 | empty_connect() |
diff --git a/test/testmesg.lua b/test/testmesg.lua index 580693b..135a008 100644 --- a/test/testmesg.lua +++ b/test/testmesg.lua | |||
| @@ -32,6 +32,8 @@ r, e = smtp.send{ | |||
| 32 | port = 2525 | 32 | port = 2525 |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | print(r, e) | ||
| 36 | |||
| 35 | -- creates a source to send a message with two parts. The first part is | 37 | -- creates a source to send a message with two parts. The first part is |
| 36 | -- plain text, the second part is a PNG image, encoded as base64. | 38 | -- plain text, the second part is a PNG image, encoded as base64. |
| 37 | source = smtp.message{ | 39 | source = smtp.message{ |
