Making progress toward a release

Documented headers.lua
Update copyright date everywhere
Remove RCSID from files
Move version back to 2.1 rather than 2.1.1
Fixed url package to support ipv6 hosts
Changed "domain" to "family" in tcp and udp structures
Implemented getfamily methods
This commit is contained in:
Diego Nehab
2012-04-23 00:18:45 +08:00
parent f37e026026
commit f960b3872a
53 changed files with 236 additions and 108 deletions

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Auxiliar routines for class hierarchy manipulation
* LuaSocket toolkit
*
* RCS ID: $Id: auxiliar.c,v 1.14 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include <string.h>
#include <stdio.h>

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Input/Output interface for Lua programs
* LuaSocket toolkit
*
* RCS ID: $Id: buffer.c,v 1.29 2009/05/27 09:31:35 diego Exp $
\*=========================================================================*/
#include "lua.h"
#include "lauxlib.h"

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Simple exception support
* LuaSocket toolkit
*
* RCS ID: $Id: except.c,v 1.8 2005/09/29 06:11:41 diego Exp $
\*=========================================================================*/
#include <stdio.h>

View File

@ -2,7 +2,6 @@
-- FTP support for the Lua language
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: ftp.lua,v 1.45 2007/07/11 19:25:47 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

View File

@ -2,7 +2,6 @@
-- Canonic header field capitalization
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id$
-----------------------------------------------------------------------------
module("socket.headers")

View File

