From 6c565dd7c06c96fd9b3394ade61f46da59590d30 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Fri, 28 May 2004 07:47:41 +0000 Subject: [PATCH] Almost there. --- TODO | 3 +++ etc/check-links.lua | 1 - etc/eol.lua | 5 ++++- etc/get.lua | 4 ++++ samples/cddb.lua | 1 - src/ftp.lua | 3 +-- src/http.lua | 3 +-- src/smtp.lua | 6 ++++-- src/url.lua | 6 ++---- test/httptest.lua | 1 - test/urltest.lua | 1 + 11 files changed, 20 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index 2d846fe..838be3d 100644 --- a/TODO +++ b/TODO @@ -35,6 +35,9 @@ * Create a passive mode option for the FTP (good for firewall). * Modules should return their namespace table in the end of the chunk. + +get.lua precisa de ftp.get com url e sink +make sure filter.chain fails gracefully. ajeitar o manual sobre select, mais liberal agora conjunto associativo diff --git a/etc/check-links.lua b/etc/check-links.lua index c200dfb..898ed4b 100644 --- a/etc/check-links.lua +++ b/etc/check-links.lua @@ -5,7 +5,6 @@ -- RCS ID: $Id$ ----------------------------------------------------------------------------- -require"luasocket" require"http" socket.http.TIMEOUT = 10 diff --git a/etc/eol.lua b/etc/eol.lua index aa43596..b13684b 100644 --- a/etc/eol.lua +++ b/etc/eol.lua @@ -1,6 +1,9 @@ +require"mime.lua" +require"ltn12.lua" + local marker = '\n' if arg and arg[1] == '-d' then marker = '\r\n' end local filter = mime.normalize(marker) local source = ltn12.source.chain(ltn12.source.file(io.stdin), filter) local sink = ltn12.sink.file(io.stdout) -ltn12.pump(source, sink) +ltn12.pump.all(source, sink) diff --git a/etc/get.lua b/etc/get.lua index aa29ec2..cc270e8 100644 --- a/etc/get.lua +++ b/etc/get.lua @@ -4,6 +4,10 @@ -- Author: Diego Nehab -- RCS ID: $Id$ ----------------------------------------------------------------------------- +require"http" +require"ftp" +require"url" + -- formats a number of seconds into human readable form function nicetime(s) local l = "s" diff --git a/samples/cddb.lua b/samples/cddb.lua index 09309e8..d2e5b59 100644 --- a/samples/cddb.lua +++ b/samples/cddb.lua @@ -1,4 +1,3 @@ -require"luasocket" require"http" if not arg or not arg[1] or not arg[2] then diff --git a/src/ftp.lua b/src/ftp.lua index efb872a..f197018 100644 --- a/src/ftp.lua +++ b/src/ftp.lua @@ -6,10 +6,9 @@ -- RCS ID: $Id$ ----------------------------------------------------------------------------- -- make sure LuaSocket is loaded -if not LUASOCKET_LIBNAME then error('module requires LuaSocket') end +require("luasocket") -- get LuaSocket namespace local socket = _G[LUASOCKET_LIBNAME] -if not socket then error('module requires LuaSocket') end -- require other modules require("ltn12") diff --git a/src/http.lua b/src/http.lua index e6a0928..7dee8e6 100644 --- a/src/http.lua +++ b/src/http.lua @@ -6,10 +6,9 @@ -- RCS ID: $Id$ ----------------------------------------------------------------------------- -- make sure LuaSocket is loaded -if not LUASOCKET_LIBNAME then error('module requires LuaSocket') end +require("luasocket") -- get LuaSocket namespace local socket = _G[LUASOCKET_LIBNAME] -if not socket then error('module requires LuaSocket') end -- require other modules require("ltn12") diff --git a/src/smtp.lua b/src/smtp.lua index 1d1905e..8b5e622 100644 --- a/src/smtp.lua +++ b/src/smtp.lua @@ -6,10 +6,11 @@ -- RCS ID: $Id$ ----------------------------------------------------------------------------- -- make sure LuaSocket is loaded -if not LUASOCKET_LIBNAME then error('module requires LuaSocket') end +require"luasocket" -- get LuaSocket namespace local socket = _G[LUASOCKET_LIBNAME] -if not socket then error('module requires LuaSocket') end + +require"ltn12" -- create smtp namespace inside LuaSocket namespace local smtp = socket.smtp or {} @@ -18,6 +19,7 @@ socket.smtp = smtp setmetatable(smtp, { __index = _G }) setfenv(1, smtp) + -- default server used to send e-mails SERVER = "localhost" -- default port diff --git a/src/url.lua b/src/url.lua index 0fba14d..b385d88 100644 --- a/src/url.lua +++ b/src/url.lua @@ -5,13 +5,11 @@ -- Conforming to: RFC 2396, LTN7 -- RCS ID: $Id$ ---------------------------------------------------------------------------- - -- make sure LuaSocket is loaded -if not LUASOCKET_LIBNAME then error('module requires LuaSocket') end +require"luasocket" -- get LuaSocket namespace local socket = _G[LUASOCKET_LIBNAME] -if not socket then error('module requires LuaSocket') end --- create smtp namespace inside LuaSocket namespace +-- create url namespace inside LuaSocket namespace local url = socket.url or {} socket.url = url -- make all module globals fall into smtp namespace diff --git a/test/httptest.lua b/test/httptest.lua index d237547..a70aa87 100644 --- a/test/httptest.lua +++ b/test/httptest.lua @@ -4,7 +4,6 @@ -- to "/luasocket-test-cgi" and "/luasocket-test-cgi/" -- needs "AllowOverride AuthConfig" on /home/c/diego/tec/luasocket/test/auth -require("luasocket") require("http") dofile("testsupport.lua") diff --git a/test/urltest.lua b/test/urltest.lua index 02b7077..8c2ee88 100644 --- a/test/urltest.lua +++ b/test/urltest.lua @@ -1,3 +1,4 @@ +require"url" dofile("testsupport.lua") local check_build_url = function(parsed)