Fixed smtp.lua loading.

Adjusted tftp module.
Added some comments.
This commit is contained in:
Diego Nehab 2004-06-16 01:02:07 +00:00
parent 843a431ef9
commit d46f7a09a7
20 changed files with 162 additions and 139 deletions

View file

@ -1,12 +1,22 @@
/*=========================================================================*\
* Simple exception support
* LuaSocket toolkit
*
* RCS ID: $Id$
\*=========================================================================*/
#include <lauxlib.h>
#include <stdio.h>
#include "except.h"
/*=========================================================================*\
* Internal function prototypes.
\*=========================================================================*/
static int global_try(lua_State *L);
static int global_protect(lua_State *L);
static int protected(lua_State *L);
/* except functions */
static luaL_reg func[] = {
{"try", global_try},
{"protect", global_protect},

View file

@ -2,7 +2,6 @@
-- FTP support for the Lua language
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- Conforming to: RFC 959, LTN7
-- RCS ID: $Id$
-----------------------------------------------------------------------------
@ -244,5 +243,3 @@ get = socket.protect(function(gett)
if type(gett) == "string" then return sget(gett)
else return tget(gett) end
end)
return ftp

View file

@ -2,7 +2,6 @@
-- HTTP/1.1 client support for the Lua language.
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- Conforming to RFC 2616
-- RCS ID: $Id$
-----------------------------------------------------------------------------
@ -23,7 +22,7 @@ _LOADED["http"] = getfenv(1)
-- Program constants
-----------------------------------------------------------------------------
-- connection timeout in seconds
TIMEOUT = 4
TIMEOUT = 60
-- default port for document retrieval
PORT = 80
-- user agent field sent in request
@ -146,7 +145,7 @@ end
local function adjustrequest(reqt)
-- parse url with default fields
local parsed = url.parse(reqt.url, {
local parsed = url.parse(reqt.url or "", {
host = "",
port = PORT,
path ="/",
@ -258,5 +257,3 @@ post = socket.protect(function(u, body)
return (table.getn(t) > 0 or nil) and table.concat(t),
respt.headers, respt.code
end)
return http

View file

@ -254,5 +254,3 @@ function pump.all(src, snk, step)
if not ret then return not err, err end
end
end
return ltn12

View file

@ -1,5 +1,5 @@
/*=========================================================================*\
* Encoding support functions
* MIME support functions
* LuaSocket toolkit
*
* RCS ID: $Id$
@ -653,7 +653,7 @@ static int mime_global_eol(lua_State *L)
const char *marker = luaL_optstring(L, 3, CRLF);
luaL_Buffer buffer;
luaL_buffinit(L, &buffer);
/* if the last character was a candidate, we output a new line */
/* end of input blackhole */
if (!input) {
lua_pushnil(L);
lua_pushnumber(L, 0);

View file

@ -1,7 +1,7 @@
#ifndef MIME_H
#define MIME_H
/*=========================================================================*\
* Mime support functions
* MIME support functions
* LuaSocket toolkit
*
* This module provides functions to implement transfer content encodings

View file

@ -73,5 +73,3 @@ wrap = choose(wrapt)
function normalize(marker)
return ltn12.filter.cycle(eol, 0, marker)
end
return mime

View file

@ -1,3 +1,9 @@
/*=========================================================================*\
* Common option interface
* LuaSocket toolkit
*
* RCS ID: $Id$
\*=========================================================================*/
#include <lauxlib.h>
#include <string.h>
@ -5,6 +11,10 @@
#include "options.h"
#include "inet.h"
/*=========================================================================*\
* Internal functions prototypes
\*=========================================================================*/
static int opt_setmembership(lua_State *L, p_sock ps, int level, int name);
static int opt_setboolean(lua_State *L, p_sock ps, int level, int name);
static int opt_set(lua_State *L, p_sock ps, int level, int name,

View file

@ -1,5 +1,14 @@
#ifndef OPTIONS_H
#define OPTIONS_H
/*=========================================================================*\
* Common option interface
* LuaSocket toolkit
*
* This module provides a common interface to socket options, used mainly by
* modules UDP and TCP.
*
* RCS ID: $Id$
\*=========================================================================*/
#include <lua.h>
#include "socket.h"

View file

@ -4,13 +4,10 @@
* Select implementation
* LuaSocket toolkit
*
* To make the code as simple as possible, the select function is
* implemented int Lua, with a few helper functions written in C.
*
* Each object that can be passed to the select function has to export two
* methods: fd() and dirty(). Fd returns the descriptor to be passed to the
* select function. Dirty() should return true if there is data ready for
* reading (required for buffered input).
* Each object that can be passed to the select function has to export
* method getfd() which returns the descriptor to be passed to the
* underlying select function. Another method, dirty(), should return
* true if there is data ready for reading (required for buffered input).
*
* RCS ID: $Id$
\*=========================================================================*/

View file

@ -2,14 +2,13 @@
-- SMTP client support for the Lua language.
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- Conforming to RFC 2821
-- RCS ID: $Id$
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- Load required modules
-----------------------------------------------------------------------------
local smtp = requirelib("smtp")
local smtp = requirelib("smtp", "luaopen_smtp", getfenv(1))
local socket = require("socket")
local ltn12 = require("ltn12")
local tp = require("tp")
@ -206,6 +205,7 @@ end
---------------------------------------------------------------------------
-- High level SMTP API
-----------------------------------------------------------------------------
socket.protect = function(a) return a end
send = socket.protect(function(mailt)
local con = open(mailt.server, mailt.port)
con:greet(mailt.domain)
@ -213,5 +213,3 @@ send = socket.protect(function(mailt)
con:quit()
return con:close()
end)
return smtp

View file

@ -166,5 +166,3 @@ end
socket.sourcet["default"] = socket.sourcet["until-closed"]
socket.source = socket.choose(socket.sourcet)
return socket

View file

@ -49,7 +49,6 @@ local metat = { __index = {} }
function metat.__index:check(ok)
local code, reply = get_reply(self.control)
print(reply)
if not code then return nil, reply end
if type(ok) ~= "function" then
if type(ok) == "table" then
@ -65,7 +64,6 @@ print(reply)
end
function metat.__index:command(cmd, arg)
print(cmd, arg)
if arg then return self.control:send(cmd .. " " .. arg.. "\r\n")
else return self.control:send(cmd .. "\r\n") end
end
@ -113,5 +111,3 @@ connect = socket.protect(function(host, port, timeout)
socket.try(control:connect(host, port))
return setmetatable({control = control}, metat)
end)
return tp

View file

@ -2,7 +2,6 @@
-- URI parsing, composition and relative URL resolution
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- Conforming to: RFC 2396, LTN7
-- RCS ID: $Id$
-----------------------------------------------------------------------------
@ -269,5 +268,3 @@ function build_path(parsed, unsafe)
if parsed.is_absolute then path = "/" .. path end
return path
end
return url