@ -2,7 +2,6 @@
-- HTTP/1.1 client support for the Lua language.
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: http.lua,v 1.72 2009/05/27 09:31:35 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Internet domain functions
* LuaSocket toolkit
*
* RCS ID: $Id: inet.c,v 1.28 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include <stdio.h>
#include <string.h>
@ -270,8 +268,8 @@ static void inet_pushresolved(lua_State *L, struct hostent *hp)
/*-------------------------------------------------------------------------*\
* Tries to create a new inet socket
\*-------------------------------------------------------------------------*/
const char *inet_trycreate(p_socket ps, int domain, int type) {
return socket_strerror(socket_create(ps, domain, type, 0));
const char *inet_trycreate(p_socket ps, int family, int type) {
return socket_strerror(socket_create(ps, family, type, 0));
}
/*-------------------------------------------------------------------------*\

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Input/Output abstraction
* LuaSocket toolkit
*
* RCS ID: $Id: io.c,v 1.6 2005/09/29 06:11:41 diego Exp $
\*=========================================================================*/
#include "io.h"

View File

@ -2,7 +2,6 @@
-- LTN12 - Filters, sources, sinks and pumps.
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: ltn12.lua,v 1.31 2006/04/03 04:45:42 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

View File

@ -11,7 +11,7 @@
/*-------------------------------------------------------------------------*\
* Current socket library version
\*-------------------------------------------------------------------------*/
#define LUASOCKET_VERSION "LuaSocket 2.1.1-rc1"
#define LUASOCKET_VERSION "LuaSocket 2.1-rc1"
#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2012 Diego Nehab"
#define LUASOCKET_AUTHORS "Diego Nehab"

View File

@ -98,7 +98,7 @@ SOCKET_win32=wsocket.obj
#
SO=$(SO_$(PLAT))
O=$(O_$(PLAT))
SOCKET_V=2.1.1
SOCKET_V=2.1
MIME_V=1.0.3
SOCKET_SO=socket.$(SO).$(SOCKET_V)
MIME_SO=mime.$(SO).$(MIME_V)

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* MIME support functions
* LuaSocket toolkit
*
* RCS ID: $Id: mime.c,v 1.29 2009/05/27 09:31:35 diego Exp $
\*=========================================================================*/
#include <string.h>

View File

@ -2,7 +2,6 @@
-- MIME support for the Lua language.
-- Author: Diego Nehab
-- Conforming to RFCs 2045-2049
-- RCS ID: $Id: mime.lua,v 1.29 2007/06/11 23:44:54 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Common option interface
* LuaSocket toolkit
*
* RCS ID: $Id: options.c,v 1.7 2009/05/27 09:31:35 diego Exp $
\*=========================================================================*/
#include <string.h>

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Select implementation
* LuaSocket toolkit
*
* RCS ID: $Id: select.c,v 1.23 2009/05/27 09:31:35 diego Exp $
\*=========================================================================*/
#include <string.h>

View File

@ -2,7 +2,6 @@
-- SMTP client support for the Lua language.
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: smtp.lua,v 1.47 2009/05/27 09:31:35 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

View File

@ -1,7 +1,6 @@
-----------------------------------------------------------------------------
-- LuaSocket helper module
-- Author: Diego Nehab
-- RCS ID: $Id: socket.lua,v 1.22 2005/11/22 08:33:29 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* TCP object
* LuaSocket toolkit
*
* RCS ID: $Id: tcp.c,v 1.42 2009/05/27 09:31:35 diego Exp $
\*=========================================================================*/
#include <string.h>
@ -23,6 +21,7 @@ static int global_create6(lua_State *L);
static int global_connect6(lua_State *L);
static int meth_connect(lua_State *L);
static int meth_listen(lua_State *L);
static int meth_getfamily(lua_State *L);
static int meth_bind(lua_State *L);
static int meth_send(lua_State *L);
static int meth_getstats(lua_State *L);
@ -49,6 +48,7 @@ static luaL_Reg tcp_methods[] = {
{"close", meth_close},
{"connect", meth_connect},
{"dirty", meth_dirty},
{"getfamily", meth_getfamily},
{"getfd", meth_getfd},
{"getoption", meth_getoption},
{"getpeername", meth_getpeername},
@ -218,7 +218,7 @@ static int meth_bind(lua_State *L)
struct addrinfo bindhints;
memset(&bindhints, 0, sizeof(bindhints));
bindhints.ai_socktype = SOCK_STREAM;
bindhints.ai_family = tcp->domain;
bindhints.ai_family = tcp->family;
bindhints.ai_flags = AI_PASSIVE;
err = inet_trybind(&tcp->sock, address, port, &bindhints);
if (err) {
@ -243,7 +243,7 @@ static int meth_connect(lua_State *L)
memset(&connecthints, 0, sizeof(connecthints));
connecthints.ai_socktype = SOCK_STREAM;
/* make sure we try to connect only to the same family */
connecthints.ai_family = tcp->domain;
connecthints.ai_family = tcp->family;
timeout_markstart(&tcp->tm);
err = inet_tryconnect(&tcp->sock, address, port,
&tcp->tm, &connecthints);
@ -269,6 +269,21 @@ static int meth_close(lua_State *L)
return 1;
}
/*-------------------------------------------------------------------------*\
* Returns family as string
\*-------------------------------------------------------------------------*/
static int meth_getfamily(lua_State *L)
{
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
if (tcp->family == PF_INET6) {
lua_pushliteral(L, "inet6");
return 1;
} else {
lua_pushliteral(L, "inet4");
return 1;
}
}
/*-------------------------------------------------------------------------*\
* Puts the sockt in listen mode
\*-------------------------------------------------------------------------*/
@ -346,9 +361,9 @@ static int meth_settimeout(lua_State *L)
/*-------------------------------------------------------------------------*\
* Creates a master tcp object
\*-------------------------------------------------------------------------*/
static int tcp_create(lua_State *L, int domain) {
static int tcp_create(lua_State *L, int family) {
t_socket sock;
const char *err = inet_trycreate(&sock, domain, SOCK_STREAM);
const char *err = inet_trycreate(&sock, family, SOCK_STREAM);
/* try to allocate a system socket */
if (!err) {
/* allocate tcp object */
@ -357,7 +372,7 @@ static int tcp_create(lua_State *L, int domain) {
auxiliar_setclass(L, "tcp{master}", -1);
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
if (domain == PF_INET6) {
if (family == PF_INET6) {
int yes = 1;
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
(void *)&yes, sizeof(yes));
@ -367,7 +382,7 @@ static int tcp_create(lua_State *L, int domain) {
(p_error) socket_ioerror, &tcp->sock);
timeout_init(&tcp->tm, -1, -1);
buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
tcp->domain = domain;
tcp->family = family;
return 1;
} else {
lua_pushnil(L);

View File

@ -25,7 +25,7 @@ typedef struct t_tcp_ {
t_io io;
t_buffer buf;
t_timeout tm;
int domain;
int family;
} t_tcp;
typedef t_tcp *p_tcp;

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Timeout management functions
* LuaSocket toolkit
*
* RCS ID: $Id: timeout.c,v 1.31 2009/05/27 09:31:35 diego Exp $
\*=========================================================================*/
#include <stdio.h>
#include <limits.h>

View File

@ -2,7 +2,6 @@
-- Unified SMTP/FTP subsystem
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: tp.lua,v 1.23 2009/05/27 09:31:35 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* UDP object
* LuaSocket toolkit
*
* RCS ID: $Id: udp.c,v 1.30 2009/05/27 09:31:35 diego Exp $
\*=========================================================================*/
#include <string.h>
@ -32,6 +30,7 @@ static int meth_send(lua_State *L);
static int meth_sendto(lua_State *L);
static int meth_receive(lua_State *L);
static int meth_receivefrom(lua_State *L);
static int meth_getfamily(lua_State *L);
static int meth_getsockname(lua_State *L);
static int meth_getpeername(lua_State *L);
static int meth_setsockname(lua_State *L);
@ -50,6 +49,7 @@ static luaL_Reg udp_methods[] = {
{"__tostring", auxiliar_tostring},
{"close", meth_close},
{"dirty", meth_dirty},
{"getfamily", meth_getfamily},
{"getfd", meth_getfd},
{"getpeername", meth_getpeername},
{"getsockname", meth_getsockname},
@ -226,6 +226,21 @@ static int meth_receivefrom(lua_State *L) {
}
}
/*-------------------------------------------------------------------------*\
* Returns family as string
\*-------------------------------------------------------------------------*/
static int meth_getfamily(lua_State *L)
{
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
if (udp->family == PF_INET6) {
lua_pushliteral(L, "inet6");
return 1;
} else {
lua_pushliteral(L, "inet4");
return 1;
}
}
/*-------------------------------------------------------------------------*\
* Select support methods
\*-------------------------------------------------------------------------*/
@ -302,7 +317,7 @@ static int meth_setpeername(lua_State *L) {
memset(&connecthints, 0, sizeof(connecthints));
connecthints.ai_socktype = SOCK_DGRAM;
/* make sure we try to connect only to the same family */
connecthints.ai_family = udp->domain;
connecthints.ai_family = udp->family;
err = inet_tryconnect(&udp->sock, address, port,
tm, &connecthints);
if (err) {
@ -338,7 +353,7 @@ static int meth_setsockname(lua_State *L) {
struct addrinfo bindhints;
memset(&bindhints, 0, sizeof(bindhints));
bindhints.ai_socktype = SOCK_DGRAM;
bindhints.ai_family = udp->domain;
bindhints.ai_family = udp->family;
bindhints.ai_flags = AI_PASSIVE;
err = inet_trybind(&udp->sock, address, port, &bindhints);
if (err) {
@ -356,9 +371,9 @@ static int meth_setsockname(lua_State *L) {
/*-------------------------------------------------------------------------*\
* Creates a master udp object
\*-------------------------------------------------------------------------*/
static int udp_create(lua_State *L, int domain) {
static int udp_create(lua_State *L, int family) {
t_socket sock;
const char *err = inet_trycreate(&sock, domain, SOCK_DGRAM);
const char *err = inet_trycreate(&sock, family, SOCK_DGRAM);
/* try to allocate a system socket */
if (!err) {
/* allocate udp object */
@ -366,14 +381,14 @@ static int udp_create(lua_State *L, int domain) {
auxiliar_setclass(L, "udp{unconnected}", -1);
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
if (domain == PF_INET6) {
if (family == PF_INET6) {
int yes = 1;
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
(void *)&yes, sizeof(yes));
}
udp->sock = sock;
timeout_init(&udp->tm, -1, -1);
udp->domain = domain;
udp->family = family;
return 1;
} else {
lua_pushnil(L);

View File

@ -23,7 +23,7 @@
typedef struct t_udp_ {
t_socket sock;
t_timeout tm;
int domain;
int family;
} t_udp;
typedef t_udp *p_udp;

View File

@ -1,8 +1,6 @@
/*=========================================================================*\
* Unix domain socket
* LuaSocket toolkit
*
* RCS ID: $Id: unix.c,v 1.14 2009/05/27 09:31:35 diego Exp $
\*=========================================================================*/
#include <string.h>

View File

@ -2,7 +2,6 @@
-- URI parsing, composition and relative URL resolution
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: url.lua,v 1.38 2006/04/03 04:45:42 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@ -16,7 +15,7 @@ module("socket.url")
-----------------------------------------------------------------------------
-- Module version
-----------------------------------------------------------------------------
_VERSION = "URL 1.0.1"
_VERSION = "URL 1.0.2"
-----------------------------------------------------------------------------
-- Encodes a string into its escaped hexadecimal representation
@ -142,7 +141,7 @@ function parse(url, default)
parsed.authority = n
return ""
end)
-- get query stringing
-- get query string
url = string.gsub(url, "%?(.*)", function(q)
parsed.query = q
return ""
@ -158,9 +157,12 @@ function parse(url, default)
if not authority then return parsed end
authority = string.gsub(authority,"^([^@]*)@",
function(u) parsed.userinfo = u; return "" end)
authority = string.gsub(authority, ":([^:]*)$",
authority = string.gsub(authority, ":([^:%]]*)$",
function(p) parsed.port = p; return "" end)
if authority ~= "" then parsed.host = authority end
if authority ~= "" then
-- IPv6?
parsed.host = string.match(authority, "^%[(.+)%]$") or authority
end
local userinfo = parsed.userinfo
if not userinfo then return parsed end
userinfo = string.gsub(userinfo, ":([^:]*)$",
@ -185,6 +187,9 @@ function build(parsed)
local authority = parsed.authority
if parsed.host then
authority = parsed.host
if string.find(authority, ":") then -- IPv6?
authority = "[" .. authority .. "]"
end
if parsed.port then authority = authority .. ":" .. parsed.port end
local userinfo = parsed.userinfo
if parsed.user then

View File

@ -5,8 +5,6 @@
* The code is now interrupt-safe.
* The penalty of calling select to avoid busy-wait is only paid when
* the I/O call fail in the first place.
*
* RCS ID: $Id: usocket.c,v 1.38 2007/10/13 23:55:20 diego Exp $
\*=========================================================================*/
#include <string.h>
#include <signal.h>

View File

@ -4,8 +4,6 @@
*
* The penalty of calling select to avoid busy-wait is only paid when
* the I/O call fail in the first place.
*
* RCS ID: $Id: wsocket.c,v 1.36 2007/06/11 23:44:54 diego Exp $
\*=========================================================================*/
#include <string.h>