mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 14:28: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
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
DIST = luasocket-2.0-beta2
|
||||
DIST = luasocket-2.0-beta3
|
||||
|
||||
LUA = \
|
||||
ftp.lua \
|
||||
|
@ -6,12 +6,15 @@
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Load required modules
|
||||
-- Declare module and import dependencies
|
||||
-----------------------------------------------------------------------------
|
||||
local socket = require("socket")
|
||||
local url = require("socket.url")
|
||||
local tp = require("socket.tp")
|
||||
|
||||
local ltn12 = require("ltn12")
|
||||
local url = require("url")
|
||||
local tp = require("tp")
|
||||
|
||||
module("socket.ftp")
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Program constants
|
||||
|
@ -6,12 +6,14 @@
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Load required modules
|
||||
-- Declare module and import dependencies
|
||||
-------------------------------------------------------------------------------
|
||||
local socket = require("socket")
|
||||
local url = require("socket.url")
|
||||
local ltn12 = require("ltn12")
|
||||
local mime = require("mime")
|
||||
local url = require("url")
|
||||
|
||||
module("socket.http")
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Program constants
|
||||
|
@ -5,6 +5,11 @@
|
||||
-- RCS ID: $Id$
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Declare module
|
||||
-----------------------------------------------------------------------------
|
||||
module("ltn12")
|
||||
|
||||
filter = {}
|
||||
source = {}
|
||||
sink = {}
|
||||
|
@ -19,6 +19,7 @@
|
||||
\*=========================================================================*/
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <compat-5.1.h>
|
||||
|
||||
/*=========================================================================*\
|
||||
* LuaSocket includes
|
||||
@ -85,9 +86,8 @@ static int global_unload(lua_State *L) {
|
||||
\*-------------------------------------------------------------------------*/
|
||||
static int base_open(lua_State *L) {
|
||||
if (sock_open()) {
|
||||
/* whoever is loading the library replaced the global environment
|
||||
* with the namespace table */
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||
/* export functions (and leave namespace table on top of stack) */
|
||||
luaL_module(L, "socket", func, 0);
|
||||
#ifdef LUASOCKET_DEBUG
|
||||
lua_pushstring(L, "DEBUG");
|
||||
lua_pushboolean(L, 1);
|
||||
@ -97,8 +97,6 @@ static int base_open(lua_State *L) {
|
||||
lua_pushstring(L, "VERSION");
|
||||
lua_pushstring(L, LUASOCKET_VERSION);
|
||||
lua_rawset(L, -3);
|
||||
/* export other functions */
|
||||
luaL_openlib(L, NULL, func, 0);
|
||||
return 1;
|
||||
} else {
|
||||
lua_pushstring(L, "unable to initialize library");
|
||||
@ -110,7 +108,7 @@ static int base_open(lua_State *L) {
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* Initializes all library modules.
|
||||
\*-------------------------------------------------------------------------*/
|
||||
LUASOCKET_API int luaopen_socket(lua_State *L) {
|
||||
LUASOCKET_API int luaopen_lsocket(lua_State *L) {
|
||||
int i;
|
||||
base_open(L);
|
||||
for (i = 0; mod[i].name; i++) mod[i].func(L);
|
||||
|
@ -13,7 +13,7 @@
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* Current luasocket version
|
||||
\*-------------------------------------------------------------------------*/
|
||||
#define LUASOCKET_VERSION "LuaSocket 2.0 (beta2)"
|
||||
#define LUASOCKET_VERSION "LuaSocket 2.0 (beta3)"
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* This macro prefixes all exported API functions
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <compat-5.1.h>
|
||||
|
||||
#include "mime.h"
|
||||
|
||||
@ -77,13 +78,9 @@ static UC b64unbase[256];
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* 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
|
||||
* with the namespace table */
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||
/* export functions */
|
||||
luaL_openlib(L, NULL, func, 0);
|
||||
luaL_module(L, "mime", func, 0);
|
||||
/* initialize lookup tables */
|
||||
qpsetup(qpclass, qpunbase);
|
||||
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")
|
||||
|
||||
-- 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 tp = require("socket.tp")
|
||||
|
||||
local ltn12 = require("ltn12")
|
||||
local mime = require("mime")
|
||||
local tp = require("tp")
|
||||
|
||||
module("socket.smtp")
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Program constants
|
||||
-----------------------------------------------------------------------------
|
||||
-- timeout for connection
|
||||
TIMEOUT = 60
|
||||
-- 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
|
||||
|
@ -6,11 +6,13 @@
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Load required modules
|
||||
-- Declare module and import dependencies
|
||||
-----------------------------------------------------------------------------
|
||||
local socket = require("socket")
|
||||
local ltn12 = require("ltn12")
|
||||
|
||||
module("socket.tp")
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Program constants
|
||||
-----------------------------------------------------------------------------
|
||||
|
@ -5,6 +5,11 @@
|
||||
-- RCS ID: $Id$
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Declare module
|
||||
-----------------------------------------------------------------------------
|
||||
module("socket.url")
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Encodes a string into its escaped hexadecimal representation
|
||||
-- Input
|
||||
|
@ -4,15 +4,15 @@
|
||||
-- to "/luasocket-test-cgi" and "/luasocket-test-cgi/"
|
||||
-- needs "AllowOverride AuthConfig" on /home/c/diego/tec/luasocket/test/auth
|
||||
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
|
||||
-- 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")
|
||||
|
||||
local host, proxy, request, response, index_file
|
||||
|
@ -8,7 +8,7 @@ local qptest = "qptest.bin"
|
||||
local eqptest = "qptest.bin2"
|
||||
local dqptest = "qptest.bin3"
|
||||
|
||||
local b64test = "luasocket.dylib"
|
||||
local b64test = "lsocket.2.0.dylib"
|
||||
local eb64test = "b64test.bin"
|
||||
local db64test = "b64test.bin2"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user