aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2005-01-02 22:44:00 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2005-01-02 22:44:00 +0000
commit97b26e0b66c840a446a0179200c7df23565330d1 (patch)
tree272f9ea0451f13b563451fb8df21a03669e90d09
parenta8254e94f8c14ac15b02be53a1cc69ba80899230 (diff)
downloadluasocket-97b26e0b66c840a446a0179200c7df23565330d1.tar.gz
luasocket-97b26e0b66c840a446a0179200c7df23565330d1.tar.bz2
luasocket-97b26e0b66c840a446a0179200c7df23565330d1.zip
Almost ready to release beta3
-rw-r--r--etc/README5
-rw-r--r--etc/dict.lua2
-rw-r--r--etc/lp.lua2
-rw-r--r--etc/tftp.lua2
-rw-r--r--luasocket.vcproj6
-rw-r--r--makefile.dist10
-rw-r--r--mime.vcproj6
-rw-r--r--samples/README2
-rw-r--r--samples/echoclnt.lua10
-rw-r--r--samples/echosrvr.lua9
-rw-r--r--samples/listener.lua7
-rw-r--r--samples/talker.lua4
-rw-r--r--samples/tinyirc.lua4
-rw-r--r--src/ftp.lua2
-rw-r--r--src/http.lua2
-rw-r--r--src/ltn12.lua22
-rw-r--r--src/luasocket.h4
-rw-r--r--src/mime.lua2
-rw-r--r--src/smtp.lua2
-rw-r--r--src/socket.lua2
-rw-r--r--src/tp.lua2
-rw-r--r--src/url.lua2
-rw-r--r--test/httptest.lua3
23 files changed, 53 insertions, 59 deletions
diff --git a/etc/README b/etc/README
index e72471d..6be740b 100644
--- a/etc/README
+++ b/etc/README
@@ -1,11 +1,6 @@
1This directory contains code that is more useful than the examples. This code 1This directory contains code that is more useful than the examples. This code
2*is* supported. 2*is* supported.
3 3
4 lua.lua -- new require and requirelib implementations
5
6This is to support dynamic loading of LuaSocket. Check the INSTALL
7file for more information.
8
9 tftp.lua -- Trivial FTP client 4 tftp.lua -- Trivial FTP client
10 5
11This module implements file retrieval by the TFTP protocol. Its main use 6This module implements file retrieval by the TFTP protocol. Its main use
diff --git a/etc/dict.lua b/etc/dict.lua
index 6c40a32..a52b977 100644
--- a/etc/dict.lua
+++ b/etc/dict.lua
@@ -151,4 +151,4 @@ get = socket.protect(function(gett)
151 else return tget(gett) end 151 else return tget(gett) end
152end) 152end)
153 153
154getmetatable(_M).__index = nil 154--getmetatable(_M).__index = nil
diff --git a/etc/lp.lua b/etc/lp.lua
index cc358d1..7637d16 100644
--- a/etc/lp.lua
+++ b/etc/lp.lua
@@ -318,4 +318,4 @@ query = socket.protect(function(p)
318 return data 318 return data
319end) 319end)
320 320
321getmetatable(_M).__index = nil 321--getmetatable(_M).__index = nil
diff --git a/etc/tftp.lua b/etc/tftp.lua
index 91b26c9..ba21a43 100644
--- a/etc/tftp.lua
+++ b/etc/tftp.lua
@@ -153,4 +153,4 @@ get = socket.protect(function(gett)
153 else return tget(gett) end 153 else return tget(gett) end
154end) 154end)
155 155
156getmetatable(_M).__index = nil 156--getmetatable(_M).__index = nil
diff --git a/luasocket.vcproj b/luasocket.vcproj
index 4699498..14cbebf 100644
--- a/luasocket.vcproj
+++ b/luasocket.vcproj
@@ -19,7 +19,7 @@
19 <Tool 19 <Tool
20 Name="VCCLCompilerTool" 20 Name="VCCLCompilerTool"
21 Optimization="0" 21 Optimization="0"
22 AdditionalIncludeDirectories="h:\include" 22 AdditionalIncludeDirectories="..\..\include, compat-5.1r2"
23 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport)" 23 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport)"
24 MinimalRebuild="TRUE" 24 MinimalRebuild="TRUE"
25 BasicRuntimeChecks="3" 25 BasicRuntimeChecks="3"
@@ -69,7 +69,7 @@
69 CharacterSet="2"> 69 CharacterSet="2">
70 <Tool 70 <Tool
71 Name="VCCLCompilerTool" 71 Name="VCCLCompilerTool"
72 AdditionalIncludeDirectories="../../include" 72 AdditionalIncludeDirectories="../../include, compat-5.1r2"
73 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG" 73 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG"
74 RuntimeLibrary="4" 74 RuntimeLibrary="4"
75 UsePrecompiledHeader="0" 75 UsePrecompiledHeader="0"
@@ -125,7 +125,7 @@
125 RelativePath=".\buffer.c"> 125 RelativePath=".\buffer.c">
126 </File> 126 </File>
127 <File 127 <File
128 RelativePath=".\compat-5.1.c"> 128 RelativePath=".\compat-5.1r2\compat-5.1.c">
129 </File> 129 </File>
130 <File 130 <File
131 RelativePath=".\except.c"> 131 RelativePath=".\except.c">
diff --git a/makefile.dist b/makefile.dist
index a31a9a5..b1ac1fa 100644
--- a/makefile.dist
+++ b/makefile.dist
@@ -4,6 +4,8 @@
4 4
5DIST = luasocket-2.0-beta3 5DIST = luasocket-2.0-beta3
6 6
7COMPAT = compat-5.1r2
8
7LUA = \ 9LUA = \
8 ftp.lua \ 10 ftp.lua \
9 http.lua \ 11 http.lua \
@@ -11,7 +13,6 @@ LUA = \
11 mime.lua \ 13 mime.lua \
12 smtp.lua \ 14 smtp.lua \
13 socket.lua \ 15 socket.lua \
14 compat-5.1.lua \
15 tp.lua \ 16 tp.lua \
16 url.lua 17 url.lua
17 18
@@ -72,9 +73,7 @@ CORE = \
72 usocket.c \ 73 usocket.c \
73 usocket.h \ 74 usocket.h \
74 wsocket.c \ 75 wsocket.c \
75 wsocket.h \ 76 wsocket.h
76 compat-5.1.c \
77 compat-5.1.h
78 77
79MAKE = \ 78MAKE = \
80 makefile.Darwin \ 79 makefile.Darwin \
@@ -92,7 +91,7 @@ MANUAL = \
92 manual/ltn12.html \ 91 manual/ltn12.html \
93 manual/luasocket.png \ 92 manual/luasocket.png \
94 manual/mime.html \ 93 manual/mime.html \
95 manual/instalation.html \ 94 manual/installation.html \
96 manual/reference.css \ 95 manual/reference.css \
97 manual/reference.html \ 96 manual/reference.html \
98 manual/smtp.html \ 97 manual/smtp.html \
@@ -107,6 +106,7 @@ dist:
107 mkdir -p $(DIST)/etc 106 mkdir -p $(DIST)/etc
108 mkdir -p $(DIST)/lua 107 mkdir -p $(DIST)/lua
109 mkdir -p $(DIST)/manual 108 mkdir -p $(DIST)/manual
109 cp -vfr $(COMPAT) $(DIST)
110 cp -vf TODO $(DIST) 110 cp -vf TODO $(DIST)
111 cp -vf $(CORE) $(DIST) 111 cp -vf $(CORE) $(DIST)
112 cp -vf README $(DIST) 112 cp -vf README $(DIST)
diff --git a/mime.vcproj b/mime.vcproj
index 9fe7aa8..9e73f7b 100644
--- a/mime.vcproj
+++ b/mime.vcproj
@@ -19,7 +19,7 @@
19 <Tool 19 <Tool
20 Name="VCCLCompilerTool" 20 Name="VCCLCompilerTool"
21 Optimization="0" 21 Optimization="0"
22 AdditionalIncludeDirectories="h:\include" 22 AdditionalIncludeDirectories="..\..\include, compat-5.1r2"
23 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport)" 23 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS;MIME_API=__declspec(dllexport)"
24 MinimalRebuild="TRUE" 24 MinimalRebuild="TRUE"
25 BasicRuntimeChecks="3" 25 BasicRuntimeChecks="3"
@@ -68,7 +68,7 @@
68 CharacterSet="2"> 68 CharacterSet="2">
69 <Tool 69 <Tool
70 Name="VCCLCompilerTool" 70 Name="VCCLCompilerTool"
71 AdditionalIncludeDirectories="../../include" 71 AdditionalIncludeDirectories="../../include, compat-5.1r2"
72 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)" 72 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)"
73 RuntimeLibrary="4" 73 RuntimeLibrary="4"
74 UsePrecompiledHeader="0" 74 UsePrecompiledHeader="0"
@@ -117,7 +117,7 @@
117 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 117 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
118 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 118 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
119 <File 119 <File
120 RelativePath=".\compat-5.1.c"> 120 RelativePath=".\compat-5.1r2\compat-5.1.c">
121 </File> 121 </File>
122 <File 122 <File
123 RelativePath=".\mime.c"> 123 RelativePath=".\mime.c">
diff --git a/samples/README b/samples/README
index 3ce4067..0100a4a 100644
--- a/samples/README
+++ b/samples/README
@@ -7,7 +7,7 @@ is not supported.
7listener.lua and talker.lua are about the simplest applications you can 7listener.lua and talker.lua are about the simplest applications you can
8write using LuaSocket. Run 8write using LuaSocket. Run
9 9
10 'lua listen.lua' and 'lua talk.lua' 10 'lua listener.lua' and 'lua talker.lua'
11 11
12on different terminals. Whatever you type on talk.lua will be 12on different terminals. Whatever you type on talk.lua will be
13printed by listen.lua. 13printed by listen.lua.
diff --git a/samples/echoclnt.lua b/samples/echoclnt.lua
index 038061d..764e433 100644
--- a/samples/echoclnt.lua
+++ b/samples/echoclnt.lua
@@ -12,13 +12,13 @@ if arg then
12 port = arg[2] or port 12 port = arg[2] or port
13end 13end
14host = socket.dns.toip(host) 14host = socket.dns.toip(host)
15udp = socket.try(socket.udp()) 15udp = assert(socket.udp())
16socket.try(udp:setpeername(host, port)) 16assert(udp:setpeername(host, port))
17print("Using remote host '" ..host.. "' and port " .. port .. "...") 17print("Using remote host '" ..host.. "' and port " .. port .. "...")
18while 1 do 18while 1 do
19 line = io.read() 19 line = io.read()
20 if not line then os.exit() end 20 if not line or line == "" then os.exit() end
21 socket.try(udp:send(line)) 21 assert(udp:send(line))
22 dgram = socket.try(udp:receive()) 22 dgram = assert(udp:receive())
23 print(dgram) 23 print(dgram)
24end 24end
diff --git a/samples/echosrvr.lua b/samples/echosrvr.lua
index 3ebbe85..d4449e5 100644
--- a/samples/echosrvr.lua
+++ b/samples/echosrvr.lua
@@ -12,10 +12,11 @@ if arg then
12 port = arg[2] or port 12 port = arg[2] or port
13end 13end
14print("Binding to host '" ..host.. "' and port " ..port.. "...") 14print("Binding to host '" ..host.. "' and port " ..port.. "...")
15udp = socket.try(socket.udp()) 15udp = assert(socket.udp())
16socket.try(udp:setsockname(host, port)) 16assert(udp:setsockname(host, port))
17socket.try(udp:settimeout(5)) 17assert(udp:settimeout(5))
18ip, port = socket.try(udp:getsockname()) 18ip, port = udp:getsockname()
19assert(ip, port)
19print("Waiting packets on " .. ip .. ":" .. port .. "...") 20print("Waiting packets on " .. ip .. ":" .. port .. "...")
20while 1 do 21while 1 do
21 dgram, ip, port = udp:receivefrom() 22 dgram, ip, port = udp:receivefrom()
diff --git a/samples/listener.lua b/samples/listener.lua
index 65c6501..4d4c3b6 100644
--- a/samples/listener.lua
+++ b/samples/listener.lua
@@ -12,10 +12,11 @@ if arg then
12 port = arg[2] or port 12 port = arg[2] or port
13end 13end
14print("Binding to host '" ..host.. "' and port " ..port.. "...") 14print("Binding to host '" ..host.. "' and port " ..port.. "...")
15s = socket.try(socket.bind(host, port)) 15s = assert(socket.bind(host, port))
16i, p = socket.try(s:getsockname()) 16i, p = s:getsockname()
17assert(i, p)
17print("Waiting connection from talker on " .. i .. ":" .. p .. "...") 18print("Waiting connection from talker on " .. i .. ":" .. p .. "...")
18c = socket.try(s:accept()) 19c = assert(s:accept())
19print("Connected. Here is the stuff:") 20print("Connected. Here is the stuff:")
20l, e = c:receive() 21l, e = c:receive()
21while not e do 22while not e do
diff --git a/samples/talker.lua b/samples/talker.lua
index 3f6e69c..901ed2c 100644
--- a/samples/talker.lua
+++ b/samples/talker.lua
@@ -12,10 +12,10 @@ if arg then
12 port = arg[2] or port 12 port = arg[2] or port
13end 13end
14print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") 14print("Attempting connection to host '" ..host.. "' and port " ..port.. "...")
15c = socket.try(socket.connect(host, port)) 15c = assert(socket.connect(host, port))
16print("Connected! Please type stuff (empty line to stop):") 16print("Connected! Please type stuff (empty line to stop):")
17l = io.read() 17l = io.read()
18while l and l ~= "" and not e do 18while l and l ~= "" and not e do
19 socket.try(c:send(l, "\n")) 19 assert(c:send(l .. "\n"))
20 l = io.read() 20 l = io.read()
21end 21end
diff --git a/samples/tinyirc.lua b/samples/tinyirc.lua
index 13f42ec..684e7c0 100644
--- a/samples/tinyirc.lua
+++ b/samples/tinyirc.lua
@@ -14,8 +14,8 @@ if arg then
14 port2 = arg[3] or port2 14 port2 = arg[3] or port2
15end 15end
16 16
17server1 = socket.try(socket.bind(host, port1)) 17server1 = assert(socket.bind(host, port1))
18server2 = socket.try(socket.bind(host, port2)) 18server2 = assert(socket.bind(host, port2))
19server1:settimeout(1) -- make sure we don't block in accept 19server1:settimeout(1) -- make sure we don't block in accept
20server2:settimeout(1) 20server2:settimeout(1)
21 21
diff --git a/src/ftp.lua b/src/ftp.lua
index c55ec4e..9b7c1e5 100644
--- a/src/ftp.lua
+++ b/src/ftp.lua
@@ -278,4 +278,4 @@ get = socket.protect(function(gett)
278 else return tget(gett) end 278 else return tget(gett) end
279end) 279end)
280 280
281getmetatable(_M).__index = nil 281--getmetatable(_M).__index = nil
diff --git a/src/http.lua b/src/http.lua
index 27ce960..5fb59ce 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -259,4 +259,4 @@ request = socket.protect(function(reqt, body)
259 else return trequest(reqt) end 259 else return trequest(reqt) end
260end) 260end)
261 261
262getmetatable(_M).__index = nil 262--getmetatable(_M).__index = nil
diff --git a/src/ltn12.lua b/src/ltn12.lua
index 813e7d6..8c80196 100644
--- a/src/ltn12.lua
+++ b/src/ltn12.lua
@@ -170,20 +170,16 @@ end
170 170
171-- creates a source that produces contents of several sources, one after the 171-- creates a source that produces contents of several sources, one after the
172-- other, as if they were concatenated 172-- other, as if they were concatenated
173-- (thanks to Wim Couwenberg)
173function source.cat(...) 174function source.cat(...)
174 local co = coroutine.create(function() 175 local src = table.remove(arg, 1)
175 local i = 1
176 while i <= table.getn(arg) do
177 local chunk, err = arg[i]()
178 if chunk then coroutine.yield(chunk)
179 elseif err then return nil, err
180 else i = i + 1 end
181 end
182 end)
183 return function() 176 return function()
184 local ret, a, b = coroutine.resume(co) 177 while src do
185 if ret then return a, b 178 local chunk, err = src()
186 else return nil, a end 179 if chunk then return chunk end
180 if err then return nil, err end
181 src = table.remove(arg, 1)
182 end
187 end 183 end
188end 184end
189 185
@@ -276,4 +272,4 @@ function pump.all(src, snk, step)
276 end 272 end
277end 273end
278 274
279getmetatable(_M).__index = nil 275--getmetatable(_M).__index = nil
diff --git a/src/luasocket.h b/src/luasocket.h
index 33524e3..db54a18 100644
--- a/src/luasocket.h
+++ b/src/luasocket.h
@@ -13,7 +13,9 @@
13/*-------------------------------------------------------------------------*\ 13/*-------------------------------------------------------------------------*\
14* Current luasocket version 14* Current luasocket version
15\*-------------------------------------------------------------------------*/ 15\*-------------------------------------------------------------------------*/
16#define LUASOCKET_VERSION "LuaSocket 2.0 (beta3)" 16#define LUASOCKET_VERSION "LuaSocket 2.0 (beta3)"
17#define LUASOCKET_COPYRIGHT "Copyright (C) 2004-2005 Diego Nehab"
18#define LUASOCKET_AUTHORS "Diego Nehab"
17 19
18/*-------------------------------------------------------------------------*\ 20/*-------------------------------------------------------------------------*\
19* This macro prefixes all exported API functions 21* This macro prefixes all exported API functions
diff --git a/src/mime.lua b/src/mime.lua
index 71efdb3..4d5bdba 100644
--- a/src/mime.lua
+++ b/src/mime.lua
@@ -85,4 +85,4 @@ function mime.stuff()
85 return ltn12.filter.cycle(dot, 2) 85 return ltn12.filter.cycle(dot, 2)
86end 86end
87 87
88getmetatable(_M).__index = nil 88--getmetatable(_M).__index = nil
diff --git a/src/smtp.lua b/src/smtp.lua
index 6281544..12c2195 100644
--- a/src/smtp.lua
+++ b/src/smtp.lua
@@ -245,4 +245,4 @@ send = socket.protect(function(mailt)
245 return s:close() 245 return s:close()
246end) 246end)
247 247
248getmetatable(_M).__index = nil 248--getmetatable(_M).__index = nil
diff --git a/src/socket.lua b/src/socket.lua
index 57619fa..e3c85f0 100644
--- a/src/socket.lua
+++ b/src/socket.lua
@@ -172,4 +172,4 @@ socket.sourcet["default"] = socket.sourcet["until-closed"]
172 172
173socket.source = socket.choose(socket.sourcet) 173socket.source = socket.choose(socket.sourcet)
174 174
175getmetatable(_M).__index = nil 175--getmetatable(_M).__index = nil
diff --git a/src/tp.lua b/src/tp.lua
index 085cc2b..1adc656 100644
--- a/src/tp.lua
+++ b/src/tp.lua
@@ -120,4 +120,4 @@ function connect(host, port, timeout)
120 return base.setmetatable({c = c}, metat) 120 return base.setmetatable({c = c}, metat)
121end 121end
122 122
123getmetatable(_M).__index = nil 123--getmetatable(_M).__index = nil
diff --git a/src/url.lua b/src/url.lua
index e6132f8..8d7b88f 100644
--- a/src/url.lua
+++ b/src/url.lua
@@ -273,4 +273,4 @@ function build_path(parsed, unsafe)
273 return path 273 return path
274end 274end
275 275
276getmetatable(_M).__index = nil 276--getmetatable(_M).__index = nil
diff --git a/test/httptest.lua b/test/httptest.lua
index 71021a4..8862ceb 100644
--- a/test/httptest.lua
+++ b/test/httptest.lua
@@ -23,7 +23,7 @@ http.TIMEOUT = 10
23local t = socket.gettime() 23local t = socket.gettime()
24 24
25host = host or "diego.student.princeton.edu" 25host = host or "diego.student.princeton.edu"
26proxy = proxy or "http://localhost:3128" 26proxy = proxy or "http://dell-diego:3128"
27prefix = prefix or "/luasocket-test" 27prefix = prefix or "/luasocket-test"
28cgiprefix = cgiprefix or "/luasocket-test-cgi" 28cgiprefix = cgiprefix or "/luasocket-test-cgi"
29index_file = "test/index.html" 29index_file = "test/index.html"
@@ -399,7 +399,6 @@ print("ok")
399 399
400------------------------------------------------------------------------ 400------------------------------------------------------------------------
401io.write("testing HEAD method: ") 401io.write("testing HEAD method: ")
402http.TIMEOUT = 1
403local r, c, h = http.request { 402local r, c, h = http.request {
404 method = "HEAD", 403 method = "HEAD",
405 url = "http://www.cs.princeton.edu/~diego/" 404 url = "http://www.cs.princeton.edu/~diego/"