aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego.nehab@gmail.com>2016-03-04 14:38:56 -0300
committerDiego Nehab <diego.nehab@gmail.com>2016-03-04 14:38:56 -0300
commitcdce73b226cc4da6a073b79bec02a6780d32ff1a (patch)
treef47dd46096b92b520607d11cb81ac3376a12976c
parentfe7b37acedd61f425b8d0b0531e78cc45554b332 (diff)
downloadluasocket-cdce73b226cc4da6a073b79bec02a6780d32ff1a.tar.gz
luasocket-cdce73b226cc4da6a073b79bec02a6780d32ff1a.tar.bz2
luasocket-cdce73b226cc4da6a073b79bec02a6780d32ff1a.zip
Added support for FTP command lists
-rw-r--r--doc/socket.html6
-rw-r--r--src/ftp.lua15
-rw-r--r--src/ltn12.lua3
3 files changed, 19 insertions, 5 deletions
diff --git a/doc/socket.html b/doc/socket.html
index fec09c4..a99d71b 100644
--- a/doc/socket.html
+++ b/doc/socket.html
@@ -243,7 +243,9 @@ non-numeric indices) in the arrays will be silently ignored.
243 243
244<p class=return> The function returns a list with the sockets ready for 244<p class=return> The function returns a list with the sockets ready for
245reading, a list with the sockets ready for writing and an error message. 245reading, a list with the sockets ready for writing and an error message.
246The error message is "<tt>timeout</tt>" if a timeout condition was met and 246The error message is "<tt>timeout</tt>" if a timeout
247condition was met, "<tt>select failed</tt>" if the call
248to <tt>select</tt> failed, and
247<tt><b>nil</b></tt> otherwise. The returned tables are 249<tt><b>nil</b></tt> otherwise. The returned tables are
248doubly keyed both by integers and also by the sockets 250doubly keyed both by integers and also by the sockets
249themselves, to simplify the test if a specific socket has 251themselves, to simplify the test if a specific socket has
@@ -251,7 +253,7 @@ changed status.
251</p> 253</p>
252 254
253<p class=note> 255<p class=note>
254<b>Note: </b>: <tt>select</tt> can monitor a limited number 256<b>Note:</b> <tt>select</tt> can monitor a limited number
255of sockets, as defined by the constant <tt>socket._SETSIZE</tt>. This 257of sockets, as defined by the constant <tt>socket._SETSIZE</tt>. This
256number may be as high as 1024 or as low as 64 by default, 258number may be as high as 1024 or as low as 64 by default,
257depending on the system. It is usually possible to change this 259depending on the system. It is usually possible to change this
diff --git a/src/ftp.lua b/src/ftp.lua
index 917cd89..e0c3cae 100644
--- a/src/ftp.lua
+++ b/src/ftp.lua
@@ -271,8 +271,17 @@ _M.command = socket.protect(function(cmdt)
271 local f = _M.open(cmdt.host, cmdt.port, cmdt.create) 271 local f = _M.open(cmdt.host, cmdt.port, cmdt.create)
272 f:greet() 272 f:greet()
273 f:login(cmdt.user, cmdt.password) 273 f:login(cmdt.user, cmdt.password)
274 f.try(f.tp:command(cmdt.command, cmdt.argument)) 274 if type(cmdt.command) == "table" then
275 if cmdt.check then f.try(f.tp:check(cmdt.check)) end 275 local argument = cmdt.argument or {}
276 local check = cmdt.check or {}
277 for i,cmd in ipairs(cmdt.command) do
278 f.try(f.tp:command(cmd, argument[i]))
279 if check[i] then f.try(f.tp:check(check[i])) end
280 end
281 else
282 f.try(f.tp:command(cmdt.command, cmdt.argument))
283 if cmdt.check then f.try(f.tp:check(cmdt.check)) end
284 end
276 f:quit() 285 f:quit()
277 return f:close() 286 return f:close()
278end) 287end)
@@ -282,4 +291,4 @@ _M.get = socket.protect(function(gett)
282 else return tget(gett) end 291 else return tget(gett) end
283end) 292end)
284 293
285return _M \ No newline at end of file 294return _M
diff --git a/src/ltn12.lua b/src/ltn12.lua
index dede0fa..575c5a7 100644
--- a/src/ltn12.lua
+++ b/src/ltn12.lua
@@ -22,6 +22,9 @@ _M.source = source
22_M.sink = sink 22_M.sink = sink
23_M.pump = pump 23_M.pump = pump
24 24
25local unpack = unpack or table.unpack
26local select = base.select
27
25-- 2048 seems to be better in windows... 28-- 2048 seems to be better in windows...
26_M.BLOCKSIZE = 2048 29_M.BLOCKSIZE = 2048
27_M._VERSION = "LTN12 1.0.3" 30_M._VERSION = "LTN12 1.0.3"