aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-22 04:49:57 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-22 04:49:57 +0000
commit7195ab620bd5029856a5c6c88e54a9a6eceb5e87 (patch)
tree9b60807d8bb2112dcec6ea2e0991e468b112ea5a
parentbce1cb30d856d167e167c4c2997f9bebe03a612c (diff)
downloadluasocket-7195ab620bd5029856a5c6c88e54a9a6eceb5e87.tar.gz
luasocket-7195ab620bd5029856a5c6c88e54a9a6eceb5e87.tar.bz2
luasocket-7195ab620bd5029856a5c6c88e54a9a6eceb5e87.zip
Few extra changes.
-rw-r--r--src/luasocket.h4
-rw-r--r--src/mime.h4
-rw-r--r--src/smtp.lua5
-rw-r--r--src/socket.lua1
-rw-r--r--src/tcp.c2
-rw-r--r--src/timeout.c3
-rw-r--r--test/testmesg.lua8
7 files changed, 11 insertions, 16 deletions
diff --git a/src/luasocket.h b/src/luasocket.h
index 35dc3d9..716b7ff 100644
--- a/src/luasocket.h
+++ b/src/luasocket.h
@@ -25,10 +25,6 @@
25/*-------------------------------------------------------------------------*\ 25/*-------------------------------------------------------------------------*\
26* Initializes the library. 26* Initializes the library.
27\*-------------------------------------------------------------------------*/ 27\*-------------------------------------------------------------------------*/
28#ifndef LUASOCKET_LIBNAME
29#define LUASOCKET_LIBNAME "socket"
30#endif
31
32LUASOCKET_API int luaopen_socket(lua_State *L); 28LUASOCKET_API int luaopen_socket(lua_State *L);
33 29
34#endif /* LUASOCKET_H */ 30#endif /* LUASOCKET_H */
diff --git a/src/mime.h b/src/mime.h
index ad8a573..688d043 100644
--- a/src/mime.h
+++ b/src/mime.h
@@ -19,10 +19,6 @@
19#define MIME_API extern 19#define MIME_API extern
20#endif 20#endif
21 21
22#ifndef MIME_LIBNAME
23#define MIME_LIBNAME "mime"
24#endif
25
26MIME_API int luaopen_mime(lua_State *L); 22MIME_API int luaopen_mime(lua_State *L);
27 23
28#endif /* MIME_H */ 24#endif /* MIME_H */
diff --git a/src/smtp.lua b/src/smtp.lua
index ac74205..c68b750 100644
--- a/src/smtp.lua
+++ b/src/smtp.lua
@@ -106,7 +106,10 @@ function open(server, port)
106 local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT)) 106 local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT))
107 local s = setmetatable({tp = tp}, metat) 107 local s = setmetatable({tp = tp}, metat)
108 -- make sure tp is closed if we get an exception 108 -- make sure tp is closed if we get an exception
109 s.try = socket.newtry(function() s:close() end) 109 s.try = socket.newtry(function()
110 if s.tp:command("QUIT") then s.tp:check("2..") end
111 s:close()
112 end)
110 return s 113 return s
111end 114end
112 115
diff --git a/src/socket.lua b/src/socket.lua
index b3889d7..ad96ddb 100644
--- a/src/socket.lua
+++ b/src/socket.lua
@@ -30,7 +30,6 @@ function socket.bind(host, port, backlog)
30 sock:setoption("reuseaddr", true) 30 sock:setoption("reuseaddr", true)
31 local res, err = sock:bind(host, port) 31 local res, err = sock:bind(host, port)
32 if not res then return nil, err end 32 if not res then return nil, err end
33 backlog = backlog or 32
34 res, err = sock:listen(backlog) 33 res, err = sock:listen(backlog)
35 if not res then return nil, err end 34 if not res then return nil, err end
36 return sock 35 return sock
diff --git a/src/tcp.c b/src/tcp.c
index cbfebdb..1f51b22 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -232,7 +232,7 @@ static int meth_close(lua_State *L)
232static int meth_listen(lua_State *L) 232static int meth_listen(lua_State *L)
233{ 233{
234 p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); 234 p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1);
235 int backlog = (int) luaL_checknumber(L, 2); 235 int backlog = (int) luaL_optnumber(L, 2, 32);
236 const char *err = sock_listen(&tcp->sock, backlog); 236 const char *err = sock_listen(&tcp->sock, backlog);
237 if (err) { 237 if (err) {
238 lua_pushnil(L); 238 lua_pushnil(L);
diff --git a/src/timeout.c b/src/timeout.c
index e089051..dcc2105 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -136,8 +136,7 @@ int tm_gettime(void)
136int tm_gettime(void) 136int tm_gettime(void)
137{ 137{
138 struct timeval v; 138 struct timeval v;
139 struct timezone z = {0, 0}; 139 gettimeofday(&v, (struct timezone *) NULL);
140 gettimeofday(&v, &z);
141 return v.tv_sec * 1000 + v.tv_usec/1000; 140 return v.tv_sec * 1000 + v.tv_usec/1000;
142} 141}
143#endif 142#endif
diff --git a/test/testmesg.lua b/test/testmesg.lua
index 3555031..e29b3cb 100644
--- a/test/testmesg.lua
+++ b/test/testmesg.lua
@@ -50,9 +50,11 @@ source = smtp.message{
50 50
51-- finally send it 51-- finally send it
52r, e = smtp.send{ 52r, e = smtp.send{
53 rcpt = "<fulano@tecgraf.puc-rio.br>", 53 rcpt = {"<diego@tecgraf.puc-rio.br>",
54 from = "<sicrano@tecgraf.puc-rio.br>", 54 "<diego@princeton.edu>" },
55 source = source 55 from = "<diego@princeton.edu>",
56 source = source,
57 server = "mail.cs.princeton.edu"
56} 58}
57 59
58print(r, e) 60print(r, e)