mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 22:38:21 +01:00
Using new module scheme. Still needs fine tuning.
This commit is contained in:
parent
e1d318f26c
commit
a04f15d1ca
@ -2,7 +2,7 @@
|
|||||||
# Distribution makefile
|
# Distribution makefile
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
|
|
||||||
DIST = luasocket-2.0-beta2
|
DIST = luasocket-2.0-beta3
|
||||||
|
|
||||||
LUA = \
|
LUA = \
|
||||||
ftp.lua \
|
ftp.lua \
|
||||||
|
@ -6,12 +6,15 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Load required modules
|
-- Declare module and import dependencies
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
|
local url = require("socket.url")
|
||||||
|
local tp = require("socket.tp")
|
||||||
|
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
local url = require("url")
|
|
||||||
local tp = require("tp")
|
module("socket.ftp")
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Program constants
|
-- Program constants
|
||||||
|
@ -6,12 +6,14 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Load required modules
|
-- Declare module and import dependencies
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
|
local url = require("socket.url")
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
local mime = require("mime")
|
local mime = require("mime")
|
||||||
local url = require("url")
|
|
||||||
|
module("socket.http")
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Program constants
|
-- Program constants
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
-- RCS ID: $Id$
|
-- RCS ID: $Id$
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- Declare module
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
module("ltn12")
|
||||||
|
|
||||||
filter = {}
|
filter = {}
|
||||||
source = {}
|
source = {}
|
||||||
sink = {}
|
sink = {}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
#include <compat-5.1.h>
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* LuaSocket includes
|
* LuaSocket includes
|
||||||
@ -85,9 +86,8 @@ static int global_unload(lua_State *L) {
|
|||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int base_open(lua_State *L) {
|
static int base_open(lua_State *L) {
|
||||||
if (sock_open()) {
|
if (sock_open()) {
|
||||||
/* whoever is loading the library replaced the global environment
|
/* export functions (and leave namespace table on top of stack) */
|
||||||
* with the namespace table */
|
luaL_module(L, "socket", func, 0);
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
|
||||||
#ifdef LUASOCKET_DEBUG
|
#ifdef LUASOCKET_DEBUG
|
||||||
lua_pushstring(L, "DEBUG");
|
lua_pushstring(L, "DEBUG");
|
||||||
lua_pushboolean(L, 1);
|
lua_pushboolean(L, 1);
|
||||||
@ -97,8 +97,6 @@ static int base_open(lua_State *L) {
|
|||||||
lua_pushstring(L, "VERSION");
|
lua_pushstring(L, "VERSION");
|
||||||
lua_pushstring(L, LUASOCKET_VERSION);
|
lua_pushstring(L, LUASOCKET_VERSION);
|
||||||
lua_rawset(L, -3);
|
lua_rawset(L, -3);
|
||||||
/* export other functions */
|
|
||||||
luaL_openlib(L, NULL, func, 0);
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
lua_pushstring(L, "unable to initialize library");
|
lua_pushstring(L, "unable to initialize library");
|
||||||
@ -110,7 +108,7 @@ static int base_open(lua_State *L) {
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes all library modules.
|
* Initializes all library modules.
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
LUASOCKET_API int luaopen_socket(lua_State *L) {
|
LUASOCKET_API int luaopen_lsocket(lua_State *L) {
|
||||||
int i;
|
int i;
|
||||||
base_open(L);
|
base_open(L);
|
||||||
for (i = 0; mod[i].name; i++) mod[i].func(L);
|
for (i = 0; mod[i].name; i++) mod[i].func(L);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Current luasocket version
|
* Current luasocket version
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
#define LUASOCKET_VERSION "LuaSocket 2.0 (beta2)"
|
#define LUASOCKET_VERSION "LuaSocket 2.0 (beta3)"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* This macro prefixes all exported API functions
|
* This macro prefixes all exported API functions
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
#include <compat-5.1.h>
|
||||||
|
|
||||||
#include "mime.h"
|
#include "mime.h"
|
||||||
|
|
||||||
@ -77,13 +78,9 @@ static UC b64unbase[256];
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes module
|
* Initializes module
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
MIME_API int luaopen_mime(lua_State *L)
|
MIME_API int luaopen_lmime(lua_State *L)
|
||||||
{
|
{
|
||||||
/* whoever is loading the library replaced the global environment
|
luaL_module(L, "mime", func, 0);
|
||||||
* with the namespace table */
|
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
|
||||||
/* export functions */
|
|
||||||
luaL_openlib(L, NULL, func, 0);
|
|
||||||
/* initialize lookup tables */
|
/* initialize lookup tables */
|
||||||
qpsetup(qpclass, qpunbase);
|
qpsetup(qpclass, qpunbase);
|
||||||
b64setup(b64unbase);
|
b64setup(b64unbase);
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Load other required modules
|
-- Declare module and import dependencies
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local mime = requirelib("mime", "luaopen_mime", getfenv(1))
|
module("mime")
|
||||||
|
local mime = require("lmime")
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
|
|
||||||
-- encode, decode and wrap algorithm tables
|
-- encode, decode and wrap algorithm tables
|
||||||
|
10
src/smtp.lua
10
src/smtp.lua
@ -6,13 +6,19 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Load required modules
|
-- Declare module and import dependencies
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
|
local tp = require("socket.tp")
|
||||||
|
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
local mime = require("mime")
|
local mime = require("mime")
|
||||||
local tp = require("tp")
|
|
||||||
|
|
||||||
|
module("socket.smtp")
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- Program constants
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
-- timeout for connection
|
-- timeout for connection
|
||||||
TIMEOUT = 60
|
TIMEOUT = 60
|
||||||
-- default server used to send e-mails
|
-- default server used to send e-mails
|
||||||
|
@ -5,9 +5,10 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Load LuaSocket from dynamic library
|
-- Declare module and import dependencies
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = requirelib("luasocket", "luaopen_socket", getfenv(1))
|
module("socket")
|
||||||
|
local socket = require("lsocket")
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Auxiliar functions
|
-- Auxiliar functions
|
||||||
|
@ -6,11 +6,13 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Load required modules
|
-- Declare module and import dependencies
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
|
|
||||||
|
module("socket.tp")
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Program constants
|
-- Program constants
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
-- RCS ID: $Id$
|
-- RCS ID: $Id$
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- Declare module
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
module("socket.url")
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Encodes a string into its escaped hexadecimal representation
|
-- Encodes a string into its escaped hexadecimal representation
|
||||||
-- Input
|
-- Input
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
-- to "/luasocket-test-cgi" and "/luasocket-test-cgi/"
|
-- to "/luasocket-test-cgi" and "/luasocket-test-cgi/"
|
||||||
-- needs "AllowOverride AuthConfig" on /home/c/diego/tec/luasocket/test/auth
|
-- needs "AllowOverride AuthConfig" on /home/c/diego/tec/luasocket/test/auth
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
|
local http = require("socket.http")
|
||||||
|
local url = require("socket.url")
|
||||||
|
|
||||||
|
local mime = require("mime")
|
||||||
|
local ltn12 = require("ltn12")
|
||||||
|
|
||||||
-- override protection to make sure we see all errors
|
-- override protection to make sure we see all errors
|
||||||
-- socket.protect = function(s) return s end
|
-- socket.protect = function(s) return s end
|
||||||
|
|
||||||
local http = require("http")
|
|
||||||
local mime = require("mime")
|
|
||||||
local url = require("url")
|
|
||||||
local ltn12 = require("ltn12")
|
|
||||||
|
|
||||||
dofile("testsupport.lua")
|
dofile("testsupport.lua")
|
||||||
|
|
||||||
local host, proxy, request, response, index_file
|
local host, proxy, request, response, index_file
|
||||||
|
@ -8,7 +8,7 @@ local qptest = "qptest.bin"
|
|||||||
local eqptest = "qptest.bin2"
|
local eqptest = "qptest.bin2"
|
||||||
local dqptest = "qptest.bin3"
|
local dqptest = "qptest.bin3"
|
||||||
|
|
||||||
local b64test = "luasocket.dylib"
|
local b64test = "lsocket.2.0.dylib"
|
||||||
local eb64test = "b64test.bin"
|
local eb64test = "b64test.bin"
|
||||||
local db64test = "b64test.bin2"
|
local db64test = "b64test.bin2"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user