Updated luasocket to 3.0rc1 (git commit 316a945)

--HG--
branch : minor
This commit is contained in:
James Watkins-Harvey
2016-10-01 16:30:53 -04:00
parent 889aaceabf
commit 8885fc621d
65 changed files with 7122 additions and 4049 deletions
@@ -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>
@@ -24,11 +22,11 @@ int auxiliar_open(lua_State *L) {
* Creates a new class with given methods
* Methods whose names start with __ are passed directly to the metatable.
\*-------------------------------------------------------------------------*/
void auxiliar_newclass(lua_State *L, const char *classname, luaL_reg *func) {
void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) {
luaL_newmetatable(L, classname); /* mt */
/* create __index table to place methods */
lua_pushstring(L, "__index"); /* mt,"__index" */
lua_newtable(L); /* mt,"__index",it */
lua_newtable(L); /* mt,"__index",it */
/* put class name into class metatable */
lua_pushstring(L, "class"); /* mt,"__index",it,"class" */
lua_pushstring(L, classname); /* mt,"__index",it,"class",classname */
@@ -81,12 +79,12 @@ void auxiliar_add2group(lua_State *L, const char *classname, const char *groupna
\*-------------------------------------------------------------------------*/
int auxiliar_checkboolean(lua_State *L, int objidx) {
if (!lua_isboolean(L, objidx))
luaL_typerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
return lua_toboolean(L, objidx);
}
/*-------------------------------------------------------------------------*\
* Return userdata pointer if object belongs to a given class, abort with
* Return userdata pointer if object belongs to a given class, abort with
* error otherwise
\*-------------------------------------------------------------------------*/
void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) {
@@ -100,7 +98,7 @@ void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) {
}
/*-------------------------------------------------------------------------*\
* Return userdata pointer if object belongs to a given group, abort with
* Return userdata pointer if object belongs to a given group, abort with
* error otherwise
\*-------------------------------------------------------------------------*/
void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) {
@@ -123,7 +121,7 @@ void auxiliar_setclass(lua_State *L, const char *classname, int objidx) {
}
/*-------------------------------------------------------------------------*\
* Get a userdata pointer if object belongs to a given group. Return NULL
* Get a userdata pointer if object belongs to a given group. Return NULL
* otherwise
\*-------------------------------------------------------------------------*/
void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) {
@@ -141,9 +139,20 @@ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) {
}
/*-------------------------------------------------------------------------*\
* Get a userdata pointer if object belongs to a given class. Return NULL
* Get a userdata pointer if object belongs to a given class. Return NULL
* otherwise
\*-------------------------------------------------------------------------*/
void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) {
return luaL_checkudata(L, objidx, classname);
}
/*-------------------------------------------------------------------------*\
* Throws error when argument does not have correct type.
* Used to be part of lauxlib in Lua 5.1, was dropped from 5.2.
\*-------------------------------------------------------------------------*/
int auxiliar_typeerror (lua_State *L, int narg, const char *tname) {
const char *msg = lua_pushfstring(L, "%s expected, got %s", tname,
luaL_typename(L, narg));
return luaL_argerror(L, narg, msg);
}
@@ -4,12 +4,12 @@
* Auxiliar routines for class hierarchy manipulation
* LuaSocket toolkit (but completely independent of other LuaSocket modules)
*
* A LuaSocket class is a name associated with Lua metatables. A LuaSocket
* group is a name associated with a class. A class can belong to any number
* A LuaSocket class is a name associated with Lua metatables. A LuaSocket
* group is a name associated with a class. A class can belong to any number
* of groups. This module provides the functionality to:
*
* - create new classes
* - add classes to groups
* - create new classes
* - add classes to groups
* - set the class of objects
* - check if an object belongs to a given class or group
* - get the userdata associated to objects
@@ -26,16 +26,15 @@
* "class" with the class name.
*
* The mapping from class name to the corresponding metatable and the
* reverse mapping are done using lauxlib.
*
* RCS ID: $Id: auxiliar.h,v 1.9 2005/10/07 04:40:59 diego Exp $
* reverse mapping are done using lauxlib.
\*=========================================================================*/
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
int auxiliar_open(lua_State *L);
void auxiliar_newclass(lua_State *L, const char *classname, luaL_reg *func);
void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func);
void auxiliar_add2group(lua_State *L, const char *classname, const char *group);
void auxiliar_setclass(lua_State *L, const char *classname, int objidx);
void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx);
@@ -44,5 +43,6 @@ void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx);
void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx);
int auxiliar_checkboolean(lua_State *L, int objidx);
int auxiliar_tostring(lua_State *L);
int auxiliar_typeerror(lua_State *L, int narg, const char *tname);
#endif /* AUXILIAR_H */
+31 -26
View File
@@ -1,11 +1,10 @@
/*=========================================================================*\
* Input/Output interface for Lua programs
* LuaSocket toolkit
*
* RCS ID: $Id: buffer.c,v 1.28 2007/06/11 23:44:54 diego Exp $
\*=========================================================================*/
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "buffer.h"
@@ -39,10 +38,10 @@ int buffer_open(lua_State *L) {
}
/*-------------------------------------------------------------------------*\
* Initializes C structure
* Initializes C structure
\*-------------------------------------------------------------------------*/
void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
buf->first = buf->last = 0;
buf->first = buf->last = 0;
buf->io = io;
buf->tm = tm;
buf->received = buf->sent = 0;
@@ -53,8 +52,8 @@ void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
* object:getstats() interface
\*-------------------------------------------------------------------------*/
int buffer_meth_getstats(lua_State *L, p_buffer buf) {
lua_pushnumber(L, buf->received);
lua_pushnumber(L, buf->sent);
lua_pushnumber(L, (lua_Number) buf->received);
lua_pushnumber(L, (lua_Number) buf->sent);
lua_pushnumber(L, timeout_gettime() - buf->birthday);
return 3;
}
@@ -63,8 +62,8 @@ int buffer_meth_getstats(lua_State *L, p_buffer buf) {
* object:setstats() interface
\*-------------------------------------------------------------------------*/
int buffer_meth_setstats(lua_State *L, p_buffer buf) {
buf->received = (long) luaL_optnumber(L, 2, buf->received);
buf->sent = (long) luaL_optnumber(L, 3, buf->sent);
buf->received = (long) luaL_optnumber(L, 2, (lua_Number) buf->received);
buf->sent = (long) luaL_optnumber(L, 3, (lua_Number) buf->sent);
if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4);
lua_pushnumber(L, 1);
return 1;
@@ -80,7 +79,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
const char *data = luaL_checklstring(L, 2, &size);
long start = (long) luaL_optnumber(L, 3, 1);
long end = (long) luaL_optnumber(L, 4, -1);
p_timeout tm = timeout_markstart(buf->tm);
timeout_markstart(buf->tm);
if (start < 0) start = (long) (size+start+1);
if (end < 0) end = (long) (size+end+1);
if (start < 1) start = (long) 1;
@@ -89,16 +88,16 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
/* check if there was an error */
if (err != IO_DONE) {
lua_pushnil(L);
lua_pushstring(L, buf->io->error(buf->io->ctx, err));
lua_pushnumber(L, sent+start-1);
lua_pushstring(L, buf->io->error(buf->io->ctx, err));
lua_pushnumber(L, (lua_Number) (sent+start-1));
} else {
lua_pushnumber(L, sent+start-1);
lua_pushnumber(L, (lua_Number) (sent+start-1));
lua_pushnil(L);
lua_pushnil(L);
}
#ifdef LUASOCKET_DEBUG
/* push time elapsed during operation as the last return value */
lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm));
lua_pushnumber(L, timeout_gettime() - timeout_getstart(buf->tm));
#endif
return lua_gettop(L) - top;
}
@@ -111,8 +110,8 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
luaL_Buffer b;
size_t size;
const char *part = luaL_optlstring(L, 3, "", &size);
p_timeout tm = timeout_markstart(buf->tm);
/* initialize buffer with optional extra prefix
timeout_markstart(buf->tm);
/* initialize buffer with optional extra prefix
* (useful for concatenating previous partial results) */
luaL_buffinit(L, &b);
luaL_addlstring(&b, part, size);
@@ -120,18 +119,24 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
if (!lua_isnumber(L, 2)) {
const char *p= luaL_optstring(L, 2, "*l");
if (p[0] == '*' && p[1] == 'l') err = recvline(buf, &b);
else if (p[0] == '*' && p[1] == 'a') err = recvall(buf, &b);
else if (p[0] == '*' && p[1] == 'a') err = recvall(buf, &b);
else luaL_argcheck(L, 0, 2, "invalid receive pattern");
/* get a fixed number of bytes (minus what was already partially
* received) */
} else err = recvraw(buf, (size_t) lua_tonumber(L, 2)-size, &b);
/* get a fixed number of bytes (minus what was already partially
* received) */
} else {
double n = lua_tonumber(L, 2);
size_t wanted = (size_t) n;
luaL_argcheck(L, n >= 0, 2, "invalid receive pattern");
if (size == 0 || wanted > size)
err = recvraw(buf, wanted-size, &b);
}
/* check if there was an error */
if (err != IO_DONE) {
/* we can't push anyting in the stack before pushing the
* contents of the buffer. this is the reason for the complication */
luaL_pushresult(&b);
lua_pushstring(L, buf->io->error(buf->io->ctx, err));
lua_pushvalue(L, -2);
lua_pushstring(L, buf->io->error(buf->io->ctx, err));
lua_pushvalue(L, -2);
lua_pushnil(L);
lua_replace(L, -4);
} else {
@@ -141,7 +146,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
}
#ifdef LUASOCKET_DEBUG
/* push time elapsed during operation as the last return value */
lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm));
lua_pushnumber(L, timeout_gettime() - timeout_getstart(buf->tm));
#endif
return lua_gettop(L) - top;
}
@@ -166,7 +171,7 @@ static int sendraw(p_buffer buf, const char *data, size_t count, size_t *sent) {
size_t total = 0;
int err = IO_DONE;
while (total < count && err == IO_DONE) {
size_t done;
size_t done = 0;
size_t step = (count-total <= STEPSIZE)? count-total: STEPSIZE;
err = io->send(io->ctx, data+total, step, &done, tm);
total += done;
@@ -214,7 +219,7 @@ static int recvall(p_buffer buf, luaL_Buffer *b) {
}
/*-------------------------------------------------------------------------*\
* Reads a line terminated by a CR LF pair or just by a LF. The CR and LF
* Reads a line terminated by a CR LF pair or just by a LF. The CR and LF
* are not returned by the function and are discarded from the buffer
\*-------------------------------------------------------------------------*/
static int recvline(p_buffer buf, luaL_Buffer *b) {
@@ -225,7 +230,7 @@ static int recvline(p_buffer buf, luaL_Buffer *b) {
pos = 0;
while (pos < count && data[pos] != '\n') {
/* we ignore all \r's */
if (data[pos] != '\r') luaL_putchar(b, data[pos]);
if (data[pos] != '\r') luaL_addchar(b, data[pos]);
pos++;
}
if (pos < count) { /* found '\n' */
@@ -244,7 +249,7 @@ static int recvline(p_buffer buf, luaL_Buffer *b) {
static void buffer_skip(p_buffer buf, size_t count) {
buf->received += count;
buf->first += count;
if (buffer_isempty(buf))
if (buffer_isempty(buf))
buf->first = buf->last = 0;
}
@@ -14,8 +14,6 @@
*
* The module is built on top of the I/O abstraction defined in io.h and the
* timeout management is done with the timeout.h interface.
*
* RCS ID: $Id: buffer.h,v 1.12 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include "lua.h"
@@ -31,8 +29,8 @@ typedef struct t_buffer_ {
size_t sent, received; /* bytes sent, and bytes received */
p_io io; /* IO driver used for this buffer */
p_timeout tm; /* timeout management for this buffer */
size_t first, last; /* index of first and last bytes of stored data */
char data[BUF_SIZE]; /* storage space for buffer data */
size_t first, last; /* index of first and last bytes of stored data */
char data[BUF_SIZE]; /* storage space for buffer data */
} t_buffer;
typedef t_buffer *p_buffer;
@@ -0,0 +1,19 @@
#include "compat.h"
#if LUA_VERSION_NUM==501
/*
** Adapted from Lua 5.2
*/
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
luaL_checkstack(L, nup+1, "too many upvalues");
for (; l->name != NULL; l++) { /* fill the table with given functions */
int i;
lua_pushstring(L, l->name);
for (i = 0; i < nup; i++) /* copy upvalues to the top */
lua_pushvalue(L, -(nup+1));
lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
lua_settable(L, -(nup + 3));
}
lua_pop(L, nup); /* remove upvalues */
}
#endif
@@ -0,0 +1,11 @@
#ifndef COMPAT_H
#define COMPAT_H
#include "lua.h"
#include "lauxlib.h"
#if LUA_VERSION_NUM==501
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
#endif
#endif
+62 -30
View File
@@ -1,17 +1,23 @@
/*=========================================================================*\
* Simple exception support
* LuaSocket toolkit
*
* RCS ID: $Id: except.c,v 1.8 2005/09/29 06:11:41 diego Exp $
\*=========================================================================*/
#include <stdio.h>
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "except.h"
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
#if LUA_VERSION_NUM < 502
#define lua_pcallk(L, na, nr, err, ctx, cont) \
(((void)ctx),((void)cont),lua_pcall(L, na, nr, err))
#endif
#if LUA_VERSION_NUM < 503
typedef int lua_KContext;
#endif
/*=========================================================================*\
* Internal function prototypes.
@@ -23,7 +29,7 @@ static int finalize(lua_State *L);
static int do_nothing(lua_State *L);
/* except functions */
static luaL_reg func[] = {
static luaL_Reg func[] = {
{"newtry", global_newtry},
{"protect", global_protect},
{NULL, NULL}
@@ -33,18 +39,17 @@ static luaL_reg func[] = {
* Try factory
\*-------------------------------------------------------------------------*/
static void wrap(lua_State *L) {
lua_newtable(L);
lua_pushnumber(L, 1);
lua_pushvalue(L, -3);
lua_settable(L, -3);
lua_insert(L, -2);
lua_pop(L, 1);
lua_createtable(L, 1, 0);
lua_pushvalue(L, -2);
lua_rawseti(L, -2, 1);
lua_pushvalue(L, lua_upvalueindex(1));
lua_setmetatable(L, -2);
}
static int finalize(lua_State *L) {
if (!lua_toboolean(L, 1)) {
lua_pushvalue(L, lua_upvalueindex(1));
lua_pcall(L, 0, 0, 0);
lua_pushvalue(L, lua_upvalueindex(2));
lua_call(L, 0, 0);
lua_settop(L, 2);
wrap(L);
lua_error(L);
@@ -52,15 +57,17 @@ static int finalize(lua_State *L) {
} else return lua_gettop(L);
}
static int do_nothing(lua_State *L) {
static int do_nothing(lua_State *L) {
(void) L;
return 0;
return 0;
}
static int global_newtry(lua_State *L) {
lua_settop(L, 1);
if (lua_isnil(L, 1)) lua_pushcfunction(L, do_nothing);
lua_pushcclosure(L, finalize, 1);
lua_pushvalue(L, lua_upvalueindex(1));
lua_insert(L, -2);
lua_pushcclosure(L, finalize, 2);
return 1;
}
@@ -68,27 +75,49 @@ static int global_newtry(lua_State *L) {
* Protect factory
\*-------------------------------------------------------------------------*/
static int unwrap(lua_State *L) {
if (lua_istable(L, -1)) {
lua_pushnumber(L, 1);
lua_gettable(L, -2);
lua_pushnil(L);
lua_insert(L, -2);
return 1;
} else return 0;
if (lua_istable(L, -1) && lua_getmetatable(L, -1)) {
int r = lua_rawequal(L, -1, lua_upvalueindex(1));
lua_pop(L, 1);
if (r) {
lua_pushnil(L);
lua_rawgeti(L, -2, 1);
return 1;
}
}
return 0;
}
static int protected_(lua_State *L) {
lua_pushvalue(L, lua_upvalueindex(1));
lua_insert(L, 1);
if (lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0) != 0) {
static int protected_finish(lua_State *L, int status, lua_KContext ctx) {
(void)ctx;
if (status != 0 && status != LUA_YIELD) {
if (unwrap(L)) return 2;
else lua_error(L);
return 0;
else return lua_error(L);
} else return lua_gettop(L);
}
#if LUA_VERSION_NUM == 502
static int protected_cont(lua_State *L) {
int ctx = 0;
int status = lua_getctx(L, &ctx);
return protected_finish(L, status, ctx);
}
#else
#define protected_cont protected_finish
#endif
static int protected_(lua_State *L) {
int status;
lua_pushvalue(L, lua_upvalueindex(2));
lua_insert(L, 1);
status = lua_pcallk(L, lua_gettop(L) - 1, LUA_MULTRET, 0, 0, protected_cont);
return protected_finish(L, status, 0);
}
static int global_protect(lua_State *L) {
lua_pushcclosure(L, protected_, 1);
lua_settop(L, 1);
lua_pushvalue(L, lua_upvalueindex(1));
lua_insert(L, 1);
lua_pushcclosure(L, protected_, 2);
return 1;
}
@@ -96,6 +125,9 @@ static int global_protect(lua_State *L) {
* Init module
\*-------------------------------------------------------------------------*/
int except_open(lua_State *L) {
luax_register(L, NULL, func);
lua_newtable(L); /* metatable for wrapped exceptions */
lua_pushboolean(L, 0);
lua_setfield(L, -2, "__metatable");
luaL_setfuncs(L, func, 1);
return 0;
}
+13 -10
View File
@@ -9,23 +9,26 @@
* error checking was taking a substantial amount of the coding. These
* function greatly simplify the task of checking errors.
*
* The main idea is that functions should return nil as its first return
* value when it finds an error, and return an error message (or value)
* The main idea is that functions should return nil as their first return
* values when they find an error, and return an error message (or value)
* following nil. In case of success, as long as the first value is not nil,
* the other values don't matter.
*
* The idea is to nest function calls with the "try" function. This function
* checks the first value, and calls "error" on the second if the first is
* nil. Otherwise, it returns all values it received.
* checks the first value, and, if it's falsy, wraps the second value in a
* table with metatable and calls "error" on it. Otherwise, it returns all
* values it received. Basically, it works like the Lua "assert" function,
* but it creates errors targeted specifically at "protect".
*
* The protect function returns a new function that behaves exactly like the
* function it receives, but the new function doesn't throw exceptions: it
* returns nil followed by the error message instead.
* The "newtry" function is a factory for "try" functions that call a
* finalizer in protected mode before calling "error".
*
* With these two function, it's easy to write functions that throw
* exceptions on error, but that don't interrupt the user script.
* The "protect" function returns a new function that behaves exactly like
* the function it receives, but the new function catches exceptions thrown
* by "try" functions and returns nil followed by the error message instead.
*
* RCS ID: $Id: except.h,v 1.2 2005/09/29 06:11:41 diego Exp $
* With these three functions, it's easy to write functions that throw
* exceptions on error, but that don't interrupt the user script.
\*=========================================================================*/
#include "lua.h"
+90 -42
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 $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@@ -16,27 +15,27 @@ local socket = require("socket")
local url = require("socket.url")
local tp = require("socket.tp")
local ltn12 = require("ltn12")
module("socket.ftp")
socket.ftp = {}
local _M = socket.ftp
-----------------------------------------------------------------------------
-- Program constants
-----------------------------------------------------------------------------
-- timeout in seconds before the program gives up on a connection
TIMEOUT = 60
_M.TIMEOUT = 60
-- default port for ftp service
PORT = 21
local PORT = 21
-- this is the default anonymous password. used when no password is
-- provided in url. should be changed to your e-mail.
USER = "ftp"
PASSWORD = "anonymous@anonymous.org"
_M.USER = "ftp"
_M.PASSWORD = "anonymous@anonymous.org"
-----------------------------------------------------------------------------
-- Low level FTP API
-----------------------------------------------------------------------------
local metat = { __index = {} }
function open(server, port, create)
local tp = socket.try(tp.connect(server, port or PORT, TIMEOUT, create))
function _M.open(server, port, create)
local tp = socket.try(tp.connect(server, port or PORT, _M.TIMEOUT, create))
local f = base.setmetatable({ tp = tp }, metat)
-- make sure everything gets closed in an exception
f.try = socket.newtry(function() f:close() end)
@@ -44,22 +43,22 @@ function open(server, port, create)
end
function metat.__index:portconnect()
self.try(self.server:settimeout(TIMEOUT))
self.try(self.server:settimeout(_M.TIMEOUT))
self.data = self.try(self.server:accept())
self.try(self.data:settimeout(TIMEOUT))
self.try(self.data:settimeout(_M.TIMEOUT))
end
function metat.__index:pasvconnect()
self.data = self.try(socket.tcp())
self.try(self.data:settimeout(TIMEOUT))
self.try(self.data:connect(self.pasvt.ip, self.pasvt.port))
self.try(self.data:settimeout(_M.TIMEOUT))
self.try(self.data:connect(self.pasvt.address, self.pasvt.port))
end
function metat.__index:login(user, password)
self.try(self.tp:command("user", user or USER))
self.try(self.tp:command("user", user or _M.USER))
local code, reply = self.try(self.tp:check{"2..", 331})
if code == 331 then
self.try(self.tp:command("pass", password or PASSWORD))
self.try(self.tp:command("pass", password or _M.PASSWORD))
self.try(self.tp:check("2.."))
end
return 1
@@ -72,32 +71,65 @@ function metat.__index:pasv()
local a, b, c, d, p1, p2 = socket.skip(2, string.find(reply, pattern))
self.try(a and b and c and d and p1 and p2, reply)
self.pasvt = {
ip = string.format("%d.%d.%d.%d", a, b, c, d),
address = string.format("%d.%d.%d.%d", a, b, c, d),
port = p1*256 + p2
}
if self.server then
self.server:close()
self.server = nil
end
return self.pasvt.ip, self.pasvt.port
return self.pasvt.address, self.pasvt.port
end
function metat.__index:port(ip, port)
function metat.__index:epsv()
self.try(self.tp:command("epsv"))
local code, reply = self.try(self.tp:check("229"))
local pattern = "%((.)(.-)%1(.-)%1(.-)%1%)"
local d, prt, address, port = string.match(reply, pattern)
self.try(port, "invalid epsv response")
self.pasvt = {
address = self.tp:getpeername(),
port = port
}
if self.server then
self.server:close()
self.server = nil
end
return self.pasvt.address, self.pasvt.port
end
function metat.__index:port(address, port)
self.pasvt = nil
if not ip then
ip, port = self.try(self.tp:getcontrol():getsockname())
self.server = self.try(socket.bind(ip, 0))
ip, port = self.try(self.server:getsockname())
self.try(self.server:settimeout(TIMEOUT))
if not address then
address, port = self.try(self.tp:getsockname())
self.server = self.try(socket.bind(address, 0))
address, port = self.try(self.server:getsockname())
self.try(self.server:settimeout(_M.TIMEOUT))
end
local pl = math.mod(port, 256)
local ph = (port - pl)/256
local arg = string.gsub(string.format("%s,%d,%d", ip, ph, pl), "%.", ",")
local arg = string.gsub(string.format("%s,%d,%d", address, ph, pl), "%.", ",")
self.try(self.tp:command("port", arg))
self.try(self.tp:check("2.."))
return 1
end
function metat.__index:eprt(family, address, port)
self.pasvt = nil
if not address then
address, port = self.try(self.tp:getsockname())
self.server = self.try(socket.bind(address, 0))
address, port = self.try(self.server:getsockname())
self.try(self.server:settimeout(_M.TIMEOUT))
end
local arg = string.format("|%s|%s|%d|", family, address, port)
self.try(self.tp:command("eprt", arg))
self.try(self.tp:check("2.."))
return 1
end
function metat.__index:send(sendt)
self.try(self.pasvt or self.server, "need port or pasv first")
-- if there is a pasvt table, we already sent a PASV command
@@ -111,12 +143,12 @@ function metat.__index:send(sendt)
-- send the transfer command and check the reply
self.try(self.tp:command(command, argument))
local code, reply = self.try(self.tp:check{"2..", "1.."})
-- if there is not a a pasvt table, then there is a server
-- if there is not a pasvt table, then there is a server
-- and we already sent a PORT command
if not self.pasvt then self:portconnect() end
-- get the sink, source and step for the transfer
local step = sendt.step or ltn12.pump.step
local readt = {self.tp.c}
local readt = { self.tp }
local checkstep = function(src, snk)
-- check status in control connection while downloading
local readyt = socket.select(readt, nil, 0)
@@ -143,7 +175,11 @@ function metat.__index:receive(recvt)
if argument == "" then argument = nil end
local command = recvt.command or "retr"
self.try(self.tp:command(command, argument))
local code = self.try(self.tp:check{"1..", "2.."})
local code,reply = self.try(self.tp:check{"1..", "2.."})
if (code >= 200) and (code <= 299) then
recvt.sink(reply)
return 1
end
if not self.pasvt then self:portconnect() end
local source = socket.source("until-closed", self.data)
local step = recvt.step or ltn12.pump.step
@@ -200,11 +236,11 @@ end
local function tput(putt)
putt = override(putt)
socket.try(putt.host, "missing hostname")
local f = open(putt.host, putt.port, putt.create)
local f = _M.open(putt.host, putt.port, putt.create)
f:greet()
f:login(putt.user, putt.password)
if putt.type then f:type(putt.type) end
f:pasv()
f:epsv()
local sent = f:send(putt)
f:quit()
f:close()
@@ -212,11 +248,11 @@ local function tput(putt)
end
local default = {
path = "/",
scheme = "ftp"
path = "/",
scheme = "ftp"
}
local function parse(u)
local function genericform(u)
local t = socket.try(url.parse(u, default))
socket.try(t.scheme == "ftp", "wrong scheme '" .. t.scheme .. "'")
socket.try(t.host, "missing hostname")
@@ -229,13 +265,15 @@ local function parse(u)
return t
end
_M.genericform = genericform
local function sput(u, body)
local putt = parse(u)
local putt = genericform(u)
putt.source = ltn12.source.string(body)
return tput(putt)
end
put = socket.protect(function(putt, body)
_M.put = socket.protect(function(putt, body)
if base.type(putt) == "string" then return sput(putt, body)
else return tput(putt) end
end)
@@ -243,39 +281,49 @@ end)
local function tget(gett)
gett = override(gett)
socket.try(gett.host, "missing hostname")
local f = open(gett.host, gett.port, gett.create)
local f = _M.open(gett.host, gett.port, gett.create)
f:greet()
f:login(gett.user, gett.password)
if gett.type then f:type(gett.type) end
f:pasv()
f:epsv()
f:receive(gett)
f:quit()
return f:close()
end
local function sget(u)
local gett = parse(u)
local gett = genericform(u)
local t = {}
gett.sink = ltn12.sink.table(t)
tget(gett)
return table.concat(t)
end
command = socket.protect(function(cmdt)
_M.command = socket.protect(function(cmdt)
cmdt = override(cmdt)
socket.try(cmdt.host, "missing hostname")
socket.try(cmdt.command, "missing command")
local f = open(cmdt.host, cmdt.port, cmdt.create)
local f = _M.open(cmdt.host, cmdt.port, cmdt.create)
f:greet()
f:login(cmdt.user, cmdt.password)
f.try(f.tp:command(cmdt.command, cmdt.argument))
if cmdt.check then f.try(f.tp:check(cmdt.check)) end
if type(cmdt.command) == "table" then
local argument = cmdt.argument or {}
local check = cmdt.check or {}
for i,cmd in ipairs(cmdt.command) do
f.try(f.tp:command(cmd, argument[i]))
if check[i] then f.try(f.tp:check(check[i])) end
end
else
f.try(f.tp:command(cmdt.command, cmdt.argument))
if cmdt.check then f.try(f.tp:check(cmdt.check)) end
end
f:quit()
return f:close()
end)
get = socket.protect(function(gett)
_M.get = socket.protect(function(gett)
if base.type(gett) == "string" then return sget(gett)
else return tget(gett) end
end)
return _M
+463 -387
View File
@@ -1,7 +1,7 @@
/* code automatically generated by bin2c -- DO NOT EDIT */
{
/* #include'ing this file in a C program is equivalent to calling
if (luaL_loadfile(L,"ftp.lua")==0) lua_call(L, 0, 0);
if (luaL_loadfile(L,"ftp.lua")==0) lua_call(L, 0, LUA_MULTRET);
*/
/* ftp.lua */
static const unsigned char B1[]={
@@ -13,174 +13,225 @@ static const unsigned char B1[]={
32, 76,117, 97, 32,108, 97,110,103,117, 97,103,101, 10, 45, 45, 32, 76,117, 97,
83,111, 99,107,101,116, 32,116,111,111,108,107,105,116, 46, 10, 45, 45, 32, 65,
117,116,104,111,114, 58, 32, 68,105,101,103,111, 32, 78,101,104, 97, 98, 10, 45,
45, 32, 82, 67, 83, 32, 73, 68, 58, 32, 36, 73,100, 58, 32,102,116,112, 46,108,
117, 97, 44,118, 32, 49, 46, 52, 53, 32, 50, 48, 48, 55, 47, 48, 55, 47, 49, 49,
32, 49, 57, 58, 50, 53, 58, 52, 55, 32,100,105,101,103,111, 32, 69,120,112, 32,
36, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45,
45, 32, 68,101, 99,108, 97,114,101, 32,109,111,100,117,108,101, 32, 97,110,100,
32,105,109,112,111,114,116, 32,100,101,112,101,110,100,101,110, 99,105,101,115,
10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,
111, 99, 97,108, 32, 98, 97,115,101, 32, 61, 32, 95, 71, 10,108,111, 99, 97,108,
32,116, 97, 98,108,101, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,116, 97,
98,108,101, 34, 41, 10,108,111, 99, 97,108, 32,115,116,114,105,110,103, 32, 61,
32,114,101,113,117,105,114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,108,
111, 99, 97,108, 32,109, 97,116,104, 32, 61, 32,114,101,113,117,105,114,101, 40,
34,109, 97,116,104, 34, 41, 10,108,111, 99, 97,108, 32,115,111, 99,107,101,116,
32, 61, 32,114,101,113,117,105,114,101, 40, 34,115,111, 99,107,101,116, 34, 41,
10,108,111, 99, 97,108, 32,117,114,108, 32, 61, 32,114,101,113,117,105,114,101,
40, 34,115,111, 99,107,101,116, 46,117,114,108, 34, 41, 10,108,111, 99, 97,108,
32,116,112, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,115,111, 99,107,101,
116, 46,116,112, 34, 41, 10,108,111, 99, 97,108, 32,108,116,110, 49, 50, 32, 61,
32,114,101,113,117,105,114,101, 40, 34,108,116,110, 49, 50, 34, 41, 10,109,111,
100,117,108,101, 40, 34,115,111, 99,107,101,116, 46,102,116,112, 34, 41, 10, 10,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45,
32, 80,114,111,103,114, 97,109, 32, 99,111,110,115,116, 97,110,116,115, 10, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,
101, 99,108, 97,114,101, 32,109,111,100,117,108,101, 32, 97,110,100, 32,105,109,
112,111,114,116, 32,100,101,112,101,110,100,101,110, 99,105,101,115, 10, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,
108, 32, 98, 97,115,101, 32, 61, 32, 95, 71, 10,108,111, 99, 97,108, 32,116, 97,
98,108,101, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,116, 97, 98,108,101,
34, 41, 10,108,111, 99, 97,108, 32,115,116,114,105,110,103, 32, 61, 32,114,101,
113,117,105,114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,108,111, 99, 97,
108, 32,109, 97,116,104, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,109, 97,
116,104, 34, 41, 10,108,111, 99, 97,108, 32,115,111, 99,107,101,116, 32, 61, 32,
114,101,113,117,105,114,101, 40, 34,115,111, 99,107,101,116, 34, 41, 10,108,111,
99, 97,108, 32,117,114,108, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,115,
111, 99,107,101,116, 46,117,114,108, 34, 41, 10,108,111, 99, 97,108, 32,116,112,
32, 61, 32,114,101,113,117,105,114,101, 40, 34,115,111, 99,107,101,116, 46,116,
112, 34, 41, 10,108,111, 99, 97,108, 32,108,116,110, 49, 50, 32, 61, 32,114,101,
113,117,105,114,101, 40, 34,108,116,110, 49, 50, 34, 41, 10,115,111, 99,107,101,
116, 46,102,116,112, 32, 61, 32,123,125, 10,108,111, 99, 97,108, 32, 95, 77, 32,
61, 32,115,111, 99,107,101,116, 46,102,116,112, 10, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 80,114,111,103,114, 97,
109, 32, 99,111,110,115,116, 97,110,116,115, 10, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,116,105,109,101,111,117,116,
32,105,110, 32,115,101, 99,111,110,100,115, 32, 98,101,102,111,114,101, 32,116,
104,101, 32,112,114,111,103,114, 97,109, 32,103,105,118,101,115, 32,117,112, 32,
111,110, 32, 97, 32, 99,111,110,110,101, 99,116,105,111,110, 10, 95, 77, 46, 84,
73, 77, 69, 79, 85, 84, 32, 61, 32, 54, 48, 10, 45, 45, 32,100,101,102, 97,117,
108,116, 32,112,111,114,116, 32,102,111,114, 32,102,116,112, 32,115,101,114,118,
105, 99,101, 10,108,111, 99, 97,108, 32, 80, 79, 82, 84, 32, 61, 32, 50, 49, 10,
45, 45, 32,116,104,105,115, 32,105,115, 32,116,104,101, 32,100,101,102, 97,117,
108,116, 32, 97,110,111,110,121,109,111,117,115, 32,112, 97,115,115,119,111,114,
100, 46, 32,117,115,101,100, 32,119,104,101,110, 32,110,111, 32,112, 97,115,115,
119,111,114,100, 32,105,115, 10, 45, 45, 32,112,114,111,118,105,100,101,100, 32,
105,110, 32,117,114,108, 46, 32,115,104,111,117,108,100, 32, 98,101, 32, 99,104,
97,110,103,101,100, 32,116,111, 32,121,111,117,114, 32,101, 45,109, 97,105,108,
46, 10, 95, 77, 46, 85, 83, 69, 82, 32, 61, 32, 34,102,116,112, 34, 10, 95, 77,
46, 80, 65, 83, 83, 87, 79, 82, 68, 32, 61, 32, 34, 97,110,111,110,121,109,111,
117,115, 64, 97,110,111,110,121,109,111,117,115, 46,111,114,103, 34, 10, 10, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,
116,105,109,101,111,117,116, 32,105,110, 32,115,101, 99,111,110,100,115, 32, 98,
101,102,111,114,101, 32,116,104,101, 32,112,114,111,103,114, 97,109, 32,103,105,
118,101,115, 32,117,112, 32,111,110, 32, 97, 32, 99,111,110,110,101, 99,116,105,
111,110, 10, 84, 73, 77, 69, 79, 85, 84, 32, 61, 32, 54, 48, 10, 45, 45, 32,100,
101,102, 97,117,108,116, 32,112,111,114,116, 32,102,111,114, 32,102,116,112, 32,
115,101,114,118,105, 99,101, 10, 80, 79, 82, 84, 32, 61, 32, 50, 49, 10, 45, 45,
32,116,104,105,115, 32,105,115, 32,116,104,101, 32,100,101,102, 97,117,108,116,
32, 97,110,111,110,121,109,111,117,115, 32,112, 97,115,115,119,111,114,100, 46,
32,117,115,101,100, 32,119,104,101,110, 32,110,111, 32,112, 97,115,115,119,111,
114,100, 32,105,115, 10, 45, 45, 32,112,114,111,118,105,100,101,100, 32,105,110,
32,117,114,108, 46, 32,115,104,111,117,108,100, 32, 98,101, 32, 99,104, 97,110,
103,101,100, 32,116,111, 32,121,111,117,114, 32,101, 45,109, 97,105,108, 46, 10,
85, 83, 69, 82, 32, 61, 32, 34,102,116,112, 34, 10, 80, 65, 83, 83, 87, 79, 82,
68, 32, 61, 32, 34, 97,110,111,110,121,109,111,117,115, 64, 97,110,111,110,121,
109,111,117,115, 46,111,114,103, 34, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45,
76,111,119, 32,108,101,118,101,108, 32, 70, 84, 80, 32, 65, 80, 73, 10, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 76,111,119, 32,108,101,118,101,
108, 32, 70, 84, 80, 32, 65, 80, 73, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32,109,101,116, 97,116, 32,
61, 32,123, 32, 95, 95,105,110,100,101,120, 32, 61, 32,123,125, 32,125, 10, 10,
102,117,110, 99,116,105,111,110, 32,111,112,101,110, 40,115,101,114,118,101,114,
44, 32,112,111,114,116, 44, 32, 99,114,101, 97,116,101, 41, 10, 32, 32, 32, 32,
108,111, 99, 97,108, 32,116,112, 32, 61, 32,115,111, 99,107,101,116, 46,116,114,
121, 40,116,112, 46, 99,111,110,110,101, 99,116, 40,115,101,114,118,101,114, 44,
32,112,111,114,116, 32,111,114, 32, 80, 79, 82, 84, 44, 32, 84, 73, 77, 69, 79,
85, 84, 44, 32, 99,114,101, 97,116,101, 41, 41, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,102, 32, 61, 32, 98, 97,115,101, 46,115,101,116,109,101,116, 97,116,
97, 98,108,101, 40,123, 32,116,112, 32, 61, 32,116,112, 32,125, 44, 32,109,101,
116, 97,116, 41, 10, 32, 32, 32, 32, 45, 45, 32,109, 97,107,101, 32,115,117,114,
101, 32,101,118,101,114,121,116,104,105,110,103, 32,103,101,116,115, 32, 99,108,
111,115,101,100, 32,105,110, 32, 97,110, 32,101,120, 99,101,112,116,105,111,110,
10, 32, 32, 32, 32,102, 46,116,114,121, 32, 61, 32,115,111, 99,107,101,116, 46,
110,101,119,116,114,121, 40,102,117,110, 99,116,105,111,110, 40, 41, 32,102, 58,
99,108,111,115,101, 40, 41, 32,101,110,100, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32,102, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,112,111,114,116, 99,111,
110,110,101, 99,116, 40, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121,
40,115,101,108,102, 46,115,101,114,118,101,114, 58,115,101,116,116,105,109,101,
111,117,116, 40, 84, 73, 77, 69, 79, 85, 84, 41, 41, 10, 32, 32, 32, 32,115,101,
108,102, 46,100, 97,116, 97, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,
101,108,102, 46,115,101,114,118,101,114, 58, 97, 99, 99,101,112,116, 40, 41, 41,
10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,100,
97,116, 97, 58,115,101,116,116,105,109,101,111,117,116, 40, 84, 73, 77, 69, 79,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,
108, 32,109,101,116, 97,116, 32, 61, 32,123, 32, 95, 95,105,110,100,101,120, 32,
61, 32,123,125, 32,125, 10, 10,102,117,110, 99,116,105,111,110, 32, 95, 77, 46,
111,112,101,110, 40,115,101,114,118,101,114, 44, 32,112,111,114,116, 44, 32, 99,
114,101, 97,116,101, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,116,112, 32,
61, 32,115,111, 99,107,101,116, 46,116,114,121, 40,116,112, 46, 99,111,110,110,
101, 99,116, 40,115,101,114,118,101,114, 44, 32,112,111,114,116, 32,111,114, 32,
80, 79, 82, 84, 44, 32, 95, 77, 46, 84, 73, 77, 69, 79, 85, 84, 44, 32, 99,114,
101, 97,116,101, 41, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 32, 61,
32, 98, 97,115,101, 46,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,123,
32,116,112, 32, 61, 32,116,112, 32,125, 44, 32,109,101,116, 97,116, 41, 10, 32,
32, 32, 32, 45, 45, 32,109, 97,107,101, 32,115,117,114,101, 32,101,118,101,114,
121,116,104,105,110,103, 32,103,101,116,115, 32, 99,108,111,115,101,100, 32,105,
110, 32, 97,110, 32,101,120, 99,101,112,116,105,111,110, 10, 32, 32, 32, 32,102,
46,116,114,121, 32, 61, 32,115,111, 99,107,101,116, 46,110,101,119,116,114,121,
40,102,117,110, 99,116,105,111,110, 40, 41, 32,102, 58, 99,108,111,115,101, 40,
41, 32,101,110,100, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102, 10,
101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46,
95, 95,105,110,100,101,120, 58,112,111,114,116, 99,111,110,110,101, 99,116, 40,
41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,
115,101,114,118,101,114, 58,115,101,116,116,105,109,101,111,117,116, 40, 95, 77,
46, 84, 73, 77, 69, 79, 85, 84, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,
100, 97,116, 97, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102,
46,115,101,114,118,101,114, 58, 97, 99, 99,101,112,116, 40, 41, 41, 10, 32, 32,
32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,100, 97,116, 97,
58,115,101,116,116,105,109,101,111,117,116, 40, 95, 77, 46, 84, 73, 77, 69, 79,
85, 84, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,
101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,112, 97,115,118, 99,111,110,
110,101, 99,116, 40, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,100, 97,116, 97,
32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,111, 99,107,101,116, 46,116,
99,112, 40, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,
101,108,102, 46,100, 97,116, 97, 58,115,101,116,116,105,109,101,111,117,116, 40,
84, 73, 77, 69, 79, 85, 84, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,
114,121, 40,115,101,108,102, 46,100, 97,116, 97, 58, 99,111,110,110,101, 99,116,
40,115,101,108,102, 46,112, 97,115,118,116, 46,105,112, 44, 32,115,101,108,102,
46,112, 97,115,118,116, 46,112,111,114,116, 41, 41, 10,101,110,100, 10, 10,102,
117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,
120, 58,108,111,103,105,110, 40,117,115,101,114, 44, 32,112, 97,115,115,119,111,
114,100, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,
102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34,117,115,101,114, 34, 44,
32,117,115,101,114, 32,111,114, 32, 85, 83, 69, 82, 41, 41, 10, 32, 32, 32, 32,
108,111, 99, 97,108, 32, 99,111,100,101, 44, 32,114,101,112,108,121, 32, 61, 32,
115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101,
99,107,123, 34, 50, 46, 46, 34, 44, 32, 51, 51, 49,125, 41, 10, 32, 32, 32, 32,
105,102, 32, 99,111,100,101, 32, 61, 61, 32, 51, 51, 49, 32,116,104,101,110, 10,
32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,
102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34,112, 97,115,115, 34, 44,
32,112, 97,115,115,119,111,114,100, 32,111,114, 32, 80, 65, 83, 83, 87, 79, 82,
68, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 46,116,114,121,
40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34,
41, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,114,101,116,117,114,
110, 32, 49, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,
116, 97,116, 46, 95, 95,105,110,100,101,120, 58,112, 97,115,118, 40, 41, 10, 32,
95, 77, 46, 84, 73, 77, 69, 79, 85, 84, 41, 41, 10, 32, 32, 32, 32,115,101,108,
102, 46,116,114,121, 40,115,101,108,102, 46,100, 97,116, 97, 58, 99,111,110,110,
101, 99,116, 40,115,101,108,102, 46,112, 97,115,118,116, 46, 97,100,100,114,101,
115,115, 44, 32,115,101,108,102, 46,112, 97,115,118,116, 46,112,111,114,116, 41,
41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,
116, 46, 95, 95,105,110,100,101,120, 58,108,111,103,105,110, 40,117,115,101,114,
44, 32,112, 97,115,115,119,111,114,100, 41, 10, 32, 32, 32, 32,115,101,108,102,
46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100,
40, 34,117,115,101,114, 34, 44, 32,117,115,101,114, 32,111,114, 32, 95, 77, 46,
85, 83, 69, 82, 41, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,111,100,
101, 44, 32,114,101,112,108,121, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,
115,101,108,102, 46,116,112, 58, 99,104,101, 99,107,123, 34, 50, 46, 46, 34, 44,
32, 51, 51, 49,125, 41, 10, 32, 32, 32, 32,105,102, 32, 99,111,100,101, 32, 61,
61, 32, 51, 51, 49, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,
101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109,
97,110,100, 40, 34,112, 97,115,115, 34, 44, 32,112, 97,115,115,119,111,114,100,
32,111,114, 32, 95, 77, 46, 80, 65, 83, 83, 87, 79, 82, 68, 41, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,
116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10, 32, 32, 32,
32,101,110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10,101,110,
100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,
105,110,100,101,120, 58,112, 97,115,118, 40, 41, 10, 32, 32, 32, 32,115,101,108,
102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,
100, 40, 34,112, 97,115,118, 34, 41, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108,
32, 99,111,100,101, 44, 32,114,101,112,108,121, 32, 61, 32,115,101,108,102, 46,
116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50,
46, 46, 34, 41, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,112, 97,116,116,
101,114,110, 32, 61, 32, 34, 40, 37,100, 43, 41, 37, 68, 40, 37,100, 43, 41, 37,
68, 40, 37,100, 43, 41, 37, 68, 40, 37,100, 43, 41, 37, 68, 40, 37,100, 43, 41,
37, 68, 40, 37,100, 43, 41, 34, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 97,
44, 32, 98, 44, 32, 99, 44, 32,100, 44, 32,112, 49, 44, 32,112, 50, 32, 61, 32,
115,111, 99,107,101,116, 46,115,107,105,112, 40, 50, 44, 32,115,116,114,105,110,
103, 46,102,105,110,100, 40,114,101,112,108,121, 44, 32,112, 97,116,116,101,114,
110, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40, 97, 32, 97,
110,100, 32, 98, 32, 97,110,100, 32, 99, 32, 97,110,100, 32,100, 32, 97,110,100,
32,112, 49, 32, 97,110,100, 32,112, 50, 44, 32,114,101,112,108,121, 41, 10, 32,
32, 32, 32,115,101,108,102, 46,112, 97,115,118,116, 32, 61, 32,123, 10, 32, 32,
32, 32, 32, 32, 32, 32, 97,100,100,114,101,115,115, 32, 61, 32,115,116,114,105,
110,103, 46,102,111,114,109, 97,116, 40, 34, 37,100, 46, 37,100, 46, 37,100, 46,
37,100, 34, 44, 32, 97, 44, 32, 98, 44, 32, 99, 44, 32,100, 41, 44, 10, 32, 32,
32, 32, 32, 32, 32, 32,112,111,114,116, 32, 61, 32,112, 49, 42, 50, 53, 54, 32,
43, 32,112, 50, 10, 32, 32, 32, 32,125, 10, 32, 32, 32, 32,105,102, 32,115,101,
108,102, 46,115,101,114,118,101,114, 32,116,104,101,110, 10, 32, 32, 32, 32, 32,
32, 32, 32,115,101,108,102, 46,115,101,114,118,101,114, 58, 99,108,111,115,101,
40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 46,115,101,114,118,
101,114, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32,
32,114,101,116,117,114,110, 32,115,101,108,102, 46,112, 97,115,118,116, 46, 97,
100,100,114,101,115,115, 44, 32,115,101,108,102, 46,112, 97,115,118,116, 46,112,
111,114,116, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,
116, 97,116, 46, 95, 95,105,110,100,101,120, 58,101,112,115,118, 40, 41, 10, 32,
32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58,
99,111,109,109, 97,110,100, 40, 34,112, 97,115,118, 34, 41, 41, 10, 32, 32, 32,
99,111,109,109, 97,110,100, 40, 34,101,112,115,118, 34, 41, 41, 10, 32, 32, 32,
32,108,111, 99, 97,108, 32, 99,111,100,101, 44, 32,114,101,112,108,121, 32, 61,
32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,
101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10, 32, 32, 32, 32,108,111, 99, 97,
108, 32,112, 97,116,116,101,114,110, 32, 61, 32, 34, 40, 37,100, 43, 41, 37, 68,
40, 37,100, 43, 41, 37, 68, 40, 37,100, 43, 41, 37, 68, 40, 37,100, 43, 41, 37,
68, 40, 37,100, 43, 41, 37, 68, 40, 37,100, 43, 41, 34, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32, 97, 44, 32, 98, 44, 32, 99, 44, 32,100, 44, 32,112, 49, 44,
32,112, 50, 32, 61, 32,115,111, 99,107,101,116, 46,115,107,105,112, 40, 50, 44,
32,115,116,114,105,110,103, 46,102,105,110,100, 40,114,101,112,108,121, 44, 32,
112, 97,116,116,101,114,110, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,
114,121, 40, 97, 32, 97,110,100, 32, 98, 32, 97,110,100, 32, 99, 32, 97,110,100,
32,100, 32, 97,110,100, 32,112, 49, 32, 97,110,100, 32,112, 50, 44, 32,114,101,
112,108,121, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,112, 97,115,118,116, 32,
61, 32,123, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,112, 32, 61, 32,115,116,114,
105,110,103, 46,102,111,114,109, 97,116, 40, 34, 37,100, 46, 37,100, 46, 37,100,
46, 37,100, 34, 44, 32, 97, 44, 32, 98, 44, 32, 99, 44, 32,100, 41, 44, 10, 32,
32, 32, 32, 32, 32, 32, 32,112,111,114,116, 32, 61, 32,112, 49, 42, 50, 53, 54,
32, 43, 32,112, 50, 10, 32, 32, 32, 32,125, 10, 32, 32, 32, 32,105,102, 32,115,
101,108,102, 46,115,101,114,118,101,114, 32,116,104,101,110, 10, 32, 32, 32, 32,
32, 32, 32, 32,115,101,108,102, 46,115,101,114,118,101,114, 58, 99,108,111,115,
101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 46,115,101,114,
118,101,114, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32,
32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,112, 97,115,118,116, 46,
105,112, 44, 32,115,101,108,102, 46,112, 97,115,118,116, 46,112,111,114,116, 10,
101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46,
95, 95,105,110,100,101,120, 58,112,111,114,116, 40,105,112, 44, 32,112,111,114,
116, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,112, 97,115,118,116, 32, 61, 32,
110,105,108, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,105,112, 32,116,104,
101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,112, 44, 32,112,111,114,116, 32,
61, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58,103,
101,116, 99,111,110,116,114,111,108, 40, 41, 58,103,101,116,115,111, 99,107,110,
97,109,101, 40, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 46,
115,101,114,118,101,114, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,111,
99,107,101,116, 46, 98,105,110,100, 40,105,112, 44, 32, 48, 41, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32,105,112, 44, 32,112,111,114,116, 32, 61, 32,115,101,108,
102, 46,116,114,121, 40,115,101,108,102, 46,115,101,114,118,101,114, 58,103,101,
116,115,111, 99,107,110, 97,109,101, 40, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,115,101,114,118,101,
114, 58,115,101,116,116,105,109,101,111,117,116, 40, 84, 73, 77, 69, 79, 85, 84,
41, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,108,111, 99, 97,108,
32,112,108, 32, 61, 32,109, 97,116,104, 46,109,111,100, 40,112,111,114,116, 44,
32, 50, 53, 54, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,112,104, 32, 61,
32, 40,112,111,114,116, 32, 45, 32,112,108, 41, 47, 50, 53, 54, 10, 32, 32, 32,
32,108,111, 99, 97,108, 32, 97,114,103, 32, 61, 32,115,116,114,105,110,103, 46,
103,115,117, 98, 40,115,116,114,105,110,103, 46,102,111,114,109, 97,116, 40, 34,
37,115, 44, 37,100, 44, 37,100, 34, 44, 32,105,112, 44, 32,112,104, 44, 32,112,
108, 41, 44, 32, 34, 37, 46, 34, 44, 32, 34, 44, 34, 41, 10, 32, 32, 32, 32,115,
101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109,
97,110,100, 40, 34,112,111,114,116, 34, 44, 32, 97,114,103, 41, 41, 10, 32, 32,
32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,
104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32, 49, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
101, 99,107, 40, 34, 50, 50, 57, 34, 41, 41, 10, 32, 32, 32, 32,108,111, 99, 97,
108, 32,112, 97,116,116,101,114,110, 32, 61, 32, 34, 37, 40, 40, 46, 41, 40, 46,
45, 41, 37, 49, 40, 46, 45, 41, 37, 49, 40, 46, 45, 41, 37, 49, 37, 41, 34, 10,
32, 32, 32, 32,108,111, 99, 97,108, 32,100, 44, 32,112,114,116, 44, 32, 97,100,
100,114,101,115,115, 44, 32,112,111,114,116, 32, 61, 32,115,116,114,105,110,103,
46,109, 97,116, 99,104, 40,114,101,112,108,121, 44, 32,112, 97,116,116,101,114,
110, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,112,111,114,116,
44, 32, 34,105,110,118, 97,108,105,100, 32,101,112,115,118, 32,114,101,115,112,
111,110,115,101, 34, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,112, 97,115,118,
116, 32, 61, 32,123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 97,100,100,114,101,115,
115, 32, 61, 32,115,101,108,102, 46,116,112, 58,103,101,116,112,101,101,114,110,
97,109,101, 40, 41, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32,112,111,114,116, 32,
61, 32,112,111,114,116, 10, 32, 32, 32, 32,125, 10, 32, 32, 32, 32,105,102, 32,
115,101,108,102, 46,115,101,114,118,101,114, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32,115,101,108,102, 46,115,101,114,118,101,114, 58, 99,108,111,
115,101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 46,115,101,
114,118,101,114, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,101,110,100, 10, 32,
32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,112, 97,115,118,116,
46, 97,100,100,114,101,115,115, 44, 32,115,101,108,102, 46,112, 97,115,118,116,
46,112,111,114,116, 10,101,110,100, 10, 10, 10,102,117,110, 99,116,105,111,110,
32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,112,111,114,116, 40,
97,100,100,114,101,115,115, 44, 32,112,111,114,116, 41, 10, 32, 32, 32, 32,115,
101,108,102, 46,112, 97,115,118,116, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,
105,102, 32,110,111,116, 32, 97,100,100,114,101,115,115, 32,116,104,101,110, 10,
32, 32, 32, 32, 32, 32, 32, 32, 97,100,100,114,101,115,115, 44, 32,112,111,114,
116, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112,
58,103,101,116,115,111, 99,107,110, 97,109,101, 40, 41, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32,115,101,108,102, 46,115,101,114,118,101,114, 32, 61, 32,115,101,
108,102, 46,116,114,121, 40,115,111, 99,107,101,116, 46, 98,105,110,100, 40, 97,
100,100,114,101,115,115, 44, 32, 48, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
97,100,100,114,101,115,115, 44, 32,112,111,114,116, 32, 61, 32,115,101,108,102,
46,116,114,121, 40,115,101,108,102, 46,115,101,114,118,101,114, 58,103,101,116,
115,111, 99,107,110, 97,109,101, 40, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,115,101,114,118,101,114,
58,115,101,116,116,105,109,101,111,117,116, 40, 95, 77, 46, 84, 73, 77, 69, 79,
85, 84, 41, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,112,108, 32, 61, 32,109, 97,116,104, 46,109,111,100, 40,112,111,114,
116, 44, 32, 50, 53, 54, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,112,104,
32, 61, 32, 40,112,111,114,116, 32, 45, 32,112,108, 41, 47, 50, 53, 54, 10, 32,
32, 32, 32,108,111, 99, 97,108, 32, 97,114,103, 32, 61, 32,115,116,114,105,110,
103, 46,103,115,117, 98, 40,115,116,114,105,110,103, 46,102,111,114,109, 97,116,
40, 34, 37,115, 44, 37,100, 44, 37,100, 34, 44, 32, 97,100,100,114,101,115,115,
44, 32,112,104, 44, 32,112,108, 41, 44, 32, 34, 37, 46, 34, 44, 32, 34, 44, 34,
41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,
116,112, 58, 99,111,109,109, 97,110,100, 40, 34,112,111,114,116, 34, 44, 32, 97,
114,103, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,
108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10,101,110,100, 10, 10,102,117,
110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120,
58,101,112,114,116, 40,102, 97,109,105,108,121, 44, 32, 97,100,100,114,101,115,
115, 44, 32,112,111,114,116, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,112, 97,
115,118,116, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,105,102, 32,110,111,116,
32, 97,100,100,114,101,115,115, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32,
32, 32, 97,100,100,114,101,115,115, 44, 32,112,111,114,116, 32, 61, 32,115,101,
108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58,103,101,116,115,111,
99,107,110, 97,109,101, 40, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,
108,102, 46,115,101,114,118,101,114, 32, 61, 32,115,101,108,102, 46,116,114,121,
40,115,111, 99,107,101,116, 46, 98,105,110,100, 40, 97,100,100,114,101,115,115,
44, 32, 48, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 97,100,100,114,101,115,
115, 44, 32,112,111,114,116, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,
101,108,102, 46,115,101,114,118,101,114, 58,103,101,116,115,111, 99,107,110, 97,
109,101, 40, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 46,116,
114,121, 40,115,101,108,102, 46,115,101,114,118,101,114, 58,115,101,116,116,105,
109,101,111,117,116, 40, 95, 77, 46, 84, 73, 77, 69, 79, 85, 84, 41, 41, 10, 32,
32, 32, 32,101,110,100, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 97,114,103,
32, 61, 32,115,116,114,105,110,103, 46,102,111,114,109, 97,116, 40, 34,124, 37,
115,124, 37,115,124, 37,100,124, 34, 44, 32,102, 97,109,105,108,121, 44, 32, 97,
100,100,114,101,115,115, 44, 32,112,111,114,116, 41, 10, 32, 32, 32, 32,115,101,
108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,
110,100, 40, 34,101,112,114,116, 34, 44, 32, 97,114,103, 41, 41, 10, 32, 32, 32,
32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,
101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32, 49, 10,101,110,100, 10, 10, 10,102,117,110, 99,116,105,111,110, 32,
109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,115,101,110,100, 40,115,
101,110,100,116, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,
101,108,102, 46,112, 97,115,118,116, 32,111,114, 32,115,101,108,102, 46,115,101,
@@ -215,254 +266,279 @@ static const unsigned char B1[]={
121, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112,
58, 99,104,101, 99,107,123, 34, 50, 46, 46, 34, 44, 32, 34, 49, 46, 46, 34,125,
41, 10, 32, 32, 32, 32, 45, 45, 32,105,102, 32,116,104,101,114,101, 32,105,115,
32,110,111,116, 32, 97, 32, 97, 32,112, 97,115,118,116, 32,116, 97, 98,108,101,
44, 32,116,104,101,110, 32,116,104,101,114,101, 32,105,115, 32, 97, 32,115,101,
114,118,101,114, 10, 32, 32, 32, 32, 45, 45, 32, 97,110,100, 32,119,101, 32, 97,
108,114,101, 97,100,121, 32,115,101,110,116, 32, 97, 32, 80, 79, 82, 84, 32, 99,
111,109,109, 97,110,100, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,115,101,
108,102, 46,112, 97,115,118,116, 32,116,104,101,110, 32,115,101,108,102, 58,112,
111,114,116, 99,111,110,110,101, 99,116, 40, 41, 32,101,110,100, 10, 32, 32, 32,
32, 45, 45, 32,103,101,116, 32,116,104,101, 32,115,105,110,107, 44, 32,115,111,
117,114, 99,101, 32, 97,110,100, 32,115,116,101,112, 32,102,111,114, 32,116,104,
101, 32,116,114, 97,110,115,102,101,114, 10, 32, 32, 32, 32,108,111, 99, 97,108,
32,115,116,101,112, 32, 61, 32,115,101,110,100,116, 46,115,116,101,112, 32,111,
114, 32,108,116,110, 49, 50, 46,112,117,109,112, 46,115,116,101,112, 10, 32, 32,
32, 32,108,111, 99, 97,108, 32,114,101, 97,100,116, 32, 61, 32,123,115,101,108,
102, 46,116,112, 46, 99,125, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,104,
101, 99,107,115,116,101,112, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,115,
114, 99, 44, 32,115,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32,
99,104,101, 99,107, 32,115,116, 97,116,117,115, 32,105,110, 32, 99,111,110,116,
114,111,108, 32, 99,111,110,110,101, 99,116,105,111,110, 32,119,104,105,108,101,
32,100,111,119,110,108,111, 97,100,105,110,103, 10, 32, 32, 32, 32, 32, 32, 32,
32,108,111, 99, 97,108, 32,114,101, 97,100,121,116, 32, 61, 32,115,111, 99,107,
101,116, 46,115,101,108,101, 99,116, 40,114,101, 97,100,116, 44, 32,110,105,108,
44, 32, 48, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,114,101, 97,100,
121,116, 91,116,112, 93, 32,116,104,101,110, 32, 99,111,100,101, 32, 61, 32,115,
101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,
107, 40, 34, 50, 46, 46, 34, 41, 41, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32,
32, 32,114,101,116,117,114,110, 32,115,116,101,112, 40,115,114, 99, 44, 32,115,
110,107, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,108,111, 99, 97,
108, 32,115,105,110,107, 32, 61, 32,115,111, 99,107,101,116, 46,115,105,110,107,
40, 34, 99,108,111,115,101, 45,119,104,101,110, 45,100,111,110,101, 34, 44, 32,
115,101,108,102, 46,100, 97,116, 97, 41, 10, 32, 32, 32, 32, 45, 45, 32,116,114,
97,110,115,102,101,114, 32, 97,108,108, 32,100, 97,116, 97, 32, 97,110,100, 32,
99,104,101, 99,107, 32,101,114,114,111,114, 10, 32, 32, 32, 32,115,101,108,102,
46,116,114,121, 40,108,116,110, 49, 50, 46,112,117,109,112, 46, 97,108,108, 40,
115,101,110,100,116, 46,115,111,117,114, 99,101, 44, 32,115,105,110,107, 44, 32,
99,104,101, 99,107,115,116,101,112, 41, 41, 10, 32, 32, 32, 32,105,102, 32,115,
116,114,105,110,103, 46,102,105,110,100, 40, 99,111,100,101, 44, 32, 34, 49, 46,
46, 34, 41, 32,116,104,101,110, 32,115,101,108,102, 46,116,114,121, 40,115,101,
108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 32,
101,110,100, 10, 32, 32, 32, 32, 45, 45, 32,100,111,110,101, 32,119,105,116,104,
32,100, 97,116, 97, 32, 99,111,110,110,101, 99,116,105,111,110, 10, 32, 32, 32,
32,115,101,108,102, 46,100, 97,116, 97, 58, 99,108,111,115,101, 40, 41, 10, 32,
32, 32, 32, 45, 45, 32,102,105,110,100, 32,111,117,116, 32,104,111,119, 32,109,
97,110,121, 32, 98,121,116,101,115, 32,119,101,114,101, 32,115,101,110,116, 10,
32, 32, 32, 32,108,111, 99, 97,108, 32,115,101,110,116, 32, 61, 32,115,111, 99,
107,101,116, 46,115,107,105,112, 40, 49, 44, 32,115,101,108,102, 46,100, 97,116,
97, 58,103,101,116,115,116, 97,116,115, 40, 41, 41, 10, 32, 32, 32, 32,115,101,
108,102, 46,100, 97,116, 97, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32,115,101,110,116, 10,101,110,100, 10, 10,102,117,110, 99,116,
105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,114,101,
99,101,105,118,101, 40,114,101, 99,118,116, 41, 10, 32, 32, 32, 32,115,101,108,
102, 46,116,114,121, 40,115,101,108,102, 46,112, 97,115,118,116, 32,111,114, 32,
115,101,108,102, 46,115,101,114,118,101,114, 44, 32, 34,110,101,101,100, 32,112,
111,114,116, 32,111,114, 32,112, 97,115,118, 32,102,105,114,115,116, 34, 41, 10,
32, 32, 32, 32,105,102, 32,115,101,108,102, 46,112, 97,115,118,116, 32,116,104,
101,110, 32,115,101,108,102, 58,112, 97,115,118, 99,111,110,110,101, 99,116, 40,
41, 32,101,110,100, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 97,114,103,117,
109,101,110,116, 32, 61, 32,114,101, 99,118,116, 46, 97,114,103,117,109,101,110,
116, 32,111,114, 10, 32, 32, 32, 32, 32, 32, 32, 32,117,114,108, 46,117,110,101,
115, 99, 97,112,101, 40,115,116,114,105,110,103, 46,103,115,117, 98, 40,114,101,
99,118,116, 46,112, 97,116,104, 32,111,114, 32, 34, 34, 44, 32, 34, 94, 91, 47,
92, 92, 93, 34, 44, 32, 34, 34, 41, 41, 10, 32, 32, 32, 32,105,102, 32, 97,114,
103,117,109,101,110,116, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 32, 97,114,
103,117,109,101,110,116, 32, 61, 32,110,105,108, 32,101,110,100, 10, 32, 32, 32,
32,108,111, 99, 97,108, 32, 99,111,109,109, 97,110,100, 32, 61, 32,114,101, 99,
118,116, 46, 99,111,109,109, 97,110,100, 32,111,114, 32, 34,114,101,116,114, 34,
10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,
112, 58, 99,111,109,109, 97,110,100, 40, 99,111,109,109, 97,110,100, 44, 32, 97,
114,103,117,109,101,110,116, 41, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,
99,111,100,101, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102,
46,116,112, 58, 99,104,101, 99,107,123, 34, 49, 46, 46, 34, 44, 32, 34, 50, 46,
46, 34,125, 41, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,115,101,108,102,
32,110,111,116, 32, 97, 32,112, 97,115,118,116, 32,116, 97, 98,108,101, 44, 32,
116,104,101,110, 32,116,104,101,114,101, 32,105,115, 32, 97, 32,115,101,114,118,
101,114, 10, 32, 32, 32, 32, 45, 45, 32, 97,110,100, 32,119,101, 32, 97,108,114,
101, 97,100,121, 32,115,101,110,116, 32, 97, 32, 80, 79, 82, 84, 32, 99,111,109,
109, 97,110,100, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,115,101,108,102,
46,112, 97,115,118,116, 32,116,104,101,110, 32,115,101,108,102, 58,112,111,114,
116, 99,111,110,110,101, 99,116, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32,115,111,117,114, 99,101, 32, 61, 32,115,111, 99,107,101,116,
46,115,111,117,114, 99,101, 40, 34,117,110,116,105,108, 45, 99,108,111,115,101,
100, 34, 44, 32,115,101,108,102, 46,100, 97,116, 97, 41, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32,115,116,101,112, 32, 61, 32,114,101, 99,118,116, 46,115,116,
101,112, 32,111,114, 32,108,116,110, 49, 50, 46,112,117,109,112, 46,115,116,101,
112, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,108,116,110, 49, 50,
46,112,117,109,112, 46, 97,108,108, 40,115,111,117,114, 99,101, 44, 32,114,101,
99,118,116, 46,115,105,110,107, 44, 32,115,116,101,112, 41, 41, 10, 32, 32, 32,
32,105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40, 99,111,100,101,
44, 32, 34, 49, 46, 46, 34, 41, 32,116,104,101,110, 32,115,101,108,102, 46,116,
114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46,
46, 34, 41, 41, 32,101,110,100, 10, 32, 32, 32, 32,115,101,108,102, 46,100, 97,
116, 97, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,
100, 97,116, 97, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,114,101,116,117,114,
110, 32, 49, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,
116, 97,116, 46, 95, 95,105,110,100,101,120, 58, 99,119,100, 40,100,105,114, 41,
10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,
112, 58, 99,111,109,109, 97,110,100, 40, 34, 99,119,100, 34, 44, 32,100,105,114,
41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102,
46,116,112, 58, 99,104,101, 99,107, 40, 50, 53, 48, 41, 41, 10, 32, 32, 32, 32,
114,101,116,117,114,110, 32, 49, 10,101,110,100, 10, 10,102,117,110, 99,116,105,
111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,116,121,112,
101, 40,116,121,112,101, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121,
40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34,116,121,
112,101, 34, 44, 32,116,121,112,101, 41, 41, 10, 32, 32, 32, 32,115,101,108,102,
46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 50,
48, 48, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10,101,110,
100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,
105,110,100,101,120, 58,103,114,101,101,116, 40, 41, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32, 99,111,100,101, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,
116, 99,111,110,110,101, 99,116, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32, 45,
45, 32,103,101,116, 32,116,104,101, 32,115,105,110,107, 44, 32,115,111,117,114,
99,101, 32, 97,110,100, 32,115,116,101,112, 32,102,111,114, 32,116,104,101, 32,
116,114, 97,110,115,102,101,114, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,
116,101,112, 32, 61, 32,115,101,110,100,116, 46,115,116,101,112, 32,111,114, 32,
108,116,110, 49, 50, 46,112,117,109,112, 46,115,116,101,112, 10, 32, 32, 32, 32,
108,111, 99, 97,108, 32,114,101, 97,100,116, 32, 61, 32,123, 32,115,101,108,102,
46,116,112, 32,125, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,104,101, 99,
107,115,116,101,112, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,115,114, 99,
44, 32,115,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32, 99,104,
101, 99,107, 32,115,116, 97,116,117,115, 32,105,110, 32, 99,111,110,116,114,111,
108, 32, 99,111,110,110,101, 99,116,105,111,110, 32,119,104,105,108,101, 32,100,
111,119,110,108,111, 97,100,105,110,103, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,
111, 99, 97,108, 32,114,101, 97,100,121,116, 32, 61, 32,115,111, 99,107,101,116,
46,115,101,108,101, 99,116, 40,114,101, 97,100,116, 44, 32,110,105,108, 44, 32,
48, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,114,101, 97,100,121,116,
91,116,112, 93, 32,116,104,101,110, 32, 99,111,100,101, 32, 61, 32,115,101,108,
102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40,
34, 50, 46, 46, 34, 41, 41, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,
114,101,116,117,114,110, 32,115,116,101,112, 40,115,114, 99, 44, 32,115,110,107,
41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,
115,105,110,107, 32, 61, 32,115,111, 99,107,101,116, 46,115,105,110,107, 40, 34,
99,108,111,115,101, 45,119,104,101,110, 45,100,111,110,101, 34, 44, 32,115,101,
108,102, 46,100, 97,116, 97, 41, 10, 32, 32, 32, 32, 45, 45, 32,116,114, 97,110,
115,102,101,114, 32, 97,108,108, 32,100, 97,116, 97, 32, 97,110,100, 32, 99,104,
101, 99,107, 32,101,114,114,111,114, 10, 32, 32, 32, 32,115,101,108,102, 46,116,
114,121, 40,108,116,110, 49, 50, 46,112,117,109,112, 46, 97,108,108, 40,115,101,
110,100,116, 46,115,111,117,114, 99,101, 44, 32,115,105,110,107, 44, 32, 99,104,
101, 99,107,115,116,101,112, 41, 41, 10, 32, 32, 32, 32,105,102, 32,115,116,114,
105,110,103, 46,102,105,110,100, 40, 99,111,100,101, 44, 32, 34, 49, 46, 46, 34,
41, 32,116,104,101,110, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102,
46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 32,101,110,
100, 10, 32, 32, 32, 32, 45, 45, 32,100,111,110,101, 32,119,105,116,104, 32,100,
97,116, 97, 32, 99,111,110,110,101, 99,116,105,111,110, 10, 32, 32, 32, 32,115,
101,108,102, 46,100, 97,116, 97, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32,
32, 45, 45, 32,102,105,110,100, 32,111,117,116, 32,104,111,119, 32,109, 97,110,
121, 32, 98,121,116,101,115, 32,119,101,114,101, 32,115,101,110,116, 10, 32, 32,
32, 32,108,111, 99, 97,108, 32,115,101,110,116, 32, 61, 32,115,111, 99,107,101,
116, 46,115,107,105,112, 40, 49, 44, 32,115,101,108,102, 46,100, 97,116, 97, 58,
103,101,116,115,116, 97,116,115, 40, 41, 41, 10, 32, 32, 32, 32,115,101,108,102,
46,100, 97,116, 97, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32,115,101,110,116, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,
110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,114,101, 99,101,
105,118,101, 40,114,101, 99,118,116, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,
116,114,121, 40,115,101,108,102, 46,112, 97,115,118,116, 32,111,114, 32,115,101,
108,102, 46,115,101,114,118,101,114, 44, 32, 34,110,101,101,100, 32,112,111,114,
116, 32,111,114, 32,112, 97,115,118, 32,102,105,114,115,116, 34, 41, 10, 32, 32,
32, 32,105,102, 32,115,101,108,102, 46,112, 97,115,118,116, 32,116,104,101,110,
32,115,101,108,102, 58,112, 97,115,118, 99,111,110,110,101, 99,116, 40, 41, 32,
101,110,100, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 97,114,103,117,109,101,
110,116, 32, 61, 32,114,101, 99,118,116, 46, 97,114,103,117,109,101,110,116, 32,
111,114, 10, 32, 32, 32, 32, 32, 32, 32, 32,117,114,108, 46,117,110,101,115, 99,
97,112,101, 40,115,116,114,105,110,103, 46,103,115,117, 98, 40,114,101, 99,118,
116, 46,112, 97,116,104, 32,111,114, 32, 34, 34, 44, 32, 34, 94, 91, 47, 92, 92,
93, 34, 44, 32, 34, 34, 41, 41, 10, 32, 32, 32, 32,105,102, 32, 97,114,103,117,
109,101,110,116, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 32, 97,114,103,117,
109,101,110,116, 32, 61, 32,110,105,108, 32,101,110,100, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32, 99,111,109,109, 97,110,100, 32, 61, 32,114,101, 99,118,116,
46, 99,111,109,109, 97,110,100, 32,111,114, 32, 34,114,101,116,114, 34, 10, 32,
32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58,
99,111,109,109, 97,110,100, 40, 99,111,109,109, 97,110,100, 44, 32, 97,114,103,
117,109,101,110,116, 41, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,111,
100,101, 44,114,101,112,108,121, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,
115,101,108,102, 46,116,112, 58, 99,104,101, 99,107,123, 34, 49, 46, 46, 34, 44,
32, 34, 50, 46, 46, 34,125, 41, 10, 32, 32, 32, 32,105,102, 32,115,116,114,105,
110,103, 46,102,105,110,100, 40, 99,111,100,101, 44, 32, 34, 49, 46, 46, 34, 41,
32,116,104,101,110, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,
116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 32,101,110,100,
32, 34, 50, 46, 46, 34,125, 41, 10, 32, 32, 32, 32,105,102, 32, 40, 99,111,100,
101, 32, 62, 61, 32, 50, 48, 48, 41, 32, 97,110,100, 32, 40, 99,111,100,101, 32,
60, 61, 32, 50, 57, 57, 41, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
32,114,101, 99,118,116, 46,115,105,110,107, 40,114,101,112,108,121, 41, 10, 32,
32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10, 32, 32, 32, 32,
101,110,100, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,115,101,108,102, 46,
112, 97,115,118,116, 32,116,104,101,110, 32,115,101,108,102, 58,112,111,114,116,
99,111,110,110,101, 99,116, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,115,111,117,114, 99,101, 32, 61, 32,115,111, 99,107,101,116, 46,
115,111,117,114, 99,101, 40, 34,117,110,116,105,108, 45, 99,108,111,115,101,100,
34, 44, 32,115,101,108,102, 46,100, 97,116, 97, 41, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,115,116,101,112, 32, 61, 32,114,101, 99,118,116, 46,115,116,101,
112, 32,111,114, 32,108,116,110, 49, 50, 46,112,117,109,112, 46,115,116,101,112,
10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,108,116,110, 49, 50, 46,
112,117,109,112, 46, 97,108,108, 40,115,111,117,114, 99,101, 44, 32,114,101, 99,
118,116, 46,115,105,110,107, 44, 32,115,116,101,112, 41, 41, 10, 32, 32, 32, 32,
105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40, 99,111,100,101, 44,
32, 34, 49, 46, 46, 34, 41, 32,116,104,101,110, 32,115,101,108,102, 46,116,114,
121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46,
34, 41, 41, 32,101,110,100, 10, 32, 32, 32, 32,115,101,108,102, 46,100, 97,116,
97, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,100,
97,116, 97, 32, 61, 32,110,105,108, 10, 32, 32, 32, 32,114,101,116,117,114,110,
32, 49, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116,
97,116, 46, 95, 95,105,110,100,101,120, 58, 99,119,100, 40,100,105,114, 41, 10,
32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112,
58, 99,111,109,109, 97,110,100, 40, 34, 99,119,100, 34, 44, 32,100,105,114, 41,
41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,
116,112, 58, 99,104,101, 99,107, 40, 50, 53, 48, 41, 41, 10, 32, 32, 32, 32,114,
101,116,117,114,110, 32, 49, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,
110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,116,121,112,101,
40,116,121,112,101, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,
115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34,116,121,112,
101, 34, 44, 32,116,121,112,101, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,
116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 50, 48,
48, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10,101,110,100,
10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,
110,100,101,120, 58,103,114,101,101,116, 40, 41, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32, 99,111,100,101, 32, 61, 32,115,101,108,102, 46,116,114,121, 40,115,
101,108,102, 46,116,112, 58, 99,104,101, 99,107,123, 34, 49, 46, 46, 34, 44, 32,
34, 50, 46, 46, 34,125, 41, 10, 32, 32, 32, 32,105,102, 32,115,116,114,105,110,
103, 46,102,105,110,100, 40, 99,111,100,101, 44, 32, 34, 49, 46, 46, 34, 41, 32,
116,104,101,110, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,
112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 32,101,110,100, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10,101,110,100, 10, 10,102,117,
110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120,
58,113,117,105,116, 40, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121,
40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34,113,117,
105,116, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,
101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10,101,110,100, 10, 10,102,
117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,
120, 58,113,117,105,116, 40, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,
121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34,113,
117,105,116, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,
115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41,
41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10,101,110,100, 10, 10,
102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,
101,120, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,105,102, 32,115,101,
108,102, 46,100, 97,116, 97, 32,116,104,101,110, 32,115,101,108,102, 46,100, 97,
116, 97, 58, 99,108,111,115,101, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,105,
102, 32,115,101,108,102, 46,115,101,114,118,101,114, 32,116,104,101,110, 32,115,
101,108,102, 46,115,101,114,118,101,114, 58, 99,108,111,115,101, 40, 41, 32,101,
110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,116,
112, 58, 99,108,111,115,101, 40, 41, 10,101,110,100, 10, 10, 45, 45, 45, 45, 45,
120, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,105,102, 32,115,101,108,
102, 46,100, 97,116, 97, 32,116,104,101,110, 32,115,101,108,102, 46,100, 97,116,
97, 58, 99,108,111,115,101, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,105,102,
32,115,101,108,102, 46,115,101,114,118,101,114, 32,116,104,101,110, 32,115,101,
108,102, 46,115,101,114,118,101,114, 58, 99,108,111,115,101, 40, 41, 32,101,110,
100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,116,112,
58, 99,108,111,115,101, 40, 41, 10,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 72,105,103,104,
32,108,101,118,101,108, 32, 70, 84, 80, 32, 65, 80, 73, 10, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 72,105,103,104, 32,
108,101,118,101,108, 32, 70, 84, 80, 32, 65, 80, 73, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32,102,
117,110, 99,116,105,111,110, 32,111,118,101,114,114,105,100,101, 40,116, 41, 10,
32, 32, 32, 32,105,102, 32,116, 46,117,114,108, 32,116,104,101,110, 10, 32, 32,
32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,117, 32, 61, 32,117,114,108, 46,
112, 97,114,115,101, 40,116, 46,117,114,108, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32,102,111,114, 32,105, 44,118, 32,105,110, 32, 98, 97,115,101, 46,112, 97,105,
114,115, 40,116, 41, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32,117, 91,105, 93, 32, 61, 32,118, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,
100, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,117, 10, 32,
32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,116, 32,101,110,100,
10,101,110,100, 10, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110,
32,116,112,117,116, 40,112,117,116,116, 41, 10, 32, 32, 32, 32,112,117,116,116,
32, 61, 32,111,118,101,114,114,105,100,101, 40,112,117,116,116, 41, 10, 32, 32,
32, 32,115,111, 99,107,101,116, 46,116,114,121, 40,112,117,116,116, 46,104,111,
115,116, 44, 32, 34,109,105,115,115,105,110,103, 32,104,111,115,116,110, 97,109,
101, 34, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 32, 61, 32,111,112,
101,110, 40,112,117,116,116, 46,104,111,115,116, 44, 32,112,117,116,116, 46,112,
111,114,116, 44, 32,112,117,116,116, 46, 99,114,101, 97,116,101, 41, 10, 32, 32,
32, 32,102, 58,103,114,101,101,116, 40, 41, 10, 32, 32, 32, 32,102, 58,108,111,
103,105,110, 40,112,117,116,116, 46,117,115,101,114, 44, 32,112,117,116,116, 46,
112, 97,115,115,119,111,114,100, 41, 10, 32, 32, 32, 32,105,102, 32,112,117,116,
116, 46,116,121,112,101, 32,116,104,101,110, 32,102, 58,116,121,112,101, 40,112,
117,116,116, 46,116,121,112,101, 41, 32,101,110,100, 10, 32, 32, 32, 32,102, 58,
112, 97,115,118, 40, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,101,110,
116, 32, 61, 32,102, 58,115,101,110,100, 40,112,117,116,116, 41, 10, 32, 32, 32,
32,102, 58,113,117,105,116, 40, 41, 10, 32, 32, 32, 32,102, 58, 99,108,111,115,
101, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,110,116, 10,
101,110,100, 10, 10,108,111, 99, 97,108, 32,100,101,102, 97,117,108,116, 32, 61,
32,123, 10, 9,112, 97,116,104, 32, 61, 32, 34, 47, 34, 44, 10, 9,115, 99,104,
101,109,101, 32, 61, 32, 34,102,116,112, 34, 10,125, 10, 10,108,111, 99, 97,108,
32,102,117,110, 99,116,105,111,110, 32,112, 97,114,115,101, 40,117, 41, 10, 32,
32, 32, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,115,111, 99,107,101,116, 46,
116,114,121, 40,117,114,108, 46,112, 97,114,115,101, 40,117, 44, 32,100,101,102,
97,117,108,116, 41, 41, 10, 32, 32, 32, 32,115,111, 99,107,101,116, 46,116,114,
121, 40,116, 46,115, 99,104,101,109,101, 32, 61, 61, 32, 34,102,116,112, 34, 44,
32, 34,119,114,111,110,103, 32,115, 99,104,101,109,101, 32, 39, 34, 32, 46, 46,
32,116, 46,115, 99,104,101,109,101, 32, 46, 46, 32, 34, 39, 34, 41, 10, 32, 32,
32, 32,115,111, 99,107,101,116, 46,116,114,121, 40,116, 46,104,111,115,116, 44,
32, 34,109,105,115,115,105,110,103, 32,104,111,115,116,110, 97,109,101, 34, 41,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32,112, 97,116, 32, 61, 32, 34, 94,116,
121,112,101, 61, 40, 46, 41, 36, 34, 10, 32, 32, 32, 32,105,102, 32,116, 46,112,
97,114, 97,109,115, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,116,
46,116,121,112,101, 32, 61, 32,115,111, 99,107,101,116, 46,115,107,105,112, 40,
50, 44, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,116, 46,112, 97,114,
97,109,115, 44, 32,112, 97,116, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,
111, 99,107,101,116, 46,116,114,121, 40,116, 46,116,121,112,101, 32, 61, 61, 32,
34, 97, 34, 32,111,114, 32,116, 46,116,121,112,101, 32, 61, 61, 32, 34,105, 34,
44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 34,105,110,118, 97,108,
105,100, 32,116,121,112,101, 32, 39, 34, 32, 46, 46, 32,116, 46,116,121,112,101,
32, 46, 46, 32, 34, 39, 34, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32,
32,114,101,116,117,114,110, 32,116, 10,101,110,100, 10, 10,108,111, 99, 97,108,
32,102,117,110, 99,116,105,111,110, 32,115,112,117,116, 40,117, 44, 32, 98,111,
100,121, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,112,117,116,116, 32, 61,
32,112, 97,114,115,101, 40,117, 41, 10, 32, 32, 32, 32,112,117,116,116, 46,115,
111,117,114, 99,101, 32, 61, 32,108,116,110, 49, 50, 46,115,111,117,114, 99,101,
46,115,116,114,105,110,103, 40, 98,111,100,121, 41, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32,116,112,117,116, 40,112,117,116,116, 41, 10,101,110,100, 10,
10,112,117,116, 32, 61, 32,115,111, 99,107,101,116, 46,112,114,111,116,101, 99,
116, 40,102,117,110, 99,116,105,111,110, 40,112,117,116,116, 44, 32, 98,111,100,
121, 41, 10, 32, 32, 32, 32,105,102, 32, 98, 97,115,101, 46,116,121,112,101, 40,
112,117,116,116, 41, 32, 61, 61, 32, 34,115,116,114,105,110,103, 34, 32,116,104,
101,110, 32,114,101,116,117,114,110, 32,115,112,117,116, 40,112,117,116,116, 44,
32, 98,111,100,121, 41, 10, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,
114,110, 32,116,112,117,116, 40,112,117,116,116, 41, 32,101,110,100, 10,101,110,
100, 41, 10, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,116,
103,101,116, 40,103,101,116,116, 41, 10, 32, 32, 32, 32,103,101,116,116, 32, 61,
32,111,118,101,114,114,105,100,101, 40,103,101,116,116, 41, 10, 32, 32, 32, 32,
115,111, 99,107,101,116, 46,116,114,121, 40,103,101,116,116, 46,104,111,115,116,
44, 32, 34,109,105,115,115,105,110,103, 32,104,111,115,116,110, 97,109,101, 34,
41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 32, 61, 32,111,112,101,110,
40,103,101,116,116, 46,104,111,115,116, 44, 32,103,101,116,116, 46,112,111,114,
116, 44, 32,103,101,116,116, 46, 99,114,101, 97,116,101, 41, 10, 32, 32, 32, 32,
102, 58,103,114,101,101,116, 40, 41, 10, 32, 32, 32, 32,102, 58,108,111,103,105,
110, 40,103,101,116,116, 46,117,115,101,114, 44, 32,103,101,116,116, 46,112, 97,
115,115,119,111,114,100, 41, 10, 32, 32, 32, 32,105,102, 32,103,101,116,116, 46,
116,121,112,101, 32,116,104,101,110, 32,102, 58,116,121,112,101, 40,103,101,116,
116, 46,116,121,112,101, 41, 32,101,110,100, 10, 32, 32, 32, 32,102, 58,112, 97,
115,118, 40, 41, 10, 32, 32, 32, 32,102, 58,114,101, 99,101,105,118,101, 40,103,
101,116,116, 41, 10, 32, 32, 32, 32,102, 58,113,117,105,116, 40, 41, 10, 32, 32,
32, 32,114,101,116,117,114,110, 32,102, 58, 99,108,111,115,101, 40, 41, 10,101,
110,100, 10, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,115,
103,101,116, 40,117, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,103,101,116,
116, 32, 61, 32,112, 97,114,115,101, 40,117, 41, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,116, 32, 61, 32,123,125, 10, 32, 32, 32, 32,103,101,116,116, 46,115,
105,110,107, 32, 61, 32,108,116,110, 49, 50, 46,115,105,110,107, 46,116, 97, 98,
108,101, 40,116, 41, 10, 32, 32, 32, 32,116,103,101,116, 40,103,101,116,116, 41,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32,116, 97, 98,108,101, 46, 99,111,
110, 99, 97,116, 40,116, 41, 10,101,110,100, 10, 10, 99,111,109,109, 97,110,100,
32, 61, 32,115,111, 99,107,101,116, 46,112,114,111,116,101, 99,116, 40,102,117,
110, 99,116,105,111,110, 40, 99,109,100,116, 41, 10, 32, 32, 32, 32, 99,109,100,
116, 32, 61, 32,111,118,101,114,114,105,100,101, 40, 99,109,100,116, 41, 10, 32,
32, 32, 32,115,111, 99,107,101,116, 46,116,114,121, 40, 99,109,100,116, 46,104,
111,115,116, 44, 32, 34,109,105,115,115,105,110,103, 32,104,111,115,116,110, 97,
109,101, 34, 41, 10, 32, 32, 32, 32,115,111, 99,107,101,116, 46,116,114,121, 40,
99,109,100,116, 46, 99,111,109,109, 97,110,100, 44, 32, 34,109,105,115,115,105,
110,103, 32, 99,111,109,109, 97,110,100, 34, 41, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,102, 32, 61, 32,111,112,101,110, 40, 99,109,100,116, 46,104,111,115,
116, 44, 32, 99,109,100,116, 46,112,111,114,116, 44, 32, 99,109,100,116, 46, 99,
114,101, 97,116,101, 41, 10, 32, 32, 32, 32,102, 58,103,114,101,101,116, 40, 41,
10, 32, 32, 32, 32,102, 58,108,111,103,105,110, 40, 99,109,100,116, 46,117,115,
101,114, 44, 32, 99,109,100,116, 46,112, 97,115,115,119,111,114,100, 41, 10, 32,
32, 32, 32,102, 46,116,114,121, 40,102, 46,116,112, 58, 99,111,109,109, 97,110,
100, 40, 99,109,100,116, 46, 99,111,109,109, 97,110,100, 44, 32, 99,109,100,116,
46, 97,114,103,117,109,101,110,116, 41, 41, 10, 32, 32, 32, 32,105,102, 32, 99,
109,100,116, 46, 99,104,101, 99,107, 32,116,104,101,110, 32,102, 46,116,114,121,
40,102, 46,116,112, 58, 99,104,101, 99,107, 40, 99,109,100,116, 46, 99,104,101,
99,107, 41, 41, 32,101,110,100, 10, 32, 32, 32, 32,102, 58,113,117,105,116, 40,
41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102, 58, 99,108,111,115,101,
40, 41, 10,101,110,100, 41, 10, 10,103,101,116, 32, 61, 32,115,111, 99,107,101,
116, 46,112,114,111,116,101, 99,116, 40,102,117,110, 99,116,105,111,110, 40,103,
101,116,116, 41, 10, 32, 32, 32, 32,105,102, 32, 98, 97,115,101, 46,116,121,112,
101, 40,103,101,116,116, 41, 32, 61, 61, 32, 34,115,116,114,105,110,103, 34, 32,
116,104,101,110, 32,114,101,116,117,114,110, 32,115,103,101,116, 40,103,101,116,
116, 41, 10, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,116,
103,101,116, 40,103,101,116,116, 41, 32,101,110,100, 10,101,110,100, 41, 10, 10,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32,102,117,
110, 99,116,105,111,110, 32,111,118,101,114,114,105,100,101, 40,116, 41, 10, 32,
32, 32, 32,105,102, 32,116, 46,117,114,108, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32,108,111, 99, 97,108, 32,117, 32, 61, 32,117,114,108, 46,112,
97,114,115,101, 40,116, 46,117,114,108, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
102,111,114, 32,105, 44,118, 32,105,110, 32, 98, 97,115,101, 46,112, 97,105,114,
115, 40,116, 41, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
117, 91,105, 93, 32, 61, 32,118, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100,
10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,117, 10, 32, 32,
32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,116, 32,101,110,100, 10,
101,110,100, 10, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,
116,112,117,116, 40,112,117,116,116, 41, 10, 32, 32, 32, 32,112,117,116,116, 32,
61, 32,111,118,101,114,114,105,100,101, 40,112,117,116,116, 41, 10, 32, 32, 32,
32,115,111, 99,107,101,116, 46,116,114,121, 40,112,117,116,116, 46,104,111,115,
116, 44, 32, 34,109,105,115,115,105,110,103, 32,104,111,115,116,110, 97,109,101,
34, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 32, 61, 32, 95, 77, 46,
111,112,101,110, 40,112,117,116,116, 46,104,111,115,116, 44, 32,112,117,116,116,
46,112,111,114,116, 44, 32,112,117,116,116, 46, 99,114,101, 97,116,101, 41, 10,
32, 32, 32, 32,102, 58,103,114,101,101,116, 40, 41, 10, 32, 32, 32, 32,102, 58,
108,111,103,105,110, 40,112,117,116,116, 46,117,115,101,114, 44, 32,112,117,116,
116, 46,112, 97,115,115,119,111,114,100, 41, 10, 32, 32, 32, 32,105,102, 32,112,
117,116,116, 46,116,121,112,101, 32,116,104,101,110, 32,102, 58,116,121,112,101,
40,112,117,116,116, 46,116,121,112,101, 41, 32,101,110,100, 10, 32, 32, 32, 32,
102, 58,101,112,115,118, 40, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,
101,110,116, 32, 61, 32,102, 58,115,101,110,100, 40,112,117,116,116, 41, 10, 32,
32, 32, 32,102, 58,113,117,105,116, 40, 41, 10, 32, 32, 32, 32,102, 58, 99,108,
111,115,101, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,110,
116, 10,101,110,100, 10, 10,108,111, 99, 97,108, 32,100,101,102, 97,117,108,116,
32, 61, 32,123, 10, 32, 32, 32, 32,112, 97,116,104, 32, 61, 32, 34, 47, 34, 44,
10, 32, 32, 32, 32,115, 99,104,101,109,101, 32, 61, 32, 34,102,116,112, 34, 10,
125, 10, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,103,101,
110,101,114,105, 99,102,111,114,109, 40,117, 41, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,116, 32, 61, 32,115,111, 99,107,101,116, 46,116,114,121, 40,117,114,
108, 46,112, 97,114,115,101, 40,117, 44, 32,100,101,102, 97,117,108,116, 41, 41,
10, 32, 32, 32, 32,115,111, 99,107,101,116, 46,116,114,121, 40,116, 46,115, 99,
104,101,109,101, 32, 61, 61, 32, 34,102,116,112, 34, 44, 32, 34,119,114,111,110,
103, 32,115, 99,104,101,109,101, 32, 39, 34, 32, 46, 46, 32,116, 46,115, 99,104,
101,109,101, 32, 46, 46, 32, 34, 39, 34, 41, 10, 32, 32, 32, 32,115,111, 99,107,
101,116, 46,116,114,121, 40,116, 46,104,111,115,116, 44, 32, 34,109,105,115,115,
105,110,103, 32,104,111,115,116,110, 97,109,101, 34, 41, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32,112, 97,116, 32, 61, 32, 34, 94,116,121,112,101, 61, 40, 46,
41, 36, 34, 10, 32, 32, 32, 32,105,102, 32,116, 46,112, 97,114, 97,109,115, 32,
116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,116, 46,116,121,112,101, 32,
61, 32,115,111, 99,107,101,116, 46,115,107,105,112, 40, 50, 44, 32,115,116,114,
105,110,103, 46,102,105,110,100, 40,116, 46,112, 97,114, 97,109,115, 44, 32,112,
97,116, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,111, 99,107,101,116, 46,
116,114,121, 40,116, 46,116,121,112,101, 32, 61, 61, 32, 34, 97, 34, 32,111,114,
32,116, 46,116,121,112,101, 32, 61, 61, 32, 34,105, 34, 44, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 34,105,110,118, 97,108,105,100, 32,116,121,112,
101, 32, 39, 34, 32, 46, 46, 32,116, 46,116,121,112,101, 32, 46, 46, 32, 34, 39,
34, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,114,101,116,117,114,
110, 32,116, 10,101,110,100, 10, 10, 95, 77, 46,103,101,110,101,114,105, 99,102,
111,114,109, 32, 61, 32,103,101,110,101,114,105, 99,102,111,114,109, 10, 10,108,
111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,115,112,117,116, 40,117,
44, 32, 98,111,100,121, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,112,117,
116,116, 32, 61, 32,103,101,110,101,114,105, 99,102,111,114,109, 40,117, 41, 10,
32, 32, 32, 32,112,117,116,116, 46,115,111,117,114, 99,101, 32, 61, 32,108,116,
110, 49, 50, 46,115,111,117,114, 99,101, 46,115,116,114,105,110,103, 40, 98,111,
100,121, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,116,112,117,116, 40,
112,117,116,116, 41, 10,101,110,100, 10, 10, 95, 77, 46,112,117,116, 32, 61, 32,
115,111, 99,107,101,116, 46,112,114,111,116,101, 99,116, 40,102,117,110, 99,116,
105,111,110, 40,112,117,116,116, 44, 32, 98,111,100,121, 41, 10, 32, 32, 32, 32,
105,102, 32, 98, 97,115,101, 46,116,121,112,101, 40,112,117,116,116, 41, 32, 61,
61, 32, 34,115,116,114,105,110,103, 34, 32,116,104,101,110, 32,114,101,116,117,
114,110, 32,115,112,117,116, 40,112,117,116,116, 44, 32, 98,111,100,121, 41, 10,
32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,116,112,117,116,
40,112,117,116,116, 41, 32,101,110,100, 10,101,110,100, 41, 10, 10,108,111, 99,
97,108, 32,102,117,110, 99,116,105,111,110, 32,116,103,101,116, 40,103,101,116,
116, 41, 10, 32, 32, 32, 32,103,101,116,116, 32, 61, 32,111,118,101,114,114,105,
100,101, 40,103,101,116,116, 41, 10, 32, 32, 32, 32,115,111, 99,107,101,116, 46,
116,114,121, 40,103,101,116,116, 46,104,111,115,116, 44, 32, 34,109,105,115,115,
105,110,103, 32,104,111,115,116,110, 97,109,101, 34, 41, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32,102, 32, 61, 32, 95, 77, 46,111,112,101,110, 40,103,101,116,
116, 46,104,111,115,116, 44, 32,103,101,116,116, 46,112,111,114,116, 44, 32,103,
101,116,116, 46, 99,114,101, 97,116,101, 41, 10, 32, 32, 32, 32,102, 58,103,114,
101,101,116, 40, 41, 10, 32, 32, 32, 32,102, 58,108,111,103,105,110, 40,103,101,
116,116, 46,117,115,101,114, 44, 32,103,101,116,116, 46,112, 97,115,115,119,111,
114,100, 41, 10, 32, 32, 32, 32,105,102, 32,103,101,116,116, 46,116,121,112,101,
32,116,104,101,110, 32,102, 58,116,121,112,101, 40,103,101,116,116, 46,116,121,
112,101, 41, 32,101,110,100, 10, 32, 32, 32, 32,102, 58,101,112,115,118, 40, 41,
10, 32, 32, 32, 32,102, 58,114,101, 99,101,105,118,101, 40,103,101,116,116, 41,
10, 32, 32, 32, 32,102, 58,113,117,105,116, 40, 41, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32,102, 58, 99,108,111,115,101, 40, 41, 10,101,110,100, 10, 10,
108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,115,103,101,116, 40,
117, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,103,101,116,116, 32, 61, 32,
103,101,110,101,114,105, 99,102,111,114,109, 40,117, 41, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32,116, 32, 61, 32,123,125, 10, 32, 32, 32, 32,103,101,116,116,
46,115,105,110,107, 32, 61, 32,108,116,110, 49, 50, 46,115,105,110,107, 46,116,
97, 98,108,101, 40,116, 41, 10, 32, 32, 32, 32,116,103,101,116, 40,103,101,116,
116, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,116, 97, 98,108,101, 46,
99,111,110, 99, 97,116, 40,116, 41, 10,101,110,100, 10, 10, 95, 77, 46, 99,111,
109,109, 97,110,100, 32, 61, 32,115,111, 99,107,101,116, 46,112,114,111,116,101,
99,116, 40,102,117,110, 99,116,105,111,110, 40, 99,109,100,116, 41, 10, 32, 32,
32, 32, 99,109,100,116, 32, 61, 32,111,118,101,114,114,105,100,101, 40, 99,109,
100,116, 41, 10, 32, 32, 32, 32,115,111, 99,107,101,116, 46,116,114,121, 40, 99,
109,100,116, 46,104,111,115,116, 44, 32, 34,109,105,115,115,105,110,103, 32,104,
111,115,116,110, 97,109,101, 34, 41, 10, 32, 32, 32, 32,115,111, 99,107,101,116,
46,116,114,121, 40, 99,109,100,116, 46, 99,111,109,109, 97,110,100, 44, 32, 34,
109,105,115,115,105,110,103, 32, 99,111,109,109, 97,110,100, 34, 41, 10, 32, 32,
32, 32,108,111, 99, 97,108, 32,102, 32, 61, 32, 95, 77, 46,111,112,101,110, 40,
99,109,100,116, 46,104,111,115,116, 44, 32, 99,109,100,116, 46,112,111,114,116,
44, 32, 99,109,100,116, 46, 99,114,101, 97,116,101, 41, 10, 32, 32, 32, 32,102,
58,103,114,101,101,116, 40, 41, 10, 32, 32, 32, 32,102, 58,108,111,103,105,110,
40, 99,109,100,116, 46,117,115,101,114, 44, 32, 99,109,100,116, 46,112, 97,115,
115,119,111,114,100, 41, 10, 32, 32, 32, 32,105,102, 32,116,121,112,101, 40, 99,
109,100,116, 46, 99,111,109,109, 97,110,100, 41, 32, 61, 61, 32, 34,116, 97, 98,
108,101, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99,
97,108, 32, 97,114,103,117,109,101,110,116, 32, 61, 32, 99,109,100,116, 46, 97,
114,103,117,109,101,110,116, 32,111,114, 32,123,125, 10, 32, 32, 32, 32, 32, 32,
32, 32,108,111, 99, 97,108, 32, 99,104,101, 99,107, 32, 61, 32, 99,109,100,116,
46, 99,104,101, 99,107, 32,111,114, 32,123,125, 10, 32, 32, 32, 32, 32, 32, 32,
32,102,111,114, 32,105, 44, 99,109,100, 32,105,110, 32,105,112, 97,105,114,115,
40, 99,109,100,116, 46, 99,111,109,109, 97,110,100, 41, 32,100,111, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,102, 46,116,114,121, 40,102, 46,116,112,
58, 99,111,109,109, 97,110,100, 40, 99,109,100, 44, 32, 97,114,103,117,109,101,
110,116, 91,105, 93, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
105,102, 32, 99,104,101, 99,107, 91,105, 93, 32,116,104,101,110, 32,102, 46,116,
114,121, 40,102, 46,116,112, 58, 99,104,101, 99,107, 40, 99,104,101, 99,107, 91,
105, 93, 41, 41, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100,
10, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,102, 46,
116,114,121, 40,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 99,109,100,
116, 46, 99,111,109,109, 97,110,100, 44, 32, 99,109,100,116, 46, 97,114,103,117,
109,101,110,116, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,109,
100,116, 46, 99,104,101, 99,107, 32,116,104,101,110, 32,102, 46,116,114,121, 40,
102, 46,116,112, 58, 99,104,101, 99,107, 40, 99,109,100,116, 46, 99,104,101, 99,
107, 41, 41, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
102, 58,113,117,105,116, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
102, 58, 99,108,111,115,101, 40, 41, 10,101,110,100, 41, 10, 10, 95, 77, 46,103,
101,116, 32, 61, 32,115,111, 99,107,101,116, 46,112,114,111,116,101, 99,116, 40,
102,117,110, 99,116,105,111,110, 40,103,101,116,116, 41, 10, 32, 32, 32, 32,105,
102, 32, 98, 97,115,101, 46,116,121,112,101, 40,103,101,116,116, 41, 32, 61, 61,
32, 34,115,116,114,105,110,103, 34, 32,116,104,101,110, 32,114,101,116,117,114,
110, 32,115,103,101,116, 40,103,101,116,116, 41, 10, 32, 32, 32, 32,101,108,115,
101, 32,114,101,116,117,114,110, 32,116,103,101,116, 40,103,101,116,116, 41, 32,
101,110,100, 10,101,110,100, 41, 10, 10,114,101,116,117,114,110, 32, 95, 77, 10,
};
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"ftp.lua")==0) lua_call(L, 0, 0);
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"ftp.lua")==0) lua_call(L, 0, LUA_MULTRET);
}
@@ -0,0 +1,104 @@
-----------------------------------------------------------------------------
-- Canonic header field capitalization
-- LuaSocket toolkit.
-- Author: Diego Nehab
-----------------------------------------------------------------------------
local socket = require("socket")
socket.headers = {}
local _M = socket.headers
_M.canonic = {
["accept"] = "Accept",
["accept-charset"] = "Accept-Charset",
["accept-encoding"] = "Accept-Encoding",
["accept-language"] = "Accept-Language",
["accept-ranges"] = "Accept-Ranges",
["action"] = "Action",
["alternate-recipient"] = "Alternate-Recipient",
["age"] = "Age",
["allow"] = "Allow",
["arrival-date"] = "Arrival-Date",
["authorization"] = "Authorization",
["bcc"] = "Bcc",
["cache-control"] = "Cache-Control",
["cc"] = "Cc",
["comments"] = "Comments",
["connection"] = "Connection",
["content-description"] = "Content-Description",
["content-disposition"] = "Content-Disposition",
["content-encoding"] = "Content-Encoding",
["content-id"] = "Content-ID",
["content-language"] = "Content-Language",
["content-length"] = "Content-Length",
["content-location"] = "Content-Location",
["content-md5"] = "Content-MD5",
["content-range"] = "Content-Range",
["content-transfer-encoding"] = "Content-Transfer-Encoding",
["content-type"] = "Content-Type",
["cookie"] = "Cookie",
["date"] = "Date",
["diagnostic-code"] = "Diagnostic-Code",
["dsn-gateway"] = "DSN-Gateway",
["etag"] = "ETag",
["expect"] = "Expect",
["expires"] = "Expires",
["final-log-id"] = "Final-Log-ID",
["final-recipient"] = "Final-Recipient",
["from"] = "From",
["host"] = "Host",
["if-match"] = "If-Match",
["if-modified-since"] = "If-Modified-Since",
["if-none-match"] = "If-None-Match",
["if-range"] = "If-Range",
["if-unmodified-since"] = "If-Unmodified-Since",
["in-reply-to"] = "In-Reply-To",
["keywords"] = "Keywords",
["last-attempt-date"] = "Last-Attempt-Date",
["last-modified"] = "Last-Modified",
["location"] = "Location",
["max-forwards"] = "Max-Forwards",
["message-id"] = "Message-ID",
["mime-version"] = "MIME-Version",
["original-envelope-id"] = "Original-Envelope-ID",
["original-recipient"] = "Original-Recipient",
["pragma"] = "Pragma",
["proxy-authenticate"] = "Proxy-Authenticate",
["proxy-authorization"] = "Proxy-Authorization",
["range"] = "Range",
["received"] = "Received",
["received-from-mta"] = "Received-From-MTA",
["references"] = "References",
["referer"] = "Referer",
["remote-mta"] = "Remote-MTA",
["reply-to"] = "Reply-To",
["reporting-mta"] = "Reporting-MTA",
["resent-bcc"] = "Resent-Bcc",
["resent-cc"] = "Resent-Cc",
["resent-date"] = "Resent-Date",
["resent-from"] = "Resent-From",
["resent-message-id"] = "Resent-Message-ID",
["resent-reply-to"] = "Resent-Reply-To",
["resent-sender"] = "Resent-Sender",
["resent-to"] = "Resent-To",
["retry-after"] = "Retry-After",
["return-path"] = "Return-Path",
["sender"] = "Sender",
["server"] = "Server",
["smtp-remote-recipient"] = "SMTP-Remote-Recipient",
["status"] = "Status",
["subject"] = "Subject",
["te"] = "TE",
["to"] = "To",
["trailer"] = "Trailer",
["transfer-encoding"] = "Transfer-Encoding",
["upgrade"] = "Upgrade",
["user-agent"] = "User-Agent",
["vary"] = "Vary",
["via"] = "Via",
["warning"] = "Warning",
["will-retry-until"] = "Will-Retry-Until",
["www-authenticate"] = "WWW-Authenticate",
["x-mailer"] = "X-Mailer",
}
return _M
@@ -0,0 +1,196 @@
/* code automatically generated by bin2c -- DO NOT EDIT */
{
/* #include'ing this file in a C program is equivalent to calling
if (luaL_loadfile(L,"headers.lua")==0) lua_call(L, 0, LUA_MULTRET);
*/
/* headers.lua */
static const unsigned char B1[]={
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45,
32, 67, 97,110,111,110,105, 99, 32,104,101, 97,100,101,114, 32,102,105,101,108,
100, 32, 99, 97,112,105,116, 97,108,105,122, 97,116,105,111,110, 10, 45, 45, 32,
76,117, 97, 83,111, 99,107,101,116, 32,116,111,111,108,107,105,116, 46, 10, 45,
45, 32, 65,117,116,104,111,114, 58, 32, 68,105,101,103,111, 32, 78,101,104, 97,
98, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
108,111, 99, 97,108, 32,115,111, 99,107,101,116, 32, 61, 32,114,101,113,117,105,
114,101, 40, 34,115,111, 99,107,101,116, 34, 41, 10,115,111, 99,107,101,116, 46,
104,101, 97,100,101,114,115, 32, 61, 32,123,125, 10,108,111, 99, 97,108, 32, 95,
77, 32, 61, 32,115,111, 99,107,101,116, 46,104,101, 97,100,101,114,115, 10, 10,
95, 77, 46, 99, 97,110,111,110,105, 99, 32, 61, 32,123, 10, 32, 32, 32, 32, 91,
34, 97, 99, 99,101,112,116, 34, 93, 32, 61, 32, 34, 65, 99, 99,101,112,116, 34,
44, 10, 32, 32, 32, 32, 91, 34, 97, 99, 99,101,112,116, 45, 99,104, 97,114,115,
101,116, 34, 93, 32, 61, 32, 34, 65, 99, 99,101,112,116, 45, 67,104, 97,114,115,
101,116, 34, 44, 10, 32, 32, 32, 32, 91, 34, 97, 99, 99,101,112,116, 45,101,110,
99,111,100,105,110,103, 34, 93, 32, 61, 32, 34, 65, 99, 99,101,112,116, 45, 69,
110, 99,111,100,105,110,103, 34, 44, 10, 32, 32, 32, 32, 91, 34, 97, 99, 99,101,
112,116, 45,108, 97,110,103,117, 97,103,101, 34, 93, 32, 61, 32, 34, 65, 99, 99,
101,112,116, 45, 76, 97,110,103,117, 97,103,101, 34, 44, 10, 32, 32, 32, 32, 91,
34, 97, 99, 99,101,112,116, 45,114, 97,110,103,101,115, 34, 93, 32, 61, 32, 34,
65, 99, 99,101,112,116, 45, 82, 97,110,103,101,115, 34, 44, 10, 32, 32, 32, 32,
91, 34, 97, 99,116,105,111,110, 34, 93, 32, 61, 32, 34, 65, 99,116,105,111,110,
34, 44, 10, 32, 32, 32, 32, 91, 34, 97,108,116,101,114,110, 97,116,101, 45,114,
101, 99,105,112,105,101,110,116, 34, 93, 32, 61, 32, 34, 65,108,116,101,114,110,
97,116,101, 45, 82,101, 99,105,112,105,101,110,116, 34, 44, 10, 32, 32, 32, 32,
91, 34, 97,103,101, 34, 93, 32, 61, 32, 34, 65,103,101, 34, 44, 10, 32, 32, 32,
32, 91, 34, 97,108,108,111,119, 34, 93, 32, 61, 32, 34, 65,108,108,111,119, 34,
44, 10, 32, 32, 32, 32, 91, 34, 97,114,114,105,118, 97,108, 45,100, 97,116,101,
34, 93, 32, 61, 32, 34, 65,114,114,105,118, 97,108, 45, 68, 97,116,101, 34, 44,
10, 32, 32, 32, 32, 91, 34, 97,117,116,104,111,114,105,122, 97,116,105,111,110,
34, 93, 32, 61, 32, 34, 65,117,116,104,111,114,105,122, 97,116,105,111,110, 34,
44, 10, 32, 32, 32, 32, 91, 34, 98, 99, 99, 34, 93, 32, 61, 32, 34, 66, 99, 99,
34, 44, 10, 32, 32, 32, 32, 91, 34, 99, 97, 99,104,101, 45, 99,111,110,116,114,
111,108, 34, 93, 32, 61, 32, 34, 67, 97, 99,104,101, 45, 67,111,110,116,114,111,
108, 34, 44, 10, 32, 32, 32, 32, 91, 34, 99, 99, 34, 93, 32, 61, 32, 34, 67, 99,
34, 44, 10, 32, 32, 32, 32, 91, 34, 99,111,109,109,101,110,116,115, 34, 93, 32,
61, 32, 34, 67,111,109,109,101,110,116,115, 34, 44, 10, 32, 32, 32, 32, 91, 34,
99,111,110,110,101, 99,116,105,111,110, 34, 93, 32, 61, 32, 34, 67,111,110,110,
101, 99,116,105,111,110, 34, 44, 10, 32, 32, 32, 32, 91, 34, 99,111,110,116,101,
110,116, 45,100,101,115, 99,114,105,112,116,105,111,110, 34, 93, 32, 61, 32, 34,
67,111,110,116,101,110,116, 45, 68,101,115, 99,114,105,112,116,105,111,110, 34,
44, 10, 32, 32, 32, 32, 91, 34, 99,111,110,116,101,110,116, 45,100,105,115,112,
111,115,105,116,105,111,110, 34, 93, 32, 61, 32, 34, 67,111,110,116,101,110,116,
45, 68,105,115,112,111,115,105,116,105,111,110, 34, 44, 10, 32, 32, 32, 32, 91,
34, 99,111,110,116,101,110,116, 45,101,110, 99,111,100,105,110,103, 34, 93, 32,
61, 32, 34, 67,111,110,116,101,110,116, 45, 69,110, 99,111,100,105,110,103, 34,
44, 10, 32, 32, 32, 32, 91, 34, 99,111,110,116,101,110,116, 45,105,100, 34, 93,
32, 61, 32, 34, 67,111,110,116,101,110,116, 45, 73, 68, 34, 44, 10, 32, 32, 32,
32, 91, 34, 99,111,110,116,101,110,116, 45,108, 97,110,103,117, 97,103,101, 34,
93, 32, 61, 32, 34, 67,111,110,116,101,110,116, 45, 76, 97,110,103,117, 97,103,
101, 34, 44, 10, 32, 32, 32, 32, 91, 34, 99,111,110,116,101,110,116, 45,108,101,
110,103,116,104, 34, 93, 32, 61, 32, 34, 67,111,110,116,101,110,116, 45, 76,101,
110,103,116,104, 34, 44, 10, 32, 32, 32, 32, 91, 34, 99,111,110,116,101,110,116,
45,108,111, 99, 97,116,105,111,110, 34, 93, 32, 61, 32, 34, 67,111,110,116,101,
110,116, 45, 76,111, 99, 97,116,105,111,110, 34, 44, 10, 32, 32, 32, 32, 91, 34,
99,111,110,116,101,110,116, 45,109,100, 53, 34, 93, 32, 61, 32, 34, 67,111,110,
116,101,110,116, 45, 77, 68, 53, 34, 44, 10, 32, 32, 32, 32, 91, 34, 99,111,110,
116,101,110,116, 45,114, 97,110,103,101, 34, 93, 32, 61, 32, 34, 67,111,110,116,
101,110,116, 45, 82, 97,110,103,101, 34, 44, 10, 32, 32, 32, 32, 91, 34, 99,111,
110,116,101,110,116, 45,116,114, 97,110,115,102,101,114, 45,101,110, 99,111,100,
105,110,103, 34, 93, 32, 61, 32, 34, 67,111,110,116,101,110,116, 45, 84,114, 97,
110,115,102,101,114, 45, 69,110, 99,111,100,105,110,103, 34, 44, 10, 32, 32, 32,
32, 91, 34, 99,111,110,116,101,110,116, 45,116,121,112,101, 34, 93, 32, 61, 32,
34, 67,111,110,116,101,110,116, 45, 84,121,112,101, 34, 44, 10, 32, 32, 32, 32,
91, 34, 99,111,111,107,105,101, 34, 93, 32, 61, 32, 34, 67,111,111,107,105,101,
34, 44, 10, 32, 32, 32, 32, 91, 34,100, 97,116,101, 34, 93, 32, 61, 32, 34, 68,
97,116,101, 34, 44, 10, 32, 32, 32, 32, 91, 34,100,105, 97,103,110,111,115,116,
105, 99, 45, 99,111,100,101, 34, 93, 32, 61, 32, 34, 68,105, 97,103,110,111,115,
116,105, 99, 45, 67,111,100,101, 34, 44, 10, 32, 32, 32, 32, 91, 34,100,115,110,
45,103, 97,116,101,119, 97,121, 34, 93, 32, 61, 32, 34, 68, 83, 78, 45, 71, 97,
116,101,119, 97,121, 34, 44, 10, 32, 32, 32, 32, 91, 34,101,116, 97,103, 34, 93,
32, 61, 32, 34, 69, 84, 97,103, 34, 44, 10, 32, 32, 32, 32, 91, 34,101,120,112,
101, 99,116, 34, 93, 32, 61, 32, 34, 69,120,112,101, 99,116, 34, 44, 10, 32, 32,
32, 32, 91, 34,101,120,112,105,114,101,115, 34, 93, 32, 61, 32, 34, 69,120,112,
105,114,101,115, 34, 44, 10, 32, 32, 32, 32, 91, 34,102,105,110, 97,108, 45,108,
111,103, 45,105,100, 34, 93, 32, 61, 32, 34, 70,105,110, 97,108, 45, 76,111,103,
45, 73, 68, 34, 44, 10, 32, 32, 32, 32, 91, 34,102,105,110, 97,108, 45,114,101,
99,105,112,105,101,110,116, 34, 93, 32, 61, 32, 34, 70,105,110, 97,108, 45, 82,
101, 99,105,112,105,101,110,116, 34, 44, 10, 32, 32, 32, 32, 91, 34,102,114,111,
109, 34, 93, 32, 61, 32, 34, 70,114,111,109, 34, 44, 10, 32, 32, 32, 32, 91, 34,
104,111,115,116, 34, 93, 32, 61, 32, 34, 72,111,115,116, 34, 44, 10, 32, 32, 32,
32, 91, 34,105,102, 45,109, 97,116, 99,104, 34, 93, 32, 61, 32, 34, 73,102, 45,
77, 97,116, 99,104, 34, 44, 10, 32, 32, 32, 32, 91, 34,105,102, 45,109,111,100,
105,102,105,101,100, 45,115,105,110, 99,101, 34, 93, 32, 61, 32, 34, 73,102, 45,
77,111,100,105,102,105,101,100, 45, 83,105,110, 99,101, 34, 44, 10, 32, 32, 32,
32, 91, 34,105,102, 45,110,111,110,101, 45,109, 97,116, 99,104, 34, 93, 32, 61,
32, 34, 73,102, 45, 78,111,110,101, 45, 77, 97,116, 99,104, 34, 44, 10, 32, 32,
32, 32, 91, 34,105,102, 45,114, 97,110,103,101, 34, 93, 32, 61, 32, 34, 73,102,
45, 82, 97,110,103,101, 34, 44, 10, 32, 32, 32, 32, 91, 34,105,102, 45,117,110,
109,111,100,105,102,105,101,100, 45,115,105,110, 99,101, 34, 93, 32, 61, 32, 34,
73,102, 45, 85,110,109,111,100,105,102,105,101,100, 45, 83,105,110, 99,101, 34,
44, 10, 32, 32, 32, 32, 91, 34,105,110, 45,114,101,112,108,121, 45,116,111, 34,
93, 32, 61, 32, 34, 73,110, 45, 82,101,112,108,121, 45, 84,111, 34, 44, 10, 32,
32, 32, 32, 91, 34,107,101,121,119,111,114,100,115, 34, 93, 32, 61, 32, 34, 75,
101,121,119,111,114,100,115, 34, 44, 10, 32, 32, 32, 32, 91, 34,108, 97,115,116,
45, 97,116,116,101,109,112,116, 45,100, 97,116,101, 34, 93, 32, 61, 32, 34, 76,
97,115,116, 45, 65,116,116,101,109,112,116, 45, 68, 97,116,101, 34, 44, 10, 32,
32, 32, 32, 91, 34,108, 97,115,116, 45,109,111,100,105,102,105,101,100, 34, 93,
32, 61, 32, 34, 76, 97,115,116, 45, 77,111,100,105,102,105,101,100, 34, 44, 10,
32, 32, 32, 32, 91, 34,108,111, 99, 97,116,105,111,110, 34, 93, 32, 61, 32, 34,
76,111, 99, 97,116,105,111,110, 34, 44, 10, 32, 32, 32, 32, 91, 34,109, 97,120,
45,102,111,114,119, 97,114,100,115, 34, 93, 32, 61, 32, 34, 77, 97,120, 45, 70,
111,114,119, 97,114,100,115, 34, 44, 10, 32, 32, 32, 32, 91, 34,109,101,115,115,
97,103,101, 45,105,100, 34, 93, 32, 61, 32, 34, 77,101,115,115, 97,103,101, 45,
73, 68, 34, 44, 10, 32, 32, 32, 32, 91, 34,109,105,109,101, 45,118,101,114,115,
105,111,110, 34, 93, 32, 61, 32, 34, 77, 73, 77, 69, 45, 86,101,114,115,105,111,
110, 34, 44, 10, 32, 32, 32, 32, 91, 34,111,114,105,103,105,110, 97,108, 45,101,
110,118,101,108,111,112,101, 45,105,100, 34, 93, 32, 61, 32, 34, 79,114,105,103,
105,110, 97,108, 45, 69,110,118,101,108,111,112,101, 45, 73, 68, 34, 44, 10, 32,
32, 32, 32, 91, 34,111,114,105,103,105,110, 97,108, 45,114,101, 99,105,112,105,
101,110,116, 34, 93, 32, 61, 32, 34, 79,114,105,103,105,110, 97,108, 45, 82,101,
99,105,112,105,101,110,116, 34, 44, 10, 32, 32, 32, 32, 91, 34,112,114, 97,103,
109, 97, 34, 93, 32, 61, 32, 34, 80,114, 97,103,109, 97, 34, 44, 10, 32, 32, 32,
32, 91, 34,112,114,111,120,121, 45, 97,117,116,104,101,110,116,105, 99, 97,116,
101, 34, 93, 32, 61, 32, 34, 80,114,111,120,121, 45, 65,117,116,104,101,110,116,
105, 99, 97,116,101, 34, 44, 10, 32, 32, 32, 32, 91, 34,112,114,111,120,121, 45,
97,117,116,104,111,114,105,122, 97,116,105,111,110, 34, 93, 32, 61, 32, 34, 80,
114,111,120,121, 45, 65,117,116,104,111,114,105,122, 97,116,105,111,110, 34, 44,
10, 32, 32, 32, 32, 91, 34,114, 97,110,103,101, 34, 93, 32, 61, 32, 34, 82, 97,
110,103,101, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101, 99,101,105,118,101,100,
34, 93, 32, 61, 32, 34, 82,101, 99,101,105,118,101,100, 34, 44, 10, 32, 32, 32,
32, 91, 34,114,101, 99,101,105,118,101,100, 45,102,114,111,109, 45,109,116, 97,
34, 93, 32, 61, 32, 34, 82,101, 99,101,105,118,101,100, 45, 70,114,111,109, 45,
77, 84, 65, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101,102,101,114,101,110, 99,
101,115, 34, 93, 32, 61, 32, 34, 82,101,102,101,114,101,110, 99,101,115, 34, 44,
10, 32, 32, 32, 32, 91, 34,114,101,102,101,114,101,114, 34, 93, 32, 61, 32, 34,
82,101,102,101,114,101,114, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101,109,111,
116,101, 45,109,116, 97, 34, 93, 32, 61, 32, 34, 82,101,109,111,116,101, 45, 77,
84, 65, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101,112,108,121, 45,116,111, 34,
93, 32, 61, 32, 34, 82,101,112,108,121, 45, 84,111, 34, 44, 10, 32, 32, 32, 32,
91, 34,114,101,112,111,114,116,105,110,103, 45,109,116, 97, 34, 93, 32, 61, 32,
34, 82,101,112,111,114,116,105,110,103, 45, 77, 84, 65, 34, 44, 10, 32, 32, 32,
32, 91, 34,114,101,115,101,110,116, 45, 98, 99, 99, 34, 93, 32, 61, 32, 34, 82,
101,115,101,110,116, 45, 66, 99, 99, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101,
115,101,110,116, 45, 99, 99, 34, 93, 32, 61, 32, 34, 82,101,115,101,110,116, 45,
67, 99, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101,115,101,110,116, 45,100, 97,
116,101, 34, 93, 32, 61, 32, 34, 82,101,115,101,110,116, 45, 68, 97,116,101, 34,
44, 10, 32, 32, 32, 32, 91, 34,114,101,115,101,110,116, 45,102,114,111,109, 34,
93, 32, 61, 32, 34, 82,101,115,101,110,116, 45, 70,114,111,109, 34, 44, 10, 32,
32, 32, 32, 91, 34,114,101,115,101,110,116, 45,109,101,115,115, 97,103,101, 45,
105,100, 34, 93, 32, 61, 32, 34, 82,101,115,101,110,116, 45, 77,101,115,115, 97,
103,101, 45, 73, 68, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101,115,101,110,116,
45,114,101,112,108,121, 45,116,111, 34, 93, 32, 61, 32, 34, 82,101,115,101,110,
116, 45, 82,101,112,108,121, 45, 84,111, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,
101,115,101,110,116, 45,115,101,110,100,101,114, 34, 93, 32, 61, 32, 34, 82,101,
115,101,110,116, 45, 83,101,110,100,101,114, 34, 44, 10, 32, 32, 32, 32, 91, 34,
114,101,115,101,110,116, 45,116,111, 34, 93, 32, 61, 32, 34, 82,101,115,101,110,
116, 45, 84,111, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101,116,114,121, 45, 97,
102,116,101,114, 34, 93, 32, 61, 32, 34, 82,101,116,114,121, 45, 65,102,116,101,
114, 34, 44, 10, 32, 32, 32, 32, 91, 34,114,101,116,117,114,110, 45,112, 97,116,
104, 34, 93, 32, 61, 32, 34, 82,101,116,117,114,110, 45, 80, 97,116,104, 34, 44,
10, 32, 32, 32, 32, 91, 34,115,101,110,100,101,114, 34, 93, 32, 61, 32, 34, 83,
101,110,100,101,114, 34, 44, 10, 32, 32, 32, 32, 91, 34,115,101,114,118,101,114,
34, 93, 32, 61, 32, 34, 83,101,114,118,101,114, 34, 44, 10, 32, 32, 32, 32, 91,
34,115,109,116,112, 45,114,101,109,111,116,101, 45,114,101, 99,105,112,105,101,
110,116, 34, 93, 32, 61, 32, 34, 83, 77, 84, 80, 45, 82,101,109,111,116,101, 45,
82,101, 99,105,112,105,101,110,116, 34, 44, 10, 32, 32, 32, 32, 91, 34,115,116,
97,116,117,115, 34, 93, 32, 61, 32, 34, 83,116, 97,116,117,115, 34, 44, 10, 32,
32, 32, 32, 91, 34,115,117, 98,106,101, 99,116, 34, 93, 32, 61, 32, 34, 83,117,
98,106,101, 99,116, 34, 44, 10, 32, 32, 32, 32, 91, 34,116,101, 34, 93, 32, 61,
32, 34, 84, 69, 34, 44, 10, 32, 32, 32, 32, 91, 34,116,111, 34, 93, 32, 61, 32,
34, 84,111, 34, 44, 10, 32, 32, 32, 32, 91, 34,116,114, 97,105,108,101,114, 34,
93, 32, 61, 32, 34, 84,114, 97,105,108,101,114, 34, 44, 10, 32, 32, 32, 32, 91,
34,116,114, 97,110,115,102,101,114, 45,101,110, 99,111,100,105,110,103, 34, 93,
32, 61, 32, 34, 84,114, 97,110,115,102,101,114, 45, 69,110, 99,111,100,105,110,
103, 34, 44, 10, 32, 32, 32, 32, 91, 34,117,112,103,114, 97,100,101, 34, 93, 32,
61, 32, 34, 85,112,103,114, 97,100,101, 34, 44, 10, 32, 32, 32, 32, 91, 34,117,
115,101,114, 45, 97,103,101,110,116, 34, 93, 32, 61, 32, 34, 85,115,101,114, 45,
65,103,101,110,116, 34, 44, 10, 32, 32, 32, 32, 91, 34,118, 97,114,121, 34, 93,
32, 61, 32, 34, 86, 97,114,121, 34, 44, 10, 32, 32, 32, 32, 91, 34,118,105, 97,
34, 93, 32, 61, 32, 34, 86,105, 97, 34, 44, 10, 32, 32, 32, 32, 91, 34,119, 97,
114,110,105,110,103, 34, 93, 32, 61, 32, 34, 87, 97,114,110,105,110,103, 34, 44,
10, 32, 32, 32, 32, 91, 34,119,105,108,108, 45,114,101,116,114,121, 45,117,110,
116,105,108, 34, 93, 32, 61, 32, 34, 87,105,108,108, 45, 82,101,116,114,121, 45,
85,110,116,105,108, 34, 44, 10, 32, 32, 32, 32, 91, 34,119,119,119, 45, 97,117,
116,104,101,110,116,105, 99, 97,116,101, 34, 93, 32, 61, 32, 34, 87, 87, 87, 45,
65,117,116,104,101,110,116,105, 99, 97,116,101, 34, 44, 10, 32, 32, 32, 32, 91,
34,120, 45,109, 97,105,108,101,114, 34, 93, 32, 61, 32, 34, 88, 45, 77, 97,105,
108,101,114, 34, 44, 10,125, 10, 10,114,101,116,117,114,110, 32, 95, 77,
};
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"headers.lua")==0) lua_call(L, 0, LUA_MULTRET);
}
+71 -39
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.71 2007/10/13 23:55:20 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@@ -13,19 +12,24 @@ local url = require("socket.url")
local ltn12 = require("ltn12")
local mime = require("mime")
local string = require("string")
local headers = require("socket.headers")
local base = _G
local table = require("table")
module("socket.http")
socket.http = {}
local _M = socket.http
-----------------------------------------------------------------------------
-- Program constants
-----------------------------------------------------------------------------
-- connection timeout in seconds
TIMEOUT = 60
-- default port for document retrieval
PORT = 80
_M.TIMEOUT = 60
-- user agent field sent in request
USERAGENT = socket._VERSION
_M.USERAGENT = socket._VERSION
-- supported schemes
local SCHEMES = { ["http"] = true }
-- default port for document retrieval
local PORT = 80
-----------------------------------------------------------------------------
-- Reads MIME headers from a connection, unfolding where needed
@@ -105,14 +109,14 @@ end
-----------------------------------------------------------------------------
local metat = { __index = {} }
function open(host, port, create)
function _M.open(host, port, create)
-- create socket with user connect function, or with default
local c = socket.try((create or socket.tcp)())
local h = base.setmetatable({ c = c }, metat)
-- create finalized try
h.try = socket.newtry(function() h:close() end)
-- set timeout before connecting
h.try(c:settimeout(TIMEOUT))
h.try(c:settimeout(_M.TIMEOUT))
h.try(c:connect(host, port or PORT))
-- here everything worked
return h
@@ -123,10 +127,11 @@ function metat.__index:sendrequestline(method, uri)
return self.try(self.c:send(reqline))
end
function metat.__index:sendheaders(headers)
function metat.__index:sendheaders(tosend)
local canonic = headers.canonic
local h = "\r\n"
for i, v in base.pairs(headers) do
h = i .. ": " .. v .. "\r\n" .. h
for f, v in base.pairs(tosend) do
h = (canonic[f] or f) .. ": " .. v .. "\r\n" .. h
end
self.try(self.c:send(h))
return 1
@@ -184,7 +189,7 @@ end
local function adjusturi(reqt)
local u = reqt
-- if there is a proxy, we need the full url. otherwise, just a part.
if not reqt.proxy and not PROXY then
if not reqt.proxy and not _M.PROXY then
u = {
path = socket.try(reqt.path, "invalid path 'nil'"),
params = reqt.params,
@@ -196,7 +201,7 @@ local function adjusturi(reqt)
end
local function adjustproxy(reqt)
local proxy = reqt.proxy or PROXY
local proxy = reqt.proxy or _M.PROXY
if proxy then
proxy = url.parse(proxy)
return proxy.host, proxy.port or 3128
@@ -207,16 +212,27 @@ end
local function adjustheaders(reqt)
-- default headers
local host = string.gsub(reqt.authority, "^.-@", "")
local lower = {
["user-agent"] = USERAGENT,
["host"] = reqt.host,
["user-agent"] = _M.USERAGENT,
["host"] = host,
["connection"] = "close, TE",
["te"] = "trailers"
}
-- if we have authentication information, pass it along
if reqt.user and reqt.password then
lower["authorization"] =
"Basic " .. (mime.b64(reqt.user .. ":" .. reqt.password))
lower["authorization"] =
"Basic " .. (mime.b64(reqt.user .. ":" ..
url.unescape(reqt.password)))
end
-- if we have proxy authentication information, pass it along
local proxy = reqt.proxy or _M.PROXY
if proxy then
proxy = url.parse(proxy)
if proxy.user and proxy.password then
lower["proxy-authorization"] =
"Basic " .. (mime.b64(proxy.user .. ":" .. proxy.password))
end
end
-- override with user headers
for i,v in base.pairs(reqt.headers or lower) do
@@ -238,23 +254,28 @@ local function adjustrequest(reqt)
local nreqt = reqt.url and url.parse(reqt.url, default) or {}
-- explicit components override url
for i,v in base.pairs(reqt) do nreqt[i] = v end
if nreqt.port == "" then nreqt.port = 80 end
socket.try(nreqt.host and nreqt.host ~= "",
"invalid host '" .. base.tostring(nreqt.host) .. "'")
if nreqt.port == "" then nreqt.port = PORT end
if not (nreqt.host and nreqt.host ~= "") then
socket.try(nil, "invalid host '" .. base.tostring(nreqt.host) .. "'")
end
-- compute uri if user hasn't overriden
nreqt.uri = reqt.uri or adjusturi(nreqt)
-- ajust host and port if there is a proxy
nreqt.host, nreqt.port = adjustproxy(nreqt)
-- adjust headers in request
nreqt.headers = adjustheaders(nreqt)
-- ajust host and port if there is a proxy
nreqt.host, nreqt.port = adjustproxy(nreqt)
return nreqt
end
local function shouldredirect(reqt, code, headers)
return headers.location and
string.gsub(headers.location, "%s", "") ~= "" and
(reqt.redirect ~= false) and
(code == 301 or code == 302) and
local location = headers.location
if not location then return false end
location = string.gsub(location, "%s", "")
if location == "" then return false end
local scheme = string.match(location, "^([%w][%w%+%-%.]*)%:")
if scheme and not SCHEMES[scheme] then return false end
return (reqt.redirect ~= false) and
(code == 301 or code == 302 or code == 303 or code == 307) and
(not reqt.method or reqt.method == "GET" or reqt.method == "HEAD")
and (not reqt.nredirects or reqt.nredirects < 5)
end
@@ -269,7 +290,7 @@ end
-- forward declarations
local trequest, tredirect
function tredirect(reqt, location)
--[[local]] function tredirect(reqt, location)
local result, code, headers, status = trequest {
-- the RFC says the redirect URL has to be absolute, but some
-- servers do not respect that
@@ -277,27 +298,27 @@ function tredirect(reqt, location)
source = reqt.source,
sink = reqt.sink,
headers = reqt.headers,
proxy = reqt.proxy,
proxy = reqt.proxy,
nredirects = (reqt.nredirects or 0) + 1,
create = reqt.create
}
}
-- pass location header back as a hint we redirected
headers = headers or {}
headers.location = headers.location or location
return result, code, headers, status
end
function trequest(reqt)
--[[local]] function trequest(reqt)
-- we loop until we get what we want, or
-- until we are sure there is no way to get it
local nreqt = adjustrequest(reqt)
local h = open(nreqt.host, nreqt.port, nreqt.create)
local h = _M.open(nreqt.host, nreqt.port, nreqt.create)
-- send request line and headers
h:sendrequestline(nreqt.method, nreqt.uri)
h:sendheaders(nreqt.headers)
-- if there is a body, send it
if nreqt.source then
h:sendbody(nreqt.headers, nreqt.source, nreqt.step)
h:sendbody(nreqt.headers, nreqt.source, nreqt.step)
end
local code, status = h:receivestatusline()
-- if it is an HTTP/0.9 server, simply get the body and we are done
@@ -307,13 +328,13 @@ function trequest(reqt)
end
local headers
-- ignore any 100-continue messages
while code == 100 do
while code == 100 do
headers = h:receiveheaders()
code, status = h:receivestatusline()
end
headers = h:receiveheaders()
-- at this point we should have a honest reply from the server
-- we can't redirect if we already used the source, so we report the error
-- we can't redirect if we already used the source, so we report the error
if shouldredirect(nreqt, code, headers) and not nreqt.source then
h:close()
return tredirect(reqt, headers.location)
@@ -326,11 +347,13 @@ function trequest(reqt)
return 1, code, headers, status
end
local function srequest(u, b)
-- turns an url and a body into a generic request
local function genericform(u, b)
local t = {}
local reqt = {
url = u,
sink = ltn12.sink.table(t)
sink = ltn12.sink.table(t),
target = t
}
if b then
reqt.source = ltn12.source.string(b)
@@ -340,11 +363,20 @@ local function srequest(u, b)
}
reqt.method = "POST"
end
local code, headers, status = socket.skip(1, trequest(reqt))
return table.concat(t), code, headers, status
return reqt
end
request = socket.protect(function(reqt, body)
_M.genericform = genericform
local function srequest(u, b)
local reqt = genericform(u, b)
local _, code, headers, status = trequest(reqt)
return table.concat(reqt.target), code, headers, status
end
_M.request = socket.protect(function(reqt, body)
if base.type(reqt) == "string" then return srequest(reqt, body)
else return trequest(reqt) end
end)
return _M
File diff suppressed because it is too large Load Diff
+332 -72
View File
@@ -1,31 +1,33 @@
/*=========================================================================*\
* 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 <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "inet.h"
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
/*=========================================================================*\
* Internal function prototypes.
\*=========================================================================*/
static int inet_global_toip(lua_State *L);
static int inet_global_getaddrinfo(lua_State *L);
static int inet_global_tohostname(lua_State *L);
static int inet_global_getnameinfo(lua_State *L);
static void inet_pushresolved(lua_State *L, struct hostent *hp);
static int inet_global_gethostname(lua_State *L);
/* DNS functions */
static luaL_reg func[] = {
{ "toip", inet_global_toip },
{ "tohostname", inet_global_tohostname },
static luaL_Reg func[] = {
{ "toip", inet_global_toip},
{ "getaddrinfo", inet_global_getaddrinfo},
{ "tohostname", inet_global_tohostname},
{ "getnameinfo", inet_global_getnameinfo},
{ "gethostname", inet_global_gethostname},
{ NULL, NULL}
};
@@ -40,7 +42,7 @@ int inet_open(lua_State *L)
{
lua_pushstring(L, "dns");
lua_newtable(L);
luax_register(L, NULL, func);
luaL_setfuncs(L, func, 0);
lua_settable(L, -3);
return 0;
}
@@ -56,7 +58,7 @@ static int inet_gethost(const char *address, struct hostent **hp) {
struct in_addr addr;
if (inet_aton(address, &addr))
return socket_gethostbyaddr((char *) &addr, sizeof(addr), hp);
else
else
return socket_gethostbyname(address, hp);
}
@@ -66,7 +68,7 @@ static int inet_gethost(const char *address, struct hostent **hp) {
\*-------------------------------------------------------------------------*/
static int inet_global_tohostname(lua_State *L) {
const char *address = luaL_checkstring(L, 1);
struct hostent *hp = NULL;
struct hostent *hp = NULL;
int err = inet_gethost(address, &hp);
if (err != IO_DONE) {
lua_pushnil(L);
@@ -78,6 +80,50 @@ static int inet_global_tohostname(lua_State *L) {
return 2;
}
static int inet_global_getnameinfo(lua_State *L) {
char hbuf[NI_MAXHOST];
char sbuf[NI_MAXSERV];
int i, ret;
struct addrinfo hints;
struct addrinfo *resolved, *iter;
const char *host = luaL_optstring(L, 1, NULL);
const char *serv = luaL_optstring(L, 2, NULL);
if (!(host || serv))
luaL_error(L, "host and serv cannot be both nil");
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_UNSPEC;
ret = getaddrinfo(host, serv, &hints, &resolved);
if (ret != 0) {
lua_pushnil(L);
lua_pushstring(L, socket_gaistrerror(ret));
return 2;
}
lua_newtable(L);
for (i = 1, iter = resolved; iter; i++, iter = iter->ai_next) {
getnameinfo(iter->ai_addr, (socklen_t) iter->ai_addrlen,
hbuf, host? (socklen_t) sizeof(hbuf): 0,
sbuf, serv? (socklen_t) sizeof(sbuf): 0, 0);
if (host) {
lua_pushnumber(L, i);
lua_pushstring(L, hbuf);
lua_settable(L, -3);
}
}
freeaddrinfo(resolved);
if (serv) {
lua_pushstring(L, sbuf);
return 2;
} else {
return 1;
}
}
/*-------------------------------------------------------------------------*\
* Returns all information provided by the resolver given a host name
* or ip address
@@ -85,7 +131,7 @@ static int inet_global_tohostname(lua_State *L) {
static int inet_global_toip(lua_State *L)
{
const char *address = luaL_checkstring(L, 1);
struct hostent *hp = NULL;
struct hostent *hp = NULL;
int err = inet_gethost(address, &hp);
if (err != IO_DONE) {
lua_pushnil(L);
@@ -97,6 +143,81 @@ static int inet_global_toip(lua_State *L)
return 2;
}
int inet_optfamily(lua_State* L, int narg, const char* def)
{
static const char* optname[] = { "unspec", "inet", "inet6", NULL };
static int optvalue[] = { AF_UNSPEC, AF_INET, AF_INET6, 0 };
return optvalue[luaL_checkoption(L, narg, def, optname)];
}
int inet_optsocktype(lua_State* L, int narg, const char* def)
{
static const char* optname[] = { "stream", "dgram", NULL };
static int optvalue[] = { SOCK_STREAM, SOCK_DGRAM, 0 };
return optvalue[luaL_checkoption(L, narg, def, optname)];
}
static int inet_global_getaddrinfo(lua_State *L)
{
const char *hostname = luaL_checkstring(L, 1);
struct addrinfo *iterator = NULL, *resolved = NULL;
struct addrinfo hints;
int i = 1, ret = 0;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_UNSPEC;
ret = getaddrinfo(hostname, NULL, &hints, &resolved);
if (ret != 0) {
lua_pushnil(L);
lua_pushstring(L, socket_gaistrerror(ret));
return 2;
}
lua_newtable(L);
for (iterator = resolved; iterator; iterator = iterator->ai_next) {
char hbuf[NI_MAXHOST];
ret = getnameinfo(iterator->ai_addr, (socklen_t) iterator->ai_addrlen,
hbuf, (socklen_t) sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
if (ret){
freeaddrinfo(resolved);
lua_pushnil(L);
lua_pushstring(L, socket_gaistrerror(ret));
return 2;
}
lua_pushnumber(L, i);
lua_newtable(L);
switch (iterator->ai_family) {
case AF_INET:
lua_pushliteral(L, "family");
lua_pushliteral(L, "inet");
lua_settable(L, -3);
break;
case AF_INET6:
lua_pushliteral(L, "family");
lua_pushliteral(L, "inet6");
lua_settable(L, -3);
break;
case AF_UNSPEC:
lua_pushliteral(L, "family");
lua_pushliteral(L, "unspec");
lua_settable(L, -3);
break;
default:
lua_pushliteral(L, "family");
lua_pushliteral(L, "unknown");
lua_settable(L, -3);
break;
}
lua_pushliteral(L, "addr");
lua_pushstring(L, hbuf);
lua_settable(L, -3);
lua_settable(L, -3);
i++;
}
freeaddrinfo(resolved);
return 1;
}
/*-------------------------------------------------------------------------*\
* Gets the host name
@@ -107,7 +228,7 @@ static int inet_global_gethostname(lua_State *L)
name[256] = '\0';
if (gethostname(name, 256) < 0) {
lua_pushnil(L);
lua_pushstring(L, "gethostname failed");
lua_pushstring(L, socket_strerror(errno));
return 2;
} else {
lua_pushstring(L, name);
@@ -115,43 +236,74 @@ static int inet_global_gethostname(lua_State *L)
}
}
/*=========================================================================*\
* Lua methods
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Retrieves socket peer name
\*-------------------------------------------------------------------------*/
int inet_meth_getpeername(lua_State *L, p_socket ps)
int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
{
struct sockaddr_in peer;
int err;
struct sockaddr_storage peer;
socklen_t peer_len = sizeof(peer);
char name[INET6_ADDRSTRLEN];
char port[6]; /* 65535 = 5 bytes + 0 to terminate it */
if (getpeername(*ps, (SA *) &peer, &peer_len) < 0) {
lua_pushnil(L);
lua_pushstring(L, "getpeername failed");
} else {
lua_pushstring(L, inet_ntoa(peer.sin_addr));
lua_pushnumber(L, ntohs(peer.sin_port));
lua_pushstring(L, socket_strerror(errno));
return 2;
}
return 2;
err = getnameinfo((struct sockaddr *) &peer, peer_len,
name, INET6_ADDRSTRLEN,
port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
return 2;
}
lua_pushstring(L, name);
lua_pushinteger(L, (int) strtol(port, (char **) NULL, 10));
switch (family) {
case AF_INET: lua_pushliteral(L, "inet"); break;
case AF_INET6: lua_pushliteral(L, "inet6"); break;
case AF_UNSPEC: lua_pushliteral(L, "unspec"); break;
default: lua_pushliteral(L, "unknown"); break;
}
return 3;
}
/*-------------------------------------------------------------------------*\
* Retrieves socket local name
\*-------------------------------------------------------------------------*/
int inet_meth_getsockname(lua_State *L, p_socket ps)
int inet_meth_getsockname(lua_State *L, p_socket ps, int family)
{
struct sockaddr_in local;
socklen_t local_len = sizeof(local);
if (getsockname(*ps, (SA *) &local, &local_len) < 0) {
int err;
struct sockaddr_storage peer;
socklen_t peer_len = sizeof(peer);
char name[INET6_ADDRSTRLEN];
char port[6]; /* 65535 = 5 bytes + 0 to terminate it */
if (getsockname(*ps, (SA *) &peer, &peer_len) < 0) {
lua_pushnil(L);
lua_pushstring(L, "getsockname failed");
} else {
lua_pushstring(L, inet_ntoa(local.sin_addr));
lua_pushnumber(L, ntohs(local.sin_port));
lua_pushstring(L, socket_strerror(errno));
return 2;
}
return 2;
err=getnameinfo((struct sockaddr *)&peer, peer_len,
name, INET6_ADDRSTRLEN, port, 6, NI_NUMERICHOST | NI_NUMERICSERV);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
return 2;
}
lua_pushstring(L, name);
lua_pushstring(L, port);
switch (family) {
case AF_INET: lua_pushliteral(L, "inet"); break;
case AF_INET6: lua_pushliteral(L, "inet6"); break;
case AF_UNSPEC: lua_pushliteral(L, "unspec"); break;
default: lua_pushliteral(L, "unknown"); break;
}
return 3;
}
/*=========================================================================*\
@@ -200,65 +352,151 @@ 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 type) {
return socket_strerror(socket_create(ps, AF_INET, type, 0));
const char *inet_trycreate(p_socket ps, int family, int type, int protocol) {
const char *err = socket_strerror(socket_create(ps, family, type, protocol));
if (err == NULL && family == AF_INET6) {
int yes = 1;
setsockopt(*ps, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&yes, sizeof(yes));
}
return err;
}
/*-------------------------------------------------------------------------*\
* "Disconnects" a DGRAM socket
\*-------------------------------------------------------------------------*/
const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm)
{
switch (family) {
case AF_INET: {
struct sockaddr_in sin;
memset((char *) &sin, 0, sizeof(sin));
sin.sin_family = AF_UNSPEC;
sin.sin_addr.s_addr = INADDR_ANY;
return socket_strerror(socket_connect(ps, (SA *) &sin,
sizeof(sin), tm));
}
case AF_INET6: {
struct sockaddr_in6 sin6;
struct in6_addr addrany = IN6ADDR_ANY_INIT;
memset((char *) &sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_UNSPEC;
sin6.sin6_addr = addrany;
return socket_strerror(socket_connect(ps, (SA *) &sin6,
sizeof(sin6), tm));
}
}
return NULL;
}
/*-------------------------------------------------------------------------*\
* Tries to connect to remote address (address, port)
\*-------------------------------------------------------------------------*/
const char *inet_tryconnect(p_socket ps, const char *address,
unsigned short port, p_timeout tm)
const char *inet_tryconnect(p_socket ps, int *family, const char *address,
const char *serv, p_timeout tm, struct addrinfo *connecthints)
{
struct sockaddr_in remote;
int err;
memset(&remote, 0, sizeof(remote));
remote.sin_family = AF_INET;
remote.sin_port = htons(port);
if (strcmp(address, "*")) {
if (!inet_aton(address, &remote.sin_addr)) {
struct hostent *hp = NULL;
struct in_addr **addr;
err = socket_gethostbyname(address, &hp);
if (err != IO_DONE) return socket_hoststrerror(err);
addr = (struct in_addr **) hp->h_addr_list;
memcpy(&remote.sin_addr, *addr, sizeof(struct in_addr));
struct addrinfo *iterator = NULL, *resolved = NULL;
const char *err = NULL;
int current_family = *family;
/* try resolving */
err = socket_gaistrerror(getaddrinfo(address, serv,
connecthints, &resolved));
if (err != NULL) {
if (resolved) freeaddrinfo(resolved);
return err;
}
for (iterator = resolved; iterator; iterator = iterator->ai_next) {
timeout_markstart(tm);
/* create new socket if necessary. if there was no
* bind, we need to create one for every new family
* that shows up while iterating. if there was a
* bind, all families will be the same and we will
* not enter this branch. */
if (current_family != iterator->ai_family || *ps == SOCKET_INVALID) {
socket_destroy(ps);
err = inet_trycreate(ps, iterator->ai_family,
iterator->ai_socktype, iterator->ai_protocol);
if (err) continue;
current_family = iterator->ai_family;
/* set non-blocking before connect */
socket_setnonblocking(ps);
}
} else remote.sin_family = AF_UNSPEC;
err = socket_connect(ps, (SA *) &remote, sizeof(remote), tm);
return socket_strerror(err);
/* try connecting to remote address */
err = socket_strerror(socket_connect(ps, (SA *) iterator->ai_addr,
(socklen_t) iterator->ai_addrlen, tm));
/* if success or timeout is zero, break out of loop */
if (err == NULL || timeout_iszero(tm)) {
*family = current_family;
break;
}
}
freeaddrinfo(resolved);
/* here, if err is set, we failed */
return err;
}
/*-------------------------------------------------------------------------*\
* Tries to accept a socket
\*-------------------------------------------------------------------------*/
const char *inet_tryaccept(p_socket server, int family, p_socket client,
p_timeout tm) {
socklen_t len;
t_sockaddr_storage addr;
switch (family) {
case AF_INET6: len = sizeof(struct sockaddr_in6); break;
case AF_INET: len = sizeof(struct sockaddr_in); break;
default: len = sizeof(addr); break;
}
return socket_strerror(socket_accept(server, client, (SA *) &addr,
&len, tm));
}
/*-------------------------------------------------------------------------*\
* Tries to bind socket to (address, port)
\*-------------------------------------------------------------------------*/
const char *inet_trybind(p_socket ps, const char *address, unsigned short port)
{
struct sockaddr_in local;
int err;
memset(&local, 0, sizeof(local));
/* address is either wildcard or a valid ip address */
local.sin_addr.s_addr = htonl(INADDR_ANY);
local.sin_port = htons(port);
local.sin_family = AF_INET;
if (strcmp(address, "*") && !inet_aton(address, &local.sin_addr)) {
struct hostent *hp = NULL;
struct in_addr **addr;
err = socket_gethostbyname(address, &hp);
if (err != IO_DONE) return socket_hoststrerror(err);
addr = (struct in_addr **) hp->h_addr_list;
memcpy(&local.sin_addr, *addr, sizeof(struct in_addr));
const char *inet_trybind(p_socket ps, int *family, const char *address,
const char *serv, struct addrinfo *bindhints) {
struct addrinfo *iterator = NULL, *resolved = NULL;
const char *err = NULL;
int current_family = *family;
/* translate luasocket special values to C */
if (strcmp(address, "*") == 0) address = NULL;
if (!serv) serv = "0";
/* try resolving */
err = socket_gaistrerror(getaddrinfo(address, serv, bindhints, &resolved));
if (err) {
if (resolved) freeaddrinfo(resolved);
return err;
}
err = socket_bind(ps, (SA *) &local, sizeof(local));
if (err != IO_DONE) socket_destroy(ps);
return socket_strerror(err);
/* iterate over resolved addresses until one is good */
for (iterator = resolved; iterator; iterator = iterator->ai_next) {
if (current_family != iterator->ai_family || *ps == SOCKET_INVALID) {
socket_destroy(ps);
err = inet_trycreate(ps, iterator->ai_family,
iterator->ai_socktype, iterator->ai_protocol);
if (err) continue;
current_family = iterator->ai_family;
}
/* try binding to local address */
err = socket_strerror(socket_bind(ps, (SA *) iterator->ai_addr,
(socklen_t) iterator->ai_addrlen));
/* keep trying unless bind succeeded */
if (err == NULL) {
*family = current_family;
/* set to non-blocking after bind */
socket_setnonblocking(ps);
break;
}
}
/* cleanup and return error */
freeaddrinfo(resolved);
/* here, if err is set, we failed */
return err;
}
/*-------------------------------------------------------------------------*\
* Some systems do not provide this so that we provide our own. It's not
* marvelously fast, but it works just fine.
* Some systems do not provide these so that we provide our own.
\*-------------------------------------------------------------------------*/
#ifdef INET_ATON
#ifdef LUASOCKET_INET_ATON
int inet_aton(const char *cp, struct in_addr *inp)
{
unsigned int a = 0, b = 0, c = 0, d = 0;
@@ -280,4 +518,26 @@ int inet_aton(const char *cp, struct in_addr *inp)
}
#endif
#ifdef LUASOCKET_INET_PTON
int inet_pton(int af, const char *src, void *dst)
{
struct addrinfo hints, *res;
int ret = 1;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = af;
hints.ai_flags = AI_NUMERICHOST;
if (getaddrinfo(src, NULL, &hints, &res) != 0) return -1;
if (af == AF_INET) {
struct sockaddr_in *in = (struct sockaddr_in *) res->ai_addr;
memcpy(dst, &in->sin_addr, sizeof(in->sin_addr));
} else if (af == AF_INET6) {
struct sockaddr_in6 *in = (struct sockaddr_in6 *) res->ai_addr;
memcpy(dst, &in->sin6_addr, sizeof(in->sin6_addr));
} else {
ret = -1;
}
freeaddrinfo(res);
return ret;
}
#endif
+22 -14
View File
@@ -1,42 +1,50 @@
#ifndef INET_H
#define INET_H
#ifndef INET_H
#define INET_H
/*=========================================================================*\
* Internet domain functions
* LuaSocket toolkit
*
* This module implements the creation and connection of internet domain
* sockets, on top of the socket.h interface, and the interface of with the
* resolver.
* resolver.
*
* The function inet_aton is provided for the platforms where it is not
* available. The module also implements the interface of the internet
* getpeername and getsockname functions as seen by Lua programs.
*
* The Lua functions toip and tohostname are also implemented here.
*
* RCS ID: $Id: inet.h,v 1.16 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include "lua.h"
#include "socket.h"
#include "timeout.h"
#ifdef _WIN32
#define INET_ATON
#define LUASOCKET_INET_ATON
#endif
int inet_open(lua_State *L);
const char *inet_trycreate(p_socket ps, int type);
const char *inet_tryconnect(p_socket ps, const char *address,
unsigned short port, p_timeout tm);
const char *inet_trybind(p_socket ps, const char *address,
unsigned short port);
const char *inet_trycreate(p_socket ps, int family, int type, int protocol);
const char *inet_tryconnect(p_socket ps, int *family, const char *address,
const char *serv, p_timeout tm, struct addrinfo *connecthints);
const char *inet_trybind(p_socket ps, int *family, const char *address,
const char *serv, struct addrinfo *bindhints);
const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm);
const char *inet_tryaccept(p_socket server, int family, p_socket client, p_timeout tm);
int inet_meth_getpeername(lua_State *L, p_socket ps);
int inet_meth_getsockname(lua_State *L, p_socket ps);
int inet_meth_getpeername(lua_State *L, p_socket ps, int family);
int inet_meth_getsockname(lua_State *L, p_socket ps, int family);
#ifdef INET_ATON
int inet_optfamily(lua_State* L, int narg, const char* def);
int inet_optsocktype(lua_State* L, int narg, const char* def);
#ifdef LUASOCKET_INET_ATON
int inet_aton(const char *cp, struct in_addr *inp);
#endif
#ifdef LUASOCKET_INET_PTON
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
int inet_pton(int af, const char *src, void *dst);
#endif
#endif /* INET_H */
+1 -3
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"
@@ -27,6 +25,6 @@ const char *io_strerror(int err) {
case IO_DONE: return NULL;
case IO_CLOSED: return "closed";
case IO_TIMEOUT: return "timeout";
default: return "unknown error";
default: return "unknown error";
}
}
@@ -11,8 +11,6 @@
*
* The module socket.h implements this interface, and thus the module tcp.h
* is very simple.
*
* RCS ID: $Id: io.h,v 1.11 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include <stdio.h>
#include "lua.h"
+32 -15
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 $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@@ -10,17 +9,25 @@
-----------------------------------------------------------------------------
local string = require("string")
local table = require("table")
local unpack = unpack or table.unpack
local base = _G
module("ltn12")
local _M = {}
if module then -- heuristic for exporting a global package table
ltn12 = _M
end
local filter,source,sink,pump = {},{},{},{}
filter = {}
source = {}
sink = {}
pump = {}
_M.filter = filter
_M.source = source
_M.sink = sink
_M.pump = pump
local unpack = unpack or table.unpack
local select = base.select
-- 2048 seems to be better in windows...
BLOCKSIZE = 2048
_VERSION = "LTN12 1.0.1"
_M.BLOCKSIZE = 2048
_M._VERSION = "LTN12 1.0.3"
-----------------------------------------------------------------------------
-- Filter stuff
@@ -38,7 +45,8 @@ end
-- chains a bunch of filters together
-- (thanks to Wim Couwenberg)
function filter.chain(...)
local n = table.getn(arg)
local arg = {...}
local n = base.select('#',...)
local top, index = 1, 1
local retry = ""
return function(chunk)
@@ -89,7 +97,7 @@ end
function source.file(handle, io_err)
if handle then
return function()
local chunk = handle:read(BLOCKSIZE)
local chunk = handle:read(_M.BLOCKSIZE)
if not chunk then handle:close() end
return chunk
end
@@ -112,8 +120,8 @@ function source.string(s)
if s then
local i = 1
return function()
local chunk = string.sub(s, i, i+BLOCKSIZE-1)
i = i + BLOCKSIZE
local chunk = string.sub(s, i, i+_M.BLOCKSIZE-1)
i = i + _M.BLOCKSIZE
if chunk ~= "" then return chunk
else return nil end
end
@@ -135,7 +143,9 @@ function source.rewind(src)
end
end
function source.chain(src, f)
-- chains a source with one or several filter(s)
function source.chain(src, f, ...)
if ... then f=filter.chain(f, ...) end
base.assert(src and f)
local last_in, last_out = "", ""
local state = "feeding"
@@ -186,6 +196,7 @@ end
-- other, as if they were concatenated
-- (thanks to Wim Couwenberg)
function source.cat(...)
local arg = {...}
local src = table.remove(arg, 1)
return function()
while src do
@@ -249,8 +260,13 @@ function sink.error(err)
end
end
-- chains a sink with a filter
function sink.chain(f, snk)
-- chains a sink with one or several filter(s)
function sink.chain(f, snk, ...)
if ... then
local args = { f, snk, ... }
snk = table.remove(args, #args)
f = filter.chain(unpack(args))
end
base.assert(f and snk)
return function(chunk, err)
if chunk ~= "" then
@@ -290,3 +306,4 @@ function pump.all(src, snk, step)
end
end
return _M
+399 -373
View File
@@ -1,7 +1,7 @@
/* code automatically generated by bin2c -- DO NOT EDIT */
{
/* #include'ing this file in a C program is equivalent to calling
if (luaL_loadfile(L,"ltn12.lua")==0) lua_call(L, 0, 0);
if (luaL_loadfile(L,"ltn12.lua")==0) lua_call(L, 0, LUA_MULTRET);
*/
/* ltn12.lua */
static const unsigned char B1[]={
@@ -13,408 +13,434 @@ static const unsigned char B1[]={
117,114, 99,101,115, 44, 32,115,105,110,107,115, 32, 97,110,100, 32,112,117,109,
112,115, 46, 10, 45, 45, 32, 76,117, 97, 83,111, 99,107,101,116, 32,116,111,111,
108,107,105,116, 46, 10, 45, 45, 32, 65,117,116,104,111,114, 58, 32, 68,105,101,
103,111, 32, 78,101,104, 97, 98, 10, 45, 45, 32, 82, 67, 83, 32, 73, 68, 58, 32,
36, 73,100, 58, 32,108,116,110, 49, 50, 46,108,117, 97, 44,118, 32, 49, 46, 51,
49, 32, 50, 48, 48, 54, 47, 48, 52, 47, 48, 51, 32, 48, 52, 58, 52, 53, 58, 52,
50, 32,100,105,101,103,111, 32, 69,120,112, 32, 36, 10, 45, 45, 45, 45, 45, 45,
103,111, 32, 78,101,104, 97, 98, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,114,
101, 32,109,111,100,117,108,101, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,114,101, 32,109,111,100,
117,108,101, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32,115,116,114,105,110,103, 32,
61, 32,114,101,113,117,105,114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,
108,111, 99, 97,108, 32,116, 97, 98,108,101, 32, 61, 32,114,101,113,117,105,114,
101, 40, 34,116, 97, 98,108,101, 34, 41, 10,108,111, 99, 97,108, 32, 98, 97,115,
101, 32, 61, 32, 95, 71, 10,109,111,100,117,108,101, 40, 34,108,116,110, 49, 50,
34, 41, 10, 10,102,105,108,116,101,114, 32, 61, 32,123,125, 10,115,111,117,114,
99,101, 32, 61, 32,123,125, 10,115,105,110,107, 32, 61, 32,123,125, 10,112,117,
109,112, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 50, 48, 52, 56, 32,115,101,101,
109,115, 32,116,111, 32, 98,101, 32, 98,101,116,116,101,114, 32,105,110, 32,119,
105,110,100,111,119,115, 46, 46, 46, 10, 66, 76, 79, 67, 75, 83, 73, 90, 69, 32,
61, 32, 50, 48, 52, 56, 10, 95, 86, 69, 82, 83, 73, 79, 78, 32, 61, 32, 34, 76,
84, 78, 49, 50, 32, 49, 46, 48, 46, 49, 34, 10, 10, 45, 45, 45, 45, 45, 45, 45,
45, 10,108,111, 99, 97,108, 32,115,116,114,105,110,103, 32, 61, 32,114,101,113,
117,105,114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,108,111, 99, 97,108,
32,116, 97, 98,108,101, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,116, 97,
98,108,101, 34, 41, 10,108,111, 99, 97,108, 32,117,110,112, 97, 99,107, 32, 61,
32,117,110,112, 97, 99,107, 32,111,114, 32,116, 97, 98,108,101, 46,117,110,112,
97, 99,107, 10,108,111, 99, 97,108, 32, 98, 97,115,101, 32, 61, 32, 95, 71, 10,
108,111, 99, 97,108, 32, 95, 77, 32, 61, 32,123,125, 10,105,102, 32,109,111,100,
117,108,101, 32,116,104,101,110, 32, 45, 45, 32,104,101,117,114,105,115,116,105,
99, 32,102,111,114, 32,101,120,112,111,114,116,105,110,103, 32, 97, 32,103,108,
111, 98, 97,108, 32,112, 97, 99,107, 97,103,101, 32,116, 97, 98,108,101, 10, 32,
32, 32, 32,108,116,110, 49, 50, 32, 61, 32, 95, 77, 10,101,110,100, 10,108,111,
99, 97,108, 32,102,105,108,116,101,114, 44,115,111,117,114, 99,101, 44,115,105,
110,107, 44,112,117,109,112, 32, 61, 32,123,125, 44,123,125, 44,123,125, 44,123,
125, 10, 10, 95, 77, 46,102,105,108,116,101,114, 32, 61, 32,102,105,108,116,101,
114, 10, 95, 77, 46,115,111,117,114, 99,101, 32, 61, 32,115,111,117,114, 99,101,
10, 95, 77, 46,115,105,110,107, 32, 61, 32,115,105,110,107, 10, 95, 77, 46,112,
117,109,112, 32, 61, 32,112,117,109,112, 10, 10,108,111, 99, 97,108, 32,117,110,
112, 97, 99,107, 32, 61, 32,117,110,112, 97, 99,107, 32,111,114, 32,116, 97, 98,
108,101, 46,117,110,112, 97, 99,107, 10,108,111, 99, 97,108, 32,115,101,108,101,
99,116, 32, 61, 32, 98, 97,115,101, 46,115,101,108,101, 99,116, 10, 10, 45, 45,
32, 50, 48, 52, 56, 32,115,101,101,109,115, 32,116,111, 32, 98,101, 32, 98,101,
116,116,101,114, 32,105,110, 32,119,105,110,100,111,119,115, 46, 46, 46, 10, 95,
77, 46, 66, 76, 79, 67, 75, 83, 73, 90, 69, 32, 61, 32, 50, 48, 52, 56, 10, 95,
77, 46, 95, 86, 69, 82, 83, 73, 79, 78, 32, 61, 32, 34, 76, 84, 78, 49, 50, 32,
49, 46, 48, 46, 51, 34, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 70,105,108,116,101,114,
32,115,116,117,102,102, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 10, 45, 45, 32, 70,105,108,116,101,114, 32,115,116,117,102,
102, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
45, 45, 32,114,101,116,117,114,110,115, 32, 97, 32,104,105,103,104, 32,108,101,
118,101,108, 32,102,105,108,116,101,114, 32,116,104, 97,116, 32, 99,121, 99,108,
101,115, 32, 97, 32,108,111,119, 45,108,101,118,101,108, 32,102,105,108,116,101,
114, 10,102,117,110, 99,116,105,111,110, 32,102,105,108,116,101,114, 46, 99,121,
99,108,101, 40,108,111,119, 44, 32, 99,116,120, 44, 32,101,120,116,114, 97, 41,
10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,114,116, 40,108,111,119,
41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,
110, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99,
97,108, 32,114,101,116, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116, 44, 32,
99,116,120, 32, 61, 32,108,111,119, 40, 99,116,120, 44, 32, 99,104,117,110,107,
44, 32,101,120,116,114, 97, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,
117,114,110, 32,114,101,116, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10,
10, 45, 45, 32, 99,104, 97,105,110,115, 32, 97, 32, 98,117,110, 99,104, 32,111,
102, 32,102,105,108,116,101,114,115, 32,116,111,103,101,116,104,101,114, 10, 45,
45, 32, 40,116,104, 97,110,107,115, 32,116,111, 32, 87,105,109, 32, 67,111,117,
119,101,110, 98,101,114,103, 41, 10,102,117,110, 99,116,105,111,110, 32,102,105,
108,116,101,114, 46, 99,104, 97,105,110, 40, 46, 46, 46, 41, 10, 32, 32, 32, 32,
108,111, 99, 97,108, 32, 97,114,103, 32, 61, 32,123, 46, 46, 46,125, 10, 32, 32,
32, 32,108,111, 99, 97,108, 32,110, 32, 61, 32, 98, 97,115,101, 46,115,101,108,
101, 99,116, 40, 39, 35, 39, 44, 46, 46, 46, 41, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,116,111,112, 44, 32,105,110,100,101,120, 32, 61, 32, 49, 44, 32, 49,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,116,114,121, 32, 61, 32, 34,
34, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,
110, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,
114,121, 32, 61, 32, 99,104,117,110,107, 32, 97,110,100, 32,114,101,116,114,121,
10, 32, 32, 32, 32, 32, 32, 32, 32,119,104,105,108,101, 32,116,114,117,101, 32,
100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,105,110,
100,101,120, 32, 61, 61, 32,116,111,112, 32,116,104,101,110, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 99,104,117,110,107, 32, 61, 32,
97,114,103, 91,105,110,100,101,120, 93, 40, 99,104,117,110,107, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,117,
110,107, 32, 61, 61, 32, 34, 34, 32,111,114, 32,116,111,112, 32, 61, 61, 32,110,
32,116,104,101,110, 32,114,101,116,117,114,110, 32, 99,104,117,110,107, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,105,
102, 32, 99,104,117,110,107, 32,116,104,101,110, 32,105,110,100,101,120, 32, 61,
32,105,110,100,101,120, 32, 43, 32, 49, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116,111,112, 32, 61, 32,116,111,
112, 43, 49, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,105,110,100,101,120, 32, 61, 32,116,111,112, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 99,104,117,110,107, 32, 61, 32, 97,114,103,
91,105,110,100,101,120, 93, 40, 99,104,117,110,107, 32,111,114, 32, 34, 34, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
99,104,117,110,107, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,110,100,
101,120, 32, 61, 32,105,110,100,101,120, 32, 45, 32, 49, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 99,104,117,110,107,
32, 61, 32,114,101,116,114,121, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,108,115,101,105,102, 32, 99,104,117,110,107, 32,116,104,
101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,105,102, 32,105,110,100,101,120, 32, 61, 61, 32,110, 32,116,104,101,
110, 32,114,101,116,117,114,110, 32, 99,104,117,110,107, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,
105,110,100,101,120, 32, 61, 32,105,110,100,101,120, 32, 43, 32, 49, 32,101,110,
100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,
115,101, 32, 98, 97,115,101, 46,101,114,114,111,114, 40, 34,102,105,108,116,101,
114, 32,114,101,116,117,114,110,101,100, 32,105,110, 97,112,112,114,111,112,114,
105, 97,116,101, 32,110,105,108, 34, 41, 32,101,110,100, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,
110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 10, 45, 45, 32,114,101,116,117,114,110,115, 32, 97, 32,104,105,
103,104, 32,108,101,118,101,108, 32,102,105,108,116,101,114, 32,116,104, 97,116,
32, 99,121, 99,108,101,115, 32, 97, 32,108,111,119, 45,108,101,118,101,108, 32,
102,105,108,116,101,114, 10,102,117,110, 99,116,105,111,110, 32,102,105,108,116,
101,114, 46, 99,121, 99,108,101, 40,108,111,119, 44, 32, 99,116,120, 44, 32,101,
120,116,114, 97, 41, 10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,114,
116, 40,108,111,119, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,
110, 99,116,105,111,110, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32,
32, 32,108,111, 99, 97,108, 32,114,101,116, 10, 32, 32, 32, 32, 32, 32, 32, 32,
114,101,116, 44, 32, 99,116,120, 32, 61, 32,108,111,119, 40, 99,116,120, 44, 32,
99,104,117,110,107, 44, 32,101,120,116,114, 97, 41, 10, 32, 32, 32, 32, 32, 32,
32, 32,114,101,116,117,114,110, 32,114,101,116, 10, 32, 32, 32, 32,101,110,100,
10,101,110,100, 10, 10, 45, 45, 32, 99,104, 97,105,110,115, 32, 97, 32, 98,117,
110, 99,104, 32,111,102, 32,102,105,108,116,101,114,115, 32,116,111,103,101,116,
104,101,114, 10, 45, 45, 32, 40,116,104, 97,110,107,115, 32,116,111, 32, 87,105,
109, 32, 67,111,117,119,101,110, 98,101,114,103, 41, 10,102,117,110, 99,116,105,
111,110, 32,102,105,108,116,101,114, 46, 99,104, 97,105,110, 40, 46, 46, 46, 41,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32,110, 32, 61, 32,116, 97, 98,108,101,
46,103,101,116,110, 40, 97,114,103, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108,
32,116,111,112, 44, 32,105,110,100,101,120, 32, 61, 32, 49, 44, 32, 49, 10, 32,
32, 32, 32,108,111, 99, 97,108, 32,114,101,116,114,121, 32, 61, 32, 34, 34, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40,
99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,114,121,
32, 61, 32, 99,104,117,110,107, 32, 97,110,100, 32,114,101,116,114,121, 10, 32,
32, 32, 32, 32, 32, 32, 32,119,104,105,108,101, 32,116,114,117,101, 32,100,111,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,105,110,100,101,
120, 32, 61, 61, 32,116,111,112, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 99,104,117,110,107, 32, 61, 32, 97,114,
103, 91,105,110,100,101,120, 93, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,117,110,107,
32, 61, 61, 32, 34, 34, 32,111,114, 32,116,111,112, 32, 61, 61, 32,110, 32,116,
104,101,110, 32,114,101,116,117,114,110, 32, 99,104,117,110,107, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,105,102, 32,
99,104,117,110,107, 32,116,104,101,110, 32,105,110,100,101,120, 32, 61, 32,105,
110,100,101,120, 32, 43, 32, 49, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116,111,112, 32, 61, 32,116,111,112, 43,
49, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,105,110,100,101,120, 32, 61, 32,116,111,112, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 99,104,117,110,107, 32, 61, 32, 97,114,103, 91,105,
110,100,101,120, 93, 40, 99,104,117,110,107, 32,111,114, 32, 34, 34, 41, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,
117,110,107, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,110,100,101,120,
32, 61, 32,105,110,100,101,120, 32, 45, 32, 49, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 99,104,117,110,107, 32, 61,
32,114,101,116,114,121, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,101,108,115,101,105,102, 32, 99,104,117,110,107, 32,116,104,101,110,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32,105,102, 32,105,110,100,101,120, 32, 61, 61, 32,110, 32,116,104,101,110, 32,
114,101,116,117,114,110, 32, 99,104,117,110,107, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,105,110,
100,101,120, 32, 61, 32,105,110,100,101,120, 32, 43, 32, 49, 32,101,110,100, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,
32, 98, 97,115,101, 46,101,114,114,111,114, 40, 34,102,105,108,116,101,114, 32,
114,101,116,117,114,110,101,100, 32,105,110, 97,112,112,114,111,112,114,105, 97,
116,101, 32,110,105,108, 34, 41, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100,
10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 83,111,117,
114, 99,101, 32,115,116,117,102,102, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 83,111,117,114, 99,
101, 32,115,116,117,102,102, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 10, 45, 45, 32, 99,114,101, 97,116,101, 32, 97,110, 32,101,
109,112,116,121, 32,115,111,117,114, 99,101, 10,108,111, 99, 97,108, 32,102,117,
110, 99,116,105,111,110, 32,101,109,112,116,121, 40, 41, 10, 32, 32, 32, 32,114,
101,116,117,114,110, 32,110,105,108, 10,101,110,100, 10, 10,102,117,110, 99,116,
105,111,110, 32,115,111,117,114, 99,101, 46,101,109,112,116,121, 40, 41, 10, 32,
32, 32, 32,114,101,116,117,114,110, 32,101,109,112,116,121, 10,101,110,100, 10,
10, 45, 45, 32,114,101,116,117,114,110,115, 32, 97, 32,115,111,117,114, 99,101,
32,116,104, 97,116, 32,106,117,115,116, 32,111,117,116,112,117,116,115, 32, 97,
110, 32,101,114,114,111,114, 10,102,117,110, 99,116,105,111,110, 32,115,111,117,
114, 99,101, 46,101,114,114,111,114, 40,101,114,114, 41, 10, 32, 32, 32, 32,114,
101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32,
32, 32, 32, 32, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,114,
10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,114,101,
97,116,101,115, 32, 97, 32,102,105,108,101, 32,115,111,117,114, 99,101, 10,102,
117,110, 99,116,105,111,110, 32,115,111,117,114, 99,101, 46,102,105,108,101, 40,
104, 97,110,100,108,101, 44, 32,105,111, 95,101,114,114, 41, 10, 32, 32, 32, 32,
105,102, 32,104, 97,110,100,108,101, 32,116,104,101,110, 10, 32, 32, 32, 32, 32,
32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,
104,117,110,107, 32, 61, 32,104, 97,110,100,108,101, 58,114,101, 97,100, 40, 66,
76, 79, 67, 75, 83, 73, 90, 69, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,105,102, 32,110,111,116, 32, 99,104,117,110,107, 32,116,104,101,110, 32,
104, 97,110,100,108,101, 58, 99,108,111,115,101, 40, 41, 32,101,110,100, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32, 99,104,
117,110,107, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
101,108,115,101, 32,114,101,116,117,114,110, 32,115,111,117,114, 99,101, 46,101,
114,114,111,114, 40,105,111, 95,101,114,114, 32,111,114, 32, 34,117,110, 97, 98,
108,101, 32,116,111, 32,111,112,101,110, 32,102,105,108,101, 34, 41, 32,101,110,
100, 10,101,110,100, 10, 10, 45, 45, 32,116,117,114,110,115, 32, 97, 32,102, 97,
110, 99,121, 32,115,111,117,114, 99,101, 32,105,110,116,111, 32, 97, 32,115,105,
109,112,108,101, 32,115,111,117,114, 99,101, 10,102,117,110, 99,116,105,111,110,
32,115,111,117,114, 99,101, 46,115,105,109,112,108,105,102,121, 40,115,114, 99,
41, 10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,114,116, 40,115,114,
99, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,
111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,
104,117,110,107, 44, 32,101,114,114, 95,111,114, 95,110,101,119, 32, 61, 32,115,
114, 99, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,114, 99, 32, 61, 32,101,
114,114, 95,111,114, 95,110,101,119, 32,111,114, 32,115,114, 99, 10, 32, 32, 32,
32, 32, 32, 32, 32,105,102, 32,110,111,116, 32, 99,104,117,110,107, 32,116,104,
101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 95,111,
114, 95,110,101,119, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,
101,116,117,114,110, 32, 99,104,117,110,107, 32,101,110,100, 10, 32, 32, 32, 32,
101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,114,101, 97,116,101,115, 32,
115,116,114,105,110,103, 32,115,111,117,114, 99,101, 10,102,117,110, 99,116,105,
111,110, 32,115,111,117,114, 99,101, 46,115,116,114,105,110,103, 40,115, 41, 10,
32, 32, 32, 32,105,102, 32,115, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32,
32, 32,108,111, 99, 97,108, 32,105, 32, 61, 32, 49, 10, 32, 32, 32, 32, 32, 32,
32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 41, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,104,
117,110,107, 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98, 40,115, 44, 32,
105, 44, 32,105, 43, 66, 76, 79, 67, 75, 83, 73, 90, 69, 45, 49, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105, 32, 61, 32,105, 32, 43, 32, 66, 76,
79, 67, 75, 83, 73, 90, 69, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
105,102, 32, 99,104,117,110,107, 32,126, 61, 32, 34, 34, 32,116,104,101,110, 32,
114,101,116,117,114,110, 32, 99,104,117,110,107, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,110,105,108,
32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32,
32,101,108,115,101, 32,114,101,116,117,114,110, 32,115,111,117,114, 99,101, 46,
101,109,112,116,121, 40, 41, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
99,114,101, 97,116,101,115, 32,114,101,119,105,110,100, 97, 98,108,101, 32,115,
111,117,114, 99,101, 10,102,117,110, 99,116,105,111,110, 32,115,111,117,114, 99,
101, 46,114,101,119,105,110,100, 40,115,114, 99, 41, 10, 32, 32, 32, 32, 98, 97,
115,101, 46, 97,115,115,101,114,116, 40,115,114, 99, 41, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32,116, 32, 61, 32,123,125, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32,102,117,110, 99,116,105,111,110, 40, 99,104,117,110,107, 41, 10, 32,
45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 99,114,101, 97,116,101, 32, 97,110,
32,101,109,112,116,121, 32,115,111,117,114, 99,101, 10,108,111, 99, 97,108, 32,
102,117,110, 99,116,105,111,110, 32,101,109,112,116,121, 40, 41, 10, 32, 32, 32,
32,114,101,116,117,114,110, 32,110,105,108, 10,101,110,100, 10, 10,102,117,110,
99,116,105,111,110, 32,115,111,117,114, 99,101, 46,101,109,112,116,121, 40, 41,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32,101,109,112,116,121, 10,101,110,
100, 10, 10, 45, 45, 32,114,101,116,117,114,110,115, 32, 97, 32,115,111,117,114,
99,101, 32,116,104, 97,116, 32,106,117,115,116, 32,111,117,116,112,117,116,115,
32, 97,110, 32,101,114,114,111,114, 10,102,117,110, 99,116,105,111,110, 32,115,
111,117,114, 99,101, 46,101,114,114,111,114, 40,101,114,114, 41, 10, 32, 32, 32,
32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 41, 10, 32,
32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,
114,114, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,
114,101, 97,116,101,115, 32, 97, 32,102,105,108,101, 32,115,111,117,114, 99,101,
10,102,117,110, 99,116,105,111,110, 32,115,111,117,114, 99,101, 46,102,105,108,
101, 40,104, 97,110,100,108,101, 44, 32,105,111, 95,101,114,114, 41, 10, 32, 32,
32, 32,105,102, 32,104, 97,110,100,108,101, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110,
40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108,
32, 99,104,117,110,107, 32, 61, 32,104, 97,110,100,108,101, 58,114,101, 97,100,
40, 95, 77, 46, 66, 76, 79, 67, 75, 83, 73, 90, 69, 41, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32, 99,104,117,110,107, 32,
116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 99,104,117,
110,107, 32, 61, 32,116, 97, 98,108,101, 46,114,101,109,111,118,101, 40,116, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32,
99,104,117,110,107, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,115,114,
99, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,
32,114,101,116,117,114,110, 32, 99,104,117,110,107, 32,101,110,100, 10, 32, 32,
32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,116, 97, 98,108,101, 46,105,110,115,101,114,116, 40,116, 44, 32, 99,
104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32,
32, 32,101,110,100, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
115,111,117,114, 99,101, 46, 99,104, 97,105,110, 40,115,114, 99, 44, 32,102, 41,
10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,114,116, 40,115,114, 99,
32, 97,110,100, 32,102, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,108, 97,
115,116, 95,105,110, 44, 32,108, 97,115,116, 95,111,117,116, 32, 61, 32, 34, 34,
44, 32, 34, 34, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,116, 97,116,101,
32, 61, 32, 34,102,101,101,100,105,110,103, 34, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,101,114,114, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,
110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
110,111,116, 32,108, 97,115,116, 95,111,117,116, 32,116,104,101,110, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 98, 97,115,101, 46,101,114,114,111,114,
40, 39,115,111,117,114, 99,101, 32,105,115, 32,101,109,112,116,121, 33, 39, 44,
32, 50, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
32, 32, 32, 32,119,104,105,108,101, 32,116,114,117,101, 32,100,111, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,115,116, 97,116,101, 32, 61,
61, 32, 34,102,101,101,100,105,110,103, 34, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108, 97,115,116, 95,105,110,
44, 32,101,114,114, 32, 61, 32,115,114, 99, 40, 41, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,101,114,114, 32,116,104,101,
110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 32,101,110,
100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108, 97,
115,116, 95,111,117,116, 32, 61, 32,102, 40,108, 97,115,116, 95,105,110, 41, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,
111,116, 32,108, 97,115,116, 95,111,117,116, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
108, 97,115,116, 95,105,110, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 98, 97,115,
101, 46,101,114,114,111,114, 40, 39,102,105,108,116,101,114, 32,114,101,116,117,
114,110,101,100, 32,105,110, 97,112,112,114,111,112,114,105, 97,116,101, 32,110,
105,108, 39, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110,
32,110,105,108, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,108,115,101,105,102, 32,108, 97,115,116, 95,111,117,116,
32,126, 61, 32, 34, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115,116, 97,116,101, 32, 61, 32,
34,101, 97,116,105,110,103, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,108, 97,115,116, 95,105,110, 32,
116,104,101,110, 32,108, 97,115,116, 95,105,110, 32, 61, 32, 34, 34, 32,101,110,
100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,114,101,116,117,114,110, 32,108, 97,115,116, 95,111,117,116, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108, 97,115,116, 95,111,117,116, 32,
61, 32,102, 40,108, 97,115,116, 95,105,110, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,108, 97,115,116, 95,111,117,116,
32, 61, 61, 32, 34, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,108, 97,115,116, 95,
105,110, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115,116,
97,116,101, 32, 61, 32, 34,102,101,101,100,105,110,103, 34, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,
116,104,101,110, 32,104, 97,110,100,108,101, 58, 99,108,111,115,101, 40, 41, 32,
101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,
114,110, 32, 99,104,117,110,107, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100,
10, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,115,111,117,
114, 99,101, 46,101,114,114,111,114, 40,105,111, 95,101,114,114, 32,111,114, 32,
34,117,110, 97, 98,108,101, 32,116,111, 32,111,112,101,110, 32,102,105,108,101,
34, 41, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,116,117,114,110,115,
32, 97, 32,102, 97,110, 99,121, 32,115,111,117,114, 99,101, 32,105,110,116,111,
32, 97, 32,115,105,109,112,108,101, 32,115,111,117,114, 99,101, 10,102,117,110,
99,116,105,111,110, 32,115,111,117,114, 99,101, 46,115,105,109,112,108,105,102,
121, 40,115,114, 99, 41, 10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,
114,116, 40,115,114, 99, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,
117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111,
99, 97,108, 32, 99,104,117,110,107, 44, 32,101,114,114, 95,111,114, 95,110,101,
119, 32, 61, 32,115,114, 99, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,114,
99, 32, 61, 32,101,114,114, 95,111,114, 95,110,101,119, 32,111,114, 32,115,114,
99, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32, 99,104,117,
110,107, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,
101,114,114, 95,111,114, 95,110,101,119, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,
108,115,101, 32,114,101,116,117,114,110, 32, 99,104,117,110,107, 32,101,110,100,
10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,114,101,
97,116,101,115, 32,115,116,114,105,110,103, 32,115,111,117,114, 99,101, 10,102,
117,110, 99,116,105,111,110, 32,115,111,117,114, 99,101, 46,115,116,114,105,110,
103, 40,115, 41, 10, 32, 32, 32, 32,105,102, 32,115, 32,116,104,101,110, 10, 32,
32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,105, 32, 61, 32, 49, 10, 32,
32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,
111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99,
97,108, 32, 99,104,117,110,107, 32, 61, 32,115,116,114,105,110,103, 46,115,117,
98, 40,115, 44, 32,105, 44, 32,105, 43, 95, 77, 46, 66, 76, 79, 67, 75, 83, 73,
90, 69, 45, 49, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105, 32,
61, 32,105, 32, 43, 32, 95, 77, 46, 66, 76, 79, 67, 75, 83, 73, 90, 69, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,117,110,107, 32,
126, 61, 32, 34, 34, 32,116,104,101,110, 32,114,101,116,117,114,110, 32, 99,104,
117,110,107, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,
32,114,101,116,117,114,110, 32,110,105,108, 32,101,110,100, 10, 32, 32, 32, 32,
32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,
117,114,110, 32,115,111,117,114, 99,101, 46,101,109,112,116,121, 40, 41, 32,101,
110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,114,101, 97,116,101,115, 32,114,
101,119,105,110,100, 97, 98,108,101, 32,115,111,117,114, 99,101, 10,102,117,110,
99,116,105,111,110, 32,115,111,117,114, 99,101, 46,114,101,119,105,110,100, 40,
115,114, 99, 41, 10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,114,116,
40,115,114, 99, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,
123,125, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,
111,110, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102,
32,110,111,116, 32, 99,104,117,110,107, 32,116,104,101,110, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 99,104,117,110,107, 32, 61, 32,116, 97, 98,108,
101, 46,114,101,109,111,118,101, 40,116, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,105,102, 32,110,111,116, 32, 99,104,117,110,107, 32,116,104,101,
110, 32,114,101,116,117,114,110, 32,115,114, 99, 40, 41, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32, 99,
104,117,110,107, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,
101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116, 97, 98,108,101, 46,
105,110,115,101,114,116, 40,116, 44, 32, 99,104,117,110,107, 41, 10, 32, 32, 32,
32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100,
10, 10, 45, 45, 32, 99,104, 97,105,110,115, 32, 97, 32,115,111,117,114, 99,101,
32,119,105,116,104, 32,111,110,101, 32,111,114, 32,115,101,118,101,114, 97,108,
32,102,105,108,116,101,114, 40,115, 41, 10,102,117,110, 99,116,105,111,110, 32,
115,111,117,114, 99,101, 46, 99,104, 97,105,110, 40,115,114, 99, 44, 32,102, 44,
32, 46, 46, 46, 41, 10, 32, 32, 32, 32,105,102, 32, 46, 46, 46, 32,116,104,101,
110, 32,102, 61,102,105,108,116,101,114, 46, 99,104, 97,105,110, 40,102, 44, 32,
46, 46, 46, 41, 32,101,110,100, 10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,
115,101,114,116, 40,115,114, 99, 32, 97,110,100, 32,102, 41, 10, 32, 32, 32, 32,
108,111, 99, 97,108, 32,108, 97,115,116, 95,105,110, 44, 32,108, 97,115,116, 95,
111,117,116, 32, 61, 32, 34, 34, 44, 32, 34, 34, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,115,116, 97,116,101, 32, 61, 32, 34,102,101,101,100,105,110,103, 34,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32,101,114,114, 10, 32, 32, 32, 32,114,
101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32,
32, 32, 32, 32, 32,105,102, 32,110,111,116, 32,108, 97,115,116, 95,111,117,116,
32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 98, 97,
115,101, 46,101,114,114,111,114, 40, 39,115,111,117,114, 99,101, 32,105,115, 32,
101,109,112,116,121, 33, 39, 44, 32, 50, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,119,104,105,108,101, 32,116,114,
117,101, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102,
32,115,116, 97,116,101, 32, 61, 61, 32, 34,102,101,101,100,105,110,103, 34, 32,
116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32,108, 97,115,116, 95,105,110, 44, 32,101,114,114, 32, 61, 32,115,114, 99, 40,
41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102,
32,101,114,114, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108,
44, 32,101,114,114, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,108, 97,115,116, 95,111,117,116, 32, 61, 32,102, 40,108,
97,115,116, 95,105,110, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,105,102, 32,110,111,116, 32,108, 97,115,116, 95,111,117,116, 32,
116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,105,102, 32,108, 97,115,116, 95,105,110, 32,116,104,101,110,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 98, 97,115,101, 46,101,114,114,111,114, 40, 39,102,105,108,
116,101,114, 32,114,101,116,117,114,110,101,100, 32, 34, 34, 39, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,
100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,
115,101,105,102, 32,110,111,116, 32,108, 97,115,116, 95,111,117,116, 32,116,104,
101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,105,102, 32,108, 97,115,116, 95,105,110, 32,116,104,101,110, 10, 32,
116,101,114, 32,114,101,116,117,114,110,101,100, 32,105,110, 97,112,112,114,111,
112,114,105, 97,116,101, 32,110,105,108, 39, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 98, 97,115,101, 46,101,114,114,111,114, 40, 39,102,105,108,116,101,
114, 32,114,101,116,117,114,110,101,100, 32,105,110, 97,112,112,114,111,112,114,
105, 97,116,101, 32,110,105,108, 39, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32,
32, 32,114,101,116,117,114,110, 32,110,105,108, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,105,102, 32,
108, 97,115,116, 95,111,117,116, 32,126, 61, 32, 34, 34, 32,116,104,101,110, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
114,101,116,117,114,110, 32,110,105,108, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,
114,110, 32,108, 97,115,116, 95,111,117,116, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10,
32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,114,101, 97,
116,101,115, 32, 97, 32,115,111,117,114, 99,101, 32,116,104, 97,116, 32,112,114,
111,100,117, 99,101,115, 32, 99,111,110,116,101,110,116,115, 32,111,102, 32,115,
101,118,101,114, 97,108, 32,115,111,117,114, 99,101,115, 44, 32,111,110,101, 32,
97,102,116,101,114, 32,116,104,101, 10, 45, 45, 32,111,116,104,101,114, 44, 32,
97,115, 32,105,102, 32,116,104,101,121, 32,119,101,114,101, 32, 99,111,110, 99,
97,116,101,110, 97,116,101,100, 10, 45, 45, 32, 40,116,104, 97,110,107,115, 32,
116,111, 32, 87,105,109, 32, 67,111,117,119,101,110, 98,101,114,103, 41, 10,102,
117,110, 99,116,105,111,110, 32,115,111,117,114, 99,101, 46, 99, 97,116, 40, 46,
46, 46, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,114, 99, 32, 61, 32,
116, 97, 98,108,101, 46,114,101,109,111,118,101, 40, 97,114,103, 44, 32, 49, 41,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110,
40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,119,104,105,108,101, 32,115,114, 99,
32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,
108, 32, 99,104,117,110,107, 44, 32,101,114,114, 32, 61, 32,115,114, 99, 40, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,117,110,
107, 32,116,104,101,110, 32,114,101,116,117,114,110, 32, 99,104,117,110,107, 32,
101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,101,
114,114, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,
101,114,114, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
115,114, 99, 32, 61, 32,116, 97, 98,108,101, 46,114,101,109,111,118,101, 40, 97,
114,103, 44, 32, 49, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32,
32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 83,105,110,107, 32,115,116,
117,102,102, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 10, 45, 45, 32, 99,114,101, 97,116,101,115, 32, 97, 32,115,105,110,107, 32,
116,104, 97,116, 32,115,116,111,114,101,115, 32,105,110,116,111, 32, 97, 32,116,
97, 98,108,101, 10,102,117,110, 99,116,105,111,110, 32,115,105,110,107, 46,116,
97, 98,108,101, 40,116, 41, 10, 32, 32, 32, 32,116, 32, 61, 32,116, 32,111,114,
32,123,125, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 32, 61, 32,102,117,
110, 99,116,105,111,110, 40, 99,104,117,110,107, 44, 32,101,114,114, 41, 10, 32,
32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,117,110,107, 32,116,104,101,110,
32,116, 97, 98,108,101, 46,105,110,115,101,114,116, 40,116, 44, 32, 99,104,117,
110,107, 41, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,
114,110, 32, 49, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32,102, 44, 32,116, 10,101,110,100, 10, 10, 45, 45, 32,116,117,114,
110,115, 32, 97, 32,102, 97,110, 99,121, 32,115,105,110,107, 32,105,110,116,111,
32, 97, 32,115,105,109,112,108,101, 32,115,105,110,107, 10,102,117,110, 99,116,
105,111,110, 32,115,105,110,107, 46,115,105,109,112,108,105,102,121, 40,115,110,
107, 41, 10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,114,116, 40,115,
110,107, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,
105,111,110, 40, 99,104,117,110,107, 44, 32,101,114,114, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,116, 44, 32,101,114,114, 95,111,
114, 95,110,101,119, 32, 61, 32,115,110,107, 40, 99,104,117,110,107, 44, 32,101,
114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32,114,
101,116, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,
101,114,114, 95,111,114, 95,110,101,119, 32,101,110,100, 10, 32, 32, 32, 32, 32,
32, 32, 32,115,110,107, 32, 61, 32,101,114,114, 95,111,114, 95,110,101,119, 32,
111,114, 32,115,110,107, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,
110, 32, 49, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
99,114,101, 97,116,101,115, 32, 97, 32,102,105,108,101, 32,115,105,110,107, 10,
102,117,110, 99,116,105,111,110, 32,115,105,110,107, 46,102,105,108,101, 40,104,
97,110,100,108,101, 44, 32,105,111, 95,101,114,114, 41, 10, 32, 32, 32, 32,105,
102, 32,104, 97,110,100,108,101, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32,
32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 99,104,
117,110,107, 44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,105,102, 32,110,111,116, 32, 99,104,117,110,107, 32,116,104,101,110, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,104, 97,110,100,
108,101, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,
104, 97,110,100,108,101, 58,119,114,105,116,101, 40, 99,104,117,110,107, 41, 32,
101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
101,108,115,101, 32,114,101,116,117,114,110, 32,115,105,110,107, 46,101,114,114,
111,114, 40,105,111, 95,101,114,114, 32,111,114, 32, 34,117,110, 97, 98,108,101,
32,116,111, 32,111,112,101,110, 32,102,105,108,101, 34, 41, 32,101,110,100, 10,
101,110,100, 10, 10, 45, 45, 32, 99,114,101, 97,116,101,115, 32, 97, 32,115,105,
110,107, 32,116,104, 97,116, 32,100,105,115, 99, 97,114,100,115, 32,100, 97,116,
97, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,110,117,108,
108, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10,101,110,100,
10, 10,102,117,110, 99,116,105,111,110, 32,115,105,110,107, 46,110,117,108,108,
40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,110,117,108,108, 10,101,
110,100, 10, 10, 45, 45, 32, 99,114,101, 97,116,101,115, 32, 97, 32,115,105,110,
107, 32,116,104, 97,116, 32,106,117,115,116, 32,114,101,116,117,114,110,115, 32,
97,110, 32,101,114,114,111,114, 10,102,117,110, 99,116,105,111,110, 32,115,105,
110,107, 46,101,114,114,111,114, 40,101,114,114, 41, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 10,
32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,104, 97,105,
110,115, 32, 97, 32,115,105,110,107, 32,119,105,116,104, 32, 97, 32,102,105,108,
116,101,114, 10,102,117,110, 99,116,105,111,110, 32,115,105,110,107, 46, 99,104,
97,105,110, 40,102, 44, 32,115,110,107, 41, 10, 32, 32, 32, 32, 98, 97,115,101,
46, 97,115,115,101,114,116, 40,102, 32, 97,110,100, 32,115,110,107, 41, 10, 32,
32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 99,
104,117,110,107, 44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,
102, 32, 99,104,117,110,107, 32,126, 61, 32, 34, 34, 32,116,104,101,110, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,102,105,108,
116,101,114,101,100, 32, 61, 32,102, 40, 99,104,117,110,107, 41, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,100,111,110,101, 32,
61, 32, 99,104,117,110,107, 32, 97,110,100, 32, 34, 34, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,119,104,105,108,101, 32,116,114,117,101, 32,100,111,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99,
97,108, 32,114,101,116, 44, 32,115,110,107,101,114,114, 32, 61, 32,115,110,107,
40,102,105,108,116,101,114,101,100, 44, 32,101,114,114, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32,114,
101,116, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,
115,110,107,101,114,114, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,105,102, 32,102,105,108,116,101,114,101,100, 32, 61,
61, 32,100,111,110,101, 32,116,104,101,110, 32,114,101,116,117,114,110, 32, 49,
32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32,102,105,108,116,101,114,101,100, 32, 61, 32,102, 40,100,111,110,101, 41, 10,
115,116, 97,116,101, 32, 61, 32, 34,101, 97,116,105,110,103, 34, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
108, 97,115,116, 95,105,110, 32,116,104,101,110, 32,108, 97,115,116, 95,105,110,
32, 61, 32, 34, 34, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,108, 97,115,
116, 95,111,117,116, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,
115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,
97,115,116, 95,111,117,116, 32, 61, 32,102, 40,108, 97,115,116, 95,105,110, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
108, 97,115,116, 95,111,117,116, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
105,102, 32,108, 97,115,116, 95,105,110, 32, 61, 61, 32, 34, 34, 32,116,104,101,
110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,115,116, 97,116,101, 32, 61, 32, 34,102,101,101,100,105,
110,103, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 98, 97,115,101, 46,101,114,
114,111,114, 40, 39,102,105,108,116,101,114, 32,114,101,116,117,114,110,101,100,
32, 34, 34, 39, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,101,108,115,101,105,102, 32,110,111,116, 32,108, 97,115,
116, 95,111,117,116, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,108, 97,115,116, 95,105,
110, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 98, 97,115,101, 46,101,114,114,111,
114, 40, 39,102,105,108,116,101,114, 32,114,101,116,117,114,110,101,100, 32,105,
110, 97,112,112,114,111,112,114,105, 97,116,101, 32,110,105,108, 39, 41, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,
108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,110,105,108, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,
110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,
108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,114,101,116,117,114,110, 32,108, 97,115,116, 95,111,117,116, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32, 49, 32,101,110,
100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 45, 45, 45,
32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10,
10, 45, 45, 32, 99,114,101, 97,116,101,115, 32, 97, 32,115,111,117,114, 99,101,
32,116,104, 97,116, 32,112,114,111,100,117, 99,101,115, 32, 99,111,110,116,101,
110,116,115, 32,111,102, 32,115,101,118,101,114, 97,108, 32,115,111,117,114, 99,
101,115, 44, 32,111,110,101, 32, 97,102,116,101,114, 32,116,104,101, 10, 45, 45,
32,111,116,104,101,114, 44, 32, 97,115, 32,105,102, 32,116,104,101,121, 32,119,
101,114,101, 32, 99,111,110, 99, 97,116,101,110, 97,116,101,100, 10, 45, 45, 32,
40,116,104, 97,110,107,115, 32,116,111, 32, 87,105,109, 32, 67,111,117,119,101,
110, 98,101,114,103, 41, 10,102,117,110, 99,116,105,111,110, 32,115,111,117,114,
99,101, 46, 99, 97,116, 40, 46, 46, 46, 41, 10, 32, 32, 32, 32,108,111, 99, 97,
108, 32, 97,114,103, 32, 61, 32,123, 46, 46, 46,125, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,115,114, 99, 32, 61, 32,116, 97, 98,108,101, 46,114,101,109,111,
118,101, 40, 97,114,103, 44, 32, 49, 41, 10, 32, 32, 32, 32,114,101,116,117,114,
110, 32,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32,119,104,105,108,101, 32,115,114, 99, 32,100,111, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,104,117,110,107, 44, 32,101,
114,114, 32, 61, 32,115,114, 99, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,105,102, 32, 99,104,117,110,107, 32,116,104,101,110, 32,114,101,116,
117,114,110, 32, 99,104,117,110,107, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,105,102, 32,101,114,114, 32,116,104,101,110, 32,114,101,
116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 32,101,110,100, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115,114, 99, 32, 61, 32,116, 97, 98,108,
101, 46,114,101,109,111,118,101, 40, 97,114,103, 44, 32, 49, 41, 10, 32, 32, 32,
32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100,
10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
45, 45, 32, 83,105,110,107, 32,115,116,117,102,102, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 80,117,109,112,
32,115,116,117,102,102, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 99,114,101, 97,116,
101,115, 32, 97, 32,115,105,110,107, 32,116,104, 97,116, 32,115,116,111,114,101,
115, 32,105,110,116,111, 32, 97, 32,116, 97, 98,108,101, 10,102,117,110, 99,116,
105,111,110, 32,115,105,110,107, 46,116, 97, 98,108,101, 40,116, 41, 10, 32, 32,
32, 32,116, 32, 61, 32,116, 32,111,114, 32,123,125, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,102, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 99,104,117,
110,107, 44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
99,104,117,110,107, 32,116,104,101,110, 32,116, 97, 98,108,101, 46,105,110,115,
101,114,116, 40,116, 44, 32, 99,104,117,110,107, 41, 32,101,110,100, 10, 32, 32,
32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10, 32, 32, 32, 32,101,
110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102, 44, 32,116, 10,101,
110,100, 10, 10, 45, 45, 32,116,117,114,110,115, 32, 97, 32,102, 97,110, 99,121,
32,115,105,110,107, 32,105,110,116,111, 32, 97, 32,115,105,109,112,108,101, 32,
115,105,110,107, 10,102,117,110, 99,116,105,111,110, 32,115,105,110,107, 46,115,
105,109,112,108,105,102,121, 40,115,110,107, 41, 10, 32, 32, 32, 32, 98, 97,115,
101, 46, 97,115,115,101,114,116, 40,115,110,107, 41, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40, 99,104,117,110,107, 44,
32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,
114,101,116, 44, 32,101,114,114, 95,111,114, 95,110,101,119, 32, 61, 32,115,110,
107, 40, 99,104,117,110,107, 44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32,
32, 32,105,102, 32,110,111,116, 32,114,101,116, 32,116,104,101,110, 32,114,101,
116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 95,111,114, 95,110,101,119,
32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,110,107, 32, 61, 32,101,
114,114, 95,111,114, 95,110,101,119, 32,111,114, 32,115,110,107, 10, 32, 32, 32,
32, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10, 32, 32, 32, 32,101,110,
100, 10,101,110,100, 10, 10, 45, 45, 32, 99,114,101, 97,116,101,115, 32, 97, 32,
102,105,108,101, 32,115,105,110,107, 10,102,117,110, 99,116,105,111,110, 32,115,
105,110,107, 46,102,105,108,101, 40,104, 97,110,100,108,101, 44, 32,105,111, 95,
101,114,114, 41, 10, 32, 32, 32, 32,105,102, 32,104, 97,110,100,108,101, 32,116,
104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,
117,110, 99,116,105,111,110, 40, 99,104,117,110,107, 44, 32,101,114,114, 41, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32, 99,
104,117,110,107, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,104, 97,110,100,108,101, 58, 99,108,111,115,101, 40, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,
117,114,110, 32, 49, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,
115,101, 32,114,101,116,117,114,110, 32,104, 97,110,100,108,101, 58,119,114,105,
116,101, 40, 99,104,117,110,107, 41, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32,
32, 32,101,110,100, 10, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,
110, 32,115,105,110,107, 46,101,114,114,111,114, 40,105,111, 95,101,114,114, 32,
111,114, 32, 34,117,110, 97, 98,108,101, 32,116,111, 32,111,112,101,110, 32,102,
105,108,101, 34, 41, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,114,
101, 97,116,101,115, 32, 97, 32,115,105,110,107, 32,116,104, 97,116, 32,100,105,
115, 99, 97,114,100,115, 32,100, 97,116, 97, 10,108,111, 99, 97,108, 32,102,117,
110, 99,116,105,111,110, 32,110,117,108,108, 40, 41, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32, 49, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
32,115,105,110,107, 46,110,117,108,108, 40, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32,110,117,108,108, 10,101,110,100, 10, 10, 45, 45, 32, 99,114,101,
97,116,101,115, 32, 97, 32,115,105,110,107, 32,116,104, 97,116, 32,106,117,115,
116, 32,114,101,116,117,114,110,115, 32, 97,110, 32,101,114,114,111,114, 10,102,
117,110, 99,116,105,111,110, 32,115,105,110,107, 46,101,114,114,111,114, 40,101,
114,114, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,
105,111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110,
32,110,105,108, 44, 32,101,114,114, 10, 32, 32, 32, 32,101,110,100, 10,101,110,
100, 10, 10, 45, 45, 32, 99,104, 97,105,110,115, 32, 97, 32,115,105,110,107, 32,
119,105,116,104, 32,111,110,101, 32,111,114, 32,115,101,118,101,114, 97,108, 32,
102,105,108,116,101,114, 40,115, 41, 10,102,117,110, 99,116,105,111,110, 32,115,
105,110,107, 46, 99,104, 97,105,110, 40,102, 44, 32,115,110,107, 44, 32, 46, 46,
46, 41, 10, 32, 32, 32, 32,105,102, 32, 46, 46, 46, 32,116,104,101,110, 10, 32,
32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32, 97,114,103,115, 32, 61, 32,
123, 32,102, 44, 32,115,110,107, 44, 32, 46, 46, 46, 32,125, 10, 32, 32, 32, 32,
32, 32, 32, 32,115,110,107, 32, 61, 32,116, 97, 98,108,101, 46,114,101,109,111,
118,101, 40, 97,114,103,115, 44, 32, 35, 97,114,103,115, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32,102, 32, 61, 32,102,105,108,116,101,114, 46, 99,104, 97,105,110,
40,117,110,112, 97, 99,107, 40, 97,114,103,115, 41, 41, 10, 32, 32, 32, 32,101,
110,100, 10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,114,116, 40,102,
32, 97,110,100, 32,115,110,107, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110,
32,102,117,110, 99,116,105,111,110, 40, 99,104,117,110,107, 44, 32,101,114,114,
41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,117,110,107, 32,126,
61, 32, 34, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,108,111, 99, 97,108, 32,102,105,108,116,101,114,101,100, 32, 61, 32,102,
40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
108,111, 99, 97,108, 32,100,111,110,101, 32, 61, 32, 99,104,117,110,107, 32, 97,
110,100, 32, 34, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,119,104,
105,108,101, 32,116,114,117,101, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,116, 44, 32,115,
110,107,101,114,114, 32, 61, 32,115,110,107, 40,102,105,108,116,101,114,101,100,
44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,105,102, 32,110,111,116, 32,114,101,116, 32,116,104,101,110, 32,114,
101,116,117,114,110, 32,110,105,108, 44, 32,115,110,107,101,114,114, 32,101,110,
100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102,
32,102,105,108,116,101,114,101,100, 32, 61, 61, 32,100,111,110,101, 32,116,104,
101,110, 32,114,101,116,117,114,110, 32, 49, 32,101,110,100, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,102,105,108,116,101,114,101,100,
32, 61, 32,102, 40,100,111,110,101, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,
114,101,116,117,114,110, 32, 49, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100,
10,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 10, 45, 45, 32,112,117,109,112,115, 32,111,110,101, 32, 99,104,
117,110,107, 32,102,114,111,109, 32,116,104,101, 32,115,111,117,114, 99,101, 32,
116,111, 32,116,104,101, 32,115,105,110,107, 10,102,117,110, 99,116,105,111,110,
32,112,117,109,112, 46,115,116,101,112, 40,115,114, 99, 44, 32,115,110,107, 41,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,104,117,110,107, 44, 32,115,114,
99, 95,101,114,114, 32, 61, 32,115,114, 99, 40, 41, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,114,101,116, 44, 32,115,110,107, 95,101,114,114, 32, 61, 32,115,
110,107, 40, 99,104,117,110,107, 44, 32,115,114, 99, 95,101,114,114, 41, 10, 32,
32, 32, 32,105,102, 32, 99,104,117,110,107, 32, 97,110,100, 32,114,101,116, 32,
116,104,101,110, 32,114,101,116,117,114,110, 32, 49, 10, 32, 32, 32, 32,101,108,
115,101, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,115,114, 99, 95,101,
114,114, 32,111,114, 32,115,110,107, 95,101,114,114, 32,101,110,100, 10,101,110,
100, 10, 10, 45, 45, 32,112,117,109,112,115, 32, 97,108,108, 32,100, 97,116, 97,
32,102,114,111,109, 32, 97, 32,115,111,117,114, 99,101, 32,116,111, 32, 97, 32,
115,105,110,107, 44, 32,117,115,105,110,103, 32, 97, 32,115,116,101,112, 32,102,
117,110, 99,116,105,111,110, 10,102,117,110, 99,116,105,111,110, 32,112,117,109,
112, 46, 97,108,108, 40,115,114, 99, 44, 32,115,110,107, 44, 32,115,116,101,112,
41, 10, 32, 32, 32, 32, 98, 97,115,101, 46, 97,115,115,101,114,116, 40,115,114,
99, 32, 97,110,100, 32,115,110,107, 41, 10, 32, 32, 32, 32,115,116,101,112, 32,
61, 32,115,116,101,112, 32,111,114, 32,112,117,109,112, 46,115,116,101,112, 10,
32, 32, 32, 32,119,104,105,108,101, 32,116,114,117,101, 32,100,111, 10, 32, 32,
32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,116, 44, 32,101,114,114,
32, 61, 32,115,116,101,112, 40,115,114, 99, 44, 32,115,110,107, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32,114,101,116, 32,116,104,101,
110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,101,114,114,
32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,
114, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,
101,116,117,114,110, 32, 49, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,
101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10,
45, 45, 45, 10, 45, 45, 32, 80,117,109,112, 32,115,116,117,102,102, 10, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,112,
117,109,112,115, 32,111,110,101, 32, 99,104,117,110,107, 32,102,114,111,109, 32,
116,104,101, 32,115,111,117,114, 99,101, 32,116,111, 32,116,104,101, 32,115,105,
110,107, 10,102,117,110, 99,116,105,111,110, 32,112,117,109,112, 46,115,116,101,
112, 40,115,114, 99, 44, 32,115,110,107, 41, 10, 32, 32, 32, 32,108,111, 99, 97,
108, 32, 99,104,117,110,107, 44, 32,115,114, 99, 95,101,114,114, 32, 61, 32,115,
114, 99, 40, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,116, 44, 32,
115,110,107, 95,101,114,114, 32, 61, 32,115,110,107, 40, 99,104,117,110,107, 44,
32,115,114, 99, 95,101,114,114, 41, 10, 32, 32, 32, 32,105,102, 32, 99,104,117,
110,107, 32, 97,110,100, 32,114,101,116, 32,116,104,101,110, 32,114,101,116,117,
114,110, 32, 49, 10, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110,
32,110,105,108, 44, 32,115,114, 99, 95,101,114,114, 32,111,114, 32,115,110,107,
95,101,114,114, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,112,117,109,
112,115, 32, 97,108,108, 32,100, 97,116, 97, 32,102,114,111,109, 32, 97, 32,115,
111,117,114, 99,101, 32,116,111, 32, 97, 32,115,105,110,107, 44, 32,117,115,105,
110,103, 32, 97, 32,115,116,101,112, 32,102,117,110, 99,116,105,111,110, 10,102,
117,110, 99,116,105,111,110, 32,112,117,109,112, 46, 97,108,108, 40,115,114, 99,
44, 32,115,110,107, 44, 32,115,116,101,112, 41, 10, 32, 32, 32, 32, 98, 97,115,
101, 46, 97,115,115,101,114,116, 40,115,114, 99, 32, 97,110,100, 32,115,110,107,
41, 10, 32, 32, 32, 32,115,116,101,112, 32, 61, 32,115,116,101,112, 32,111,114,
32,112,117,109,112, 46,115,116,101,112, 10, 32, 32, 32, 32,119,104,105,108,101,
32,116,114,117,101, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99,
97,108, 32,114,101,116, 44, 32,101,114,114, 32, 61, 32,115,116,101,112, 40,115,
114, 99, 44, 32,115,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
110,111,116, 32,114,101,116, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,105,102, 32,101,114,114, 32,116,104,101,110, 32,114,101,116,
117,114,110, 32,110,105,108, 44, 32,101,114,114, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32, 49, 32,101,
110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,101,
110,100, 10,101,110,100, 10, 10,114,101,116,117,114,110, 32, 95, 77, 10,
};
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"ltn12.lua")==0) lua_call(L, 0, 0);
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"ltn12.lua")==0) lua_call(L, 0, LUA_MULTRET);
}
@@ -1,17 +0,0 @@
#ifndef LUA_WRAP_H
#define LUA_WRAP_H
#define LUA_COMPAT_ALL
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#if LUA_VERSION_NUM > 501
# define luaL_reg luaL_Reg
# define luaL_putchar(B, c) luaL_addchar(B, c)
# define luaL_typerror(L, n, t) luax_typerror(L, n, t)
extern int luax_typerror(lua_State *L, int narg, const char *type);
#endif
#endif // LUA_WRAP_H
@@ -10,8 +10,6 @@
* involved in setting up both client and server connections. The provided
* IO routines, however, follow the Lua style, being very similar to the
* standard Lua read and write functions.
*
* RCS ID: $Id: luasocket.c,v 1.53 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
/*=========================================================================*\
@@ -19,10 +17,7 @@
\*=========================================================================*/
#include "lua.h"
#include "lauxlib.h"
#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501)
#include "compat-5.1.h"
#endif
#include "compat.h"
/*=========================================================================*\
* LuaSocket includes
@@ -37,8 +32,6 @@
#include "udp.h"
#include "select.h"
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
/*-------------------------------------------------------------------------*\
* Internal function prototypes
\*-------------------------------------------------------------------------*/
@@ -49,7 +42,7 @@ static int base_open(lua_State *L);
/*-------------------------------------------------------------------------*\
* Modules and functions
\*-------------------------------------------------------------------------*/
static const luaL_reg mod[] = {
static const luaL_Reg mod[] = {
{"auxiliar", auxiliar_open},
{"except", except_open},
{"timeout", timeout_open},
@@ -61,7 +54,7 @@ static const luaL_reg mod[] = {
{NULL, NULL}
};
static luaL_reg func[] = {
static luaL_Reg func[] = {
{"skip", global_skip},
{"__unload", global_unload},
{NULL, NULL}
@@ -71,7 +64,7 @@ static luaL_reg func[] = {
* Skip a few arguments
\*-------------------------------------------------------------------------*/
static int global_skip(lua_State *L) {
int amount = (int) luaL_checknumber(L, 1);
int amount = luaL_checkinteger(L, 1);
int ret = lua_gettop(L) - amount - 1;
return ret >= 0 ? ret : 0;
}
@@ -91,7 +84,8 @@ static int global_unload(lua_State *L) {
static int base_open(lua_State *L) {
if (socket_open()) {
/* export functions (and leave namespace table on top of stack) */
luax_register(L, "socket", func);
lua_newtable(L);
luaL_setfuncs(L, func, 0);
#ifdef LUASOCKET_DEBUG
lua_pushstring(L, "_DEBUG");
lua_pushboolean(L, 1);
@@ -112,7 +106,7 @@ static int base_open(lua_State *L) {
/*-------------------------------------------------------------------------*\
* Initializes all library modules.
\*-------------------------------------------------------------------------*/
int LUASOCKET_API luaopen_socket_core(lua_State *L) {
LUASOCKET_API int luaopen_socket_core(lua_State *L) {
int i;
base_open(L);
for (i = 0; mod[i].name; i++) mod[i].func(L);
@@ -5,17 +5,14 @@
* Networking support for the Lua language
* Diego Nehab
* 9/11/1999
*
* RCS ID: $Id: luasocket.h,v 1.25 2007/06/11 23:44:54 diego Exp $
\*=========================================================================*/
#include "lua.h"
/*-------------------------------------------------------------------------*\
* Current socket library version
\*-------------------------------------------------------------------------*/
#define LUASOCKET_VERSION "LuaSocket 2.0.2"
#define LUASOCKET_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab"
#define LUASOCKET_AUTHORS "Diego Nehab"
#define LUASOCKET_VERSION "LuaSocket 3.0-rc1"
#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2013 Diego Nehab"
/*-------------------------------------------------------------------------*\
* This macro prefixes all exported API functions
@@ -0,0 +1,438 @@
# luasocket src/makefile
#
# Definitions in this section can be overriden on the command line or in the
# environment.
#
# These are equivalent:
#
# export PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw
# make
#
# and
#
# make PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw
# PLAT: linux macosx win32 mingw
# platform to build for
PLAT?=linux
# LUAV: 5.1 5.2
# lua version to build against
LUAV?=5.1
# MYCFLAGS: to be set by user if needed
MYCFLAGS?=
# MYLDFLAGS: to be set by user if needed
MYLDFLAGS?=
# DEBUG: NODEBUG DEBUG
# debug mode causes luasocket to collect and returns timing information useful
# for testing and debugging luasocket itself
DEBUG?=NODEBUG
# where lua headers are found for macosx builds
# LUAINC_macosx:
# /opt/local/include
LUAINC_macosx_base?=/opt/local/include
LUAINC_macosx?=$(LUAINC_macosx_base)/lua/$(LUAV)
# FIXME default should this default to fink or to macports?
# What happens when more than one Lua version is installed?
LUAPREFIX_macosx?=/opt/local
CDIR_macosx?=lib/lua/$(LUAV)
LDIR_macosx?=share/lua/$(LUAV)
# LUAINC_linux:
# /usr/include/lua$(LUAV)
# /usr/local/include
# /usr/local/include/lua$(LUAV)
# where lua headers are found for linux builds
LUAINC_linux_base?=/usr/include
LUAINC_linux?=$(LUAINC_linux_base)/lua/$(LUAV)
LUAPREFIX_linux?=/usr/local
CDIR_linux?=lib/lua/$(LUAV)
LDIR_linux?=share/lua/$(LUAV)
# LUAINC_freebsd:
# /usr/local/include/lua$(LUAV)
# where lua headers are found for freebsd builds
LUAINC_freebsd_base?=/usr/local/include/
LUAINC_freebsd?=$(LUAINC_freebsd_base)/lua$(LUAV)
LUAPREFIX_freebsd?=/usr/local/
CDIR_freebsd?=lib/lua/$(LUAV)
LDIR_freebsd?=share/lua/$(LUAV)
# where lua headers are found for mingw builds
# LUAINC_mingw:
# /opt/local/include
LUAINC_mingw_base?=/usr/include
LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUAV)
LUALIB_mingw_base?=/usr/bin
LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUAV)/lua$(subst .,,$(LUAV)).dll
LUAPREFIX_mingw?=/usr
CDIR_mingw?=lua/$(LUAV)
LDIR_mingw?=lua/$(LUAV)/lua
# LUAINC_win32:
# LUALIB_win32:
# where lua headers and libraries are found for win32 builds
LUAPREFIX_win32?=
LUAINC_win32?=$(LUAPREFIX_win32)/include/lua/$(LUAV)
PLATFORM_win32?=Release
CDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)
LDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)/lua
LUALIB_win32?=$(LUAPREFIX_win32)/lib/lua/$(LUAV)/$(PLATFORM_win32)
LUALIBNAME_win32?=lua$(subst .,,$(LUAV)).lib
# LUAINC_solaris:
LUAINC_solaris_base?=/usr/include
LUAINC_solaris?=$(LUAINC_solaris_base)/lua/$(LUAV)
LUAPREFIX_solaris?=/usr/local
CDIR_solaris?=lib/lua/$(LUAV)
LDIR_solaris?=share/lua/$(LUAV)
# prefix: /usr/local /usr /opt/local /sw
# the top of the default install tree
prefix?=$(LUAPREFIX_$(PLAT))
CDIR?=$(CDIR_$(PLAT))
LDIR?=$(LDIR_$(PLAT))
# DESTDIR: (no default)
# used by package managers to install into a temporary destination
DESTDIR=
#------
# Definitions below can be overridden on the make command line, but
# shouldn't have to be.
#------
# Install directories
#
INSTALL_DIR=install -d
INSTALL_DATA=install -m644
INSTALL_EXEC=install
INSTALL_TOP=$(DESTDIR)$(prefix)
INSTALL_TOP_LDIR=$(INSTALL_TOP)/$(LDIR)
INSTALL_TOP_CDIR=$(INSTALL_TOP)/$(CDIR)
INSTALL_SOCKET_LDIR=$(INSTALL_TOP_LDIR)/socket
INSTALL_SOCKET_CDIR=$(INSTALL_TOP_CDIR)/socket
INSTALL_MIME_LDIR=$(INSTALL_TOP_LDIR)/mime
INSTALL_MIME_CDIR=$(INSTALL_TOP_CDIR)/mime
print:
@echo PLAT=$(PLAT)
@echo LUAV=$(LUAV)
@echo DEBUG=$(DEBUG)
@echo prefix=$(prefix)
@echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT))
@echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT))
@echo INSTALL_TOP_CDIR=$(INSTALL_TOP_CDIR)
@echo INSTALL_TOP_LDIR=$(INSTALL_TOP_LDIR)
@echo CFLAGS=$(CFLAGS)
@echo LDFLAGS=$(LDFLAGS)
#------
# Supported platforms
#
PLATS= macosx linux win32 mingw solaris
#------
# Compiler and linker settings
# for Mac OS X
SO_macosx=so
O_macosx=o
CC_macosx=gcc
DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN \
-DLUASOCKET_API='__attribute__((visibility("default")))' \
-DUNIX_API='__attribute__((visibility("default")))' \
-DMIME_API='__attribute__((visibility("default")))'
CFLAGS_macosx= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \
-fvisibility=hidden
LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o
LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
SOCKET_macosx=usocket.o
#------
# Compiler and linker settings
# for Linux
SO_linux=so
O_linux=o
CC_linux=gcc
DEF_linux=-DLUASOCKET_$(DEBUG) \
-DLUASOCKET_API='__attribute__((visibility("default")))' \
-DUNIX_API='__attribute__((visibility("default")))' \
-DMIME_API='__attribute__((visibility("default")))'
CFLAGS_linux= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \
-Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden
LDFLAGS_linux=-O -shared -fpic -o
LD_linux=gcc
SOCKET_linux=usocket.o
#------
# Compiler and linker settings
# for FreeBSD
SO_freebsd=so
O_freebsd=o
CC_freebsd=gcc
DEF_freebsd=-DLUASOCKET_$(DEBUG) \
-DLUASOCKET_API='__attribute__((visibility("default")))' \
-DUNIX_API='__attribute__((visibility("default")))' \
-DMIME_API='__attribute__((visibility("default")))'
CFLAGS_freebsd= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \
-Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden
LDFLAGS_freebsd=-O -shared -fpic -o
LD_freebsd=gcc
SOCKET_freebsd=usocket.o
#------
# Compiler and linker settings
# for Solaris
SO_solaris=so
O_solaris=o
CC_solaris=gcc
DEF_solaris=-DLUASOCKET_$(DEBUG) \
-DLUASOCKET_API='__attribute__((visibility("default")))' \
-DUNIX_API='__attribute__((visibility("default")))' \
-DMIME_API='__attribute__((visibility("default")))'
CFLAGS_solaris=-I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \
-Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden
LDFLAGS_solaris=-lnsl -lsocket -lresolv -O -shared -fpic -o
LD_solaris=gcc
SOCKET_solaris=usocket.o
#------
# Compiler and linker settings
# for MingW
SO_mingw=dll
O_mingw=o
CC_mingw=gcc
DEF_mingw= -DLUASOCKET_INET_PTON -DLUASOCKET_$(DEBUG) \
-DWINVER=0x0501 -DLUASOCKET_API='__declspec(dllexport)' \
-DMIME_API='__declspec(dllexport)'
CFLAGS_mingw= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \
-fvisibility=hidden
LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o
LD_mingw=gcc
SOCKET_mingw=wsocket.o
#------
# Compiler and linker settings
# for Win32
SO_win32=dll
O_win32=obj
CC_win32=cl
DEF_win32= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \
//D "LUASOCKET_API=__declspec(dllexport)" //D "_CRT_SECURE_NO_WARNINGS" \
//D "_WINDLL" //D "MIME_API=__declspec(dllexport)" \
//D "LUASOCKET_$(DEBUG)"
CFLAGS_win32=//I "$(LUAINC)" $(DEF) //O2 //Ot //MD //W3 //nologo
LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \
//MANIFEST //MANIFESTFILE:"intermediate.manifest" \
//MANIFESTUAC:"level='asInvoker' uiAccess='false'" \
//SUBSYSTEM:WINDOWS //OPT:REF //OPT:ICF //DYNAMICBASE:NO \
//MACHINE:X86 /LIBPATH:"$(shell cmd //c echo $(LUALIB))" \
$(LUALIBNAME_win32) ws2_32.lib //OUT:
LD_win32=cl
SOCKET_win32=wsocket.obj
.SUFFIXES: .obj
.c.obj:
$(CC) $(CFLAGS) //Fo"$@" //c $<
#------
# Output file names
#
SO=$(SO_$(PLAT))
O=$(O_$(PLAT))
SOCKET_V=3.0-rc1
MIME_V=1.0.3
SOCKET_SO=socket-$(SOCKET_V).$(SO)
MIME_SO=mime-$(MIME_V).$(SO)
UNIX_SO=unix.$(SO)
SERIAL_SO=serial.$(SO)
SOCKET=$(SOCKET_$(PLAT))
#------
# Settings selected for platform
#
CC=$(CC_$(PLAT))
DEF=$(DEF_$(PLAT))
CFLAGS=$(MYCFLAGS) $(CFLAGS_$(PLAT))
LDFLAGS=$(MYLDFLAGS) $(LDFLAGS_$(PLAT))
LD=$(LD_$(PLAT))
LUAINC= $(LUAINC_$(PLAT))
LUALIB= $(LUALIB_$(PLAT))
#------
# Modules belonging to socket-core
#
SOCKET_OBJS= \
luasocket.$(O) \
timeout.$(O) \
buffer.$(O) \
io.$(O) \
auxiliar.$(O) \
compat.$(O) \
options.$(O) \
inet.$(O) \
$(SOCKET) \
except.$(O) \
select.$(O) \
tcp.$(O) \
udp.$(O)
#------
# Modules belonging mime-core
#
MIME_OBJS= \
mime.$(O) \
compat.$(O)
#------
# Modules belonging unix (local domain sockets)
#
UNIX_OBJS=\
buffer.$(O) \
auxiliar.$(O) \
options.$(O) \
timeout.$(O) \
io.$(O) \
usocket.$(O) \
unixtcp.$(O) \
unixudp.$(O) \
compat.$(O) \
unix.$(O)
#------
# Modules belonging to serial (device streams)
#
SERIAL_OBJS=\
buffer.$(O) \
auxiliar.$(O) \
options.$(O) \
timeout.$(O) \
io.$(O) \
usocket.$(O) \
serial.$(O)
#------
# Files to install
#
TO_SOCKET_LDIR= \
http.lua \
url.lua \
tp.lua \
ftp.lua \
headers.lua \
smtp.lua
TO_TOP_LDIR= \
ltn12.lua \
socket.lua \
mime.lua
#------
# Targets
#
default: $(PLAT)
freebsd:
$(MAKE) all-unix PLAT=freebsd
macosx:
$(MAKE) all-unix PLAT=macosx
win32:
$(MAKE) all PLAT=win32
linux:
$(MAKE) all-unix PLAT=linux
mingw:
$(MAKE) all PLAT=mingw
solaris:
$(MAKE) all-unix PLAT=solaris
none:
@echo "Please run"
@echo " make PLATFORM"
@echo "where PLATFORM is one of these:"
@echo " $(PLATS)"
all: $(SOCKET_SO) $(MIME_SO)
$(SOCKET_SO): $(SOCKET_OBJS)
$(LD) $(SOCKET_OBJS) $(LDFLAGS)$@
$(MIME_SO): $(MIME_OBJS)
$(LD) $(MIME_OBJS) $(LDFLAGS)$@
all-unix: all $(UNIX_SO) $(SERIAL_SO)
$(UNIX_SO): $(UNIX_OBJS)
$(LD) $(UNIX_OBJS) $(LDFLAGS)$@
$(SERIAL_SO): $(SERIAL_OBJS)
$(LD) $(SERIAL_OBJS) $(LDFLAGS)$@
install:
$(INSTALL_DIR) $(INSTALL_TOP_LDIR)
$(INSTALL_DATA) $(TO_TOP_LDIR) $(INSTALL_TOP_LDIR)
$(INSTALL_DIR) $(INSTALL_SOCKET_LDIR)
$(INSTALL_DATA) $(TO_SOCKET_LDIR) $(INSTALL_SOCKET_LDIR)
$(INSTALL_DIR) $(INSTALL_SOCKET_CDIR)
$(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_CDIR)/core.$(SO)
$(INSTALL_DIR) $(INSTALL_MIME_CDIR)
$(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_CDIR)/core.$(SO)
install-unix: install
$(INSTALL_EXEC) $(UNIX_SO) $(INSTALL_SOCKET_CDIR)/$(UNIX_SO)
$(INSTALL_EXEC) $(SERIAL_SO) $(INSTALL_SOCKET_CDIR)/$(SERIAL_SO)
local:
$(MAKE) install INSTALL_TOP_CDIR=.. INSTALL_TOP_LDIR=..
clean:
rm -f $(SOCKET_SO) $(SOCKET_OBJS) $(SERIAL_OBJS)
rm -f $(MIME_SO) $(UNIX_SO) $(SERIAL_SO) $(MIME_OBJS) $(UNIX_OBJS)
.PHONY: all $(PLATS) default clean echo none
#------
# List of dependencies
#
compat.$(O): compat.c compat.h
auxiliar.$(O): auxiliar.c auxiliar.h
buffer.$(O): buffer.c buffer.h io.h timeout.h
except.$(O): except.c except.h
inet.$(O): inet.c inet.h socket.h io.h timeout.h usocket.h
io.$(O): io.c io.h timeout.h
luasocket.$(O): luasocket.c luasocket.h auxiliar.h except.h \
timeout.h buffer.h io.h inet.h socket.h usocket.h tcp.h \
udp.h select.h
mime.$(O): mime.c mime.h
options.$(O): options.c auxiliar.h options.h socket.h io.h \
timeout.h usocket.h inet.h
select.$(O): select.c socket.h io.h timeout.h usocket.h select.h
serial.$(O): serial.c auxiliar.h socket.h io.h timeout.h usocket.h \
options.h unix.h buffer.h
tcp.$(O): tcp.c auxiliar.h socket.h io.h timeout.h usocket.h \
inet.h options.h tcp.h buffer.h
timeout.$(O): timeout.c auxiliar.h timeout.h
udp.$(O): udp.c auxiliar.h socket.h io.h timeout.h usocket.h \
inet.h options.h udp.h
unix.$(O): unix.c auxiliar.h socket.h io.h timeout.h usocket.h \
options.h unix.h buffer.h
usocket.$(O): usocket.c socket.h io.h timeout.h usocket.h
wsocket.$(O): wsocket.c socket.h io.h timeout.h usocket.h
@@ -0,0 +1,92 @@
local _M = {}
if module then
mbox = _M
end
function _M.split_message(message_s)
local message = {}
message_s = string.gsub(message_s, "\r\n", "\n")
string.gsub(message_s, "^(.-\n)\n", function (h) message.headers = h end)
string.gsub(message_s, "^.-\n\n(.*)", function (b) message.body = b end)
if not message.body then
string.gsub(message_s, "^\n(.*)", function (b) message.body = b end)
end
if not message.headers and not message.body then
message.headers = message_s
end
return message.headers or "", message.body or ""
end
function _M.split_headers(headers_s)
local headers = {}
headers_s = string.gsub(headers_s, "\r\n", "\n")
headers_s = string.gsub(headers_s, "\n[ ]+", " ")
string.gsub("\n" .. headers_s, "\n([^\n]+)", function (h) table.insert(headers, h) end)
return headers
end
function _M.parse_header(header_s)
header_s = string.gsub(header_s, "\n[ ]+", " ")
header_s = string.gsub(header_s, "\n+", "")
local _, __, name, value = string.find(header_s, "([^%s:]-):%s*(.*)")
return name, value
end
function _M.parse_headers(headers_s)
local headers_t = _M.split_headers(headers_s)
local headers = {}
for i = 1, #headers_t do
local name, value = _M.parse_header(headers_t[i])
if name then
name = string.lower(name)
if headers[name] then
headers[name] = headers[name] .. ", " .. value
else headers[name] = value end
end
end
return headers
end
function _M.parse_from(from)
local _, __, name, address = string.find(from, "^%s*(.-)%s*%<(.-)%>")
if not address then
_, __, address = string.find(from, "%s*(.+)%s*")
end
name = name or ""
address = address or ""
if name == "" then name = address end
name = string.gsub(name, '"', "")
return name, address
end
function _M.split_mbox(mbox_s)
local mbox = {}
mbox_s = string.gsub(mbox_s, "\r\n", "\n") .."\n\nFrom \n"
local nj, i, j = 1, 1, 1
while 1 do
i, nj = string.find(mbox_s, "\n\nFrom .-\n", j)
if not i then break end
local message = string.sub(mbox_s, j, i-1)
table.insert(mbox, message)
j = nj+1
end
return mbox
end
function _M.parse(mbox_s)
local mbox = _M.split_mbox(mbox_s)
for i = 1, #mbox do
mbox[i] = _M.parse_message(mbox[i])
end
return mbox
end
function _M.parse_message(message_s)
local message = {}
message.headers, message.body = _M.split_message(message_s)
message.headers = _M.parse_headers(message.headers)
return message
end
return _M
@@ -0,0 +1,144 @@
/* code automatically generated by bin2c -- DO NOT EDIT */
{
/* #include'ing this file in a C program is equivalent to calling
if (luaL_loadfile(L,"mbox.lua")==0) lua_call(L, 0, LUA_MULTRET);
*/
/* mbox.lua */
static const unsigned char B1[]={
108,111, 99, 97,108, 32, 95, 77, 32, 61, 32,123,125, 10, 10,105,102, 32,109,111,
100,117,108,101, 32,116,104,101,110, 10, 32, 32, 32, 32,109, 98,111,120, 32, 61,
32, 95, 77, 10,101,110,100, 32, 10, 10,102,117,110, 99,116,105,111,110, 32, 95,
77, 46,115,112,108,105,116, 95,109,101,115,115, 97,103,101, 40,109,101,115,115,
97,103,101, 95,115, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,109,101,115,
115, 97,103,101, 32, 61, 32,123,125, 10, 32, 32, 32, 32,109,101,115,115, 97,103,
101, 95,115, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,109,101,
115,115, 97,103,101, 95,115, 44, 32, 34, 92,114, 92,110, 34, 44, 32, 34, 92,110,
34, 41, 10, 32, 32, 32, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,109,
101,115,115, 97,103,101, 95,115, 44, 32, 34, 94, 40, 46, 45, 92,110, 41, 92,110,
34, 44, 32,102,117,110, 99,116,105,111,110, 32, 40,104, 41, 32,109,101,115,115,
97,103,101, 46,104,101, 97,100,101,114,115, 32, 61, 32,104, 32,101,110,100, 41,
10, 32, 32, 32, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,109,101,115,
115, 97,103,101, 95,115, 44, 32, 34, 94, 46, 45, 92,110, 92,110, 40, 46, 42, 41,
34, 44, 32,102,117,110, 99,116,105,111,110, 32, 40, 98, 41, 32,109,101,115,115,
97,103,101, 46, 98,111,100,121, 32, 61, 32, 98, 32,101,110,100, 41, 10, 32, 32,
32, 32,105,102, 32,110,111,116, 32,109,101,115,115, 97,103,101, 46, 98,111,100,
121, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,116,114,105,110,
103, 46,103,115,117, 98, 40,109,101,115,115, 97,103,101, 95,115, 44, 32, 34, 94,
92,110, 40, 46, 42, 41, 34, 44, 32,102,117,110, 99,116,105,111,110, 32, 40, 98,
41, 32,109,101,115,115, 97,103,101, 46, 98,111,100,121, 32, 61, 32, 98, 32,101,
110,100, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,105,102, 32,110,
111,116, 32,109,101,115,115, 97,103,101, 46,104,101, 97,100,101,114,115, 32, 97,
110,100, 32,110,111,116, 32,109,101,115,115, 97,103,101, 46, 98,111,100,121, 32,
116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,109,101,115,115, 97,103,101,
46,104,101, 97,100,101,114,115, 32, 61, 32,109,101,115,115, 97,103,101, 95,115,
10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
109,101,115,115, 97,103,101, 46,104,101, 97,100,101,114,115, 32,111,114, 32, 34,
34, 44, 32,109,101,115,115, 97,103,101, 46, 98,111,100,121, 32,111,114, 32, 34,
34, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, 95, 77, 46,115,
112,108,105,116, 95,104,101, 97,100,101,114,115, 40,104,101, 97,100,101,114,115,
95,115, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,104,101, 97,100,101,114,
115, 32, 61, 32,123,125, 10, 32, 32, 32, 32,104,101, 97,100,101,114,115, 95,115,
32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,104,101, 97,100,101,
114,115, 95,115, 44, 32, 34, 92,114, 92,110, 34, 44, 32, 34, 92,110, 34, 41, 10,
32, 32, 32, 32,104,101, 97,100,101,114,115, 95,115, 32, 61, 32,115,116,114,105,
110,103, 46,103,115,117, 98, 40,104,101, 97,100,101,114,115, 95,115, 44, 32, 34,
92,110, 91, 32, 93, 43, 34, 44, 32, 34, 32, 34, 41, 10, 32, 32, 32, 32,115,116,
114,105,110,103, 46,103,115,117, 98, 40, 34, 92,110, 34, 32, 46, 46, 32,104,101,
97,100,101,114,115, 95,115, 44, 32, 34, 92,110, 40, 91, 94, 92,110, 93, 43, 41,
34, 44, 32,102,117,110, 99,116,105,111,110, 32, 40,104, 41, 32,116, 97, 98,108,
101, 46,105,110,115,101,114,116, 40,104,101, 97,100,101,114,115, 44, 32,104, 41,
32,101,110,100, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,104,101, 97,
100,101,114,115, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, 95,
77, 46,112, 97,114,115,101, 95,104,101, 97,100,101,114, 40,104,101, 97,100,101,
114, 95,115, 41, 10, 32, 32, 32, 32,104,101, 97,100,101,114, 95,115, 32, 61, 32,
115,116,114,105,110,103, 46,103,115,117, 98, 40,104,101, 97,100,101,114, 95,115,
44, 32, 34, 92,110, 91, 32, 93, 43, 34, 44, 32, 34, 32, 34, 41, 10, 32, 32, 32,
32,104,101, 97,100,101,114, 95,115, 32, 61, 32,115,116,114,105,110,103, 46,103,
115,117, 98, 40,104,101, 97,100,101,114, 95,115, 44, 32, 34, 92,110, 43, 34, 44,
32, 34, 34, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 95, 44, 32, 95, 95,
44, 32,110, 97,109,101, 44, 32,118, 97,108,117,101, 32, 61, 32,115,116,114,105,
110,103, 46,102,105,110,100, 40,104,101, 97,100,101,114, 95,115, 44, 32, 34, 40,
91, 94, 37,115, 58, 93, 45, 41, 58, 37,115, 42, 40, 46, 42, 41, 34, 41, 10, 32,
32, 32, 32,114,101,116,117,114,110, 32,110, 97,109,101, 44, 32,118, 97,108,117,
101, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, 95, 77, 46,112,
97,114,115,101, 95,104,101, 97,100,101,114,115, 40,104,101, 97,100,101,114,115,
95,115, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,104,101, 97,100,101,114,
115, 95,116, 32, 61, 32, 95, 77, 46,115,112,108,105,116, 95,104,101, 97,100,101,
114,115, 40,104,101, 97,100,101,114,115, 95,115, 41, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,104,101, 97,100,101,114,115, 32, 61, 32,123,125, 10, 32, 32, 32,
32,102,111,114, 32,105, 32, 61, 32, 49, 44, 32, 35,104,101, 97,100,101,114,115,
95,116, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,
110, 97,109,101, 44, 32,118, 97,108,117,101, 32, 61, 32, 95, 77, 46,112, 97,114,
115,101, 95,104,101, 97,100,101,114, 40,104,101, 97,100,101,114,115, 95,116, 91,
105, 93, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110, 97,109,101, 32,
116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,110, 97,109,
101, 32, 61, 32,115,116,114,105,110,103, 46,108,111,119,101,114, 40,110, 97,109,
101, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,104,101,
97,100,101,114,115, 91,110, 97,109,101, 93, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,104,101, 97,100,101,114,115,
91,110, 97,109,101, 93, 32, 61, 32,104,101, 97,100,101,114,115, 91,110, 97,109,
101, 93, 32, 46, 46, 32, 34, 44, 32, 34, 32, 46, 46, 32,118, 97,108,117,101, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,104,101, 97,
100,101,114,115, 91,110, 97,109,101, 93, 32, 61, 32,118, 97,108,117,101, 32,101,
110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,101,
110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,104,101, 97,100,101,114,
115, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32, 95, 77, 46,112,
97,114,115,101, 95,102,114,111,109, 40,102,114,111,109, 41, 10, 32, 32, 32, 32,
108,111, 99, 97,108, 32, 95, 44, 32, 95, 95, 44, 32,110, 97,109,101, 44, 32, 97,
100,100,114,101,115,115, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100,
40,102,114,111,109, 44, 32, 34, 94, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 37,
60, 40, 46, 45, 41, 37, 62, 34, 41, 10, 32, 32, 32, 32,105,102, 32,110,111,116,
32, 97,100,100,114,101,115,115, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32,
32, 32, 95, 44, 32, 95, 95, 44, 32, 97,100,100,114,101,115,115, 32, 61, 32,115,
116,114,105,110,103, 46,102,105,110,100, 40,102,114,111,109, 44, 32, 34, 37,115,
42, 40, 46, 43, 41, 37,115, 42, 34, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32,
32, 32, 32,110, 97,109,101, 32, 61, 32,110, 97,109,101, 32,111,114, 32, 34, 34,
10, 32, 32, 32, 32, 97,100,100,114,101,115,115, 32, 61, 32, 97,100,100,114,101,
115,115, 32,111,114, 32, 34, 34, 10, 32, 32, 32, 32,105,102, 32,110, 97,109,101,
32, 61, 61, 32, 34, 34, 32,116,104,101,110, 32,110, 97,109,101, 32, 61, 32, 97,
100,100,114,101,115,115, 32,101,110,100, 10, 32, 32, 32, 32,110, 97,109,101, 32,
61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,110, 97,109,101, 44, 32,
39, 34, 39, 44, 32, 34, 34, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
110, 97,109,101, 44, 32, 97,100,100,114,101,115,115, 10,101,110,100, 10, 10,102,
117,110, 99,116,105,111,110, 32, 95, 77, 46,115,112,108,105,116, 95,109, 98,111,
120, 40,109, 98,111,120, 95,115, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,
109, 98,111,120, 32, 61, 32,123,125, 10, 32, 32, 32, 32,109, 98,111,120, 95,115,
32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,109, 98,111,120, 95,
115, 44, 32, 34, 92,114, 92,110, 34, 44, 32, 34, 92,110, 34, 41, 32, 46, 46, 34,
92,110, 92,110, 70,114,111,109, 32, 92,110, 34, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,110,106, 44, 32,105, 44, 32,106, 32, 61, 32, 49, 44, 32, 49, 44, 32,
49, 10, 32, 32, 32, 32,119,104,105,108,101, 32, 49, 32,100,111, 10, 32, 32, 32,
32, 32, 32, 32, 32,105, 44, 32,110,106, 32, 61, 32,115,116,114,105,110,103, 46,
102,105,110,100, 40,109, 98,111,120, 95,115, 44, 32, 34, 92,110, 92,110, 70,114,
111,109, 32, 46, 45, 92,110, 34, 44, 32,106, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32,105,102, 32,110,111,116, 32,105, 32,116,104,101,110, 32, 98,114,101, 97,107,
32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,109,
101,115,115, 97,103,101, 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98, 40,
109, 98,111,120, 95,115, 44, 32,106, 44, 32,105, 45, 49, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32,116, 97, 98,108,101, 46,105,110,115,101,114,116, 40,109, 98,111,
120, 44, 32,109,101,115,115, 97,103,101, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
106, 32, 61, 32,110,106, 43, 49, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32,
32,114,101,116,117,114,110, 32,109, 98,111,120, 10,101,110,100, 10, 10,102,117,
110, 99,116,105,111,110, 32, 95, 77, 46,112, 97,114,115,101, 40,109, 98,111,120,
95,115, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,109, 98,111,120, 32, 61,
32, 95, 77, 46,115,112,108,105,116, 95,109, 98,111,120, 40,109, 98,111,120, 95,
115, 41, 10, 32, 32, 32, 32,102,111,114, 32,105, 32, 61, 32, 49, 44, 32, 35,109,
98,111,120, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32,109, 98,111,120, 91,
105, 93, 32, 61, 32, 95, 77, 46,112, 97,114,115,101, 95,109,101,115,115, 97,103,
101, 40,109, 98,111,120, 91,105, 93, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32,
32, 32, 32,114,101,116,117,114,110, 32,109, 98,111,120, 10,101,110,100, 10, 10,
102,117,110, 99,116,105,111,110, 32, 95, 77, 46,112, 97,114,115,101, 95,109,101,
115,115, 97,103,101, 40,109,101,115,115, 97,103,101, 95,115, 41, 10, 32, 32, 32,
32,108,111, 99, 97,108, 32,109,101,115,115, 97,103,101, 32, 61, 32,123,125, 10,
32, 32, 32, 32,109,101,115,115, 97,103,101, 46,104,101, 97,100,101,114,115, 44,
32,109,101,115,115, 97,103,101, 46, 98,111,100,121, 32, 61, 32, 95, 77, 46,115,
112,108,105,116, 95,109,101,115,115, 97,103,101, 40,109,101,115,115, 97,103,101,
95,115, 41, 10, 32, 32, 32, 32,109,101,115,115, 97,103,101, 46,104,101, 97,100,
101,114,115, 32, 61, 32, 95, 77, 46,112, 97,114,115,101, 95,104,101, 97,100,101,
114,115, 40,109,101,115,115, 97,103,101, 46,104,101, 97,100,101,114,115, 41, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32,109,101,115,115, 97,103,101, 10,101,
110,100, 10, 10,114,101,116,117,114,110, 32, 95, 77, 10,
};
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"mbox.lua")==0) lua_call(L, 0, LUA_MULTRET);
}
+116 -108
View File
@@ -1,22 +1,15 @@
/*=========================================================================*\
* MIME support functions
* LuaSocket toolkit
*
* RCS ID: $Id: mime.c,v 1.28 2005/11/20 07:20:23 diego Exp $
\*=========================================================================*/
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501)
#include "compat-5.1.h"
#endif
#include "compat.h"
#include "mime.h"
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
/*=========================================================================*\
* Don't want to trust escape character constants
\*=========================================================================*/
@@ -37,20 +30,20 @@ static int mime_global_eol(lua_State *L);
static int mime_global_dot(lua_State *L);
static size_t dot(int c, size_t state, luaL_Buffer *buffer);
static void b64setup(UC *b64unbase);
static void b64setup(UC *base);
static size_t b64encode(UC c, UC *input, size_t size, luaL_Buffer *buffer);
static size_t b64pad(const UC *input, size_t size, luaL_Buffer *buffer);
static size_t b64decode(UC c, UC *input, size_t size, luaL_Buffer *buffer);
static void qpsetup(UC *qpclass, UC *qpunbase);
static void qpsetup(UC *class, UC *unbase);
static void qpquote(UC c, luaL_Buffer *buffer);
static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer);
static size_t qpencode(UC c, UC *input, size_t size,
static size_t qpencode(UC c, UC *input, size_t size,
const char *marker, luaL_Buffer *buffer);
static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer);
/* code support functions */
static luaL_reg func[] = {
static luaL_Reg func[] = {
{ "dot", mime_global_dot },
{ "b64", mime_global_b64 },
{ "eol", mime_global_eol },
@@ -85,7 +78,8 @@ static UC b64unbase[256];
\*-------------------------------------------------------------------------*/
MIME_API int luaopen_mime_core(lua_State *L)
{
luax_register(L, "mime", func);
lua_newtable(L);
luaL_setfuncs(L, func, 0);
/* make version string available to scripts */
lua_pushstring(L, "_VERSION");
lua_pushstring(L, MIME_VERSION);
@@ -102,15 +96,15 @@ MIME_API int luaopen_mime_core(lua_State *L)
/*-------------------------------------------------------------------------*\
* Incrementaly breaks a string into lines. The string can have CRLF breaks.
* A, n = wrp(l, B, length)
* A is a copy of B, broken into lines of at most 'length' bytes.
* 'l' is how many bytes are left for the first line of B.
* 'n' is the number of bytes left in the last line of A.
* A is a copy of B, broken into lines of at most 'length' bytes.
* 'l' is how many bytes are left for the first line of B.
* 'n' is the number of bytes left in the last line of A.
\*-------------------------------------------------------------------------*/
static int mime_global_wrp(lua_State *L)
{
size_t size = 0;
int left = (int) luaL_checknumber(L, 1);
const UC *input = (UC *) luaL_optlstring(L, 2, NULL, &size);
const UC *input = (const UC *) luaL_optlstring(L, 2, NULL, &size);
const UC *last = input + size;
int length = (int) luaL_optnumber(L, 3, 76);
luaL_Buffer buffer;
@@ -122,7 +116,7 @@ static int mime_global_wrp(lua_State *L)
else lua_pushnil(L);
lua_pushnumber(L, length);
return 2;
}
}
luaL_buffinit(L, &buffer);
while (input < last) {
switch (*input) {
@@ -137,7 +131,7 @@ static int mime_global_wrp(lua_State *L)
left = length;
luaL_addstring(&buffer, CRLF);
}
luaL_putchar(&buffer, *input);
luaL_addchar(&buffer, *input);
left--;
break;
}
@@ -149,22 +143,22 @@ static int mime_global_wrp(lua_State *L)
}
/*-------------------------------------------------------------------------*\
* Fill base64 decode map.
* Fill base64 decode map.
\*-------------------------------------------------------------------------*/
static void b64setup(UC *b64unbase)
static void b64setup(UC *unbase)
{
int i;
for (i = 0; i <= 255; i++) b64unbase[i] = (UC) 255;
for (i = 0; i < 64; i++) b64unbase[b64base[i]] = (UC) i;
b64unbase['='] = 0;
for (i = 0; i <= 255; i++) unbase[i] = (UC) 255;
for (i = 0; i < 64; i++) unbase[b64base[i]] = (UC) i;
unbase['='] = 0;
}
/*-------------------------------------------------------------------------*\
* Acumulates bytes in input buffer until 3 bytes are available.
* Acumulates bytes in input buffer until 3 bytes are available.
* Translate the 3 bytes into Base64 form and append to buffer.
* Returns new number of bytes in buffer.
\*-------------------------------------------------------------------------*/
static size_t b64encode(UC c, UC *input, size_t size,
static size_t b64encode(UC c, UC *input, size_t size,
luaL_Buffer *buffer)
{
input[size++] = c;
@@ -173,7 +167,7 @@ static size_t b64encode(UC c, UC *input, size_t size,
unsigned long value = 0;
value += input[0]; value <<= 8;
value += input[1]; value <<= 8;
value += input[2];
value += input[2];
code[3] = b64base[value & 0x3f]; value >>= 6;
code[2] = b64base[value & 0x3f]; value >>= 6;
code[1] = b64base[value & 0x3f]; value >>= 6;
@@ -185,11 +179,11 @@ static size_t b64encode(UC c, UC *input, size_t size,
}
/*-------------------------------------------------------------------------*\
* Encodes the Base64 last 1 or 2 bytes and adds padding '='
* Encodes the Base64 last 1 or 2 bytes and adds padding '='
* Result, if any, is appended to buffer.
* Returns 0.
\*-------------------------------------------------------------------------*/
static size_t b64pad(const UC *input, size_t size,
static size_t b64pad(const UC *input, size_t size,
luaL_Buffer *buffer)
{
unsigned long value = 0;
@@ -202,7 +196,7 @@ static size_t b64pad(const UC *input, size_t size,
luaL_addlstring(buffer, (char *) code, 4);
break;
case 2:
value = input[0]; value <<= 8;
value = input[0]; value <<= 8;
value |= input[1]; value <<= 2;
code[2] = b64base[value & 0x3f]; value >>= 6;
code[1] = b64base[value & 0x3f]; value >>= 6;
@@ -216,11 +210,11 @@ static size_t b64pad(const UC *input, size_t size,
}
/*-------------------------------------------------------------------------*\
* Acumulates bytes in input buffer until 4 bytes are available.
* Acumulates bytes in input buffer until 4 bytes are available.
* Translate the 4 bytes from Base64 form and append to buffer.
* Returns new number of bytes in buffer.
\*-------------------------------------------------------------------------*/
static size_t b64decode(UC c, UC *input, size_t size,
static size_t b64decode(UC c, UC *input, size_t size,
luaL_Buffer *buffer)
{
/* ignore invalid characters */
@@ -238,7 +232,7 @@ static size_t b64decode(UC c, UC *input, size_t size,
decoded[1] = (UC) (value & 0xff); value >>= 8;
decoded[0] = (UC) value;
/* take care of paddding */
valid = (input[2] == '=') ? 1 : (input[3] == '=') ? 2 : 3;
valid = (input[2] == '=') ? 1 : (input[3] == '=') ? 2 : 3;
luaL_addlstring(buffer, (char *) decoded, valid);
return 0;
/* need more data */
@@ -250,7 +244,7 @@ static size_t b64decode(UC c, UC *input, size_t size,
* A, B = b64(C, D)
* A is the encoded version of the largest prefix of C .. D that is
* divisible by 3. B has the remaining bytes of C .. D, *without* encoding.
* The easiest thing would be to concatenate the two strings and
* The easiest thing would be to concatenate the two strings and
* encode the result, but we can't afford that or Lua would dupplicate
* every chunk we received.
\*-------------------------------------------------------------------------*/
@@ -258,7 +252,7 @@ static int mime_global_b64(lua_State *L)
{
UC atom[3];
size_t isize = 0, asize = 0;
const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize);
const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
const UC *last = input + isize;
luaL_Buffer buffer;
/* end-of-input blackhole */
@@ -267,22 +261,27 @@ static int mime_global_b64(lua_State *L)
lua_pushnil(L);
return 2;
}
/* make sure we don't confuse buffer stuff with arguments */
lua_settop(L, 2);
/* process first part of the input */
luaL_buffinit(L, &buffer);
while (input < last)
while (input < last)
asize = b64encode(*input++, atom, asize, &buffer);
input = (UC *) luaL_optlstring(L, 2, NULL, &isize);
input = (const UC *) luaL_optlstring(L, 2, NULL, &isize);
/* if second part is nil, we are done */
if (!input) {
size_t osize = 0;
asize = b64pad(atom, asize, &buffer);
luaL_pushresult(&buffer);
if (!(*lua_tostring(L, -1))) lua_pushnil(L);
/* if the output is empty and the input is nil, return nil */
lua_tolstring(L, -1, &osize);
if (osize == 0) lua_pushnil(L);
lua_pushnil(L);
return 2;
}
/* otherwise process the second part */
last = input + isize;
while (input < last)
while (input < last)
asize = b64encode(*input++, atom, asize, &buffer);
luaL_pushresult(&buffer);
lua_pushlstring(L, (char *) atom, asize);
@@ -299,7 +298,7 @@ static int mime_global_unb64(lua_State *L)
{
UC atom[4];
size_t isize = 0, asize = 0;
const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize);
const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
const UC *last = input + isize;
luaL_Buffer buffer;
/* end-of-input blackhole */
@@ -308,21 +307,26 @@ static int mime_global_unb64(lua_State *L)
lua_pushnil(L);
return 2;
}
/* make sure we don't confuse buffer stuff with arguments */
lua_settop(L, 2);
/* process first part of the input */
luaL_buffinit(L, &buffer);
while (input < last)
while (input < last)
asize = b64decode(*input++, atom, asize, &buffer);
input = (UC *) luaL_optlstring(L, 2, NULL, &isize);
input = (const UC *) luaL_optlstring(L, 2, NULL, &isize);
/* if second is nil, we are done */
if (!input) {
size_t osize = 0;
luaL_pushresult(&buffer);
if (!(*lua_tostring(L, -1))) lua_pushnil(L);
/* if the output is empty and the input is nil, return nil */
lua_tolstring(L, -1, &osize);
if (osize == 0) lua_pushnil(L);
lua_pushnil(L);
return 2;
}
/* otherwise, process the rest of the input */
last = input + isize;
while (input < last)
while (input < last)
asize = b64decode(*input++, atom, asize, &buffer);
luaL_pushresult(&buffer);
lua_pushlstring(L, (char *) atom, asize);
@@ -338,31 +342,31 @@ static int mime_global_unb64(lua_State *L)
* 9 and 32 can be plain, unless in the end of a line, where must be =XX
* encoded lines must be no longer than 76 not counting CRLF
* soft line-break are =CRLF
* To encode one byte, we need to see the next two.
* To encode one byte, we need to see the next two.
* Worst case is when we see a space, and wonder if a CRLF is comming
\*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*\
* Split quoted-printable characters into classes
* Precompute reverse map for encoding
\*-------------------------------------------------------------------------*/
static void qpsetup(UC *qpclass, UC *qpunbase)
static void qpsetup(UC *cl, UC *unbase)
{
int i;
for (i = 0; i < 256; i++) qpclass[i] = QP_QUOTED;
for (i = 33; i <= 60; i++) qpclass[i] = QP_PLAIN;
for (i = 62; i <= 126; i++) qpclass[i] = QP_PLAIN;
qpclass['\t'] = QP_IF_LAST;
qpclass[' '] = QP_IF_LAST;
qpclass['\r'] = QP_CR;
for (i = 0; i < 256; i++) qpunbase[i] = 255;
qpunbase['0'] = 0; qpunbase['1'] = 1; qpunbase['2'] = 2;
qpunbase['3'] = 3; qpunbase['4'] = 4; qpunbase['5'] = 5;
qpunbase['6'] = 6; qpunbase['7'] = 7; qpunbase['8'] = 8;
qpunbase['9'] = 9; qpunbase['A'] = 10; qpunbase['a'] = 10;
qpunbase['B'] = 11; qpunbase['b'] = 11; qpunbase['C'] = 12;
qpunbase['c'] = 12; qpunbase['D'] = 13; qpunbase['d'] = 13;
qpunbase['E'] = 14; qpunbase['e'] = 14; qpunbase['F'] = 15;
qpunbase['f'] = 15;
for (i = 0; i < 256; i++) cl[i] = QP_QUOTED;
for (i = 33; i <= 60; i++) cl[i] = QP_PLAIN;
for (i = 62; i <= 126; i++) cl[i] = QP_PLAIN;
cl['\t'] = QP_IF_LAST;
cl[' '] = QP_IF_LAST;
cl['\r'] = QP_CR;
for (i = 0; i < 256; i++) unbase[i] = 255;
unbase['0'] = 0; unbase['1'] = 1; unbase['2'] = 2;
unbase['3'] = 3; unbase['4'] = 4; unbase['5'] = 5;
unbase['6'] = 6; unbase['7'] = 7; unbase['8'] = 8;
unbase['9'] = 9; unbase['A'] = 10; unbase['a'] = 10;
unbase['B'] = 11; unbase['b'] = 11; unbase['C'] = 12;
unbase['c'] = 12; unbase['D'] = 13; unbase['d'] = 13;
unbase['E'] = 14; unbase['e'] = 14; unbase['F'] = 15;
unbase['f'] = 15;
}
/*-------------------------------------------------------------------------*\
@@ -370,16 +374,16 @@ static void qpsetup(UC *qpclass, UC *qpunbase)
\*-------------------------------------------------------------------------*/
static void qpquote(UC c, luaL_Buffer *buffer)
{
luaL_putchar(buffer, '=');
luaL_putchar(buffer, qpbase[c >> 4]);
luaL_putchar(buffer, qpbase[c & 0x0F]);
luaL_addchar(buffer, '=');
luaL_addchar(buffer, qpbase[c >> 4]);
luaL_addchar(buffer, qpbase[c & 0x0F]);
}
/*-------------------------------------------------------------------------*\
* Accumulate characters until we are sure about how to deal with them.
* Once we are sure, output to the buffer, in the correct form.
* Once we are sure, output to the buffer, in the correct form.
\*-------------------------------------------------------------------------*/
static size_t qpencode(UC c, UC *input, size_t size,
static size_t qpencode(UC c, UC *input, size_t size,
const char *marker, luaL_Buffer *buffer)
{
input[size++] = c;
@@ -402,7 +406,7 @@ static size_t qpencode(UC c, UC *input, size_t size,
qpquote(input[0], buffer);
luaL_addstring(buffer, marker);
return 0;
} else luaL_putchar(buffer, input[0]);
} else luaL_addchar(buffer, input[0]);
break;
/* might have to be quoted always */
case QP_QUOTED:
@@ -410,7 +414,7 @@ static size_t qpencode(UC c, UC *input, size_t size,
break;
/* might never have to be quoted */
default:
luaL_putchar(buffer, input[0]);
luaL_addchar(buffer, input[0]);
break;
}
input[0] = input[1]; input[1] = input[2];
@@ -420,13 +424,13 @@ static size_t qpencode(UC c, UC *input, size_t size,
}
/*-------------------------------------------------------------------------*\
* Deal with the final characters
* Deal with the final characters
\*-------------------------------------------------------------------------*/
static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer)
{
size_t i;
for (i = 0; i < size; i++) {
if (qpclass[input[i]] == QP_PLAIN) luaL_putchar(buffer, input[i]);
if (qpclass[input[i]] == QP_PLAIN) luaL_addchar(buffer, input[i]);
else qpquote(input[i], buffer);
}
if (size > 0) luaL_addstring(buffer, EQCRLF);
@@ -437,8 +441,8 @@ static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer)
* Incrementally converts a string to quoted-printable
* A, B = qp(C, D, marker)
* Marker is the text to be used to replace CRLF sequences found in A.
* A is the encoded version of the largest prefix of C .. D that
* can be encoded without doubts.
* A is the encoded version of the largest prefix of C .. D that
* can be encoded without doubts.
* B has the remaining bytes of C .. D, *without* encoding.
\*-------------------------------------------------------------------------*/
static int mime_global_qp(lua_State *L)
@@ -446,7 +450,7 @@ static int mime_global_qp(lua_State *L)
size_t asize = 0, isize = 0;
UC atom[3];
const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize);
const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
const UC *last = input + isize;
const char *marker = luaL_optstring(L, 3, CRLF);
luaL_Buffer buffer;
@@ -456,11 +460,13 @@ static int mime_global_qp(lua_State *L)
lua_pushnil(L);
return 2;
}
/* make sure we don't confuse buffer stuff with arguments */
lua_settop(L, 3);
/* process first part of input */
luaL_buffinit(L, &buffer);
while (input < last)
asize = qpencode(*input++, atom, asize, marker, &buffer);
input = (UC *) luaL_optlstring(L, 2, NULL, &isize);
input = (const UC *) luaL_optlstring(L, 2, NULL, &isize);
/* if second part is nil, we are done */
if (!input) {
asize = qppad(atom, asize, &buffer);
@@ -480,7 +486,7 @@ static int mime_global_qp(lua_State *L)
/*-------------------------------------------------------------------------*\
* Accumulate characters until we are sure about how to deal with them.
* Once we are sure, output the to the buffer, in the correct form.
* Once we are sure, output the to the buffer, in the correct form.
\*-------------------------------------------------------------------------*/
static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) {
int d;
@@ -488,23 +494,23 @@ static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) {
/* deal with all characters we can deal */
switch (input[0]) {
/* if we have an escape character */
case '=':
if (size < 3) return size;
case '=':
if (size < 3) return size;
/* eliminate soft line break */
if (input[1] == '\r' && input[2] == '\n') return 0;
/* decode quoted representation */
c = qpunbase[input[1]]; d = qpunbase[input[2]];
/* if it is an invalid, do not decode */
if (c > 15 || d > 15) luaL_addlstring(buffer, (char *)input, 3);
else luaL_putchar(buffer, (c << 4) + d);
else luaL_addchar(buffer, (char) ((c << 4) + d));
return 0;
case '\r':
if (size < 2) return size;
if (size < 2) return size;
if (input[1] == '\n') luaL_addlstring(buffer, (char *)input, 2);
return 0;
default:
if (input[0] == '\t' || (input[0] > 31 && input[0] < 127))
luaL_putchar(buffer, input[0]);
luaL_addchar(buffer, input[0]);
return 0;
}
}
@@ -512,15 +518,15 @@ static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) {
/*-------------------------------------------------------------------------*\
* Incrementally decodes a string in quoted-printable
* A, B = qp(C, D)
* A is the decoded version of the largest prefix of C .. D that
* can be decoded without doubts.
* A is the decoded version of the largest prefix of C .. D that
* can be decoded without doubts.
* B has the remaining bytes of C .. D, *without* decoding.
\*-------------------------------------------------------------------------*/
static int mime_global_unqp(lua_State *L)
{
size_t asize = 0, isize = 0;
UC atom[3];
const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize);
const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
const UC *last = input + isize;
luaL_Buffer buffer;
/* end-of-input blackhole */
@@ -529,18 +535,20 @@ static int mime_global_unqp(lua_State *L)
lua_pushnil(L);
return 2;
}
/* make sure we don't confuse buffer stuff with arguments */
lua_settop(L, 2);
/* process first part of input */
luaL_buffinit(L, &buffer);
while (input < last)
asize = qpdecode(*input++, atom, asize, &buffer);
input = (UC *) luaL_optlstring(L, 2, NULL, &isize);
input = (const UC *) luaL_optlstring(L, 2, NULL, &isize);
/* if second part is nil, we are done */
if (!input) {
luaL_pushresult(&buffer);
if (!(*lua_tostring(L, -1))) lua_pushnil(L);
lua_pushnil(L);
return 2;
}
}
/* otherwise process rest of input */
last = input + isize;
while (input < last)
@@ -553,9 +561,9 @@ static int mime_global_unqp(lua_State *L)
/*-------------------------------------------------------------------------*\
* Incrementally breaks a quoted-printed string into lines
* A, n = qpwrp(l, B, length)
* A is a copy of B, broken into lines of at most 'length' bytes.
* 'l' is how many bytes are left for the first line of B.
* 'n' is the number of bytes left in the last line of A.
* A is a copy of B, broken into lines of at most 'length' bytes.
* 'l' is how many bytes are left for the first line of B.
* 'n' is the number of bytes left in the last line of A.
* There are two complications: lines can't be broken in the middle
* of an encoded =XX, and there might be line breaks already
\*-------------------------------------------------------------------------*/
@@ -563,7 +571,7 @@ static int mime_global_qpwrp(lua_State *L)
{
size_t size = 0;
int left = (int) luaL_checknumber(L, 1);
const UC *input = (UC *) luaL_optlstring(L, 2, NULL, &size);
const UC *input = (const UC *) luaL_optlstring(L, 2, NULL, &size);
const UC *last = input + size;
int length = (int) luaL_optnumber(L, 3, 76);
luaL_Buffer buffer;
@@ -588,16 +596,16 @@ static int mime_global_qpwrp(lua_State *L)
if (left <= 3) {
left = length;
luaL_addstring(&buffer, EQCRLF);
}
luaL_putchar(&buffer, *input);
}
luaL_addchar(&buffer, *input);
left--;
break;
default:
default:
if (left <= 1) {
left = length;
luaL_addstring(&buffer, EQCRLF);
}
luaL_putchar(&buffer, *input);
luaL_addchar(&buffer, *input);
left--;
break;
}
@@ -620,7 +628,7 @@ static int mime_global_qpwrp(lua_State *L)
* last is the previous character
\*-------------------------------------------------------------------------*/
#define eolcandidate(c) (c == '\r' || c == '\n')
static int eolprocess(int c, int last, const char *marker,
static int eolprocess(int c, int last, const char *marker,
luaL_Buffer *buffer)
{
if (eolcandidate(c)) {
@@ -632,21 +640,21 @@ static int eolprocess(int c, int last, const char *marker,
return c;
}
} else {
luaL_putchar(buffer, c);
luaL_addchar(buffer, (char) c);
return 0;
}
}
/*-------------------------------------------------------------------------*\
* Converts a string to uniform EOL convention.
* Converts a string to uniform EOL convention.
* A, n = eol(o, B, marker)
* A is the converted version of the largest prefix of B that can be
* converted unambiguously. 'o' is the context returned by the previous
* converted unambiguously. 'o' is the context returned by the previous
* call. 'n' is the new context.
\*-------------------------------------------------------------------------*/
static int mime_global_eol(lua_State *L)
{
int ctx = (int) luaL_checknumber(L, 1);
int ctx = luaL_checkinteger(L, 1);
size_t isize = 0;
const char *input = luaL_optlstring(L, 2, NULL, &isize);
const char *last = input + isize;
@@ -668,19 +676,19 @@ static int mime_global_eol(lua_State *L)
}
/*-------------------------------------------------------------------------*\
* Takes one byte and stuff it if needed.
* Takes one byte and stuff it if needed.
\*-------------------------------------------------------------------------*/
static size_t dot(int c, size_t state, luaL_Buffer *buffer)
{
luaL_putchar(buffer, c);
luaL_addchar(buffer, (char) c);
switch (c) {
case '\r':
case '\r':
return 1;
case '\n':
return (state == 1)? 2: 0;
case '.':
if (state == 2)
luaL_putchar(buffer, '.');
case '\n':
return (state == 1)? 2: 0;
case '.':
if (state == 2)
luaL_addchar(buffer, '.');
default:
return 0;
}
@@ -704,10 +712,10 @@ static int mime_global_dot(lua_State *L)
}
/* process all input */
luaL_buffinit(L, &buffer);
while (input < last)
while (input < last)
state = dot(*input++, state, &buffer);
luaL_pushresult(&buffer);
lua_pushnumber(L, state);
lua_pushnumber(L, (lua_Number) state);
return 2;
}
+2 -4
View File
@@ -7,16 +7,14 @@
* This module provides functions to implement transfer content encodings
* and formatting conforming to RFC 2045. It is used by mime.lua, which
* provide a higher level interface to this functionality.
*
* RCS ID: $Id: mime.h,v 1.15 2007/06/11 23:44:54 diego Exp $
\*=========================================================================*/
#include "lua.h"
/*-------------------------------------------------------------------------*\
* Current MIME library version
\*-------------------------------------------------------------------------*/
#define MIME_VERSION "MIME 1.0.2"
#define MIME_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab"
#define MIME_VERSION "MIME 1.0.3"
#define MIME_COPYRIGHT "Copyright (C) 2004-2013 Diego Nehab"
#define MIME_AUTHORS "Diego Nehab"
/*-------------------------------------------------------------------------*\
+21 -18
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 $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@@ -13,12 +12,14 @@ local ltn12 = require("ltn12")
local mime = require("mime.core")
local io = require("io")
local string = require("string")
module("mime")
local _M = mime
-- encode, decode and wrap algorithm tables
encodet = {}
decodet = {}
wrapt = {}
local encodet, decodet, wrapt = {},{},{}
_M.encodet = encodet
_M.decodet = decodet
_M.wrapt = wrapt
-- creates a function that chooses a filter by name from a given table
local function choose(table)
@@ -35,21 +36,21 @@ end
-- define the encoding filters
encodet['base64'] = function()
return ltn12.filter.cycle(b64, "")
return ltn12.filter.cycle(_M.b64, "")
end
encodet['quoted-printable'] = function(mode)
return ltn12.filter.cycle(qp, "",
return ltn12.filter.cycle(_M.qp, "",
(mode == "binary") and "=0D=0A" or "\r\n")
end
-- define the decoding filters
decodet['base64'] = function()
return ltn12.filter.cycle(unb64, "")
return ltn12.filter.cycle(_M.unb64, "")
end
decodet['quoted-printable'] = function()
return ltn12.filter.cycle(unqp, "")
return ltn12.filter.cycle(_M.unqp, "")
end
local function format(chunk)
@@ -62,26 +63,28 @@ end
-- define the line-wrap filters
wrapt['text'] = function(length)
length = length or 76
return ltn12.filter.cycle(wrp, length, length)
return ltn12.filter.cycle(_M.wrp, length, length)
end
wrapt['base64'] = wrapt['text']
wrapt['default'] = wrapt['text']
wrapt['quoted-printable'] = function()
return ltn12.filter.cycle(qpwrp, 76, 76)
return ltn12.filter.cycle(_M.qpwrp, 76, 76)
end
-- function that choose the encoding, decoding or wrap algorithm
encode = choose(encodet)
decode = choose(decodet)
wrap = choose(wrapt)
_M.encode = choose(encodet)
_M.decode = choose(decodet)
_M.wrap = choose(wrapt)
-- define the end-of-line normalization filter
function normalize(marker)
return ltn12.filter.cycle(eol, 0, marker)
function _M.normalize(marker)
return ltn12.filter.cycle(_M.eol, 0, marker)
end
-- high level stuffing filter
function stuff()
return ltn12.filter.cycle(dot, 2)
function _M.stuff()
return ltn12.filter.cycle(_M.dot, 2)
end
return _M
+101 -98
View File
@@ -1,7 +1,7 @@
/* code automatically generated by bin2c -- DO NOT EDIT */
{
/* #include'ing this file in a C program is equivalent to calling
if (luaL_loadfile(L,"mime.lua")==0) lua_call(L, 0, 0);
if (luaL_loadfile(L,"mime.lua")==0) lua_call(L, 0, LUA_MULTRET);
*/
/* mime.lua */
static const unsigned char B1[]={
@@ -13,94 +13,95 @@ static const unsigned char B1[]={
101, 32, 76,117, 97, 32,108, 97,110,103,117, 97,103,101, 46, 10, 45, 45, 32, 65,
117,116,104,111,114, 58, 32, 68,105,101,103,111, 32, 78,101,104, 97, 98, 10, 45,
45, 32, 67,111,110,102,111,114,109,105,110,103, 32,116,111, 32, 82, 70, 67,115,
32, 50, 48, 52, 53, 45, 50, 48, 52, 57, 10, 45, 45, 32, 82, 67, 83, 32, 73, 68,
58, 32, 36, 73,100, 58, 32,109,105,109,101, 46,108,117, 97, 44,118, 32, 49, 46,
50, 57, 32, 50, 48, 48, 55, 47, 48, 54, 47, 49, 49, 32, 50, 51, 58, 52, 52, 58,
53, 52, 32,100,105,101,103,111, 32, 69,120,112, 32, 36, 10, 45, 45, 45, 45, 45,
32, 50, 48, 52, 53, 45, 50, 48, 52, 57, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,
114,101, 32,109,111,100,117,108,101, 32, 97,110,100, 32,105,109,112,111,114,116,
32,100,101,112,101,110,100,101,110, 99,105,101,115, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,114,101, 32,109,
111,100,117,108,101, 32, 97,110,100, 32,105,109,112,111,114,116, 32,100,101,112,
101,110,100,101,110, 99,105,101,115, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32, 98, 97,
115,101, 32, 61, 32, 95, 71, 10,108,111, 99, 97,108, 32,108,116,110, 49, 50, 32,
61, 32,114,101,113,117,105,114,101, 40, 34,108,116,110, 49, 50, 34, 41, 10,108,
111, 99, 97,108, 32,109,105,109,101, 32, 61, 32,114,101,113,117,105,114,101, 40,
34,109,105,109,101, 46, 99,111,114,101, 34, 41, 10,108,111, 99, 97,108, 32,105,
111, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,105,111, 34, 41, 10,108,111,
99, 97,108, 32,115,116,114,105,110,103, 32, 61, 32,114,101,113,117,105,114,101,
40, 34,115,116,114,105,110,103, 34, 41, 10,109,111,100,117,108,101, 40, 34,109,
105,109,101, 34, 41, 10, 10, 45, 45, 32,101,110, 99,111,100,101, 44, 32,100,101,
99,111,100,101, 32, 97,110,100, 32,119,114, 97,112, 32, 97,108,103,111,114,105,
116,104,109, 32,116, 97, 98,108,101,115, 10,101,110, 99,111,100,101,116, 32, 61,
32,123,125, 10,100,101, 99,111,100,101,116, 32, 61, 32,123,125, 10,119,114, 97,
112,116, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 99,114,101, 97,116,101,115, 32,
97, 32,102,117,110, 99,116,105,111,110, 32,116,104, 97,116, 32, 99,104,111,111,
115,101,115, 32, 97, 32,102,105,108,116,101,114, 32, 98,121, 32,110, 97,109,101,
32,102,114,111,109, 32, 97, 32,103,105,118,101,110, 32,116, 97, 98,108,101, 10,
108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32, 99,104,111,111,115,
101, 40,116, 97, 98,108,101, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
102,117,110, 99,116,105,111,110, 40,110, 97,109,101, 44, 32,111,112,116, 49, 44,
32,111,112,116, 50, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 98, 97,
115,101, 46,116,121,112,101, 40,110, 97,109,101, 41, 32,126, 61, 32, 34,115,116,
114,105,110,103, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,110, 97,109,101, 44, 32,111,112,116, 49, 44, 32,111,112,116, 50, 32,
61, 32, 34,100,101,102, 97,117,108,116, 34, 44, 32,110, 97,109,101, 44, 32,111,
112,116, 49, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
32, 32, 32, 32,108,111, 99, 97,108, 32,102, 32, 61, 32,116, 97, 98,108,101, 91,
110, 97,109,101, 32,111,114, 32, 34,110,105,108, 34, 93, 10, 32, 32, 32, 32, 32,
32, 32, 32,105,102, 32,110,111,116, 32,102, 32,116,104,101,110, 32, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 98, 97,115,101, 46,101,114,114,111,114,
40, 34,117,110,107,110,111,119,110, 32,107,101,121, 32, 40, 34, 32, 46, 46, 32,
98, 97,115,101, 46,116,111,115,116,114,105,110,103, 40,110, 97,109,101, 41, 32,
46, 46, 32, 34, 41, 34, 44, 32, 51, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,
108,115,101, 32,114,101,116,117,114,110, 32,102, 40,111,112,116, 49, 44, 32,111,
112,116, 50, 41, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100,
10, 10, 45, 45, 32,100,101,102,105,110,101, 32,116,104,101, 32,101,110, 99,111,
100,105,110,103, 32,102,105,108,116,101,114,115, 10,101,110, 99,111,100,101,116,
91, 39, 98, 97,115,101, 54, 52, 39, 93, 32, 61, 32,102,117,110, 99,116,105,111,
110, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,108,116,110, 49, 50,
46,102,105,108,116,101,114, 46, 99,121, 99,108,101, 40, 98, 54, 52, 44, 32, 34,
34, 41, 10,101,110,100, 10, 10,101,110, 99,111,100,101,116, 91, 39,113,117,111,
116,101,100, 45,112,114,105,110,116, 97, 98,108,101, 39, 93, 32, 61, 32,102,117,
110, 99,116,105,111,110, 40,109,111,100,101, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32,108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,
108,101, 40,113,112, 44, 32, 34, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 40,
109,111,100,101, 32, 61, 61, 32, 34, 98,105,110, 97,114,121, 34, 41, 32, 97,110,
100, 32, 34, 61, 48, 68, 61, 48, 65, 34, 32,111,114, 32, 34, 92,114, 92,110, 34,
41, 10,101,110,100, 10, 10, 45, 45, 32,100,101,102,105,110,101, 32,116,104,101,
32,100,101, 99,111,100,105,110,103, 32,102,105,108,116,101,114,115, 10,100,101,
45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32, 98, 97,115,101, 32, 61,
32, 95, 71, 10,108,111, 99, 97,108, 32,108,116,110, 49, 50, 32, 61, 32,114,101,
113,117,105,114,101, 40, 34,108,116,110, 49, 50, 34, 41, 10,108,111, 99, 97,108,
32,109,105,109,101, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,109,105,109,
101, 46, 99,111,114,101, 34, 41, 10,108,111, 99, 97,108, 32,105,111, 32, 61, 32,
114,101,113,117,105,114,101, 40, 34,105,111, 34, 41, 10,108,111, 99, 97,108, 32,
115,116,114,105,110,103, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,115,116,
114,105,110,103, 34, 41, 10,108,111, 99, 97,108, 32, 95, 77, 32, 61, 32,109,105,
109,101, 10, 10, 45, 45, 32,101,110, 99,111,100,101, 44, 32,100,101, 99,111,100,
101, 32, 97,110,100, 32,119,114, 97,112, 32, 97,108,103,111,114,105,116,104,109,
32,116, 97, 98,108,101,115, 10,108,111, 99, 97,108, 32,101,110, 99,111,100,101,
116, 44, 32,100,101, 99,111,100,101,116, 44, 32,119,114, 97,112,116, 32, 61, 32,
123,125, 44,123,125, 44,123,125, 10, 10, 95, 77, 46,101,110, 99,111,100,101,116,
32, 61, 32,101,110, 99,111,100,101,116, 10, 95, 77, 46,100,101, 99,111,100,101,
116, 32, 61, 32,100,101, 99,111,100,101,116, 10, 95, 77, 46,119,114, 97,112,116,
32, 32, 32, 61, 32,119,114, 97,112,116, 32, 32, 10, 10, 45, 45, 32, 99,114,101,
97,116,101,115, 32, 97, 32,102,117,110, 99,116,105,111,110, 32,116,104, 97,116,
32, 99,104,111,111,115,101,115, 32, 97, 32,102,105,108,116,101,114, 32, 98,121,
32,110, 97,109,101, 32,102,114,111,109, 32, 97, 32,103,105,118,101,110, 32,116,
97, 98,108,101, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,
99,104,111,111,115,101, 40,116, 97, 98,108,101, 41, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40,110, 97,109,101, 44, 32,
111,112,116, 49, 44, 32,111,112,116, 50, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
105,102, 32, 98, 97,115,101, 46,116,121,112,101, 40,110, 97,109,101, 41, 32,126,
61, 32, 34,115,116,114,105,110,103, 34, 32,116,104,101,110, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,110, 97,109,101, 44, 32,111,112,116, 49, 44, 32,
111,112,116, 50, 32, 61, 32, 34,100,101,102, 97,117,108,116, 34, 44, 32,110, 97,
109,101, 44, 32,111,112,116, 49, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100,
10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,102, 32, 61, 32,116,
97, 98,108,101, 91,110, 97,109,101, 32,111,114, 32, 34,110,105,108, 34, 93, 10,
32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32,102, 32,116,104,101,
110, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 98, 97,115,101, 46,
101,114,114,111,114, 40, 34,117,110,107,110,111,119,110, 32,107,101,121, 32, 40,
34, 32, 46, 46, 32, 98, 97,115,101, 46,116,111,115,116,114,105,110,103, 40,110,
97,109,101, 41, 32, 46, 46, 32, 34, 41, 34, 44, 32, 51, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,102, 40,111,112,
116, 49, 44, 32,111,112,116, 50, 41, 32,101,110,100, 10, 32, 32, 32, 32,101,110,
100, 10,101,110,100, 10, 10, 45, 45, 32,100,101,102,105,110,101, 32,116,104,101,
32,101,110, 99,111,100,105,110,103, 32,102,105,108,116,101,114,115, 10,101,110,
99,111,100,101,116, 91, 39, 98, 97,115,101, 54, 52, 39, 93, 32, 61, 32,102,117,
110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,101, 40,117,
110, 98, 54, 52, 44, 32, 34, 34, 41, 10,101,110,100, 10, 10,100,101, 99,111,100,
101,116, 91, 39,113,117,111,116,101,100, 45,112,114,105,110,116, 97, 98,108,101,
39, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32,
114,101,116,117,114,110, 32,108,116,110, 49, 50, 46,102,105,108,116,101,114, 46,
99,121, 99,108,101, 40,117,110,113,112, 44, 32, 34, 34, 41, 10,101,110,100, 10,
10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,102,111,114,109,
97,116, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32,105,102, 32, 99,104,117,
110,107, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,
104,117,110,107, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 32,114,101,116,117,
114,110, 32, 34, 39, 39, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,
32,114,101,116,117,114,110, 32,115,116,114,105,110,103, 46,108,101,110, 40, 99,
104,117,110,107, 41, 32,101,110,100, 10, 32, 32, 32, 32,101,108,115,101, 32,114,
101,116,117,114,110, 32, 34,110,105,108, 34, 32,101,110,100, 10,101,110,100, 10,
10, 45, 45, 32,100,101,102,105,110,101, 32,116,104,101, 32,108,105,110,101, 45,
119,114, 97,112, 32,102,105,108,116,101,114,115, 10,119,114, 97,112,116, 91, 39,
116,101,120,116, 39, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,108,101,
110,103,116,104, 41, 10, 32, 32, 32, 32,108,101,110,103,116,104, 32, 61, 32,108,
101,110,103,116,104, 32,111,114, 32, 55, 54, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32,108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,
101, 40,119,114,112, 44, 32,108,101,110,103,116,104, 44, 32,108,101,110,103,116,
108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,101, 40, 95,
77, 46, 98, 54, 52, 44, 32, 34, 34, 41, 10,101,110,100, 10, 10,101,110, 99,111,
100,101,116, 91, 39,113,117,111,116,101,100, 45,112,114,105,110,116, 97, 98,108,
101, 39, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,109,111,100,101, 41,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32,108,116,110, 49, 50, 46,102,105,
108,116,101,114, 46, 99,121, 99,108,101, 40, 95, 77, 46,113,112, 44, 32, 34, 34,
44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 40,109,111,100,101, 32, 61, 61, 32, 34,
98,105,110, 97,114,121, 34, 41, 32, 97,110,100, 32, 34, 61, 48, 68, 61, 48, 65,
34, 32,111,114, 32, 34, 92,114, 92,110, 34, 41, 10,101,110,100, 10, 10, 45, 45,
32,100,101,102,105,110,101, 32,116,104,101, 32,100,101, 99,111,100,105,110,103,
32,102,105,108,116,101,114,115, 10,100,101, 99,111,100,101,116, 91, 39, 98, 97,
115,101, 54, 52, 39, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32,108,116,110, 49, 50, 46,102,105,108,
116,101,114, 46, 99,121, 99,108,101, 40, 95, 77, 46,117,110, 98, 54, 52, 44, 32,
34, 34, 41, 10,101,110,100, 10, 10,100,101, 99,111,100,101,116, 91, 39,113,117,
111,116,101,100, 45,112,114,105,110,116, 97, 98,108,101, 39, 93, 32, 61, 32,102,
117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110,
32,108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,101, 40,
95, 77, 46,117,110,113,112, 44, 32, 34, 34, 41, 10,101,110,100, 10, 10,108,111,
99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,102,111,114,109, 97,116, 40,
99,104,117,110,107, 41, 10, 32, 32, 32, 32,105,102, 32, 99,104,117,110,107, 32,
116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,117,110,
107, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,
34, 39, 39, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,
116,117,114,110, 32,115,116,114,105,110,103, 46,108,101,110, 40, 99,104,117,110,
107, 41, 32,101,110,100, 10, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,
114,110, 32, 34,110,105,108, 34, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45,
32,100,101,102,105,110,101, 32,116,104,101, 32,108,105,110,101, 45,119,114, 97,
112, 32,102,105,108,116,101,114,115, 10,119,114, 97,112,116, 91, 39,116,101,120,
116, 39, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,108,101,110,103,116,
104, 41, 10, 32, 32, 32, 32,108,101,110,103,116,104, 32, 61, 32,108,101,110,103,
116,104, 32,111,114, 32, 55, 54, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,101, 40, 95,
77, 46,119,114,112, 44, 32,108,101,110,103,116,104, 44, 32,108,101,110,103,116,
104, 41, 10,101,110,100, 10,119,114, 97,112,116, 91, 39, 98, 97,115,101, 54, 52,
39, 93, 32, 61, 32,119,114, 97,112,116, 91, 39,116,101,120,116, 39, 93, 10,119,
114, 97,112,116, 91, 39,100,101,102, 97,117,108,116, 39, 93, 32, 61, 32,119,114,
@@ -108,26 +109,28 @@ static const unsigned char B1[]={
113,117,111,116,101,100, 45,112,114,105,110,116, 97, 98,108,101, 39, 93, 32, 61,
32,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32,108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,
101, 40,113,112,119,114,112, 44, 32, 55, 54, 44, 32, 55, 54, 41, 10,101,110,100,
10, 10, 45, 45, 32,102,117,110, 99,116,105,111,110, 32,116,104, 97,116, 32, 99,
104,111,111,115,101, 32,116,104,101, 32,101,110, 99,111,100,105,110,103, 44, 32,
100,101, 99,111,100,105,110,103, 32,111,114, 32,119,114, 97,112, 32, 97,108,103,
111,114,105,116,104,109, 10,101,110, 99,111,100,101, 32, 61, 32, 99,104,111,111,
115,101, 40,101,110, 99,111,100,101,116, 41, 10,100,101, 99,111,100,101, 32, 61,
32, 99,104,111,111,115,101, 40,100,101, 99,111,100,101,116, 41, 10,119,114, 97,
112, 32, 61, 32, 99,104,111,111,115,101, 40,119,114, 97,112,116, 41, 10, 10, 45,
45, 32,100,101,102,105,110,101, 32,116,104,101, 32,101,110,100, 45,111,102, 45,
108,105,110,101, 32,110,111,114,109, 97,108,105,122, 97,116,105,111,110, 32,102,
105,108,116,101,114, 10,102,117,110, 99,116,105,111,110, 32,110,111,114,109, 97,
108,105,122,101, 40,109, 97,114,107,101,114, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32,108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,
108,101, 40,101,111,108, 44, 32, 48, 44, 32,109, 97,114,107,101,114, 41, 10,101,
110,100, 10, 10, 45, 45, 32,104,105,103,104, 32,108,101,118,101,108, 32,115,116,
117,102,102,105,110,103, 32,102,105,108,116,101,114, 10,102,117,110, 99,116,105,
111,110, 32,115,116,117,102,102, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,
110, 32,108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,101,
40,100,111,116, 44, 32, 50, 41, 10,101,110,100, 10,
101, 40, 95, 77, 46,113,112,119,114,112, 44, 32, 55, 54, 44, 32, 55, 54, 41, 10,
101,110,100, 10, 10, 45, 45, 32,102,117,110, 99,116,105,111,110, 32,116,104, 97,
116, 32, 99,104,111,111,115,101, 32,116,104,101, 32,101,110, 99,111,100,105,110,
103, 44, 32,100,101, 99,111,100,105,110,103, 32,111,114, 32,119,114, 97,112, 32,
97,108,103,111,114,105,116,104,109, 10, 95, 77, 46,101,110, 99,111,100,101, 32,
61, 32, 99,104,111,111,115,101, 40,101,110, 99,111,100,101,116, 41, 10, 95, 77,
46,100,101, 99,111,100,101, 32, 61, 32, 99,104,111,111,115,101, 40,100,101, 99,
111,100,101,116, 41, 10, 95, 77, 46,119,114, 97,112, 32, 61, 32, 99,104,111,111,
115,101, 40,119,114, 97,112,116, 41, 10, 10, 45, 45, 32,100,101,102,105,110,101,
32,116,104,101, 32,101,110,100, 45,111,102, 45,108,105,110,101, 32,110,111,114,
109, 97,108,105,122, 97,116,105,111,110, 32,102,105,108,116,101,114, 10,102,117,
110, 99,116,105,111,110, 32, 95, 77, 46,110,111,114,109, 97,108,105,122,101, 40,
109, 97,114,107,101,114, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,108,
116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,101, 40, 95, 77,
46,101,111,108, 44, 32, 48, 44, 32,109, 97,114,107,101,114, 41, 10,101,110,100,
10, 10, 45, 45, 32,104,105,103,104, 32,108,101,118,101,108, 32,115,116,117,102,
102,105,110,103, 32,102,105,108,116,101,114, 10,102,117,110, 99,116,105,111,110,
32, 95, 77, 46,115,116,117,102,102, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32,108,116,110, 49, 50, 46,102,105,108,116,101,114, 46, 99,121, 99,108,
101, 40, 95, 77, 46,100,111,116, 44, 32, 50, 41, 10,101,110,100, 10, 10,114,101,
116,117,114,110, 32, 95, 77,
};
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"mime.lua")==0) lua_call(L, 0, 0);
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"mime.lua")==0) lua_call(L, 0, LUA_MULTRET);
}
+255 -30
View File
@@ -1,10 +1,8 @@
/*=========================================================================*\
* Common option interface
* Common option interface
* LuaSocket toolkit
*
* RCS ID: $Id: options.c,v 1.6 2005/11/20 07:20:23 diego Exp $
\*=========================================================================*/
#include <string.h>
#include <string.h>
#include "lauxlib.h"
@@ -17,9 +15,15 @@
* Internal functions prototypes
\*=========================================================================*/
static int opt_setmembership(lua_State *L, p_socket ps, int level, int name);
static int opt_ip6_setmembership(lua_State *L, p_socket ps, int level, int name);
static int opt_setboolean(lua_State *L, p_socket ps, int level, int name);
static int opt_set(lua_State *L, p_socket ps, int level, int name,
static int opt_getboolean(lua_State *L, p_socket ps, int level, int name);
static int opt_setint(lua_State *L, p_socket ps, int level, int name);
static int opt_getint(lua_State *L, p_socket ps, int level, int name);
static int opt_set(lua_State *L, p_socket ps, int level, int name,
void *val, int len);
static int opt_get(lua_State *L, p_socket ps, int level, int name,
void *val, int* len);
/*=========================================================================*\
* Exported functions
@@ -40,96 +44,277 @@ int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps)
return opt->func(L, ps);
}
/* enables reuse of local address */
int opt_reuseaddr(lua_State *L, p_socket ps)
int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps)
{
return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
const char *name = luaL_checkstring(L, 2); /* obj, name, ... */
while (opt->name && strcmp(name, opt->name))
opt++;
if (!opt->func) {
char msg[45];
sprintf(msg, "unsupported option `%.35s'", name);
luaL_argerror(L, 2, msg);
}
return opt->func(L, ps);
}
/* enables reuse of local address */
int opt_set_reuseaddr(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
}
int opt_get_reuseaddr(lua_State *L, p_socket ps)
{
return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
}
/* enables reuse of local port */
int opt_set_reuseport(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEPORT);
}
int opt_get_reuseport(lua_State *L, p_socket ps)
{
return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEPORT);
}
/* disables the Naggle algorithm */
int opt_tcp_nodelay(lua_State *L, p_socket ps)
int opt_set_tcp_nodelay(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY);
return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY);
}
int opt_keepalive(lua_State *L, p_socket ps)
int opt_get_tcp_nodelay(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE);
return opt_getboolean(L, ps, IPPROTO_TCP, TCP_NODELAY);
}
int opt_dontroute(lua_State *L, p_socket ps)
int opt_set_keepalive(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE);
}
int opt_get_keepalive(lua_State *L, p_socket ps)
{
return opt_getboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE);
}
int opt_set_dontroute(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE);
}
int opt_broadcast(lua_State *L, p_socket ps)
int opt_get_dontroute(lua_State *L, p_socket ps)
{
return opt_getboolean(L, ps, SOL_SOCKET, SO_DONTROUTE);
}
int opt_set_broadcast(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
}
int opt_ip_multicast_loop(lua_State *L, p_socket ps)
int opt_get_broadcast(lua_State *L, p_socket ps)
{
return opt_getboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
}
int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps)
{
return opt_setint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
}
int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps)
{
return opt_getint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
}
int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps)
{
return opt_setint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
}
int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps)
{
return opt_getint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
}
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
}
int opt_linger(lua_State *L, p_socket ps)
int opt_get_ip_multicast_loop(lua_State *L, p_socket ps)
{
return opt_getboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
}
int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
}
int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps)
{
return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
}
int opt_set_linger(lua_State *L, p_socket ps)
{
struct linger li; /* obj, name, table */
if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE));
if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE));
lua_pushstring(L, "on");
lua_gettable(L, 3);
if (!lua_isboolean(L, -1))
if (!lua_isboolean(L, -1))
luaL_argerror(L, 3, "boolean 'on' field expected");
li.l_onoff = (u_short) lua_toboolean(L, -1);
lua_pushstring(L, "timeout");
lua_gettable(L, 3);
if (!lua_isnumber(L, -1))
if (!lua_isnumber(L, -1))
luaL_argerror(L, 3, "number 'timeout' field expected");
li.l_linger = (u_short) lua_tonumber(L, -1);
return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li));
}
int opt_ip_multicast_ttl(lua_State *L, p_socket ps)
int opt_get_linger(lua_State *L, p_socket ps)
{
int val = (int) luaL_checknumber(L, 3); /* obj, name, int */
return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &val, sizeof(val));
struct linger li; /* obj, name */
int len = sizeof(li);
int err = opt_get(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, &len);
if (err)
return err;
lua_newtable(L);
lua_pushboolean(L, li.l_onoff);
lua_setfield(L, -2, "on");
lua_pushinteger(L, li.l_linger);
lua_setfield(L, -2, "timeout");
return 1;
}
int opt_ip_add_membership(lua_State *L, p_socket ps)
int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps)
{
return opt_setint(L, ps, IPPROTO_IP, IP_MULTICAST_TTL);
}
int opt_set_ip_multicast_if(lua_State *L, p_socket ps)
{
const char *address = luaL_checkstring(L, 3); /* obj, name, ip */
struct in_addr val;
val.s_addr = htonl(INADDR_ANY);
if (strcmp(address, "*") && !inet_aton(address, &val))
luaL_argerror(L, 3, "ip expected");
return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_IF,
(char *) &val, sizeof(val));
}
int opt_get_ip_multicast_if(lua_State *L, p_socket ps)
{
struct in_addr val;
socklen_t len = sizeof(val);
if (getsockopt(*ps, IPPROTO_IP, IP_MULTICAST_IF, (char *) &val, &len) < 0) {
lua_pushnil(L);
lua_pushstring(L, "getsockopt failed");
return 2;
}
lua_pushstring(L, inet_ntoa(val));
return 1;
}
int opt_set_ip_add_membership(lua_State *L, p_socket ps)
{
return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP);
}
int opt_ip_drop_membersip(lua_State *L, p_socket ps)
int opt_set_ip_drop_membersip(lua_State *L, p_socket ps)
{
return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP);
}
int opt_set_ip6_add_membership(lua_State *L, p_socket ps)
{
return opt_ip6_setmembership(L, ps, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP);
}
int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps)
{
return opt_ip6_setmembership(L, ps, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP);
}
int opt_get_ip6_v6only(lua_State *L, p_socket ps)
{
return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
}
int opt_set_ip6_v6only(lua_State *L, p_socket ps)
{
return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
}
/*=========================================================================*\
* Auxiliar functions
\*=========================================================================*/
static int opt_setmembership(lua_State *L, p_socket ps, int level, int name)
{
struct ip_mreq val; /* obj, name, table */
if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE));
if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE));
lua_pushstring(L, "multiaddr");
lua_gettable(L, 3);
if (!lua_isstring(L, -1))
if (!lua_isstring(L, -1))
luaL_argerror(L, 3, "string 'multiaddr' field expected");
if (!inet_aton(lua_tostring(L, -1), &val.imr_multiaddr))
if (!inet_aton(lua_tostring(L, -1), &val.imr_multiaddr))
luaL_argerror(L, 3, "invalid 'multiaddr' ip address");
lua_pushstring(L, "interface");
lua_gettable(L, 3);
if (!lua_isstring(L, -1))
if (!lua_isstring(L, -1))
luaL_argerror(L, 3, "string 'interface' field expected");
val.imr_interface.s_addr = htonl(INADDR_ANY);
if (strcmp(lua_tostring(L, -1), "*") &&
!inet_aton(lua_tostring(L, -1), &val.imr_interface))
!inet_aton(lua_tostring(L, -1), &val.imr_interface))
luaL_argerror(L, 3, "invalid 'interface' ip address");
return opt_set(L, ps, level, name, (char *) &val, sizeof(val));
}
static
static int opt_ip6_setmembership(lua_State *L, p_socket ps, int level, int name)
{
struct ipv6_mreq val; /* obj, opt-name, table */
memset(&val, 0, sizeof(val));
if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE));
lua_pushstring(L, "multiaddr");
lua_gettable(L, 3);
if (!lua_isstring(L, -1))
luaL_argerror(L, 3, "string 'multiaddr' field expected");
if (!inet_pton(AF_INET6, lua_tostring(L, -1), &val.ipv6mr_multiaddr))
luaL_argerror(L, 3, "invalid 'multiaddr' ip address");
lua_pushstring(L, "interface");
lua_gettable(L, 3);
/* By default we listen to interface on default route
* (sigh). However, interface= can override it. We should
* support either number, or name for it. Waiting for
* windows port of if_nametoindex */
if (!lua_isnil(L, -1)) {
if (lua_isnumber(L, -1)) {
val.ipv6mr_interface = (unsigned int) lua_tonumber(L, -1);
} else
luaL_argerror(L, -1, "number 'interface' field expected");
}
return opt_set(L, ps, level, name, (char *) &val, sizeof(val));
}
static
int opt_get(lua_State *L, p_socket ps, int level, int name, void *val, int* len)
{
socklen_t socklen = *len;
if (getsockopt(*ps, level, name, (char *) val, &socklen) < 0) {
lua_pushnil(L);
lua_pushstring(L, "getsockopt failed");
return 2;
}
*len = socklen;
return 0;
}
static
int opt_set(lua_State *L, p_socket ps, int level, int name, void *val, int len)
{
if (setsockopt(*ps, level, name, (char *) val, len) < 0) {
@@ -141,9 +326,49 @@ int opt_set(lua_State *L, p_socket ps, int level, int name, void *val, int len)
return 1;
}
static int opt_getboolean(lua_State *L, p_socket ps, int level, int name)
{
int val = 0;
int len = sizeof(val);
int err = opt_get(L, ps, level, name, (char *) &val, &len);
if (err)
return err;
lua_pushboolean(L, val);
return 1;
}
int opt_get_error(lua_State *L, p_socket ps)
{
int val = 0;
socklen_t len = sizeof(val);
if (getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *) &val, &len) < 0) {
lua_pushnil(L);
lua_pushstring(L, "getsockopt failed");
return 2;
}
lua_pushstring(L, socket_strerror(val));
return 1;
}
static int opt_setboolean(lua_State *L, p_socket ps, int level, int name)
{
int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */
return opt_set(L, ps, level, name, (char *) &val, sizeof(val));
}
static int opt_getint(lua_State *L, p_socket ps, int level, int name)
{
int val = 0;
int len = sizeof(val);
int err = opt_get(L, ps, level, name, (char *) &val, &len);
if (err)
return err;
lua_pushnumber(L, val);
return 1;
}
static int opt_setint(lua_State *L, p_socket ps, int level, int name)
{
int val = (int) lua_tonumber(L, 3); /* obj, name, int */
return opt_set(L, ps, level, name, (char *) &val, sizeof(val));
}
+37 -14
View File
@@ -6,8 +6,6 @@
*
* This module provides a common interface to socket options, used mainly by
* modules UDP and TCP.
*
* RCS ID: $Id: options.h,v 1.4 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include "lua.h"
@@ -20,20 +18,45 @@ typedef struct t_opt {
} t_opt;
typedef t_opt *p_opt;
/* supported options */
int opt_dontroute(lua_State *L, p_socket ps);
int opt_broadcast(lua_State *L, p_socket ps);
int opt_reuseaddr(lua_State *L, p_socket ps);
int opt_tcp_nodelay(lua_State *L, p_socket ps);
int opt_keepalive(lua_State *L, p_socket ps);
int opt_linger(lua_State *L, p_socket ps);
int opt_reuseaddr(lua_State *L, p_socket ps);
int opt_ip_multicast_ttl(lua_State *L, p_socket ps);
int opt_ip_multicast_loop(lua_State *L, p_socket ps);
int opt_ip_add_membership(lua_State *L, p_socket ps);
int opt_ip_drop_membersip(lua_State *L, p_socket ps);
/* supported options for setoption */
int opt_set_dontroute(lua_State *L, p_socket ps);
int opt_set_broadcast(lua_State *L, p_socket ps);
int opt_set_tcp_nodelay(lua_State *L, p_socket ps);
int opt_set_keepalive(lua_State *L, p_socket ps);
int opt_set_linger(lua_State *L, p_socket ps);
int opt_set_reuseaddr(lua_State *L, p_socket ps);
int opt_set_reuseport(lua_State *L, p_socket ps);
int opt_set_ip_multicast_if(lua_State *L, p_socket ps);
int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps);
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps);
int opt_set_ip_add_membership(lua_State *L, p_socket ps);
int opt_set_ip_drop_membersip(lua_State *L, p_socket ps);
int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps);
int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps);
int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps);
int opt_set_ip6_add_membership(lua_State *L, p_socket ps);
int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps);
int opt_set_ip6_v6only(lua_State *L, p_socket ps);
/* supported options for getoption */
int opt_get_dontroute(lua_State *L, p_socket ps);
int opt_get_broadcast(lua_State *L, p_socket ps);
int opt_get_reuseaddr(lua_State *L, p_socket ps);
int opt_get_reuseport(lua_State *L, p_socket ps);
int opt_get_tcp_nodelay(lua_State *L, p_socket ps);
int opt_get_keepalive(lua_State *L, p_socket ps);
int opt_get_linger(lua_State *L, p_socket ps);
int opt_get_ip_multicast_loop(lua_State *L, p_socket ps);
int opt_get_ip_multicast_if(lua_State *L, p_socket ps);
int opt_get_error(lua_State *L, p_socket ps);
int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps);
int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps);
int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
int opt_get_ip6_v6only(lua_State *L, p_socket ps);
int opt_get_reuseport(lua_State *L, p_socket ps);
/* invokes the appropriate option handler */
int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps);
int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps);
#endif
@@ -0,0 +1,28 @@
#ifndef PIERROR_H
#define PIERROR_H
/*=========================================================================*\
* Error messages
* Defines platform independent error messages
\*=========================================================================*/
#define PIE_HOST_NOT_FOUND "host not found"
#define PIE_ADDRINUSE "address already in use"
#define PIE_ISCONN "already connected"
#define PIE_ACCESS "permission denied"
#define PIE_CONNREFUSED "connection refused"
#define PIE_CONNABORTED "closed"
#define PIE_CONNRESET "closed"
#define PIE_TIMEDOUT "timeout"
#define PIE_AGAIN "temporary failure in name resolution"
#define PIE_BADFLAGS "invalid value for ai_flags"
#define PIE_BADHINTS "invalid value for hints"
#define PIE_FAIL "non-recoverable failure in name resolution"
#define PIE_FAMILY "ai_family not supported"
#define PIE_MEMORY "memory allocation failure"
#define PIE_NONAME "host or service not provided, or not known"
#define PIE_OVERFLOW "argument buffer overflow"
#define PIE_PROTOCOL "resolved protocol is unknown"
#define PIE_SERVICE "service not supported for socket type"
#define PIE_SOCKTYPE "ai_socktype not supported"
#endif
@@ -1 +0,0 @@
if not socket then error("No socket.") end
+50 -32
View File
@@ -1,35 +1,32 @@
/*=========================================================================*\
* Select implementation
* LuaSocket toolkit
*
* RCS ID: $Id: select.c,v 1.22 2005/11/20 07:20:23 diego Exp $
\*=========================================================================*/
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "socket.h"
#include "timeout.h"
#include "select.h"
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
/*=========================================================================*\
* Internal function prototypes.
\*=========================================================================*/
static t_socket getfd(lua_State *L);
static int dirty(lua_State *L);
static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
int itab, fd_set *set);
static void collect_fd(lua_State *L, int tab, int itab,
fd_set *set, t_socket *max_fd);
static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set);
static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
int itab, int tab, int start);
static void make_assoc(lua_State *L, int tab);
static int global_select(lua_State *L);
/* functions in library namespace */
static luaL_reg func[] = {
static luaL_Reg func[] = {
{"select", global_select},
{NULL, NULL}
};
@@ -41,7 +38,13 @@ static luaL_reg func[] = {
* Initializes module
\*-------------------------------------------------------------------------*/
int select_open(lua_State *L) {
luax_register(L, NULL, func);
lua_pushstring(L, "_SETSIZE");
lua_pushinteger(L, FD_SETSIZE);
lua_rawset(L, -3);
lua_pushstring(L, "_SOCKETINVALID");
lua_pushinteger(L, SOCKET_INVALID);
lua_rawset(L, -3);
luaL_setfuncs(L, func, 0);
return 0;
}
@@ -53,7 +56,7 @@ int select_open(lua_State *L) {
\*-------------------------------------------------------------------------*/
static int global_select(lua_State *L) {
int rtab, wtab, itab, ret, ndirty;
t_socket max_fd;
t_socket max_fd = SOCKET_INVALID;
fd_set rset, wset;
t_timeout tm;
double t = luaL_optnumber(L, 3, -1);
@@ -62,12 +65,12 @@ static int global_select(lua_State *L) {
lua_newtable(L); itab = lua_gettop(L);
lua_newtable(L); rtab = lua_gettop(L);
lua_newtable(L); wtab = lua_gettop(L);
max_fd = collect_fd(L, 1, SOCKET_INVALID, itab, &rset);
collect_fd(L, 1, itab, &rset, &max_fd);
collect_fd(L, 2, itab, &wset, &max_fd);
ndirty = check_dirty(L, 1, rtab, &rset);
t = ndirty > 0? 0.0: t;
timeout_init(&tm, t, -1);
timeout_markstart(&tm);
max_fd = collect_fd(L, 2, max_fd, itab, &wset);
ret = socket_select(max_fd+1, &rset, &wset, NULL, &tm);
if (ret > 0 || ndirty > 0) {
return_fd(L, &rset, max_fd+1, itab, rtab, ndirty);
@@ -79,7 +82,7 @@ static int global_select(lua_State *L) {
lua_pushstring(L, "timeout");
return 3;
} else {
lua_pushstring(L, "error");
luaL_error(L, "select failed");
return 3;
}
}
@@ -94,9 +97,11 @@ static t_socket getfd(lua_State *L) {
if (!lua_isnil(L, -1)) {
lua_pushvalue(L, -2);
lua_call(L, 1, 1);
if (lua_isnumber(L, -1))
fd = (t_socket) lua_tonumber(L, -1);
}
if (lua_isnumber(L, -1)) {
double numfd = lua_tonumber(L, -1);
fd = (numfd >= 0.0)? (t_socket) numfd: SOCKET_INVALID;
}
}
lua_pop(L, 1);
return fd;
}
@@ -109,17 +114,19 @@ static int dirty(lua_State *L) {
lua_pushvalue(L, -2);
lua_call(L, 1, 1);
is = lua_toboolean(L, -1);
}
}
lua_pop(L, 1);
return is;
}
static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
int itab, fd_set *set) {
int i = 1;
if (lua_isnil(L, tab))
return max_fd;
while (1) {
static void collect_fd(lua_State *L, int tab, int itab,
fd_set *set, t_socket *max_fd) {
int i = 1, n = 0;
/* nil is the same as an empty table */
if (lua_isnil(L, tab)) return;
/* otherwise we need it to be a table */
luaL_checktype(L, tab, LUA_TTABLE);
for ( ;; ) {
t_socket fd;
lua_pushnumber(L, i);
lua_gettable(L, tab);
@@ -127,26 +134,37 @@ static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
lua_pop(L, 1);
break;
}
/* getfd figures out if this is a socket */
fd = getfd(L);
if (fd != SOCKET_INVALID) {
/* make sure we don't overflow the fd_set */
#ifdef _WIN32
if (n >= FD_SETSIZE)
luaL_argerror(L, tab, "too many sockets");
#else
if (fd >= FD_SETSIZE)
luaL_argerror(L, tab, "descriptor too large for set size");
#endif
FD_SET(fd, set);
if (max_fd == SOCKET_INVALID || max_fd < fd)
max_fd = fd;
lua_pushnumber(L, fd);
n++;
/* keep track of the largest descriptor so far */
if (*max_fd == SOCKET_INVALID || *max_fd < fd)
*max_fd = fd;
/* make sure we can map back from descriptor to the object */
lua_pushnumber(L, (lua_Number) fd);
lua_pushvalue(L, -2);
lua_settable(L, itab);
}
lua_pop(L, 1);
i = i + 1;
}
return max_fd;
}
static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) {
int ndirty = 0, i = 1;
if (lua_isnil(L, tab))
if (lua_isnil(L, tab))
return 0;
while (1) {
for ( ;; ) {
t_socket fd;
lua_pushnumber(L, i);
lua_gettable(L, tab);
@@ -167,13 +185,13 @@ static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) {
return ndirty;
}
static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
int itab, int tab, int start) {
t_socket fd;
for (fd = 0; fd < max_fd; fd++) {
if (FD_ISSET(fd, set)) {
lua_pushnumber(L, ++start);
lua_pushnumber(L, fd);
lua_pushnumber(L, (lua_Number) fd);
lua_gettable(L, itab);
lua_settable(L, tab);
}
@@ -183,7 +201,7 @@ static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
static void make_assoc(lua_State *L, int tab) {
int i = 1, atab;
lua_newtable(L); atab = lua_gettop(L);
while (1) {
for ( ;; ) {
lua_pushnumber(L, i);
lua_gettable(L, tab);
if (!lua_isnil(L, -1)) {
@@ -8,8 +8,6 @@
* 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: select.h,v 1.7 2004/06/16 01:02:07 diego Exp $
\*=========================================================================*/
int select_open(lua_State *L);
@@ -0,0 +1,172 @@
/*=========================================================================*\
* Serial stream
* LuaSocket toolkit
\*=========================================================================*/
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "auxiliar.h"
#include "socket.h"
#include "options.h"
#include "unix.h"
#include <sys/un.h>
/*
Reuses userdata definition from unix.h, since it is useful for all
stream-like objects.
If we stored the serial path for use in error messages or userdata
printing, we might need our own userdata definition.
Group usage is semi-inherited from unix.c, but unnecessary since we
have only one object type.
*/
/*=========================================================================*\
* Internal function prototypes
\*=========================================================================*/
static int global_create(lua_State *L);
static int meth_send(lua_State *L);
static int meth_receive(lua_State *L);
static int meth_close(lua_State *L);
static int meth_settimeout(lua_State *L);
static int meth_getfd(lua_State *L);
static int meth_setfd(lua_State *L);
static int meth_dirty(lua_State *L);
static int meth_getstats(lua_State *L);
static int meth_setstats(lua_State *L);
/* serial object methods */
static luaL_Reg serial_methods[] = {
{"__gc", meth_close},
{"__tostring", auxiliar_tostring},
{"close", meth_close},
{"dirty", meth_dirty},
{"getfd", meth_getfd},
{"getstats", meth_getstats},
{"setstats", meth_setstats},
{"receive", meth_receive},
{"send", meth_send},
{"setfd", meth_setfd},
{"settimeout", meth_settimeout},
{NULL, NULL}
};
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
LUASOCKET_API int luaopen_socket_serial(lua_State *L) {
/* create classes */
auxiliar_newclass(L, "serial{client}", serial_methods);
/* create class groups */
auxiliar_add2group(L, "serial{client}", "serial{any}");
lua_pushcfunction(L, global_create);
return 1;
}
/*=========================================================================*\
* Lua methods
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Just call buffered IO methods
\*-------------------------------------------------------------------------*/
static int meth_send(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1);
return buffer_meth_send(L, &un->buf);
}
static int meth_receive(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1);
return buffer_meth_receive(L, &un->buf);
}
static int meth_getstats(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1);
return buffer_meth_getstats(L, &un->buf);
}
static int meth_setstats(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1);
return buffer_meth_setstats(L, &un->buf);
}
/*-------------------------------------------------------------------------*\
* Select support methods
\*-------------------------------------------------------------------------*/
static int meth_getfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1);
lua_pushnumber(L, (int) un->sock);
return 1;
}
/* this is very dangerous, but can be handy for those that are brave enough */
static int meth_setfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1);
un->sock = (t_socket) luaL_checknumber(L, 2);
return 0;
}
static int meth_dirty(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1);
lua_pushboolean(L, !buffer_isempty(&un->buf));
return 1;
}
/*-------------------------------------------------------------------------*\
* Closes socket used by object
\*-------------------------------------------------------------------------*/
static int meth_close(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1);
socket_destroy(&un->sock);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Just call tm methods
\*-------------------------------------------------------------------------*/
static int meth_settimeout(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1);
return timeout_meth_settimeout(L, &un->tm);
}
/*=========================================================================*\
* Library functions
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Creates a serial object
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L) {
const char* path = luaL_checkstring(L, 1);
/* allocate unix object */
p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix));
/* open serial device */
t_socket sock = open(path, O_NOCTTY|O_RDWR);
/*printf("open %s on %d\n", path, sock);*/
if (sock < 0) {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(errno));
lua_pushnumber(L, errno);
return 3;
}
/* set its type as client object */
auxiliar_setclass(L, "serial{client}", -1);
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
un->sock = sock;
io_init(&un->io, (p_send) socket_write, (p_recv) socket_read,
(p_error) socket_ioerror, &un->sock);
timeout_init(&un->tm, -1, -1);
buffer_init(&un->buf, &un->io, &un->tm);
return 1;
}
+25 -20
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.46 2007/03/12 04:08:40 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@@ -16,23 +15,26 @@ local os = require("os")
local socket = require("socket")
local tp = require("socket.tp")
local ltn12 = require("ltn12")
local headers = require("socket.headers")
local mime = require("mime")
module("socket.smtp")
socket.smtp = {}
local _M = socket.smtp
-----------------------------------------------------------------------------
-- Program constants
-----------------------------------------------------------------------------
-- timeout for connection
TIMEOUT = 60
_M.TIMEOUT = 60
-- default server used to send e-mails
SERVER = "localhost"
_M.SERVER = "localhost"
-- default port
PORT = 25
_M.PORT = 25
-- domain used in HELO command and default sendmail
-- If we are under a CGI, try to get from environment
DOMAIN = os.getenv("SERVER_NAME") or "localhost"
_M.DOMAIN = os.getenv("SERVER_NAME") or "localhost"
-- default time zone (means we don't know)
ZONE = "-0000"
_M.ZONE = "-0000"
---------------------------------------------------------------------------
-- Low level SMTP API
@@ -41,7 +43,7 @@ local metat = { __index = {} }
function metat.__index:greet(domain)
self.try(self.tp:check("2.."))
self.try(self.tp:command("EHLO", domain or DOMAIN))
self.try(self.tp:command("EHLO", domain or _M.DOMAIN))
return socket.skip(1, self.try(self.tp:check("2..")))
end
@@ -75,9 +77,9 @@ end
function metat.__index:login(user, password)
self.try(self.tp:command("AUTH", "LOGIN"))
self.try(self.tp:check("3.."))
self.try(self.tp:command(mime.b64(user)))
self.try(self.tp:send(mime.b64(user) .. "\r\n"))
self.try(self.tp:check("3.."))
self.try(self.tp:command(mime.b64(password)))
self.try(self.tp:send(mime.b64(password) .. "\r\n"))
return self.try(self.tp:check("2.."))
end
@@ -111,9 +113,9 @@ function metat.__index:send(mailt)
self:data(ltn12.source.chain(mailt.source, mime.stuff()), mailt.step)
end
function open(server, port, create)
local tp = socket.try(tp.connect(server or SERVER, port or PORT,
TIMEOUT, create))
function _M.open(server, port, create)
local tp = socket.try(tp.connect(server or _M.SERVER, port or _M.PORT,
_M.TIMEOUT, create))
local s = base.setmetatable({tp = tp}, metat)
-- make sure tp is closed if we get an exception
s.try = socket.newtry(function()
@@ -146,10 +148,11 @@ end
local send_message
-- yield the headers all at once, it's faster
local function send_headers(headers)
local function send_headers(tosend)
local canonic = headers.canonic
local h = "\r\n"
for i,v in base.pairs(headers) do
h = i .. ': ' .. v .. "\r\n" .. h
for f,v in base.pairs(tosend) do
h = (canonic[f] or f) .. ': ' .. v .. "\r\n" .. h
end
coroutine.yield(h)
end
@@ -220,14 +223,14 @@ end
local function adjust_headers(mesgt)
local lower = lower_headers(mesgt.headers)
lower["date"] = lower["date"] or
os.date("!%a, %d %b %Y %H:%M:%S ") .. (mesgt.zone or ZONE)
os.date("!%a, %d %b %Y %H:%M:%S ") .. (mesgt.zone or _M.ZONE)
lower["x-mailer"] = lower["x-mailer"] or socket._VERSION
-- this can't be overriden
lower["mime-version"] = "1.0"
return lower
end
function message(mesgt)
function _M.message(mesgt)
mesgt.headers = adjust_headers(mesgt)
-- create and return message source
local co = coroutine.create(function() send_message(mesgt) end)
@@ -241,11 +244,13 @@ end
---------------------------------------------------------------------------
-- High level SMTP API
-----------------------------------------------------------------------------
send = socket.protect(function(mailt)
local s = open(mailt.server, mailt.port, mailt.create)
_M.send = socket.protect(function(mailt)
local s = _M.open(mailt.server, mailt.port, mailt.create)
local ext = s:greet(mailt.domain)
s:auth(mailt.user, mailt.password, ext)
s:send(mailt)
s:quit()
return s:close()
end)
return _M
+345 -340
View File
@@ -1,7 +1,7 @@
/* code automatically generated by bin2c -- DO NOT EDIT */
{
/* #include'ing this file in a C program is equivalent to calling
if (luaL_loadfile(L,"smtp.lua")==0) lua_call(L, 0, 0);
if (luaL_loadfile(L,"smtp.lua")==0) lua_call(L, 0, LUA_MULTRET);
*/
/* smtp.lua */
static const unsigned char B1[]={
@@ -13,291 +13,321 @@ static const unsigned char B1[]={
32,102,111,114, 32,116,104,101, 32, 76,117, 97, 32,108, 97,110,103,117, 97,103,
101, 46, 10, 45, 45, 32, 76,117, 97, 83,111, 99,107,101,116, 32,116,111,111,108,
107,105,116, 46, 10, 45, 45, 32, 65,117,116,104,111,114, 58, 32, 68,105,101,103,
111, 32, 78,101,104, 97, 98, 10, 45, 45, 32, 82, 67, 83, 32, 73, 68, 58, 32, 36,
73,100, 58, 32,115,109,116,112, 46,108,117, 97, 44,118, 32, 49, 46, 52, 54, 32,
50, 48, 48, 55, 47, 48, 51, 47, 49, 50, 32, 48, 52, 58, 48, 56, 58, 52, 48, 32,
100,105,101,103,111, 32, 69,120,112, 32, 36, 10, 45, 45, 45, 45, 45, 45, 45, 45,
111, 32, 78,101,104, 97, 98, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,114,101, 32,
109,111,100,117,108,101, 32, 97,110,100, 32,105,109,112,111,114,116, 32,100,101,
112,101,110,100,101,110, 99,105,101,115, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,114,101, 32,109,111,100,117,
108,101, 32, 97,110,100, 32,105,109,112,111,114,116, 32,100,101,112,101,110,100,
101,110, 99,105,101,115, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32, 98, 97,115,101, 32,
61, 32, 95, 71, 10,108,111, 99, 97,108, 32, 99,111,114,111,117,116,105,110,101,
32, 61, 32,114,101,113,117,105,114,101, 40, 34, 99,111,114,111,117,116,105,110,
101, 34, 41, 10,108,111, 99, 97,108, 32,115,116,114,105,110,103, 32, 61, 32,114,
101,113,117,105,114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,108,111, 99,
97,108, 32,109, 97,116,104, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,109,
97,116,104, 34, 41, 10,108,111, 99, 97,108, 32,111,115, 32, 61, 32,114,101,113,
117,105,114,101, 40, 34,111,115, 34, 41, 10,108,111, 99, 97,108, 32,115,111, 99,
107,101,116, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,115,111, 99,107,101,
116, 34, 41, 10,108,111, 99, 97,108, 32,116,112, 32, 61, 32,114,101,113,117,105,
114,101, 40, 34,115,111, 99,107,101,116, 46,116,112, 34, 41, 10,108,111, 99, 97,
108, 32,108,116,110, 49, 50, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,108,
116,110, 49, 50, 34, 41, 10,108,111, 99, 97,108, 32,109,105,109,101, 32, 61, 32,
114,101,113,117,105,114,101, 40, 34,109,105,109,101, 34, 41, 10,109,111,100,117,
108,101, 40, 34,115,111, 99,107,101,116, 46,115,109,116,112, 34, 41, 10, 10, 45,
45, 45, 45, 45, 10,108,111, 99, 97,108, 32, 98, 97,115,101, 32, 61, 32, 95, 71,
10,108,111, 99, 97,108, 32, 99,111,114,111,117,116,105,110,101, 32, 61, 32,114,
101,113,117,105,114,101, 40, 34, 99,111,114,111,117,116,105,110,101, 34, 41, 10,
108,111, 99, 97,108, 32,115,116,114,105,110,103, 32, 61, 32,114,101,113,117,105,
114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,108,111, 99, 97,108, 32,109,
97,116,104, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,109, 97,116,104, 34,
41, 10,108,111, 99, 97,108, 32,111,115, 32, 61, 32,114,101,113,117,105,114,101,
40, 34,111,115, 34, 41, 10,108,111, 99, 97,108, 32,115,111, 99,107,101,116, 32,
61, 32,114,101,113,117,105,114,101, 40, 34,115,111, 99,107,101,116, 34, 41, 10,
108,111, 99, 97,108, 32,116,112, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,
115,111, 99,107,101,116, 46,116,112, 34, 41, 10,108,111, 99, 97,108, 32,108,116,
110, 49, 50, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,108,116,110, 49, 50,
34, 41, 10,108,111, 99, 97,108, 32,104,101, 97,100,101,114,115, 32, 61, 32,114,
101,113,117,105,114,101, 40, 34,115,111, 99,107,101,116, 46,104,101, 97,100,101,
114,115, 34, 41, 10,108,111, 99, 97,108, 32,109,105,109,101, 32, 61, 32,114,101,
113,117,105,114,101, 40, 34,109,105,109,101, 34, 41, 10, 10,115,111, 99,107,101,
116, 46,115,109,116,112, 32, 61, 32,123,125, 10,108,111, 99, 97,108, 32, 95, 77,
32, 61, 32,115,111, 99,107,101,116, 46,115,109,116,112, 10, 10, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,
80,114,111,103,114, 97,109, 32, 99,111,110,115,116, 97,110,116,115, 10, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 80,114,111,
103,114, 97,109, 32, 99,111,110,115,116, 97,110,116,115, 10, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,116,
105,109,101,111,117,116, 32,102,111,114, 32, 99,111,110,110,101, 99,116,105,111,
110, 10, 84, 73, 77, 69, 79, 85, 84, 32, 61, 32, 54, 48, 10, 45, 45, 32,100,101,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,116,105,109,101,
111,117,116, 32,102,111,114, 32, 99,111,110,110,101, 99,116,105,111,110, 10, 95,
77, 46, 84, 73, 77, 69, 79, 85, 84, 32, 61, 32, 54, 48, 10, 45, 45, 32,100,101,
102, 97,117,108,116, 32,115,101,114,118,101,114, 32,117,115,101,100, 32,116,111,
32,115,101,110,100, 32,101, 45,109, 97,105,108,115, 10, 83, 69, 82, 86, 69, 82,
32, 61, 32, 34,108,111, 99, 97,108,104,111,115,116, 34, 10, 45, 45, 32,100,101,
102, 97,117,108,116, 32,112,111,114,116, 10, 80, 79, 82, 84, 32, 61, 32, 50, 53,
10, 45, 45, 32,100,111,109, 97,105,110, 32,117,115,101,100, 32,105,110, 32, 72,
69, 76, 79, 32, 99,111,109,109, 97,110,100, 32, 97,110,100, 32,100,101,102, 97,
117,108,116, 32,115,101,110,100,109, 97,105,108, 10, 45, 45, 32, 73,102, 32,119,
101, 32, 97,114,101, 32,117,110,100,101,114, 32, 97, 32, 67, 71, 73, 44, 32,116,
114,121, 32,116,111, 32,103,101,116, 32,102,114,111,109, 32,101,110,118,105,114,
111,110,109,101,110,116, 10, 68, 79, 77, 65, 73, 78, 32, 61, 32,111,115, 46,103,
101,116,101,110,118, 40, 34, 83, 69, 82, 86, 69, 82, 95, 78, 65, 77, 69, 34, 41,
32,111,114, 32, 34,108,111, 99, 97,108,104,111,115,116, 34, 10, 45, 45, 32,100,
101,102, 97,117,108,116, 32,116,105,109,101, 32,122,111,110,101, 32, 40,109,101,
97,110,115, 32,119,101, 32,100,111,110, 39,116, 32,107,110,111,119, 41, 10, 90,
79, 78, 69, 32, 61, 32, 34, 45, 48, 48, 48, 48, 34, 10, 10, 45, 45, 45, 45, 45,
32,115,101,110,100, 32,101, 45,109, 97,105,108,115, 10, 95, 77, 46, 83, 69, 82,
86, 69, 82, 32, 61, 32, 34,108,111, 99, 97,108,104,111,115,116, 34, 10, 45, 45,
32,100,101,102, 97,117,108,116, 32,112,111,114,116, 10, 95, 77, 46, 80, 79, 82,
84, 32, 61, 32, 50, 53, 10, 45, 45, 32,100,111,109, 97,105,110, 32,117,115,101,
100, 32,105,110, 32, 72, 69, 76, 79, 32, 99,111,109,109, 97,110,100, 32, 97,110,
100, 32,100,101,102, 97,117,108,116, 32,115,101,110,100,109, 97,105,108, 10, 45,
45, 32, 73,102, 32,119,101, 32, 97,114,101, 32,117,110,100,101,114, 32, 97, 32,
67, 71, 73, 44, 32,116,114,121, 32,116,111, 32,103,101,116, 32,102,114,111,109,
32,101,110,118,105,114,111,110,109,101,110,116, 10, 95, 77, 46, 68, 79, 77, 65,
73, 78, 32, 61, 32,111,115, 46,103,101,116,101,110,118, 40, 34, 83, 69, 82, 86,
69, 82, 95, 78, 65, 77, 69, 34, 41, 32,111,114, 32, 34,108,111, 99, 97,108,104,
111,115,116, 34, 10, 45, 45, 32,100,101,102, 97,117,108,116, 32,116,105,109,101,
32,122,111,110,101, 32, 40,109,101, 97,110,115, 32,119,101, 32,100,111,110, 39,
116, 32,107,110,111,119, 41, 10, 95, 77, 46, 90, 79, 78, 69, 32, 61, 32, 34, 45,
48, 48, 48, 48, 34, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 76,111,119, 32,108,101,
118,101,108, 32, 83, 77, 84, 80, 32, 65, 80, 73, 10, 45, 45, 45, 45, 45, 45, 45,
45, 45, 10, 45, 45, 32, 76,111,119, 32,108,101,118,101,108, 32, 83, 77, 84, 80,
32, 65, 80, 73, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32,109,101,116,
97,116, 32, 61, 32,123, 32, 95, 95,105,110,100,101,120, 32, 61, 32,123,125, 32,
125, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,
105,110,100,101,120, 58,103,114,101,101,116, 40,100,111,109, 97,105,110, 41, 10,
32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112,
58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10, 32, 32, 32, 32,115,
101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109,
97,110,100, 40, 34, 69, 72, 76, 79, 34, 44, 32,100,111,109, 97,105,110, 32,111,
114, 32, 68, 79, 77, 65, 73, 78, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,
110, 32,115,111, 99,107,101,116, 46,115,107,105,112, 40, 49, 44, 32,115,101,108,
102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40,
34, 50, 46, 46, 34, 41, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,
111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,109, 97,105,
108, 40,102,114,111,109, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121,
40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34, 77, 65,
73, 76, 34, 44, 32, 34, 70, 82, 79, 77, 58, 34, 32, 46, 46, 32,102,114,111,109,
41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,116,
114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46,
46, 34, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,
101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,114, 99,112,116, 40,116,111,
41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,
116,112, 58, 99,111,109,109, 97,110,100, 40, 34, 82, 67, 80, 84, 34, 44, 32, 34,
84, 79, 58, 34, 32, 46, 46, 32,116,111, 41, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112,
58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10,101,110,100, 10, 10,
102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,
101,120, 58,100, 97,116, 97, 40,115,114, 99, 44, 32,115,116,101,112, 41, 10, 32,
45, 45, 10,108,111, 99, 97,108, 32,109,101,116, 97,116, 32, 61, 32,123, 32, 95,
95,105,110,100,101,120, 32, 61, 32,123,125, 32,125, 10, 10,102,117,110, 99,116,
105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,103,114,
101,101,116, 40,100,111,109, 97,105,110, 41, 10, 32, 32, 32, 32,115,101,108,102,
46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34,
50, 46, 46, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,
115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34, 69, 72, 76,
79, 34, 44, 32,100,111,109, 97,105,110, 32,111,114, 32, 95, 77, 46, 68, 79, 77,
65, 73, 78, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,111, 99,
107,101,116, 46,115,107,105,112, 40, 49, 44, 32,115,101,108,102, 46,116,114,121,
40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34,
41, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,
116, 97,116, 46, 95, 95,105,110,100,101,120, 58,109, 97,105,108, 40,102,114,111,
109, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102,
46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34, 77, 65, 73, 76, 34, 44, 32,
34, 70, 82, 79, 77, 58, 34, 32, 46, 46, 32,102,114,111,109, 41, 41, 10, 32, 32,
32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,116,114,121, 40,115,101,
108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10,
101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46,
95, 95,105,110,100,101,120, 58,114, 99,112,116, 40,116,111, 41, 10, 32, 32, 32,
32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,
109,109, 97,110,100, 40, 34, 82, 67, 80, 84, 34, 44, 32, 34, 84, 79, 58, 34, 32,
46, 46, 32,116,111, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,
101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,
107, 40, 34, 50, 46, 46, 34, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,
105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,100, 97,
116, 97, 40,115,114, 99, 44, 32,115,116,101,112, 41, 10, 32, 32, 32, 32,115,101,
108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,
110,100, 40, 34, 68, 65, 84, 65, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102,
46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34,
51, 46, 46, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,
115,101,108,102, 46,116,112, 58,115,111,117,114, 99,101, 40,115,114, 99, 44, 32,
115,116,101,112, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,
115,101,108,102, 46,116,112, 58,115,101,110,100, 40, 34, 92,114, 92,110, 46, 92,
114, 92,110, 34, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,
108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107,
40, 34, 50, 46, 46, 34, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,
111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,113,117,105,
116, 40, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,
102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34, 81, 85, 73, 84, 34, 41,
41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,116,114,
121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46,
34, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,
116, 97,116, 46, 95, 95,105,110,100,101,120, 58, 99,108,111,115,101, 40, 41, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,116,112, 58, 99,
108,111,115,101, 40, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,108,111,103,105,110,
40,117,115,101,114, 44, 32,112, 97,115,115,119,111,114,100, 41, 10, 32, 32, 32,
32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,111,
109,109, 97,110,100, 40, 34, 65, 85, 84, 72, 34, 44, 32, 34, 76, 79, 71, 73, 78,
34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,
102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 51, 46, 46, 34, 41, 41, 10, 32,
32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58,
99,111,109,109, 97,110,100, 40, 34, 68, 65, 84, 65, 34, 41, 41, 10, 32, 32, 32,
32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,
101, 99,107, 40, 34, 51, 46, 46, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102,
46,116,114,121, 40,115,101,108,102, 46,116,112, 58,115,111,117,114, 99,101, 40,
115,114, 99, 44, 32,115,116,101,112, 41, 41, 10, 32, 32, 32, 32,115,101,108,102,
46,116,114,121, 40,115,101,108,102, 46,116,112, 58,115,101,110,100, 40, 34, 92,
114, 92,110, 46, 92,114, 92,110, 34, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,
115,101,110,100, 40,109,105,109,101, 46, 98, 54, 52, 40,117,115,101,114, 41, 32,
46, 46, 32, 34, 92,114, 92,110, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102,
46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34,
51, 46, 46, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,
115,101,108,102, 46,116,112, 58,115,101,110,100, 40,109,105,109,101, 46, 98, 54,
52, 40,112, 97,115,115,119,111,114,100, 41, 32, 46, 46, 32, 34, 92,114, 92,110,
34, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,
116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50,
46, 46, 34, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,112,108, 97,105,110, 40,
117,115,101,114, 44, 32,112, 97,115,115,119,111,114,100, 41, 10, 32, 32, 32, 32,
108,111, 99, 97,108, 32, 97,117,116,104, 32, 61, 32, 34, 80, 76, 65, 73, 78, 32,
34, 32, 46, 46, 32,109,105,109,101, 46, 98, 54, 52, 40, 34, 92, 48, 34, 32, 46,
46, 32,117,115,101,114, 32, 46, 46, 32, 34, 92, 48, 34, 32, 46, 46, 32,112, 97,
115,115,119,111,114,100, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121,
40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34, 65, 85,
84, 72, 34, 44, 32, 97,117,116,104, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58,
99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10,101,110,100, 10, 10,102,
117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,
120, 58,113,117,105,116, 40, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,
121, 40,115,101,108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40, 34, 81,
85, 73, 84, 34, 41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,
108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107,
40, 34, 50, 46, 46, 34, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,
111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58, 99,108,111,
115,101, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102,
46,116,112, 58, 99,108,111,115,101, 40, 41, 10,101,110,100, 10, 10,102,117,110,
99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,
108,111,103,105,110, 40,117,115,101,114, 44, 32,112, 97,115,115,119,111,114,100,
41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,
116,112, 58, 99,111,109,109, 97,110,100, 40, 34, 65, 85, 84, 72, 34, 44, 32, 34,
76, 79, 71, 73, 78, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,
121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 51, 46, 46,
34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,
102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40,109,105,109,101, 46, 98, 54,
52, 40,117,115,101,114, 41, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,
114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 51, 46,
46, 34, 41, 41, 10, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,
108,102, 46,116,112, 58, 99,111,109,109, 97,110,100, 40,109,105,109,101, 46, 98,
54, 52, 40,112, 97,115,115,119,111,114,100, 41, 41, 41, 10, 32, 32, 32, 32,114,
101,116,117,114,110, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,
116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46, 46, 34, 41, 41, 10,101,110,100,
10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,
110,100,101,120, 58,112,108, 97,105,110, 40,117,115,101,114, 44, 32,112, 97,115,
115,119,111,114,100, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 97,117,116,
104, 32, 61, 32, 34, 80, 76, 65, 73, 78, 32, 34, 32, 46, 46, 32,109,105,109,101,
46, 98, 54, 52, 40, 34, 92, 48, 34, 32, 46, 46, 32,117,115,101,114, 32, 46, 46,
32, 34, 92, 48, 34, 32, 46, 46, 32,112, 97,115,115,119,111,114,100, 41, 10, 32,
32, 32, 32,115,101,108,102, 46,116,114,121, 40,115,101,108,102, 46,116,112, 58,
99,111,109,109, 97,110,100, 40, 34, 65, 85, 84, 72, 34, 44, 32, 97,117,116,104,
41, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,116,
114,121, 40,115,101,108,102, 46,116,112, 58, 99,104,101, 99,107, 40, 34, 50, 46,
46, 34, 41, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,
101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58, 97,117,116,104, 40,117,115,
101,114, 44, 32,112, 97,115,115,119,111,114,100, 44, 32,101,120,116, 41, 10, 32,
32, 32, 32,105,102, 32,110,111,116, 32,117,115,101,114, 32,111,114, 32,110,111,
116, 32,112, 97,115,115,119,111,114,100, 32,116,104,101,110, 32,114,101,116,117,
114,110, 32, 49, 32,101,110,100, 10, 32, 32, 32, 32,105,102, 32,115,116,114,105,
110,103, 46,102,105,110,100, 40,101,120,116, 44, 32, 34, 65, 85, 84, 72, 91, 94,
92,110, 93, 43, 76, 79, 71, 73, 78, 34, 41, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 58,108,111,103,
105,110, 40,117,115,101,114, 44, 32,112, 97,115,115,119,111,114,100, 41, 10, 32,
32, 32, 32,101,108,115,101,105,102, 32,115,116,114,105,110,103, 46,102,105,110,
100, 40,101,120,116, 44, 32, 34, 65, 85, 84, 72, 91, 94, 92,110, 93, 43, 80, 76,
65, 73, 78, 34, 41, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,
101,116,117,114,110, 32,115,101,108,102, 58,112,108, 97,105,110, 40,117,115,101,
114, 44, 32,112, 97,115,115,119,111,114,100, 41, 10, 32, 32, 32, 32,101,108,115,
101, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 46,116,114,121, 40,110,
105,108, 44, 32, 34, 97,117,116,104,101,110,116,105, 99, 97,116,105,111,110, 32,
110,111,116, 32,115,117,112,112,111,114,116,101,100, 34, 41, 10, 32, 32, 32, 32,
101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,115,101,110,100, 32,109,101,115,
115, 97,103,101, 32,111,114, 32,116,104,114,111,119, 32, 97,110, 32,101,120, 99,
101,112,116,105,111,110, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,
116, 46, 95, 95,105,110,100,101,120, 58,115,101,110,100, 40,109, 97,105,108,116,
41, 10, 32, 32, 32, 32,115,101,108,102, 58,109, 97,105,108, 40,109, 97,105,108,
116, 46,102,114,111,109, 41, 10, 32, 32, 32, 32,105,102, 32, 98, 97,115,101, 46,
116,121,112,101, 40,109, 97,105,108,116, 46,114, 99,112,116, 41, 32, 61, 61, 32,
34,116, 97, 98,108,101, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
32,102,111,114, 32,105, 44,118, 32,105,110, 32, 98, 97,115,101, 46,105,112, 97,
105,114,115, 40,109, 97,105,108,116, 46,114, 99,112,116, 41, 32,100,111, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 58,114, 99,112,116,
40,118, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,108,102, 58,114, 99,
112,116, 40,109, 97,105,108,116, 46,114, 99,112,116, 41, 10, 32, 32, 32, 32,101,
110,100, 10, 32, 32, 32, 32,115,101,108,102, 58,100, 97,116, 97, 40,108,116,110,
49, 50, 46,115,111,117,114, 99,101, 46, 99,104, 97,105,110, 40,109, 97,105,108,
116, 46,115,111,117,114, 99,101, 44, 32,109,105,109,101, 46,115,116,117,102,102,
40, 41, 41, 44, 32,109, 97,105,108,116, 46,115,116,101,112, 41, 10,101,110,100,
10, 10,102,117,110, 99,116,105,111,110, 32,111,112,101,110, 40,115,101,114,118,
101,114, 44, 32,112,111,114,116, 44, 32, 99,114,101, 97,116,101, 41, 10, 32, 32,
32, 32,108,111, 99, 97,108, 32,116,112, 32, 61, 32,115,111, 99,107,101,116, 46,
116,114,121, 40,116,112, 46, 99,111,110,110,101, 99,116, 40,115,101,114,118,101,
114, 32,111,114, 32, 83, 69, 82, 86, 69, 82, 44, 32,112,111,114,116, 32,111,114,
32, 80, 79, 82, 84, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 84, 73, 77, 69, 79,
85, 84, 44, 32, 99,114,101, 97,116,101, 41, 41, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,115, 32, 61, 32, 98, 97,115,101, 46,115,101,116,109,101,116, 97,116,
97, 98,108,101, 40,123,116,112, 32, 61, 32,116,112,125, 44, 32,109,101,116, 97,
116, 41, 10, 32, 32, 32, 32, 45, 45, 32,109, 97,107,101, 32,115,117,114,101, 32,
116,112, 32,105,115, 32, 99,108,111,115,101,100, 32,105,102, 32,119,101, 32,103,
101,116, 32, 97,110, 32,101,120, 99,101,112,116,105,111,110, 10, 32, 32, 32, 32,
115, 46,116,114,121, 32, 61, 32,115,111, 99,107,101,116, 46,110,101,119,116,114,
121, 40,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32,115, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,101,110,100, 41, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32,115, 10,101,110,100, 10, 10, 45, 45,
32, 99,111,110,118,101,114,116, 32,104,101, 97,100,101,114,115, 32,116,111, 32,
108,111,119,101,114, 99, 97,115,101, 10,108,111, 99, 97,108, 32,102,117,110, 99,
116,105,111,110, 32,108,111,119,101,114, 95,104,101, 97,100,101,114,115, 40,104,
101, 97,100,101,114,115, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,108,111,
119,101,114, 32, 61, 32,123,125, 10, 32, 32, 32, 32,102,111,114, 32,105, 44,118,
32,105,110, 32, 98, 97,115,101, 46,112, 97,105,114,115, 40,104,101, 97,100,101,
114,115, 32,111,114, 32,108,111,119,101,114, 41, 32,100,111, 10, 32, 32, 32, 32,
32, 32, 32, 32,108,111,119,101,114, 91,115,116,114,105,110,103, 46,108,111,119,
101,114, 40,105, 41, 93, 32, 61, 32,118, 10, 32, 32, 32, 32,101,110,100, 10, 32,
32, 32, 32,114,101,116,117,114,110, 32,108,111,119,101,114, 10,101,110,100, 10,
10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
120, 58, 97,117,116,104, 40,117,115,101,114, 44, 32,112, 97,115,115,119,111,114,
100, 44, 32,101,120,116, 41, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,117,
115,101,114, 32,111,114, 32,110,111,116, 32,112, 97,115,115,119,111,114,100, 32,
116,104,101,110, 32,114,101,116,117,114,110, 32, 49, 32,101,110,100, 10, 32, 32,
32, 32,105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,101,120,116,
44, 32, 34, 65, 85, 84, 72, 91, 94, 92,110, 93, 43, 76, 79, 71, 73, 78, 34, 41,
32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110,
32,115,101,108,102, 58,108,111,103,105,110, 40,117,115,101,114, 44, 32,112, 97,
115,115,119,111,114,100, 41, 10, 32, 32, 32, 32,101,108,115,101,105,102, 32,115,
116,114,105,110,103, 46,102,105,110,100, 40,101,120,116, 44, 32, 34, 65, 85, 84,
72, 91, 94, 92,110, 93, 43, 80, 76, 65, 73, 78, 34, 41, 32,116,104,101,110, 10,
32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 58,
112,108, 97,105,110, 40,117,115,101,114, 44, 32,112, 97,115,115,119,111,114,100,
41, 10, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,
101,108,102, 46,116,114,121, 40,110,105,108, 44, 32, 34, 97,117,116,104,101,110,
116,105, 99, 97,116,105,111,110, 32,110,111,116, 32,115,117,112,112,111,114,116,
101,100, 34, 41, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45,
32,115,101,110,100, 32,109,101,115,115, 97,103,101, 32,111,114, 32,116,104,114,
111,119, 32, 97,110, 32,101,120, 99,101,112,116,105,111,110, 10,102,117,110, 99,
116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,115,
101,110,100, 40,109, 97,105,108,116, 41, 10, 32, 32, 32, 32,115,101,108,102, 58,
109, 97,105,108, 40,109, 97,105,108,116, 46,102,114,111,109, 41, 10, 32, 32, 32,
32,105,102, 32, 98, 97,115,101, 46,116,121,112,101, 40,109, 97,105,108,116, 46,
114, 99,112,116, 41, 32, 61, 61, 32, 34,116, 97, 98,108,101, 34, 32,116,104,101,
110, 10, 32, 32, 32, 32, 32, 32, 32, 32,102,111,114, 32,105, 44,118, 32,105,110,
32, 98, 97,115,101, 46,105,112, 97,105,114,115, 40,109, 97,105,108,116, 46,114,
99,112,116, 41, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
115,101,108,102, 58,114, 99,112,116, 40,118, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32,101,110,100, 10, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32,
32, 32,115,101,108,102, 58,114, 99,112,116, 40,109, 97,105,108,116, 46,114, 99,
112,116, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,115,101,108,102,
58,100, 97,116, 97, 40,108,116,110, 49, 50, 46,115,111,117,114, 99,101, 46, 99,
104, 97,105,110, 40,109, 97,105,108,116, 46,115,111,117,114, 99,101, 44, 32,109,
105,109,101, 46,115,116,117,102,102, 40, 41, 41, 44, 32,109, 97,105,108,116, 46,
115,116,101,112, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,
95, 77, 46,111,112,101,110, 40,115,101,114,118,101,114, 44, 32,112,111,114,116,
44, 32, 99,114,101, 97,116,101, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,
116,112, 32, 61, 32,115,111, 99,107,101,116, 46,116,114,121, 40,116,112, 46, 99,
111,110,110,101, 99,116, 40,115,101,114,118,101,114, 32,111,114, 32, 95, 77, 46,
83, 69, 82, 86, 69, 82, 44, 32,112,111,114,116, 32,111,114, 32, 95, 77, 46, 80,
79, 82, 84, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 95, 77, 46, 84, 73, 77, 69,
79, 85, 84, 44, 32, 99,114,101, 97,116,101, 41, 41, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,115, 32, 61, 32, 98, 97,115,101, 46,115,101,116,109,101,116, 97,
116, 97, 98,108,101, 40,123,116,112, 32, 61, 32,116,112,125, 44, 32,109,101,116,
97,116, 41, 10, 32, 32, 32, 32, 45, 45, 32,109, 97,107,101, 32,115,117,114,101,
32,116,112, 32,105,115, 32, 99,108,111,115,101,100, 32,105,102, 32,119,101, 32,
103,101,116, 32, 97,110, 32,101,120, 99,101,112,116,105,111,110, 10, 32, 32, 32,
32,115, 46,116,114,121, 32, 61, 32,115,111, 99,107,101,116, 46,110,101,119,116,
114,121, 40,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32,
32, 32,115, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,101,110,100, 41,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115, 10,101,110,100, 10, 10, 45,
45, 32, 99,111,110,118,101,114,116, 32,104,101, 97,100,101,114,115, 32,116,111,
32,108,111,119,101,114, 99, 97,115,101, 10,108,111, 99, 97,108, 32,102,117,110,
99,116,105,111,110, 32,108,111,119,101,114, 95,104,101, 97,100,101,114,115, 40,
104,101, 97,100,101,114,115, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,108,
111,119,101,114, 32, 61, 32,123,125, 10, 32, 32, 32, 32,102,111,114, 32,105, 44,
118, 32,105,110, 32, 98, 97,115,101, 46,112, 97,105,114,115, 40,104,101, 97,100,
101,114,115, 32,111,114, 32,108,111,119,101,114, 41, 32,100,111, 10, 32, 32, 32,
32, 32, 32, 32, 32,108,111,119,101,114, 91,115,116,114,105,110,103, 46,108,111,
119,101,114, 40,105, 41, 93, 32, 61, 32,118, 10, 32, 32, 32, 32,101,110,100, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32,108,111,119,101,114, 10,101,110,100,
10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,
77,117,108,116,105,112, 97,114,116, 32,109,101,115,115, 97,103,101, 32,115,111,
117,114, 99,101, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45,
32, 77,117,108,116,105,112, 97,114,116, 32,109,101,115,115, 97,103,101, 32,115,
111,117,114, 99,101, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 10, 45, 45, 32,114,101,116,117,114,110,115, 32, 97, 32,104,111,112,101,
102,117,108,108,121, 32,117,110,105,113,117,101, 32,109,105,109,101, 32, 98,111,
117,110,100, 97,114,121, 10,108,111, 99, 97,108, 32,115,101,113,110,111, 32, 61,
32, 48, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,110,101,
119, 98,111,117,110,100, 97,114,121, 40, 41, 10, 32, 32, 32, 32,115,101,113,110,
111, 32, 61, 32,115,101,113,110,111, 32, 43, 32, 49, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32,115,116,114,105,110,103, 46,102,111,114,109, 97,116, 40, 39,
37,115, 37, 48, 53,100, 61, 61, 37, 48, 53,117, 39, 44, 32,111,115, 46,100, 97,
116,101, 40, 39, 37,100, 37,109, 37, 89, 37, 72, 37, 77, 37, 83, 39, 41, 44, 10,
32, 32, 32, 32, 32, 32, 32, 32,109, 97,116,104, 46,114, 97,110,100,111,109, 40,
48, 44, 32, 57, 57, 57, 57, 57, 41, 44, 32,115,101,113,110,111, 41, 10,101,110,
100, 10, 10, 45, 45, 32,115,101,110,100, 95,109,101,115,115, 97,103,101, 32,102,
111,114,119, 97,114,100, 32,100,101, 99,108, 97,114, 97,116,105,111,110, 10,108,
111, 99, 97,108, 32,115,101,110,100, 95,109,101,115,115, 97,103,101, 10, 10, 45,
45, 32,121,105,101,108,100, 32,116,104,101, 32,104,101, 97,100,101,114,115, 32,
97,108,108, 32, 97,116, 32,111,110, 99,101, 44, 32,105,116, 39,115, 32,102, 97,
115,116,101,114, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,
115,101,110,100, 95,104,101, 97,100,101,114,115, 40,104,101, 97,100,101,114,115,
41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,104, 32, 61, 32, 34, 92,114, 92,
110, 34, 10, 32, 32, 32, 32,102,111,114, 32,105, 44,118, 32,105,110, 32, 98, 97,
115,101, 46,112, 97,105,114,115, 40,104,101, 97,100,101,114,115, 41, 32,100,111,
10, 32, 32, 32, 32, 32, 32, 32, 32,104, 32, 61, 32,105, 32, 46, 46, 32, 39, 58,
32, 39, 32, 46, 46, 32,118, 32, 46, 46, 32, 34, 92,114, 92,110, 34, 32, 46, 46,
32,104, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 99,111,114,111,117,
116,105,110,101, 46,121,105,101,108,100, 40,104, 41, 10,101,110,100, 10, 10, 45,
45, 32,121,105,101,108,100, 32,109,117,108,116,105,112, 97,114,116, 32,109,101,
115,115, 97,103,101, 32, 98,111,100,121, 32,102,114,111,109, 32, 97, 32,109,117,
108,116,105,112, 97,114,116, 32,109,101,115,115, 97,103,101, 32,116, 97, 98,108,
101, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,115,101,110,
100, 95,109,117,108,116,105,112, 97,114,116, 40,109,101,115,103,116, 41, 10, 32,
32, 32, 32, 45, 45, 32,109, 97,107,101, 32,115,117,114,101, 32,119,101, 32,104,
97,118,101, 32,111,117,114, 32, 98,111,117,110,100, 97,114,121, 32, 97,110,100,
32,115,101,110,100, 32,104,101, 97,100,101,114,115, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32, 98,100, 32, 61, 32,110,101,119, 98,111,117,110,100, 97,114,121,
40, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,104,101, 97,100,101,114,115,
32, 61, 32,108,111,119,101,114, 95,104,101, 97,100,101,114,115, 40,109,101,115,
103,116, 46,104,101, 97,100,101,114,115, 32,111,114, 32,123,125, 41, 10, 32, 32,
32, 32,104,101, 97,100,101,114,115, 91, 39, 99,111,110,116,101,110,116, 45,116,
121,112,101, 39, 93, 32, 61, 32,104,101, 97,100,101,114,115, 91, 39, 99,111,110,
116,101,110,116, 45,116,121,112,101, 39, 93, 32,111,114, 32, 39,109,117,108,116,
105,112, 97,114,116, 47,109,105,120,101,100, 39, 10, 32, 32, 32, 32,104,101, 97,
100,101,114,115, 91, 39, 99,111,110,116,101,110,116, 45,116,121,112,101, 39, 93,
32, 61, 32,104,101, 97,100,101,114,115, 91, 39, 99,111,110,116,101,110,116, 45,
116,121,112,101, 39, 93, 32, 46, 46, 10, 32, 32, 32, 32, 32, 32, 32, 32, 39, 59,
32, 98,111,117,110,100, 97,114,121, 61, 34, 39, 32, 46, 46, 32, 32, 98,100, 32,
46, 46, 32, 39, 34, 39, 10, 32, 32, 32, 32,115,101,110,100, 95,104,101, 97,100,
101,114,115, 40,104,101, 97,100,101,114,115, 41, 10, 32, 32, 32, 32, 45, 45, 32,
115,101,110,100, 32,112,114,101, 97,109, 98,108,101, 10, 32, 32, 32, 32,105,102,
32,109,101,115,103,116, 46, 98,111,100,121, 46,112,114,101, 97,109, 98,108,101,
32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 99,111,114,111,117,116,
105,110,101, 46,121,105,101,108,100, 40,109,101,115,103,116, 46, 98,111,100,121,
46,112,114,101, 97,109, 98,108,101, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 99,
45, 45, 45, 10, 45, 45, 32,114,101,116,117,114,110,115, 32, 97, 32,104,111,112,
101,102,117,108,108,121, 32,117,110,105,113,117,101, 32,109,105,109,101, 32, 98,
111,117,110,100, 97,114,121, 10,108,111, 99, 97,108, 32,115,101,113,110,111, 32,
61, 32, 48, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,110,
101,119, 98,111,117,110,100, 97,114,121, 40, 41, 10, 32, 32, 32, 32,115,101,113,
110,111, 32, 61, 32,115,101,113,110,111, 32, 43, 32, 49, 10, 32, 32, 32, 32,114,
101,116,117,114,110, 32,115,116,114,105,110,103, 46,102,111,114,109, 97,116, 40,
39, 37,115, 37, 48, 53,100, 61, 61, 37, 48, 53,117, 39, 44, 32,111,115, 46,100,
97,116,101, 40, 39, 37,100, 37,109, 37, 89, 37, 72, 37, 77, 37, 83, 39, 41, 44,
10, 32, 32, 32, 32, 32, 32, 32, 32,109, 97,116,104, 46,114, 97,110,100,111,109,
40, 48, 44, 32, 57, 57, 57, 57, 57, 41, 44, 32,115,101,113,110,111, 41, 10,101,
110,100, 10, 10, 45, 45, 32,115,101,110,100, 95,109,101,115,115, 97,103,101, 32,
102,111,114,119, 97,114,100, 32,100,101, 99,108, 97,114, 97,116,105,111,110, 10,
108,111, 99, 97,108, 32,115,101,110,100, 95,109,101,115,115, 97,103,101, 10, 10,
45, 45, 32,121,105,101,108,100, 32,116,104,101, 32,104,101, 97,100,101,114,115,
32, 97,108,108, 32, 97,116, 32,111,110, 99,101, 44, 32,105,116, 39,115, 32,102,
97,115,116,101,114, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110,
32,115,101,110,100, 95,104,101, 97,100,101,114,115, 40,116,111,115,101,110,100,
41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99, 97,110,111,110,105, 99, 32,
61, 32,104,101, 97,100,101,114,115, 46, 99, 97,110,111,110,105, 99, 10, 32, 32,
32, 32,108,111, 99, 97,108, 32,104, 32, 61, 32, 34, 92,114, 92,110, 34, 10, 32,
32, 32, 32,102,111,114, 32,102, 44,118, 32,105,110, 32, 98, 97,115,101, 46,112,
97,105,114,115, 40,116,111,115,101,110,100, 41, 32,100,111, 10, 32, 32, 32, 32,
32, 32, 32, 32,104, 32, 61, 32, 40, 99, 97,110,111,110,105, 99, 91,102, 93, 32,
111,114, 32,102, 41, 32, 46, 46, 32, 39, 58, 32, 39, 32, 46, 46, 32,118, 32, 46,
46, 32, 34, 92,114, 92,110, 34, 32, 46, 46, 32,104, 10, 32, 32, 32, 32,101,110,
100, 10, 32, 32, 32, 32, 99,111,114,111,117,116,105,110,101, 46,121,105,101,108,
100, 40,104, 41, 10,101,110,100, 10, 10, 45, 45, 32,121,105,101,108,100, 32,109,
117,108,116,105,112, 97,114,116, 32,109,101,115,115, 97,103,101, 32, 98,111,100,
121, 32,102,114,111,109, 32, 97, 32,109,117,108,116,105,112, 97,114,116, 32,109,
101,115,115, 97,103,101, 32,116, 97, 98,108,101, 10,108,111, 99, 97,108, 32,102,
117,110, 99,116,105,111,110, 32,115,101,110,100, 95,109,117,108,116,105,112, 97,
114,116, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32, 45, 45, 32,109, 97,107,
101, 32,115,117,114,101, 32,119,101, 32,104, 97,118,101, 32,111,117,114, 32, 98,
111,117,110,100, 97,114,121, 32, 97,110,100, 32,115,101,110,100, 32,104,101, 97,
100,101,114,115, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 98,100, 32, 61, 32,
110,101,119, 98,111,117,110,100, 97,114,121, 40, 41, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,104,101, 97,100,101,114,115, 32, 61, 32,108,111,119,101,114, 95,
104,101, 97,100,101,114,115, 40,109,101,115,103,116, 46,104,101, 97,100,101,114,
115, 32,111,114, 32,123,125, 41, 10, 32, 32, 32, 32,104,101, 97,100,101,114,115,
91, 39, 99,111,110,116,101,110,116, 45,116,121,112,101, 39, 93, 32, 61, 32,104,
101, 97,100,101,114,115, 91, 39, 99,111,110,116,101,110,116, 45,116,121,112,101,
39, 93, 32,111,114, 32, 39,109,117,108,116,105,112, 97,114,116, 47,109,105,120,
101,100, 39, 10, 32, 32, 32, 32,104,101, 97,100,101,114,115, 91, 39, 99,111,110,
116,101,110,116, 45,116,121,112,101, 39, 93, 32, 61, 32,104,101, 97,100,101,114,
115, 91, 39, 99,111,110,116,101,110,116, 45,116,121,112,101, 39, 93, 32, 46, 46,
10, 32, 32, 32, 32, 32, 32, 32, 32, 39, 59, 32, 98,111,117,110,100, 97,114,121,
61, 34, 39, 32, 46, 46, 32, 32, 98,100, 32, 46, 46, 32, 39, 34, 39, 10, 32, 32,
32, 32,115,101,110,100, 95,104,101, 97,100,101,114,115, 40,104,101, 97,100,101,
114,115, 41, 10, 32, 32, 32, 32, 45, 45, 32,115,101,110,100, 32,112,114,101, 97,
109, 98,108,101, 10, 32, 32, 32, 32,105,102, 32,109,101,115,103,116, 46, 98,111,
100,121, 46,112,114,101, 97,109, 98,108,101, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32, 99,111,114,111,117,116,105,110,101, 46,121,105,101,108,100,
40,109,101,115,103,116, 46, 98,111,100,121, 46,112,114,101, 97,109, 98,108,101,
41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 99,111,114,111,117,116,105,110,101, 46,
121,105,101,108,100, 40, 34, 92,114, 92,110, 34, 41, 10, 32, 32, 32, 32,101,110,
100, 10, 32, 32, 32, 32, 45, 45, 32,115,101,110,100, 32,101, 97, 99,104, 32,112,
97,114,116, 32,115,101,112, 97,114, 97,116,101,100, 32, 98,121, 32, 97, 32, 98,
111,117,110,100, 97,114,121, 10, 32, 32, 32, 32,102,111,114, 32,105, 44, 32,109,
32,105,110, 32, 98, 97,115,101, 46,105,112, 97,105,114,115, 40,109,101,115,103,
116, 46, 98,111,100,121, 41, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32, 99,
111,114,111,117,116,105,110,101, 46,121,105,101,108,100, 40, 34, 92,114, 92,110,
34, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 45, 45, 32,115,101,
110,100, 32,101, 97, 99,104, 32,112, 97,114,116, 32,115,101,112, 97,114, 97,116,
101,100, 32, 98,121, 32, 97, 32, 98,111,117,110,100, 97,114,121, 10, 32, 32, 32,
32,102,111,114, 32,105, 44, 32,109, 32,105,110, 32, 98, 97,115,101, 46,105,112,
97,105,114,115, 40,109,101,115,103,116, 46, 98,111,100,121, 41, 32,100,111, 10,
32, 32, 32, 32, 32, 32, 32, 32, 99,111,114,111,117,116,105,110,101, 46,121,105,
101,108,100, 40, 34, 92,114, 92,110, 45, 45, 34, 32, 46, 46, 32, 98,100, 32, 46,
46, 32, 34, 92,114, 92,110, 34, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,
110,100, 95,109,101,115,115, 97,103,101, 40,109, 41, 10, 32, 32, 32, 32,101,110,
100, 10, 32, 32, 32, 32, 45, 45, 32,115,101,110,100, 32,108, 97,115,116, 32, 98,
111,117,110,100, 97,114,121, 10, 32, 32, 32, 32, 99,111,114,111,117,116,105,110,
101, 46,121,105,101,108,100, 40, 34, 92,114, 92,110, 45, 45, 34, 32, 46, 46, 32,
98,100, 32, 46, 46, 32, 34, 45, 45, 92,114, 92,110, 92,114, 92,110, 34, 41, 10,
32, 32, 32, 32, 45, 45, 32,115,101,110,100, 32,101,112,105,108,111,103,117,101,
10, 32, 32, 32, 32,105,102, 32,109,101,115,103,116, 46, 98,111,100,121, 46,101,
112,105,108,111,103,117,101, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
32, 99,111,114,111,117,116,105,110,101, 46,121,105,101,108,100, 40,109,101,115,
103,116, 46, 98,111,100,121, 46,101,112,105,108,111,103,117,101, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32, 99,111,114,111,117,116,105,110,101, 46,121,105,101,108,
100, 40, 34, 92,114, 92,110, 34, 41, 10, 32, 32, 32, 32,101,110,100, 10,101,110,
45, 45, 34, 32, 46, 46, 32, 98,100, 32, 46, 46, 32, 34, 92,114, 92,110, 34, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32,115,101,110,100, 95,109,101,115,115, 97,103,
101, 40,109, 41, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 45, 45, 32,
115,101,110,100, 32,108, 97,115,116, 32, 98,111,117,110,100, 97,114,121, 10, 32,
32, 32, 32, 99,111,114,111,117,116,105,110,101, 46,121,105,101,108,100, 40, 34,
92,114, 92,110, 45, 45, 34, 32, 46, 46, 32, 98,100, 32, 46, 46, 32, 34, 45, 45,
92,114, 92,110, 92,114, 92,110, 34, 41, 10, 32, 32, 32, 32, 45, 45, 32,115,101,
110,100, 32,101,112,105,108,111,103,117,101, 10, 32, 32, 32, 32,105,102, 32,109,
101,115,103,116, 46, 98,111,100,121, 46,101,112,105,108,111,103,117,101, 32,116,
104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 99,111,114,111,117,116,105,110,
101, 46,121,105,101,108,100, 40,109,101,115,103,116, 46, 98,111,100,121, 46,101,
112,105,108,111,103,117,101, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 99,111,114,
111,117,116,105,110,101, 46,121,105,101,108,100, 40, 34, 92,114, 92,110, 34, 41,
10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,121,105,101,
108,100, 32,109,101,115,115, 97,103,101, 32, 98,111,100,121, 32,102,114,111,109,
32, 97, 32,115,111,117,114, 99,101, 10,108,111, 99, 97,108, 32,102,117,110, 99,
116,105,111,110, 32,115,101,110,100, 95,115,111,117,114, 99,101, 40,109,101,115,
103,116, 41, 10, 32, 32, 32, 32, 45, 45, 32,109, 97,107,101, 32,115,117,114,101,
32,119,101, 32,104, 97,118,101, 32, 97, 32, 99,111,110,116,101,110,116, 45,116,
121,112,101, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,104,101, 97,100,101,114,
115, 32, 61, 32,108,111,119,101,114, 95,104,101, 97,100,101,114,115, 40,109,101,
115,103,116, 46,104,101, 97,100,101,114,115, 32,111,114, 32,123,125, 41, 10, 32,
32, 32, 32,104,101, 97,100,101,114,115, 91, 39, 99,111,110,116,101,110,116, 45,
116,121,112,101, 39, 93, 32, 61, 32,104,101, 97,100,101,114,115, 91, 39, 99,111,
110,116,101,110,116, 45,116,121,112,101, 39, 93, 32,111,114, 10, 32, 32, 32, 32,
32, 32, 32, 32, 39,116,101,120,116, 47,112,108, 97,105,110, 59, 32, 99,104, 97,
114,115,101,116, 61, 34,105,115,111, 45, 56, 56, 53, 57, 45, 49, 34, 39, 10, 32,
32, 32, 32,115,101,110,100, 95,104,101, 97,100,101,114,115, 40,104,101, 97,100,
101,114,115, 41, 10, 32, 32, 32, 32, 45, 45, 32,115,101,110,100, 32, 98,111,100,
121, 32,102,114,111,109, 32,115,111,117,114, 99,101, 10, 32, 32, 32, 32,119,104,
105,108,101, 32,116,114,117,101, 32,100,111, 10, 32, 32, 32, 32, 32, 32, 32, 32,
108,111, 99, 97,108, 32, 99,104,117,110,107, 44, 32,101,114,114, 32, 61, 32,109,
101,115,103,116, 46, 98,111,100,121, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
105,102, 32,101,114,114, 32,116,104,101,110, 32, 99,111,114,111,117,116,105,110,
101, 46,121,105,101,108,100, 40,110,105,108, 44, 32,101,114,114, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32,101,108,115,101,105,102, 32, 99,104,117,110,107, 32,116,
104,101,110, 32, 99,111,114,111,117,116,105,110,101, 46,121,105,101,108,100, 40,
99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,
98,114,101, 97,107, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,
100, 10, 10, 45, 45, 32,121,105,101,108,100, 32,109,101,115,115, 97,103,101, 32,
98,111,100,121, 32,102,114,111,109, 32, 97, 32,115,111,117,114, 99,101, 10,108,
98,111,100,121, 32,102,114,111,109, 32, 97, 32,115,116,114,105,110,103, 10,108,
111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32,115,101,110,100, 95,115,
111,117,114, 99,101, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32, 45, 45, 32,
116,114,105,110,103, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32, 45, 45, 32,
109, 97,107,101, 32,115,117,114,101, 32,119,101, 32,104, 97,118,101, 32, 97, 32,
99,111,110,116,101,110,116, 45,116,121,112,101, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,104,101, 97,100,101,114,115, 32, 61, 32,108,111,119,101,114, 95,104,
@@ -309,102 +339,77 @@ static const unsigned char B1[]={
108, 97,105,110, 59, 32, 99,104, 97,114,115,101,116, 61, 34,105,115,111, 45, 56,
56, 53, 57, 45, 49, 34, 39, 10, 32, 32, 32, 32,115,101,110,100, 95,104,101, 97,
100,101,114,115, 40,104,101, 97,100,101,114,115, 41, 10, 32, 32, 32, 32, 45, 45,
32,115,101,110,100, 32, 98,111,100,121, 32,102,114,111,109, 32,115,111,117,114,
99,101, 10, 32, 32, 32, 32,119,104,105,108,101, 32,116,114,117,101, 32,100,111,
10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,104,117,110,107,
44, 32,101,114,114, 32, 61, 32,109,101,115,103,116, 46, 98,111,100,121, 40, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,101,114,114, 32,116,104,101,110,
32, 99,111,114,111,117,116,105,110,101, 46,121,105,101,108,100, 40,110,105,108,
44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,105,
102, 32, 99,104,117,110,107, 32,116,104,101,110, 32, 99,111,114,111,117,116,105,
110,101, 46,121,105,101,108,100, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32,101,108,115,101, 32, 98,114,101, 97,107, 32,101,110,100, 10, 32,
32, 32, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,121,105,101,108,100,
32,109,101,115,115, 97,103,101, 32, 98,111,100,121, 32,102,114,111,109, 32, 97,
32,115,116,114,105,110,103, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,
111,110, 32,115,101,110,100, 95,115,116,114,105,110,103, 40,109,101,115,103,116,
41, 10, 32, 32, 32, 32, 45, 45, 32,109, 97,107,101, 32,115,117,114,101, 32,119,
101, 32,104, 97,118,101, 32, 97, 32, 99,111,110,116,101,110,116, 45,116,121,112,
101, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,104,101, 97,100,101,114,115, 32,
61, 32,108,111,119,101,114, 95,104,101, 97,100,101,114,115, 40,109,101,115,103,
116, 46,104,101, 97,100,101,114,115, 32,111,114, 32,123,125, 41, 10, 32, 32, 32,
32,104,101, 97,100,101,114,115, 91, 39, 99,111,110,116,101,110,116, 45,116,121,
112,101, 39, 93, 32, 61, 32,104,101, 97,100,101,114,115, 91, 39, 99,111,110,116,
101,110,116, 45,116,121,112,101, 39, 93, 32,111,114, 10, 32, 32, 32, 32, 32, 32,
32, 32, 39,116,101,120,116, 47,112,108, 97,105,110, 59, 32, 99,104, 97,114,115,
101,116, 61, 34,105,115,111, 45, 56, 56, 53, 57, 45, 49, 34, 39, 10, 32, 32, 32,
32,115,101,110,100, 95,104,101, 97,100,101,114,115, 40,104,101, 97,100,101,114,
115, 41, 10, 32, 32, 32, 32, 45, 45, 32,115,101,110,100, 32, 98,111,100,121, 32,
102,114,111,109, 32,115,116,114,105,110,103, 10, 32, 32, 32, 32, 99,111,114,111,
117,116,105,110,101, 46,121,105,101,108,100, 40,109,101,115,103,116, 46, 98,111,
100,121, 41, 10,101,110,100, 10, 10, 45, 45, 32,109,101,115,115, 97,103,101, 32,
115,111,117,114, 99,101, 10,102,117,110, 99,116,105,111,110, 32,115,101,110,100,
95,109,101,115,115, 97,103,101, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32,
105,102, 32, 98, 97,115,101, 46,116,121,112,101, 40,109,101,115,103,116, 46, 98,
111,100,121, 41, 32, 61, 61, 32, 34,116, 97, 98,108,101, 34, 32,116,104,101,110,
32,115,101,110,100, 95,109,117,108,116,105,112, 97,114,116, 40,109,101,115,103,
116, 41, 10, 32, 32, 32, 32,101,108,115,101,105,102, 32, 98, 97,115,101, 46,116,
32,115,101,110,100, 32, 98,111,100,121, 32,102,114,111,109, 32,115,116,114,105,
110,103, 10, 32, 32, 32, 32, 99,111,114,111,117,116,105,110,101, 46,121,105,101,
108,100, 40,109,101,115,103,116, 46, 98,111,100,121, 41, 10,101,110,100, 10, 10,
45, 45, 32,109,101,115,115, 97,103,101, 32,115,111,117,114, 99,101, 10,102,117,
110, 99,116,105,111,110, 32,115,101,110,100, 95,109,101,115,115, 97,103,101, 40,
109,101,115,103,116, 41, 10, 32, 32, 32, 32,105,102, 32, 98, 97,115,101, 46,116,
121,112,101, 40,109,101,115,103,116, 46, 98,111,100,121, 41, 32, 61, 61, 32, 34,
102,117,110, 99,116,105,111,110, 34, 32,116,104,101,110, 32,115,101,110,100, 95,
115,111,117,114, 99,101, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32,101,108,
115,101, 32,115,101,110,100, 95,115,116,114,105,110,103, 40,109,101,115,103,116,
41, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,115,101,116, 32,100,101,
102, 97,117,108, 32,104,101, 97,100,101,114,115, 10,108,111, 99, 97,108, 32,102,
117,110, 99,116,105,111,110, 32, 97,100,106,117,115,116, 95,104,101, 97,100,101,
114,115, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,
108,111,119,101,114, 32, 61, 32,108,111,119,101,114, 95,104,101, 97,100,101,114,
115, 40,109,101,115,103,116, 46,104,101, 97,100,101,114,115, 41, 10, 32, 32, 32,
32,108,111,119,101,114, 91, 34,100, 97,116,101, 34, 93, 32, 61, 32,108,111,119,
101,114, 91, 34,100, 97,116,101, 34, 93, 32,111,114, 10, 32, 32, 32, 32, 32, 32,
32, 32,111,115, 46,100, 97,116,101, 40, 34, 33, 37, 97, 44, 32, 37,100, 32, 37,
98, 32, 37, 89, 32, 37, 72, 58, 37, 77, 58, 37, 83, 32, 34, 41, 32, 46, 46, 32,
40,109,101,115,103,116, 46,122,111,110,101, 32,111,114, 32, 90, 79, 78, 69, 41,
10, 32, 32, 32, 32,108,111,119,101,114, 91, 34,120, 45,109, 97,105,108,101,114,
34, 93, 32, 61, 32,108,111,119,101,114, 91, 34,120, 45,109, 97,105,108,101,114,
34, 93, 32,111,114, 32,115,111, 99,107,101,116, 46, 95, 86, 69, 82, 83, 73, 79,
78, 10, 32, 32, 32, 32, 45, 45, 32,116,104,105,115, 32, 99, 97,110, 39,116, 32,
98,101, 32,111,118,101,114,114,105,100,101,110, 10, 32, 32, 32, 32,108,111,119,
101,114, 91, 34,109,105,109,101, 45,118,101,114,115,105,111,110, 34, 93, 32, 61,
32, 34, 49, 46, 48, 34, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,108,111,
119,101,114, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,
115,115, 97,103,101, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32,109,101,115,
103,116, 46,104,101, 97,100,101,114,115, 32, 61, 32, 97,100,106,117,115,116, 95,
104,101, 97,100,101,114,115, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32, 45,
45, 32, 99,114,101, 97,116,101, 32, 97,110,100, 32,114,101,116,117,114,110, 32,
109,101,115,115, 97,103,101, 32,115,111,117,114, 99,101, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32, 99,111, 32, 61, 32, 99,111,114,111,117,116,105,110,101, 46,
99,114,101, 97,116,101, 40,102,117,110, 99,116,105,111,110, 40, 41, 32,115,101,
110,100, 95,109,101,115,115, 97,103,101, 40,109,101,115,103,116, 41, 32,101,110,
100, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,
111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,
101,116, 44, 32, 97, 44, 32, 98, 32, 61, 32, 99,111,114,111,117,116,105,110,101,
46,114,101,115,117,109,101, 40, 99,111, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
105,102, 32,114,101,116, 32,116,104,101,110, 32,114,101,116,117,114,110, 32, 97,
44, 32, 98, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,
117,114,110, 32,110,105,108, 44, 32, 97, 32,101,110,100, 10, 32, 32, 32, 32,101,
110,100, 10,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
116, 97, 98,108,101, 34, 32,116,104,101,110, 32,115,101,110,100, 95,109,117,108,
116,105,112, 97,114,116, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32,101,108,
115,101,105,102, 32, 98, 97,115,101, 46,116,121,112,101, 40,109,101,115,103,116,
46, 98,111,100,121, 41, 32, 61, 61, 32, 34,102,117,110, 99,116,105,111,110, 34,
32,116,104,101,110, 32,115,101,110,100, 95,115,111,117,114, 99,101, 40,109,101,
115,103,116, 41, 10, 32, 32, 32, 32,101,108,115,101, 32,115,101,110,100, 95,115,
116,114,105,110,103, 40,109,101,115,103,116, 41, 32,101,110,100, 10,101,110,100,
10, 10, 45, 45, 32,115,101,116, 32,100,101,102, 97,117,108, 32,104,101, 97,100,
101,114,115, 10,108,111, 99, 97,108, 32,102,117,110, 99,116,105,111,110, 32, 97,
100,106,117,115,116, 95,104,101, 97,100,101,114,115, 40,109,101,115,103,116, 41,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32,108,111,119,101,114, 32, 61, 32,108,
111,119,101,114, 95,104,101, 97,100,101,114,115, 40,109,101,115,103,116, 46,104,
101, 97,100,101,114,115, 41, 10, 32, 32, 32, 32,108,111,119,101,114, 91, 34,100,
97,116,101, 34, 93, 32, 61, 32,108,111,119,101,114, 91, 34,100, 97,116,101, 34,
93, 32,111,114, 10, 32, 32, 32, 32, 32, 32, 32, 32,111,115, 46,100, 97,116,101,
40, 34, 33, 37, 97, 44, 32, 37,100, 32, 37, 98, 32, 37, 89, 32, 37, 72, 58, 37,
77, 58, 37, 83, 32, 34, 41, 32, 46, 46, 32, 40,109,101,115,103,116, 46,122,111,
110,101, 32,111,114, 32, 95, 77, 46, 90, 79, 78, 69, 41, 10, 32, 32, 32, 32,108,
111,119,101,114, 91, 34,120, 45,109, 97,105,108,101,114, 34, 93, 32, 61, 32,108,
111,119,101,114, 91, 34,120, 45,109, 97,105,108,101,114, 34, 93, 32,111,114, 32,
115,111, 99,107,101,116, 46, 95, 86, 69, 82, 83, 73, 79, 78, 10, 32, 32, 32, 32,
45, 45, 32,116,104,105,115, 32, 99, 97,110, 39,116, 32, 98,101, 32,111,118,101,
114,114,105,100,101,110, 10, 32, 32, 32, 32,108,111,119,101,114, 91, 34,109,105,
109,101, 45,118,101,114,115,105,111,110, 34, 93, 32, 61, 32, 34, 49, 46, 48, 34,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32,108,111,119,101,114, 10,101,110,
100, 10, 10,102,117,110, 99,116,105,111,110, 32, 95, 77, 46,109,101,115,115, 97,
103,101, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32,109,101,115,103,116, 46,
104,101, 97,100,101,114,115, 32, 61, 32, 97,100,106,117,115,116, 95,104,101, 97,
100,101,114,115, 40,109,101,115,103,116, 41, 10, 32, 32, 32, 32, 45, 45, 32, 99,
114,101, 97,116,101, 32, 97,110,100, 32,114,101,116,117,114,110, 32,109,101,115,
115, 97,103,101, 32,115,111,117,114, 99,101, 10, 32, 32, 32, 32,108,111, 99, 97,
108, 32, 99,111, 32, 61, 32, 99,111,114,111,117,116,105,110,101, 46, 99,114,101,
97,116,101, 40,102,117,110, 99,116,105,111,110, 40, 41, 32,115,101,110,100, 95,
109,101,115,115, 97,103,101, 40,109,101,115,103,116, 41, 32,101,110,100, 41, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,110, 40,
41, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,116, 44,
32, 97, 44, 32, 98, 32, 61, 32, 99,111,114,111,117,116,105,110,101, 46,114,101,
115,117,109,101, 40, 99,111, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
114,101,116, 32,116,104,101,110, 32,114,101,116,117,114,110, 32, 97, 44, 32, 98,
10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110,
32,110,105,108, 44, 32, 97, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,
101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 10, 45, 45, 32, 72,105,103,104, 32,108,101,118,101,108, 32, 83, 77,
84, 80, 32, 65, 80, 73, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
10, 45, 45, 32, 72,105,103,104, 32,108,101,118,101,108, 32, 83, 77, 84, 80, 32,
65, 80, 73, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 10,115,101,110,100, 32, 61, 32,115,111, 99,107,101,116, 46,112,
45, 10, 95, 77, 46,115,101,110,100, 32, 61, 32,115,111, 99,107,101,116, 46,112,
114,111,116,101, 99,116, 40,102,117,110, 99,116,105,111,110, 40,109, 97,105,108,
116, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115, 32, 61, 32,111,112,101,
110, 40,109, 97,105,108,116, 46,115,101,114,118,101,114, 44, 32,109, 97,105,108,
116, 46,112,111,114,116, 44, 32,109, 97,105,108,116, 46, 99,114,101, 97,116,101,
41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,101,120,116, 32, 61, 32,115, 58,
103,114,101,101,116, 40,109, 97,105,108,116, 46,100,111,109, 97,105,110, 41, 10,
32, 32, 32, 32,115, 58, 97,117,116,104, 40,109, 97,105,108,116, 46,117,115,101,
114, 44, 32,109, 97,105,108,116, 46,112, 97,115,115,119,111,114,100, 44, 32,101,
120,116, 41, 10, 32, 32, 32, 32,115, 58,115,101,110,100, 40,109, 97,105,108,116,
41, 10, 32, 32, 32, 32,115, 58,113,117,105,116, 40, 41, 10, 32, 32, 32, 32,114,
101,116,117,114,110, 32,115, 58, 99,108,111,115,101, 40, 41, 10,101,110,100, 41,
10,
116, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115, 32, 61, 32, 95, 77, 46,
111,112,101,110, 40,109, 97,105,108,116, 46,115,101,114,118,101,114, 44, 32,109,
97,105,108,116, 46,112,111,114,116, 44, 32,109, 97,105,108,116, 46, 99,114,101,
97,116,101, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,101,120,116, 32, 61,
32,115, 58,103,114,101,101,116, 40,109, 97,105,108,116, 46,100,111,109, 97,105,
110, 41, 10, 32, 32, 32, 32,115, 58, 97,117,116,104, 40,109, 97,105,108,116, 46,
117,115,101,114, 44, 32,109, 97,105,108,116, 46,112, 97,115,115,119,111,114,100,
44, 32,101,120,116, 41, 10, 32, 32, 32, 32,115, 58,115,101,110,100, 40,109, 97,
105,108,116, 41, 10, 32, 32, 32, 32,115, 58,113,117,105,116, 40, 41, 10, 32, 32,
32, 32,114,101,116,117,114,110, 32,115, 58, 99,108,111,115,101, 40, 41, 10,101,
110,100, 41, 10, 10,114,101,116,117,114,110, 32, 95, 77,
};
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"smtp.lua")==0) lua_call(L, 0, 0);
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"smtp.lua")==0) lua_call(L, 0, LUA_MULTRET);
}
@@ -8,8 +8,6 @@
* differences. Also, not all *nix platforms behave the same. This module
* (and the associated usocket.h and wsocket.h) factor these differences and
* creates a interface compatible with the io.h module.
*
* RCS ID: $Id: socket.h,v 1.20 2005/11/20 07:20:23 diego Exp $
\*=========================================================================*/
#include "io.h"
@@ -61,6 +59,7 @@ int socket_accept(p_socket ps, p_socket pa, SA *addr,
socklen_t *addr_len, p_timeout tm);
const char *socket_hoststrerror(int err);
const char *socket_gaistrerror(int err);
const char *socket_strerror(int err);
/* these are perfect to use with the io abstraction module
@@ -68,6 +67,9 @@ const char *socket_strerror(int err);
int socket_send(p_socket ps, const char *data, size_t count,
size_t *sent, p_timeout tm);
int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm);
int socket_write(p_socket ps, const char *data, size_t count,
size_t *sent, p_timeout tm);
int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm);
const char *socket_ioerror(p_socket ps, int err);
int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp);
+45 -29
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 $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@@ -11,37 +10,52 @@ local base = _G
local string = require("string")
local math = require("math")
local socket = require("socket.core")
module("socket")
local _M = socket
-----------------------------------------------------------------------------
-- Exported auxiliar functions
-----------------------------------------------------------------------------
function connect(address, port, laddress, lport)
local sock, err = socket.tcp()
if not sock then return nil, err end
if laddress then
local res, err = sock:bind(laddress, lport, -1)
if not res then return nil, err end
function _M.connect4(address, port, laddress, lport)
return socket.connect(address, port, laddress, lport, "inet")
end
function _M.connect6(address, port, laddress, lport)
return socket.connect(address, port, laddress, lport, "inet6")
end
function _M.bind(host, port, backlog)
if host == "*" then host = "0.0.0.0" end
local addrinfo, err = socket.dns.getaddrinfo(host);
if not addrinfo then return nil, err end
local sock, res
err = "no info on address"
for i, alt in base.ipairs(addrinfo) do
if alt.family == "inet" then
sock, err = socket.tcp4()
else
sock, err = socket.tcp6()
end
if not sock then return nil, err end
sock:setoption("reuseaddr", true)
res, err = sock:bind(alt.addr, port)
if not res then
sock:close()
else
res, err = sock:listen(backlog)
if not res then
sock:close()
else
return sock
end
end
end
local res, err = sock:connect(address, port)
if not res then return nil, err end
return sock
return nil, err
end
function bind(host, port, backlog)
local sock, err = socket.tcp()
if not sock then return nil, err end
sock:setoption("reuseaddr", true)
local res, err = sock:bind(host, port)
if not res then return nil, err end
res, err = sock:listen(backlog)
if not res then return nil, err end
return sock
end
_M.try = _M.newtry()
try = newtry()
function choose(table)
function _M.choose(table)
return function(name, opt1, opt2)
if base.type(name) ~= "string" then
name, opt1, opt2 = "default", name, opt1
@@ -56,10 +70,11 @@ end
-- Socket sources and sinks, conforming to LTN12
-----------------------------------------------------------------------------
-- create namespaces inside LuaSocket namespace
sourcet = {}
sinkt = {}
local sourcet, sinkt = {}, {}
_M.sourcet = sourcet
_M.sinkt = sinkt
BLOCKSIZE = 2048
_M.BLOCKSIZE = 2048
sinkt["close-when-done"] = function(sock)
return base.setmetatable({
@@ -89,7 +104,7 @@ end
sinkt["default"] = sinkt["keep-open"]
sink = choose(sinkt)
_M.sink = _M.choose(sinkt)
sourcet["by-length"] = function(sock, length)
return base.setmetatable({
@@ -129,5 +144,6 @@ end
sourcet["default"] = sourcet["until-closed"]
source = choose(sourcet)
_M.source = _M.choose(sourcet)
return _M
+200 -181
View File
@@ -1,7 +1,7 @@
/* code automatically generated by bin2c -- DO NOT EDIT */
{
/* #include'ing this file in a C program is equivalent to calling
if (luaL_loadfile(L,"socket.lua")==0) lua_call(L, 0, 0);
if (luaL_loadfile(L,"socket.lua")==0) lua_call(L, 0, LUA_MULTRET);
*/
/* socket.lua */
static const unsigned char B1[]={
@@ -11,205 +11,224 @@ static const unsigned char B1[]={
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45,
32, 76,117, 97, 83,111, 99,107,101,116, 32,104,101,108,112,101,114, 32,109,111,
100,117,108,101, 10, 45, 45, 32, 65,117,116,104,111,114, 58, 32, 68,105,101,103,
111, 32, 78,101,104, 97, 98, 10, 45, 45, 32, 82, 67, 83, 32, 73, 68, 58, 32, 36,
73,100, 58, 32,115,111, 99,107,101,116, 46,108,117, 97, 44,118, 32, 49, 46, 50,
50, 32, 50, 48, 48, 53, 47, 49, 49, 47, 50, 50, 32, 48, 56, 58, 51, 51, 58, 50,
57, 32,100,105,101,103,111, 32, 69,120,112, 32, 36, 10, 45, 45, 45, 45, 45, 45,
111, 32, 78,101,104, 97, 98, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,114,
101, 32,109,111,100,117,108,101, 32, 97,110,100, 32,105,109,112,111,114,116, 32,
100,101,112,101,110,100,101,110, 99,105,101,115, 10, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,114,101, 32,109,111,100,117,
108,101, 32, 97,110,100, 32,105,109,112,111,114,116, 32,100,101,112,101,110,100,
101,110, 99,105,101,115, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32, 98, 97,115,
101, 32, 61, 32, 95, 71, 10,108,111, 99, 97,108, 32,115,116,114,105,110,103, 32,
61, 32,114,101,113,117,105,114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,
108,111, 99, 97,108, 32,109, 97,116,104, 32, 61, 32,114,101,113,117,105,114,101,
40, 34,109, 97,116,104, 34, 41, 10,108,111, 99, 97,108, 32,115,111, 99,107,101,
116, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,115,111, 99,107,101,116, 46,
99,111,114,101, 34, 41, 10,109,111,100,117,108,101, 40, 34,115,111, 99,107,101,
116, 34, 41, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 10,108,111, 99, 97,108, 32, 98, 97,115,101, 32, 61, 32, 95, 71,
10,108,111, 99, 97,108, 32,115,116,114,105,110,103, 32, 61, 32,114,101,113,117,
105,114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,108,111, 99, 97,108, 32,
109, 97,116,104, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,109, 97,116,104,
34, 41, 10,108,111, 99, 97,108, 32,115,111, 99,107,101,116, 32, 61, 32,114,101,
113,117,105,114,101, 40, 34,115,111, 99,107,101,116, 46, 99,111,114,101, 34, 41,
10, 10,108,111, 99, 97,108, 32, 95, 77, 32, 61, 32,115,111, 99,107,101,116, 10,
10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45,
45, 32, 69,120,112,111,114,116,101,100, 32, 97,117,120,105,108,105, 97,114, 32,
102,117,110, 99,116,105,111,110,115, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 10, 45, 45, 32, 69,120,112,111,114,116,101,100, 32, 97,117,120,105,108,
105, 97,114, 32,102,117,110, 99,116,105,111,110,115, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,102,117,110, 99,116,105,111,110,
32, 99,111,110,110,101, 99,116, 40, 97,100,100,114,101,115,115, 44, 32,112,111,
45, 45, 45, 45, 45, 45, 45, 10,102,117,110, 99,116,105,111,110, 32, 95, 77, 46,
99,111,110,110,101, 99,116, 52, 40, 97,100,100,114,101,115,115, 44, 32,112,111,
114,116, 44, 32,108, 97,100,100,114,101,115,115, 44, 32,108,112,111,114,116, 41,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,111, 99,107, 44, 32,101,114,114,
32, 61, 32,115,111, 99,107,101,116, 46,116, 99,112, 40, 41, 10, 32, 32, 32, 32,
105,102, 32,110,111,116, 32,115,111, 99,107, 32,116,104,101,110, 32,114,101,116,
117,114,110, 32,110,105,108, 44, 32,101,114,114, 32,101,110,100, 10, 32, 32, 32,
32,105,102, 32,108, 97,100,100,114,101,115,115, 32,116,104,101,110, 10, 32, 32,
32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,115, 44, 32,101,114,114,
32, 61, 32,115,111, 99,107, 58, 98,105,110,100, 40,108, 97,100,100,114,101,115,
115, 44, 32,108,112,111,114,116, 44, 32, 45, 49, 41, 10, 32, 32, 32, 32, 32, 32,
32, 32,105,102, 32,110,111,116, 32,114,101,115, 32,116,104,101,110, 32,114,101,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,111, 99,107,101,116, 46, 99,
111,110,110,101, 99,116, 40, 97,100,100,114,101,115,115, 44, 32,112,111,114,116,
44, 32,108, 97,100,100,114,101,115,115, 44, 32,108,112,111,114,116, 44, 32, 34,
105,110,101,116, 34, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
32, 95, 77, 46, 99,111,110,110,101, 99,116, 54, 40, 97,100,100,114,101,115,115,
44, 32,112,111,114,116, 44, 32,108, 97,100,100,114,101,115,115, 44, 32,108,112,
111,114,116, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,111, 99,107,
101,116, 46, 99,111,110,110,101, 99,116, 40, 97,100,100,114,101,115,115, 44, 32,
112,111,114,116, 44, 32,108, 97,100,100,114,101,115,115, 44, 32,108,112,111,114,
116, 44, 32, 34,105,110,101,116, 54, 34, 41, 10,101,110,100, 10, 10,102,117,110,
99,116,105,111,110, 32, 95, 77, 46, 98,105,110,100, 40,104,111,115,116, 44, 32,
112,111,114,116, 44, 32, 98, 97, 99,107,108,111,103, 41, 10, 32, 32, 32, 32,105,
102, 32,104,111,115,116, 32, 61, 61, 32, 34, 42, 34, 32,116,104,101,110, 32,104,
111,115,116, 32, 61, 32, 34, 48, 46, 48, 46, 48, 46, 48, 34, 32,101,110,100, 10,
32, 32, 32, 32,108,111, 99, 97,108, 32, 97,100,100,114,105,110,102,111, 44, 32,
101,114,114, 32, 61, 32,115,111, 99,107,101,116, 46,100,110,115, 46,103,101,116,
97,100,100,114,105,110,102,111, 40,104,111,115,116, 41, 59, 10, 32, 32, 32, 32,
105,102, 32,110,111,116, 32, 97,100,100,114,105,110,102,111, 32,116,104,101,110,
32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 32,101,110,100,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,111, 99,107, 44, 32,114,101,115,
10, 32, 32, 32, 32,101,114,114, 32, 61, 32, 34,110,111, 32,105,110,102,111, 32,
111,110, 32, 97,100,100,114,101,115,115, 34, 10, 32, 32, 32, 32,102,111,114, 32,
105, 44, 32, 97,108,116, 32,105,110, 32, 98, 97,115,101, 46,105,112, 97,105,114,
115, 40, 97,100,100,114,105,110,102,111, 41, 32,100,111, 10, 32, 32, 32, 32, 32,
32, 32, 32,105,102, 32, 97,108,116, 46,102, 97,109,105,108,121, 32, 61, 61, 32,
34,105,110,101,116, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,115,111, 99,107, 44, 32,101,114,114, 32, 61, 32,115,111, 99,107,
101,116, 46,116, 99,112, 52, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,
115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115,111, 99,107, 44,
32,101,114,114, 32, 61, 32,115,111, 99,107,101,116, 46,116, 99,112, 54, 40, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32,
32,105,102, 32,110,111,116, 32,115,111, 99,107, 32,116,104,101,110, 32,114,101,
116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 32,101,110,100, 10, 32, 32,
32, 32,101,110,100, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,115, 44,
32,101,114,114, 32, 61, 32,115,111, 99,107, 58, 99,111,110,110,101, 99,116, 40,
97,100,100,114,101,115,115, 44, 32,112,111,114,116, 41, 10, 32, 32, 32, 32,105,
102, 32,110,111,116, 32,114,101,115, 32,116,104,101,110, 32,114,101,116,117,114,
110, 32,110,105,108, 44, 32,101,114,114, 32,101,110,100, 10, 32, 32, 32, 32,114,
101,116,117,114,110, 32,115,111, 99,107, 10,101,110,100, 10, 10,102,117,110, 99,
116,105,111,110, 32, 98,105,110,100, 40,104,111,115,116, 44, 32,112,111,114,116,
44, 32, 98, 97, 99,107,108,111,103, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108,
32,115,111, 99,107, 44, 32,101,114,114, 32, 61, 32,115,111, 99,107,101,116, 46,
116, 99,112, 40, 41, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,115,111, 99,
107, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,
114,114, 32,101,110,100, 10, 32, 32, 32, 32,115,111, 99,107, 58,115,101,116,111,
112,116,105,111,110, 40, 34,114,101,117,115,101, 97,100,100,114, 34, 44, 32,116,
114,117,101, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,115, 44, 32,
101,114,114, 32, 61, 32,115,111, 99,107, 58, 98,105,110,100, 40,104,111,115,116,
44, 32,112,111,114,116, 41, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,114,
101,115, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,
101,114,114, 32,101,110,100, 10, 32, 32, 32, 32,114,101,115, 44, 32,101,114,114,
32, 61, 32,115,111, 99,107, 58,108,105,115,116,101,110, 40, 98, 97, 99,107,108,
111,103, 41, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32,114,101,115, 32,116,
104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 32,
101,110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,111, 99,107, 10,
101,110,100, 10, 10,116,114,121, 32, 61, 32,110,101,119,116,114,121, 40, 41, 10,
10,102,117,110, 99,116,105,111,110, 32, 99,104,111,111,115,101, 40,116, 97, 98,
108,101, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,
105,111,110, 40,110, 97,109,101, 44, 32,111,112,116, 49, 44, 32,111,112,116, 50,
41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 98, 97,115,101, 46,116,121,
112,101, 40,110, 97,109,101, 41, 32,126, 61, 32, 34,115,116,114,105,110,103, 34,
32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,110, 97,
109,101, 44, 32,111,112,116, 49, 44, 32,111,112,116, 50, 32, 61, 32, 34,100,101,
102, 97,117,108,116, 34, 44, 32,110, 97,109,101, 44, 32,111,112,116, 49, 10, 32,
32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,
111, 99, 97,108, 32,102, 32, 61, 32,116, 97, 98,108,101, 91,110, 97,109,101, 32,
111,114, 32, 34,110,105,108, 34, 93, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102,
32,110,111,116, 32,102, 32,116,104,101,110, 32, 98, 97,115,101, 46,101,114,114,
111,114, 40, 34,117,110,107,110,111,119,110, 32,107,101,121, 32, 40, 34, 46, 46,
32, 98, 97,115,101, 46,116,111,115,116,114,105,110,103, 40,110, 97,109,101, 41,
32, 46, 46, 34, 41, 34, 44, 32, 51, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,
108,115,101, 32,114,101,116,117,114,110, 32,102, 40,111,112,116, 49, 44, 32,111,
112,116, 50, 41, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100,
10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
45, 45, 32, 83,111, 99,107,101,116, 32,115,111,117,114, 99,101,115, 32, 97,110,
100, 32,115,105,110,107,115, 44, 32, 99,111,110,102,111,114,109,105,110,103, 32,
116,111, 32, 76, 84, 78, 49, 50, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
32, 32, 32, 32, 32, 32,115,111, 99,107, 58,115,101,116,111,112,116,105,111,110,
40, 34,114,101,117,115,101, 97,100,100,114, 34, 44, 32,116,114,117,101, 41, 10,
32, 32, 32, 32, 32, 32, 32, 32,114,101,115, 44, 32,101,114,114, 32, 61, 32,115,
111, 99,107, 58, 98,105,110,100, 40, 97,108,116, 46, 97,100,100,114, 44, 32,112,
111,114,116, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32,
114,101,115, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32,115,111, 99,107, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32, 32, 32,
32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,
101,115, 44, 32,101,114,114, 32, 61, 32,115,111, 99,107, 58,108,105,115,116,101,
110, 40, 98, 97, 99,107,108,111,103, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,105,102, 32,110,111,116, 32,114,101,115, 32,116,104,101,110, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115,111, 99,107, 58,
99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32,114,101,116,117,114,110, 32,115,111, 99,107, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100,
10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
110,105,108, 44, 32,101,114,114, 10,101,110,100, 10, 10, 95, 77, 46,116,114,121,
32, 61, 32, 95, 77, 46,110,101,119,116,114,121, 40, 41, 10, 10,102,117,110, 99,
116,105,111,110, 32, 95, 77, 46, 99,104,111,111,115,101, 40,116, 97, 98,108,101,
41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,102,117,110, 99,116,105,111,
110, 40,110, 97,109,101, 44, 32,111,112,116, 49, 44, 32,111,112,116, 50, 41, 10,
32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 98, 97,115,101, 46,116,121,112,101,
40,110, 97,109,101, 41, 32,126, 61, 32, 34,115,116,114,105,110,103, 34, 32,116,
104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,110, 97,109,101,
44, 32,111,112,116, 49, 44, 32,111,112,116, 50, 32, 61, 32, 34,100,101,102, 97,
117,108,116, 34, 44, 32,110, 97,109,101, 44, 32,111,112,116, 49, 10, 32, 32, 32,
32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99,
97,108, 32,102, 32, 61, 32,116, 97, 98,108,101, 91,110, 97,109,101, 32,111,114,
32, 34,110,105,108, 34, 93, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,
111,116, 32,102, 32,116,104,101,110, 32, 98, 97,115,101, 46,101,114,114,111,114,
40, 34,117,110,107,110,111,119,110, 32,107,101,121, 32, 40, 34, 46, 46, 32, 98,
97,115,101, 46,116,111,115,116,114,105,110,103, 40,110, 97,109,101, 41, 32, 46,
46, 34, 41, 34, 44, 32, 51, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,
101, 32,114,101,116,117,114,110, 32,102, 40,111,112,116, 49, 44, 32,111,112,116,
50, 41, 32,101,110,100, 10, 32, 32, 32, 32,101,110,100, 10,101,110,100, 10, 10,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 99,114,101, 97,116,101, 32,110, 97,109,
101,115,112, 97, 99,101,115, 32,105,110,115,105,100,101, 32, 76,117, 97, 83,111,
99,107,101,116, 32,110, 97,109,101,115,112, 97, 99,101, 10,115,111,117,114, 99,
101,116, 32, 61, 32,123,125, 10,115,105,110,107,116, 32, 61, 32,123,125, 10, 10,
66, 76, 79, 67, 75, 83, 73, 90, 69, 32, 61, 32, 50, 48, 52, 56, 10, 10,115,105,
110,107,116, 91, 34, 99,108,111,115,101, 45,119,104,101,110, 45,100,111,110,101,
34, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,115,111, 99,107, 41, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32, 98, 97,115,101, 46,115,101,116,109,
101,116, 97,116, 97, 98,108,101, 40,123, 10, 32, 32, 32, 32, 32, 32, 32, 32,103,
101,116,102,100, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 32,114,101,
116,117,114,110, 32,115,111, 99,107, 58,103,101,116,102,100, 40, 41, 32,101,110,
100, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32,100,105,114,116,121, 32, 61, 32,102,
117,110, 99,116,105,111,110, 40, 41, 32,114,101,116,117,114,110, 32,115,111, 99,
107, 58,100,105,114,116,121, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,125, 44,
32,123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 95, 95, 99, 97,108,108, 32, 61, 32,
102,117,110, 99,116,105,111,110, 40,115,101,108,102, 44, 32, 99,104,117,110,107,
44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,
102, 32,110,111,116, 32, 99,104,117,110,107, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115,111, 99,107, 58, 99,108,
111,115,101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,114,101,116,117,114,110, 32, 49, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,115,111, 99,107, 58,
115,101,110,100, 40, 99,104,117,110,107, 41, 32,101,110,100, 10, 32, 32, 32, 32,
32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,125, 41, 10,101,110,100, 10, 10,
115,105,110,107,116, 91, 34,107,101,101,112, 45,111,112,101,110, 34, 93, 32, 61,
32,102,117,110, 99,116,105,111,110, 40,115,111, 99,107, 41, 10, 32, 32, 32, 32,
114,101,116,117,114,110, 32, 98, 97,115,101, 46,115,101,116,109,101,116, 97,116,
97, 98,108,101, 40,123, 10, 32, 32, 32, 32, 32, 32, 32, 32,103,101,116,102,100,
32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 32,114,101,116,117,114,110,
32,115,111, 99,107, 58,103,101,116,102,100, 40, 41, 32,101,110,100, 44, 10, 32,
32, 32, 32, 32, 32, 32, 32,100,105,114,116,121, 32, 61, 32,102,117,110, 99,116,
105,111,110, 40, 41, 32,114,101,116,117,114,110, 32,115,111, 99,107, 58,100,105,
114,116,121, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,125, 44, 32,123, 10, 32,
32, 32, 32, 32, 32, 32, 32, 95, 95, 99, 97,108,108, 32, 61, 32,102,117,110, 99,
116,105,111,110, 40,115,101,108,102, 44, 32, 99,104,117,110,107, 44, 32,101,114,
114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32, 99,104,
117,110,107, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,115,111, 99,107,
58,115,101,110,100, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32, 49, 32,101,
110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,125,
41, 10,101,110,100, 10, 10,115,105,110,107,116, 91, 34,100,101,102, 97,117,108,
116, 34, 93, 32, 61, 32,115,105,110,107,116, 91, 34,107,101,101,112, 45,111,112,
101,110, 34, 93, 10, 10,115,105,110,107, 32, 61, 32, 99,104,111,111,115,101, 40,
115,105,110,107,116, 41, 10, 10,115,111,117,114, 99,101,116, 91, 34, 98,121, 45,
108,101,110,103,116,104, 34, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,
115,111, 99,107, 44, 32,108,101,110,103,116,104, 41, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32, 98, 97,115,101, 46,115,101,116,109,101,116, 97,116, 97, 98,
108,101, 40,123, 10, 32, 32, 32, 32, 32, 32, 32, 32,103,101,116,102,100, 32, 61,
32,102,117,110, 99,116,105,111,110, 40, 41, 32,114,101,116,117,114,110, 32,115,
111, 99,107, 58,103,101,116,102,100, 40, 41, 32,101,110,100, 44, 10, 32, 32, 32,
32, 32, 32, 32, 32,100,105,114,116,121, 32, 61, 32,102,117,110, 99,116,105,111,
110, 40, 41, 32,114,101,116,117,114,110, 32,115,111, 99,107, 58,100,105,114,116,
121, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,125, 44, 32,123, 10, 32, 32, 32,
32, 32, 32, 32, 32, 95, 95, 99, 97,108,108, 32, 61, 32,102,117,110, 99,116,105,
111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
108,101,110,103,116,104, 32, 60, 61, 32, 48, 32,116,104,101,110, 32,114,101,116,
117,114,110, 32,110,105,108, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,108,111, 99, 97,108, 32,115,105,122,101, 32, 61, 32,109, 97,116,
104, 46,109,105,110, 40,115,111, 99,107,101,116, 46, 66, 76, 79, 67, 75, 83, 73,
90, 69, 44, 32,108,101,110,103,116,104, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,108,111, 99, 97,108, 32, 99,104,117,110,107, 44, 32,101,114,114,
32, 61, 32,115,111, 99,107, 58,114,101, 99,101,105,118,101, 40,115,105,122,101,
41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,101,114,114,
32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,
114, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,101,
110,103,116,104, 32, 61, 32,108,101,110,103,116,104, 32, 45, 32,115,116,114,105,
110,103, 46,108,101,110, 40, 99,104,117,110,107, 41, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32, 99,104,117,110,107, 10, 32,
32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,125, 41, 10,101,110,
100, 10, 10,115,111,117,114, 99,101,116, 91, 34,117,110,116,105,108, 45, 99,108,
111,115,101,100, 34, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,115,111,
99,107, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,100,111,110,101, 10, 32,
32, 32, 32,114,101,116,117,114,110, 32, 98, 97,115,101, 46,115,101,116,109,101,
116, 97,116, 97, 98,108,101, 40,123, 10, 32, 32, 32, 32, 32, 32, 32, 32,103,101,
116,102,100, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 32,114,101,116,
117,114,110, 32,115,111, 99,107, 58,103,101,116,102,100, 40, 41, 32,101,110,100,
44, 10, 32, 32, 32, 32, 32, 32, 32, 32,100,105,114,116,121, 32, 61, 32,102,117,
110, 99,116,105,111,110, 40, 41, 32,114,101,116,117,114,110, 32,115,111, 99,107,
58,100,105,114,116,121, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,125, 44, 32,
123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 95, 95, 99, 97,108,108, 32, 61, 32,102,
117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,105,102, 32,100,111,110,101, 32,116,104,101,110, 32,114,101,116,117,114,
110, 32,110,105,108, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,108,111, 99, 97,108, 32, 99,104,117,110,107, 44, 32,101,114,114, 44, 32,
112, 97,114,116,105, 97,108, 32, 61, 32,115,111, 99,107, 58,114,101, 99,101,105,
118,101, 40,115,111, 99,107,101,116, 46, 66, 76, 79, 67, 75, 83, 73, 90, 69, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,110,111,116, 32,
101,114,114, 32,116,104,101,110, 32,114,101,116,117,114,110, 32, 99,104,117,110,
107, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101,105,102,
32,101,114,114, 32, 61, 61, 32, 34, 99,108,111,115,101,100, 34, 32,116,104,101,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45,
32, 83,111, 99,107,101,116, 32,115,111,117,114, 99,101,115, 32, 97,110,100, 32,
115,105,110,107,115, 44, 32, 99,111,110,102,111,114,109,105,110,103, 32,116,111,
32, 76, 84, 78, 49, 50, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 10, 45, 45, 32, 99,114,101, 97,116,101, 32,110, 97,109,101,115,
112, 97, 99,101,115, 32,105,110,115,105,100,101, 32, 76,117, 97, 83,111, 99,107,
101,116, 32,110, 97,109,101,115,112, 97, 99,101, 10,108,111, 99, 97,108, 32,115,
111,117,114, 99,101,116, 44, 32,115,105,110,107,116, 32, 61, 32,123,125, 44, 32,
123,125, 10, 95, 77, 46,115,111,117,114, 99,101,116, 32, 61, 32,115,111,117,114,
99,101,116, 10, 95, 77, 46,115,105,110,107,116, 32, 61, 32,115,105,110,107,116,
10, 10, 95, 77, 46, 66, 76, 79, 67, 75, 83, 73, 90, 69, 32, 61, 32, 50, 48, 52,
56, 10, 10,115,105,110,107,116, 91, 34, 99,108,111,115,101, 45,119,104,101,110,
45,100,111,110,101, 34, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,115,
111, 99,107, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 98, 97,115,101,
46,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,123, 10, 32, 32, 32, 32,
32, 32, 32, 32,103,101,116,102,100, 32, 61, 32,102,117,110, 99,116,105,111,110,
40, 41, 32,114,101,116,117,114,110, 32,115,111, 99,107, 58,103,101,116,102,100,
40, 41, 32,101,110,100, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32,100,105,114,116,
121, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 32,114,101,116,117,114,
110, 32,115,111, 99,107, 58,100,105,114,116,121, 40, 41, 32,101,110,100, 10, 32,
32, 32, 32,125, 44, 32,123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 95, 95, 99, 97,
108,108, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,115,101,108,102, 44, 32,
99,104,117,110,107, 44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,105,102, 32,110,111,116, 32, 99,104,117,110,107, 32,116,104,101,
110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115,111,
99,107, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,100,111,110,101, 32, 61, 32, 49, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,112,
97,114,116,105, 97,108, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,
108,115,101, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,114, 32,
101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
125, 41, 10,101,110,100, 10, 10, 10,115,111,117,114, 99,101,116, 91, 34,100,101,
102, 97,117,108,116, 34, 93, 32, 61, 32,115,111,117,114, 99,101,116, 91, 34,117,
110,116,105,108, 45, 99,108,111,115,101,100, 34, 93, 10, 10,115,111,117,114, 99,
101, 32, 61, 32, 99,104,111,111,115,101, 40,115,111,117,114, 99,101,116, 41, 10,
10,
32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32, 49, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,
115,111, 99,107, 58,115,101,110,100, 40, 99,104,117,110,107, 41, 32,101,110,100,
10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,125, 41, 10,
101,110,100, 10, 10,115,105,110,107,116, 91, 34,107,101,101,112, 45,111,112,101,
110, 34, 93, 32, 61, 32,102,117,110, 99,116,105,111,110, 40,115,111, 99,107, 41,
10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 98, 97,115,101, 46,115,101,116,
109,101,116, 97,116, 97, 98,108,101, 40,123, 10, 32, 32, 32, 32, 32, 32, 32, 32,
103,101,116,102,100, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 32,114,
101,116,117,114,110, 32,115,111, 99,107, 58,103,101,116,102,100, 40, 41, 32,101,
110,100, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32,100,105,114,116,121, 32, 61, 32,
102,117,110, 99,116,105,111,110, 40, 41, 32,114,101,116,117,114,110, 32,115,111,
99,107, 58,100,105,114,116,121, 40, 41, 32,101,110,100, 10, 32, 32, 32, 32,125,
44, 32,123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 95, 95, 99, 97,108,108, 32, 61,
32,102,117,110, 99,116,105,111,110, 40,115,101,108,102, 44, 32, 99,104,117,110,
107, 44, 32,101,114,114, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
105,102, 32, 99,104,117,110,107, 32,116,104,101,110, 32,114,101,116,117,114,110,
32,115,111, 99,107, 58,115,101,110,100, 40, 99,104,117,110,107, 41, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,
110, 32, 49, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10,
32, 32, 32, 32,125, 41, 10,101,110,100, 10, 10,115,105,110,107,116, 91, 34,100,
101,102, 97,117,108,116, 34, 93, 32, 61, 32,115,105,110,107,116, 91, 34,107,101,
101,112, 45,111,112,101,110, 34, 93, 10, 10, 95, 77, 46,115,105,110,107, 32, 61,
32, 95, 77, 46, 99,104,111,111,115,101, 40,115,105,110,107,116, 41, 10, 10,115,
111,117,114, 99,101,116, 91, 34, 98,121, 45,108,101,110,103,116,104, 34, 93, 32,
61, 32,102,117,110, 99,116,105,111,110, 40,115,111, 99,107, 44, 32,108,101,110,
103,116,104, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 98, 97,115,101,
46,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,123, 10, 32, 32, 32, 32,
32, 32, 32, 32,103,101,116,102,100, 32, 61, 32,102,117,110, 99,116,105,111,110,
40, 41, 32,114,101,116,117,114,110, 32,115,111, 99,107, 58,103,101,116,102,100,
40, 41, 32,101,110,100, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32,100,105,114,116,
121, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 32,114,101,116,117,114,
110, 32,115,111, 99,107, 58,100,105,114,116,121, 40, 41, 32,101,110,100, 10, 32,
32, 32, 32,125, 44, 32,123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 95, 95, 99, 97,
108,108, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,108,101,110,103,116,104, 32, 60, 61,
32, 48, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 32,101,
110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108,
32,115,105,122,101, 32, 61, 32,109, 97,116,104, 46,109,105,110, 40,115,111, 99,
107,101,116, 46, 66, 76, 79, 67, 75, 83, 73, 90, 69, 44, 32,108,101,110,103,116,
104, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108,
32, 99,104,117,110,107, 44, 32,101,114,114, 32, 61, 32,115,111, 99,107, 58,114,
101, 99,101,105,118,101, 40,115,105,122,101, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,105,102, 32,101,114,114, 32,116,104,101,110, 32,114,101,116,
117,114,110, 32,110,105,108, 44, 32,101,114,114, 32,101,110,100, 10, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32,108,101,110,103,116,104, 32, 61, 32,108,101,
110,103,116,104, 32, 45, 32,115,116,114,105,110,103, 46,108,101,110, 40, 99,104,
117,110,107, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,
117,114,110, 32, 99,104,117,110,107, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,
100, 10, 32, 32, 32, 32,125, 41, 10,101,110,100, 10, 10,115,111,117,114, 99,101,
116, 91, 34,117,110,116,105,108, 45, 99,108,111,115,101,100, 34, 93, 32, 61, 32,
102,117,110, 99,116,105,111,110, 40,115,111, 99,107, 41, 10, 32, 32, 32, 32,108,
111, 99, 97,108, 32,100,111,110,101, 10, 32, 32, 32, 32,114,101,116,117,114,110,
32, 98, 97,115,101, 46,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,123,
10, 32, 32, 32, 32, 32, 32, 32, 32,103,101,116,102,100, 32, 61, 32,102,117,110,
99,116,105,111,110, 40, 41, 32,114,101,116,117,114,110, 32,115,111, 99,107, 58,
103,101,116,102,100, 40, 41, 32,101,110,100, 44, 10, 32, 32, 32, 32, 32, 32, 32,
32,100,105,114,116,121, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41, 32,
114,101,116,117,114,110, 32,115,111, 99,107, 58,100,105,114,116,121, 40, 41, 32,
101,110,100, 10, 32, 32, 32, 32,125, 44, 32,123, 10, 32, 32, 32, 32, 32, 32, 32,
32, 95, 95, 99, 97,108,108, 32, 61, 32,102,117,110, 99,116,105,111,110, 40, 41,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,100,111,110,101,
32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 32,101,110,100,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,
104,117,110,107, 44, 32,101,114,114, 44, 32,112, 97,114,116,105, 97,108, 32, 61,
32,115,111, 99,107, 58,114,101, 99,101,105,118,101, 40,115,111, 99,107,101,116,
46, 66, 76, 79, 67, 75, 83, 73, 90, 69, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,105,102, 32,110,111,116, 32,101,114,114, 32,116,104,101,110, 32,
114,101,116,117,114,110, 32, 99,104,117,110,107, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,101,108,115,101,105,102, 32,101,114,114, 32, 61, 61, 32, 34,
99,108,111,115,101,100, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32,115,111, 99,107, 58, 99,108,111,115,101, 40,
41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,100,111,
110,101, 32, 61, 32, 49, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32,114,101,116,117,114,110, 32,112, 97,114,116,105, 97,108, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,
110, 32,110,105,108, 44, 32,101,114,114, 32,101,110,100, 10, 32, 32, 32, 32, 32,
32, 32, 32,101,110,100, 10, 32, 32, 32, 32,125, 41, 10,101,110,100, 10, 10, 10,
115,111,117,114, 99,101,116, 91, 34,100,101,102, 97,117,108,116, 34, 93, 32, 61,
32,115,111,117,114, 99,101,116, 91, 34,117,110,116,105,108, 45, 99,108,111,115,
101,100, 34, 93, 10, 10, 95, 77, 46,115,111,117,114, 99,101, 32, 61, 32, 95, 77,
46, 99,104,111,111,115,101, 40,115,111,117,114, 99,101,116, 41, 10, 10,114,101,
116,117,114,110, 32, 95, 77, 10,
};
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"socket.lua")==0) lua_call(L, 0, 0);
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"socket.lua")==0) lua_call(L, 0, LUA_MULTRET);
}
+188 -78
View File
@@ -1,13 +1,12 @@
/*=========================================================================*\
* TCP object
* TCP object
* LuaSocket toolkit
*
* RCS ID: $Id: tcp.c,v 1.41 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include <string.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "auxiliar.h"
#include "socket.h"
@@ -15,14 +14,16 @@
#include "options.h"
#include "tcp.h"
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
/*=========================================================================*\
* Internal function prototypes
\*=========================================================================*/
static int global_create(lua_State *L);
static int global_create4(lua_State *L);
static int global_create6(lua_State *L);
static int global_connect(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);
@@ -33,14 +34,16 @@ static int meth_shutdown(lua_State *L);
static int meth_receive(lua_State *L);
static int meth_accept(lua_State *L);
static int meth_close(lua_State *L);
static int meth_getoption(lua_State *L);
static int meth_setoption(lua_State *L);
static int meth_gettimeout(lua_State *L);
static int meth_settimeout(lua_State *L);
static int meth_getfd(lua_State *L);
static int meth_setfd(lua_State *L);
static int meth_dirty(lua_State *L);
/* tcp object methods */
static luaL_reg tcp[] = {
static luaL_Reg tcp_methods[] = {
{"__gc", meth_close},
{"__tostring", auxiliar_tostring},
{"accept", meth_accept},
@@ -48,7 +51,9 @@ static luaL_reg tcp[] = {
{"close", meth_close},
{"connect", meth_connect},
{"dirty", meth_dirty},
{"getfamily", meth_getfamily},
{"getfd", meth_getfd},
{"getoption", meth_getoption},
{"getpeername", meth_getpeername},
{"getsockname", meth_getsockname},
{"getstats", meth_getstats},
@@ -61,22 +66,38 @@ static luaL_reg tcp[] = {
{"setpeername", meth_connect},
{"setsockname", meth_bind},
{"settimeout", meth_settimeout},
{"gettimeout", meth_gettimeout},
{"shutdown", meth_shutdown},
{NULL, NULL}
};
/* socket option handlers */
static t_opt opt[] = {
{"keepalive", opt_keepalive},
{"reuseaddr", opt_reuseaddr},
{"tcp-nodelay", opt_tcp_nodelay},
{"linger", opt_linger},
static t_opt optget[] = {
{"keepalive", opt_get_keepalive},
{"reuseaddr", opt_get_reuseaddr},
{"reuseport", opt_get_reuseport},
{"tcp-nodelay", opt_get_tcp_nodelay},
{"linger", opt_get_linger},
{"error", opt_get_error},
{NULL, NULL}
};
static t_opt optset[] = {
{"keepalive", opt_set_keepalive},
{"reuseaddr", opt_set_reuseaddr},
{"reuseport", opt_set_reuseport},
{"tcp-nodelay", opt_set_tcp_nodelay},
{"ipv6-v6only", opt_set_ip6_v6only},
{"linger", opt_set_linger},
{NULL, NULL}
};
/* functions in library namespace */
static luaL_reg func[] = {
static luaL_Reg func[] = {
{"tcp", global_create},
{"tcp4", global_create4},
{"tcp6", global_create6},
{"connect", global_connect},
{NULL, NULL}
};
@@ -86,15 +107,15 @@ static luaL_reg func[] = {
int tcp_open(lua_State *L)
{
/* create classes */
auxiliar_newclass(L, "tcp{master}", tcp);
auxiliar_newclass(L, "tcp{client}", tcp);
auxiliar_newclass(L, "tcp{server}", tcp);
auxiliar_newclass(L, "tcp{master}", tcp_methods);
auxiliar_newclass(L, "tcp{client}", tcp_methods);
auxiliar_newclass(L, "tcp{server}", tcp_methods);
/* create class groups */
auxiliar_add2group(L, "tcp{master}", "tcp{any}");
auxiliar_add2group(L, "tcp{client}", "tcp{any}");
auxiliar_add2group(L, "tcp{server}", "tcp{any}");
/* define library functions */
luax_register(L, NULL, func);
luaL_setfuncs(L, func, 0);
return 0;
}
@@ -127,10 +148,16 @@ static int meth_setstats(lua_State *L) {
/*-------------------------------------------------------------------------*\
* Just call option handler
\*-------------------------------------------------------------------------*/
static int meth_getoption(lua_State *L)
{
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
return opt_meth_getoption(L, optget, &tcp->sock);
}
static int meth_setoption(lua_State *L)
{
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
return opt_meth_setoption(L, opt, &tcp->sock);
return opt_meth_setoption(L, optset, &tcp->sock);
}
/*-------------------------------------------------------------------------*\
@@ -147,7 +174,7 @@ static int meth_getfd(lua_State *L)
static int meth_setfd(lua_State *L)
{
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
tcp->sock = (t_socket) luaL_checknumber(L, 2);
tcp->sock = (t_socket) luaL_checknumber(L, 2);
return 0;
}
@@ -159,43 +186,50 @@ static int meth_dirty(lua_State *L)
}
/*-------------------------------------------------------------------------*\
* Waits for and returns a client object attempting connection to the
* server object
* Waits for and returns a client object attempting connection to the
* server object
\*-------------------------------------------------------------------------*/
static int meth_accept(lua_State *L)
{
p_tcp server = (p_tcp) auxiliar_checkclass(L, "tcp{server}", 1);
p_timeout tm = timeout_markstart(&server->tm);
t_socket sock;
int err = socket_accept(&server->sock, &sock, NULL, NULL, tm);
const char *err = inet_tryaccept(&server->sock, server->family, &sock, tm);
/* if successful, push client socket */
if (err == IO_DONE) {
if (err == NULL) {
p_tcp clnt = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
auxiliar_setclass(L, "tcp{client}", -1);
/* initialize structure fields */
memset(clnt, 0, sizeof(t_tcp));
socket_setnonblocking(&sock);
clnt->sock = sock;
io_init(&clnt->io, (p_send) socket_send, (p_recv) socket_recv,
io_init(&clnt->io, (p_send) socket_send, (p_recv) socket_recv,
(p_error) socket_ioerror, &clnt->sock);
timeout_init(&clnt->tm, -1, -1);
buffer_init(&clnt->buf, &clnt->io, &clnt->tm);
clnt->family = server->family;
return 1;
} else {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(err));
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
}
/*-------------------------------------------------------------------------*\
* Binds an object to an address
* Binds an object to an address
\*-------------------------------------------------------------------------*/
static int meth_bind(lua_State *L)
{
static int meth_bind(lua_State *L) {
p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{master}", 1);
const char *address = luaL_checkstring(L, 2);
unsigned short port = (unsigned short) luaL_checknumber(L, 3);
const char *err = inet_trybind(&tcp->sock, address, port);
const char *port = luaL_checkstring(L, 3);
const char *err;
struct addrinfo bindhints;
memset(&bindhints, 0, sizeof(bindhints));
bindhints.ai_socktype = SOCK_STREAM;
bindhints.ai_family = tcp->family;
bindhints.ai_flags = AI_PASSIVE;
err = inet_trybind(&tcp->sock, &tcp->family, address, port, &bindhints);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
@@ -208,13 +242,19 @@ static int meth_bind(lua_State *L)
/*-------------------------------------------------------------------------*\
* Turns a master tcp object into a client object.
\*-------------------------------------------------------------------------*/
static int meth_connect(lua_State *L)
{
static int meth_connect(lua_State *L) {
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
const char *address = luaL_checkstring(L, 2);
unsigned short port = (unsigned short) luaL_checknumber(L, 3);
p_timeout tm = timeout_markstart(&tcp->tm);
const char *err = inet_tryconnect(&tcp->sock, address, port, tm);
const char *port = luaL_checkstring(L, 3);
struct addrinfo connecthints;
const char *err;
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->family;
timeout_markstart(&tcp->tm);
err = inet_tryconnect(&tcp->sock, &tcp->family, address, port,
&tcp->tm, &connecthints);
/* have to set the class even if it failed due to non-blocking connects */
auxiliar_setclass(L, "tcp{client}", 1);
if (err) {
@@ -222,13 +262,12 @@ static int meth_connect(lua_State *L)
lua_pushstring(L, err);
return 2;
}
/* turn master object into a client object */
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Closes socket used by object
* Closes socket used by object
\*-------------------------------------------------------------------------*/
static int meth_close(lua_State *L)
{
@@ -238,6 +277,24 @@ 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 == AF_INET6) {
lua_pushliteral(L, "inet6");
return 1;
} else if (tcp->family == AF_INET) {
lua_pushliteral(L, "inet4");
return 1;
} else {
lua_pushliteral(L, "inet4");
return 1;
}
}
/*-------------------------------------------------------------------------*\
* Puts the sockt in listen mode
\*-------------------------------------------------------------------------*/
@@ -262,27 +319,13 @@ static int meth_listen(lua_State *L)
\*-------------------------------------------------------------------------*/
static int meth_shutdown(lua_State *L)
{
/* SHUT_RD, SHUT_WR, SHUT_RDWR have the value 0, 1, 2, so we can use method index directly */
static const char* methods[] = { "receive", "send", "both", NULL };
p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
const char *how = luaL_optstring(L, 2, "both");
switch (how[0]) {
case 'b':
if (strcmp(how, "both")) goto error;
socket_shutdown(&tcp->sock, 2);
break;
case 's':
if (strcmp(how, "send")) goto error;
socket_shutdown(&tcp->sock, 1);
break;
case 'r':
if (strcmp(how, "receive")) goto error;
socket_shutdown(&tcp->sock, 0);
break;
}
int how = luaL_checkoption(L, 2, "both", methods);
socket_shutdown(&tcp->sock, how);
lua_pushnumber(L, 1);
return 1;
error:
luaL_argerror(L, 2, "invalid shutdown method");
return 0;
}
/*-------------------------------------------------------------------------*\
@@ -291,13 +334,13 @@ error:
static int meth_getpeername(lua_State *L)
{
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
return inet_meth_getpeername(L, &tcp->sock);
return inet_meth_getpeername(L, &tcp->sock, tcp->family);
}
static int meth_getsockname(lua_State *L)
{
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
return inet_meth_getsockname(L, &tcp->sock);
return inet_meth_getsockname(L, &tcp->sock, tcp->family);
}
/*-------------------------------------------------------------------------*\
@@ -309,33 +352,100 @@ static int meth_settimeout(lua_State *L)
return timeout_meth_settimeout(L, &tcp->tm);
}
static int meth_gettimeout(lua_State *L)
{
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
return timeout_meth_gettimeout(L, &tcp->tm);
}
/*=========================================================================*\
* Library functions
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Creates a master tcp object
* Creates a master tcp object
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L)
{
t_socket sock;
const char *err = inet_trycreate(&sock, SOCK_STREAM);
/* try to allocate a system socket */
if (!err) {
/* allocate tcp object */
p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
/* set its type as master object */
auxiliar_setclass(L, "tcp{master}", -1);
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
tcp->sock = sock;
io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv,
(p_error) socket_ioerror, &tcp->sock);
timeout_init(&tcp->tm, -1, -1);
buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
return 1;
} else {
static int tcp_create(lua_State *L, int family) {
p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
memset(tcp, 0, sizeof(t_tcp));
/* set its type as master object */
auxiliar_setclass(L, "tcp{master}", -1);
/* if family is AF_UNSPEC, we leave the socket invalid and
* store AF_UNSPEC into family. This will allow it to later be
* replaced with an AF_INET6 or AF_INET socket upon first use. */
tcp->sock = SOCKET_INVALID;
tcp->family = family;
io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv,
(p_error) socket_ioerror, &tcp->sock);
timeout_init(&tcp->tm, -1, -1);
buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
if (family != AF_UNSPEC) {
const char *err = inet_trycreate(&tcp->sock, family, SOCK_STREAM, 0);
if (err != NULL) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
socket_setnonblocking(&tcp->sock);
}
return 1;
}
static int global_create(lua_State *L) {
return tcp_create(L, AF_UNSPEC);
}
static int global_create4(lua_State *L) {
return tcp_create(L, AF_INET);
}
static int global_create6(lua_State *L) {
return tcp_create(L, AF_INET6);
}
static int global_connect(lua_State *L) {
const char *remoteaddr = luaL_checkstring(L, 1);
const char *remoteserv = luaL_checkstring(L, 2);
const char *localaddr = luaL_optstring(L, 3, NULL);
const char *localserv = luaL_optstring(L, 4, "0");
int family = inet_optfamily(L, 5, "unspec");
p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
struct addrinfo bindhints, connecthints;
const char *err = NULL;
/* initialize tcp structure */
memset(tcp, 0, sizeof(t_tcp));
io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv,
(p_error) socket_ioerror, &tcp->sock);
timeout_init(&tcp->tm, -1, -1);
buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
tcp->sock = SOCKET_INVALID;
tcp->family = AF_UNSPEC;
/* allow user to pick local address and port */
memset(&bindhints, 0, sizeof(bindhints));
bindhints.ai_socktype = SOCK_STREAM;
bindhints.ai_family = family;
bindhints.ai_flags = AI_PASSIVE;
if (localaddr) {
err = inet_trybind(&tcp->sock, &tcp->family, localaddr,
localserv, &bindhints);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
}
/* try to connect to remote address and port */
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->family;
err = inet_tryconnect(&tcp->sock, &tcp->family, remoteaddr, remoteserv,
&tcp->tm, &connecthints);
if (err) {
socket_destroy(&tcp->sock);
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
auxiliar_setclass(L, "tcp{client}", -1);
return 1;
}
+1 -2
View File
@@ -13,8 +13,6 @@
* objects are tcp objects bound to some local address. Client objects are
* tcp objects either connected to some address or returned by the accept
* method of a server object.
*
* RCS ID: $Id: tcp.h,v 1.7 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include "lua.h"
@@ -27,6 +25,7 @@ typedef struct t_tcp_ {
t_io io;
t_buffer buf;
t_timeout tm;
int family;
} t_tcp;
typedef t_tcp *p_tcp;
+32 -13
View File
@@ -1,13 +1,14 @@
/*=========================================================================*\
* Timeout management functions
* LuaSocket toolkit
*
* RCS ID: $Id: timeout.c,v 1.30 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include <stdio.h>
#include <limits.h>
#include <float.h>
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "auxiliar.h"
#include "timeout.h"
@@ -27,15 +28,13 @@
#define MAX(x, y) ((x) > (y) ? x : y)
#endif
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
/*=========================================================================*\
* Internal function prototypes
\*=========================================================================*/
static int timeout_lua_gettime(lua_State *L);
static int timeout_lua_sleep(lua_State *L);
static luaL_reg func[] = {
static luaL_Reg func[] = {
{ "gettime", timeout_lua_gettime },
{ "sleep", timeout_lua_sleep },
{ NULL, NULL }
@@ -54,7 +53,7 @@ void timeout_init(p_timeout tm, double block, double total) {
/*-------------------------------------------------------------------------*\
* Determines how much time we have left for the next system call,
* if the previous call was successful
* if the previous call was successful
* Input
* tm: timeout control structure
* Returns
@@ -109,7 +108,7 @@ double timeout_getretry(p_timeout tm) {
}
/*-------------------------------------------------------------------------*\
* Marks the operation start time in structure
* Marks the operation start time in structure
* Input
* tm: timeout control structure
\*-------------------------------------------------------------------------*/
@@ -119,7 +118,7 @@ p_timeout timeout_markstart(p_timeout tm) {
}
/*-------------------------------------------------------------------------*\
* Gets time in s, relative to January 1, 1970 (UTC)
* Gets time in s, relative to January 1, 1970 (UTC)
* Returns
* time in s.
\*-------------------------------------------------------------------------*/
@@ -146,7 +145,7 @@ double timeout_gettime(void) {
* Initializes module
\*-------------------------------------------------------------------------*/
int timeout_open(lua_State *L) {
luax_register(L, NULL, func);
luaL_setfuncs(L, func, 0);
return 0;
}
@@ -161,7 +160,7 @@ int timeout_meth_settimeout(lua_State *L, p_timeout tm) {
const char *mode = luaL_optstring(L, 3, "b");
switch (*mode) {
case 'b':
tm->block = t;
tm->block = t;
break;
case 'r': case 't':
tm->total = t;
@@ -174,6 +173,16 @@ int timeout_meth_settimeout(lua_State *L, p_timeout tm) {
return 1;
}
/*-------------------------------------------------------------------------*\
* Gets timeout values for IO operations
* Lua Output: block, total
\*-------------------------------------------------------------------------*/
int timeout_meth_gettimeout(lua_State *L, p_timeout tm) {
lua_pushnumber(L, tm->block);
lua_pushnumber(L, tm->total);
return 2;
}
/*=========================================================================*\
* Test support functions
\*=========================================================================*/
@@ -189,13 +198,23 @@ static int timeout_lua_gettime(lua_State *L)
/*-------------------------------------------------------------------------*\
* Sleep for n seconds.
\*-------------------------------------------------------------------------*/
#ifdef _WIN32
int timeout_lua_sleep(lua_State *L)
{
double n = luaL_checknumber(L, 1);
#ifdef _WIN32
Sleep((int)(n*1000));
if (n < 0.0) n = 0.0;
if (n < DBL_MAX/1000.0) n *= 1000.0;
if (n > INT_MAX) n = INT_MAX;
Sleep((int)n);
return 0;
}
#else
int timeout_lua_sleep(lua_State *L)
{
double n = luaL_checknumber(L, 1);
struct timespec t, r;
if (n < 0.0) n = 0.0;
if (n > INT_MAX) n = INT_MAX;
t.tv_sec = (int) n;
n -= t.tv_sec;
t.tv_nsec = (int) (n * 1000000000);
@@ -204,6 +223,6 @@ int timeout_lua_sleep(lua_State *L)
t.tv_sec = r.tv_sec;
t.tv_nsec = r.tv_nsec;
}
#endif
return 0;
}
#endif
@@ -3,8 +3,6 @@
/*=========================================================================*\
* Timeout management functions
* LuaSocket toolkit
*
* RCS ID: $Id: timeout.h,v 1.14 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include "lua.h"
@@ -24,6 +22,7 @@ p_timeout timeout_markstart(p_timeout tm);
double timeout_getstart(p_timeout tm);
double timeout_gettime(void);
int timeout_meth_settimeout(lua_State *L, p_timeout tm);
int timeout_meth_gettimeout(lua_State *L, p_timeout tm);
#define timeout_iszero(tm) ((tm)->block == 0.0)
+18 -7
View File
@@ -2,7 +2,6 @@
-- Unified SMTP/FTP subsystem
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id: tp.lua,v 1.22 2006/03/14 09:04:15 diego Exp $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@@ -12,12 +11,14 @@ local base = _G
local string = require("string")
local socket = require("socket")
local ltn12 = require("ltn12")
module("socket.tp")
socket.tp = {}
local _M = socket.tp
-----------------------------------------------------------------------------
-- Program constants
-----------------------------------------------------------------------------
TIMEOUT = 60
_M.TIMEOUT = 60
-----------------------------------------------------------------------------
-- Implementation
@@ -45,6 +46,14 @@ end
-- metatable for sock object
local metat = { __index = {} }
function metat.__index:getpeername()
return self.c:getpeername()
end
function metat.__index:getsockname()
return self.c:getpeername()
end
function metat.__index:check(ok)
local code, reply = get_reply(self.c)
if not code then return nil, reply end
@@ -64,6 +73,7 @@ function metat.__index:check(ok)
end
function metat.__index:command(cmd, arg)
cmd = string.upper(cmd)
if arg then
return self.c:send(cmd .. " " .. arg.. "\r\n")
else
@@ -72,7 +82,7 @@ function metat.__index:command(cmd, arg)
end
function metat.__index:sink(snk, pat)
local chunk, err = c:receive(pat)
local chunk, err = self.c:receive(pat)
return snk(chunk, err)
end
@@ -105,14 +115,14 @@ end
-- closes the underlying c
function metat.__index:close()
self.c:close()
return 1
return 1
end
-- connect with server and return c object
function connect(host, port, timeout, create)
function _M.connect(host, port, timeout, create)
local c, e = (create or socket.tcp)()
if not c then return nil, e end
c:settimeout(timeout or TIMEOUT)
c:settimeout(timeout or _M.TIMEOUT)
local r, e = c:connect(host, port)
if not r then
c:close()
@@ -121,3 +131,4 @@ function connect(host, port, timeout, create)
return base.setmetatable({c = c}, metat)
end
return _M
+161 -153
View File
@@ -1,7 +1,7 @@
/* code automatically generated by bin2c -- DO NOT EDIT */
{
/* #include'ing this file in a C program is equivalent to calling
if (luaL_loadfile(L,"tp.lua")==0) lua_call(L, 0, 0);
if (luaL_loadfile(L,"tp.lua")==0) lua_call(L, 0, LUA_MULTRET);
*/
/* tp.lua */
static const unsigned char B1[]={
@@ -12,181 +12,189 @@ static const unsigned char B1[]={
32, 85,110,105,102,105,101,100, 32, 83, 77, 84, 80, 47, 70, 84, 80, 32,115,117,
98,115,121,115,116,101,109, 10, 45, 45, 32, 76,117, 97, 83,111, 99,107,101,116,
32,116,111,111,108,107,105,116, 46, 10, 45, 45, 32, 65,117,116,104,111,114, 58,
32, 68,105,101,103,111, 32, 78,101,104, 97, 98, 10, 45, 45, 32, 82, 67, 83, 32,
73, 68, 58, 32, 36, 73,100, 58, 32,116,112, 46,108,117, 97, 44,118, 32, 49, 46,
50, 50, 32, 50, 48, 48, 54, 47, 48, 51, 47, 49, 52, 32, 48, 57, 58, 48, 52, 58,
49, 53, 32,100,105,101,103,111, 32, 69,120,112, 32, 36, 10, 45, 45, 45, 45, 45,
32, 68,105,101,103,111, 32, 78,101,104, 97, 98, 10, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,
114,101, 32,109,111,100,117,108,101, 32, 97,110,100, 32,105,109,112,111,114,116,
32,100,101,112,101,110,100,101,110, 99,105,101,115, 10, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 99,108, 97,114,101,
32,109,111,100,117,108,101, 32, 97,110,100, 32,105,109,112,111,114,116, 32,100,
101,112,101,110,100,101,110, 99,105,101,115, 10, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32, 98, 97,
115,101, 32, 61, 32, 95, 71, 10,108,111, 99, 97,108, 32,115,116,114,105,110,103,
32, 61, 32,114,101,113,117,105,114,101, 40, 34,115,116,114,105,110,103, 34, 41,
10,108,111, 99, 97,108, 32,115,111, 99,107,101,116, 32, 61, 32,114,101,113,117,
105,114,101, 40, 34,115,111, 99,107,101,116, 34, 41, 10,108,111, 99, 97,108, 32,
108,116,110, 49, 50, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,108,116,110,
49, 50, 34, 41, 10,109,111,100,117,108,101, 40, 34,115,111, 99,107,101,116, 46,
116,112, 34, 41, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 10,108,111, 99, 97,108, 32, 98, 97,115,101,
32, 61, 32, 95, 71, 10,108,111, 99, 97,108, 32,115,116,114,105,110,103, 32, 61,
32,114,101,113,117,105,114,101, 40, 34,115,116,114,105,110,103, 34, 41, 10,108,
111, 99, 97,108, 32,115,111, 99,107,101,116, 32, 61, 32,114,101,113,117,105,114,
101, 40, 34,115,111, 99,107,101,116, 34, 41, 10,108,111, 99, 97,108, 32,108,116,
110, 49, 50, 32, 61, 32,114,101,113,117,105,114,101, 40, 34,108,116,110, 49, 50,
34, 41, 10, 10,115,111, 99,107,101,116, 46,116,112, 32, 61, 32,123,125, 10,108,
111, 99, 97,108, 32, 95, 77, 32, 61, 32,115,111, 99,107,101,116, 46,116,112, 10,
10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45,
45, 32, 80,114,111,103,114, 97,109, 32, 99,111,110,115,116, 97,110,116,115, 10,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 10, 45, 45, 32, 80,114,111,103,114, 97,109, 32, 99,111,110,115,116,
97,110,116,115, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 95, 77,
46, 84, 73, 77, 69, 79, 85, 84, 32, 61, 32, 54, 48, 10, 10, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 10, 84, 73, 77, 69, 79, 85, 84, 32, 61, 32, 54, 48, 10, 10, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 73,109,112,108,
101,109,101,110,116, 97,116,105,111,110, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 73,109,
112,108,101,109,101,110,116, 97,116,105,111,110, 10, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,103,101,116,115, 32,115,
101,114,118,101,114, 32,114,101,112,108,121, 32, 40,119,111,114,107,115, 32,102,
111,114, 32, 83, 77, 84, 80, 32, 97,110,100, 32, 70, 84, 80, 41, 10,108,111, 99,
97,108, 32,102,117,110, 99,116,105,111,110, 32,103,101,116, 95,114,101,112,108,
121, 40, 99, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,111,100,101, 44,
32, 99,117,114,114,101,110,116, 44, 32,115,101,112, 10, 32, 32, 32, 32,108,111,
99, 97,108, 32,108,105,110,101, 44, 32,101,114,114, 32, 61, 32, 99, 58,114,101,
99,101,105,118,101, 40, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,
112,108,121, 32, 61, 32,108,105,110,101, 10, 32, 32, 32, 32,105,102, 32,101,114,
114, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,
114,114, 32,101,110,100, 10, 32, 32, 32, 32, 99,111,100,101, 44, 32,115,101,112,
32, 61, 32,115,111, 99,107,101,116, 46,115,107,105,112, 40, 50, 44, 32,115,116,
114,105,110,103, 46,102,105,110,100, 40,108,105,110,101, 44, 32, 34, 94, 40, 37,
100, 37,100, 37,100, 41, 40, 46, 63, 41, 34, 41, 41, 10, 32, 32, 32, 32,105,102,
32,110,111,116, 32, 99,111,100,101, 32,116,104,101,110, 32,114,101,116,117,114,
110, 32,110,105,108, 44, 32, 34,105,110,118, 97,108,105,100, 32,115,101,114,118,
101,114, 32,114,101,112,108,121, 34, 32,101,110,100, 10, 32, 32, 32, 32,105,102,
32,115,101,112, 32, 61, 61, 32, 34, 45, 34, 32,116,104,101,110, 32, 45, 45, 32,
114,101,112,108,121, 32,105,115, 32,109,117,108,116,105,108,105,110,101, 10, 32,
32, 32, 32, 32, 32, 32, 32,114,101,112,101, 97,116, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,108,105,110,101, 44, 32,101,114,114, 32, 61, 32, 99, 58,
114,101, 99,101,105,118,101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,105,102, 32,101,114,114, 32,116,104,101,110, 32,114,101,116,117,114,110,
32,110,105,108, 44, 32,101,114,114, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 99,117,114,114,101,110,116, 44, 32,115,101,112, 32, 61,
45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32,103,101,116,115, 32,115,101,114,
118,101,114, 32,114,101,112,108,121, 32, 40,119,111,114,107,115, 32,102,111,114,
32, 83, 77, 84, 80, 32, 97,110,100, 32, 70, 84, 80, 41, 10,108,111, 99, 97,108,
32,102,117,110, 99,116,105,111,110, 32,103,101,116, 95,114,101,112,108,121, 40,
99, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,111,100,101, 44, 32, 99,
117,114,114,101,110,116, 44, 32,115,101,112, 10, 32, 32, 32, 32,108,111, 99, 97,
108, 32,108,105,110,101, 44, 32,101,114,114, 32, 61, 32, 99, 58,114,101, 99,101,
105,118,101, 40, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,114,101,112,108,
121, 32, 61, 32,108,105,110,101, 10, 32, 32, 32, 32,105,102, 32,101,114,114, 32,
116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101,114,114,
32,101,110,100, 10, 32, 32, 32, 32, 99,111,100,101, 44, 32,115,101,112, 32, 61,
32,115,111, 99,107,101,116, 46,115,107,105,112, 40, 50, 44, 32,115,116,114,105,
110,103, 46,102,105,110,100, 40,108,105,110,101, 44, 32, 34, 94, 40, 37,100, 37,
100, 37,100, 41, 40, 46, 63, 41, 34, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,114,101,112,108,121, 32, 61, 32,114,101,112,108,121, 32, 46, 46,
32, 34, 92,110, 34, 32, 46, 46, 32,108,105,110,101, 10, 32, 32, 32, 32, 32, 32,
32, 32, 45, 45, 32,114,101,112,108,121, 32,101,110,100,115, 32,119,105,116,104,
32,115, 97,109,101, 32, 99,111,100,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,117,
110,116,105,108, 32, 99,111,100,101, 32, 61, 61, 32, 99,117,114,114,101,110,116,
32, 97,110,100, 32,115,101,112, 32, 61, 61, 32, 34, 32, 34, 10, 32, 32, 32, 32,
101,110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 99,111,100,101, 44,
32,114,101,112,108,121, 10,101,110,100, 10, 10, 45, 45, 32,109,101,116, 97,116,
97, 98,108,101, 32,102,111,114, 32,115,111, 99,107, 32,111, 98,106,101, 99,116,
10,108,111, 99, 97,108, 32,109,101,116, 97,116, 32, 61, 32,123, 32, 95, 95,105,
110,100,101,120, 32, 61, 32,123,125, 32,125, 10, 10,102,117,110, 99,116,105,111,
110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58, 99,104,101, 99,
107, 40,111,107, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,111,100,101,
44, 32,114,101,112,108,121, 32, 61, 32,103,101,116, 95,114,101,112,108,121, 40,
115,101,108,102, 46, 99, 41, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32, 99,
111,100,101, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44,
32,114,101,112,108,121, 32,101,110,100, 10, 32, 32, 32, 32,105,102, 32, 98, 97,
115,101, 46,116,121,112,101, 40,111,107, 41, 32,126, 61, 32, 34,102,117,110, 99,
116,105,111,110, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,105,
102, 32, 98, 97,115,101, 46,116,121,112,101, 40,111,107, 41, 32, 61, 61, 32, 34,
116, 97, 98,108,101, 34, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,102,111,114, 32,105, 44, 32,118, 32,105,110, 32, 98, 97,115,101,
46,105,112, 97,105,114,115, 40,111,107, 41, 32,100,111, 10, 32, 32, 32, 32, 32,
100, 37,100, 41, 40, 46, 63, 41, 34, 41, 41, 10, 32, 32, 32, 32,105,102, 32,110,
111,116, 32, 99,111,100,101, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,
110,105,108, 44, 32, 34,105,110,118, 97,108,105,100, 32,115,101,114,118,101,114,
32,114,101,112,108,121, 34, 32,101,110,100, 10, 32, 32, 32, 32,105,102, 32,115,
101,112, 32, 61, 61, 32, 34, 45, 34, 32,116,104,101,110, 32, 45, 45, 32,114,101,
112,108,121, 32,105,115, 32,109,117,108,116,105,108,105,110,101, 10, 32, 32, 32,
32, 32, 32, 32, 32,114,101,112,101, 97,116, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32,108,105,110,101, 44, 32,101,114,114, 32, 61, 32, 99, 58,114,101,
99,101,105,118,101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
105,102, 32,101,114,114, 32,116,104,101,110, 32,114,101,116,117,114,110, 32,110,
105,108, 44, 32,101,114,114, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 99,117,114,114,101,110,116, 44, 32,115,101,112, 32, 61, 32,115,
111, 99,107,101,116, 46,115,107,105,112, 40, 50, 44, 32,115,116,114,105,110,103,
46,102,105,110,100, 40,108,105,110,101, 44, 32, 34, 94, 40, 37,100, 37,100, 37,
100, 41, 40, 46, 63, 41, 34, 41, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,114,101,112,108,121, 32, 61, 32,114,101,112,108,121, 32, 46, 46, 32, 34,
92,110, 34, 32, 46, 46, 32,108,105,110,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,
45, 45, 32,114,101,112,108,121, 32,101,110,100,115, 32,119,105,116,104, 32,115,
97,109,101, 32, 99,111,100,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,117,110,116,
105,108, 32, 99,111,100,101, 32, 61, 61, 32, 99,117,114,114,101,110,116, 32, 97,
110,100, 32,115,101,112, 32, 61, 61, 32, 34, 32, 34, 10, 32, 32, 32, 32,101,110,
100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 99,111,100,101, 44, 32,114,
101,112,108,121, 10,101,110,100, 10, 10, 45, 45, 32,109,101,116, 97,116, 97, 98,
108,101, 32,102,111,114, 32,115,111, 99,107, 32,111, 98,106,101, 99,116, 10,108,
111, 99, 97,108, 32,109,101,116, 97,116, 32, 61, 32,123, 32, 95, 95,105,110,100,
101,120, 32, 61, 32,123,125, 32,125, 10, 10,102,117,110, 99,116,105,111,110, 32,
109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,103,101,116,112,101,101,
114,110, 97,109,101, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,
101,108,102, 46, 99, 58,103,101,116,112,101,101,114,110, 97,109,101, 40, 41, 10,
101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46,
95, 95,105,110,100,101,120, 58,103,101,116,115,111, 99,107,110, 97,109,101, 40,
41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46, 99, 58,
103,101,116,112,101,101,114,110, 97,109,101, 40, 41, 10,101,110,100, 10, 10,102,
117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,
120, 58, 99,104,101, 99,107, 40,111,107, 41, 10, 32, 32, 32, 32,108,111, 99, 97,
108, 32, 99,111,100,101, 44, 32,114,101,112,108,121, 32, 61, 32,103,101,116, 95,
114,101,112,108,121, 40,115,101,108,102, 46, 99, 41, 10, 32, 32, 32, 32,105,102,
32,110,111,116, 32, 99,111,100,101, 32,116,104,101,110, 32,114,101,116,117,114,
110, 32,110,105,108, 44, 32,114,101,112,108,121, 32,101,110,100, 10, 32, 32, 32,
32,105,102, 32, 98, 97,115,101, 46,116,121,112,101, 40,111,107, 41, 32,126, 61,
32, 34,102,117,110, 99,116,105,111,110, 34, 32,116,104,101,110, 10, 32, 32, 32,
32, 32, 32, 32, 32,105,102, 32, 98, 97,115,101, 46,116,121,112,101, 40,111,107,
41, 32, 61, 61, 32, 34,116, 97, 98,108,101, 34, 32,116,104,101,110, 10, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,102,111,114, 32,105, 44, 32,118, 32,105,
110, 32, 98, 97,115,101, 46,105,112, 97,105,114,115, 40,111,107, 41, 32,100,111,
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,
115,116,114,105,110,103, 46,102,105,110,100, 40, 99,111,100,101, 44, 32,118, 41,
32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32, 98, 97,115,101, 46,116,111,
110,117,109, 98,101,114, 40, 99,111,100,101, 41, 44, 32,114,101,112,108,121, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,
114,101,112,108,121, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,105,102, 32,115,116,114,105,110,103,
46,102,105,110,100, 40, 99,111,100,101, 44, 32,118, 41, 32,116,104,101,110, 10,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
114,101,116,117,114,110, 32, 98, 97,115,101, 46,116,111,110,117,109, 98,101,114,
40, 99,111,100,101, 41, 44, 32,114,101,112,108,121, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,114,101,112,108,121, 10,
32, 32, 32, 32, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32,105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
99,111,100,101, 44, 32,111,107, 41, 32,116,104,101,110, 32,114,101,116,117,114,
110, 32, 98, 97,115,101, 46,116,111,110,117,109, 98,101,114, 40, 99,111,100,101,
41, 44, 32,114,101,112,108,121, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32,101,108,115,101, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,114,101,
112,108,121, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 10,
32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,111,107, 40, 98,
97,115,101, 46,116,111,110,117,109, 98,101,114, 40, 99,111,100,101, 41, 44, 32,
114,101,112,108,121, 41, 32,101,110,100, 10,101,110,100, 10, 10,102,117,110, 99,
116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58, 99,
111,109,109, 97,110,100, 40, 99,109,100, 44, 32, 97,114,103, 41, 10, 32, 32, 32,
32,105,102, 32, 97,114,103, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32,
32,114,101,116,117,114,110, 32,115,101,108,102, 46, 99, 58,115,101,110,100, 40,
99,109,100, 32, 46, 46, 32, 34, 32, 34, 32, 46, 46, 32, 97,114,103, 46, 46, 32,
34, 92,114, 92,110, 34, 41, 10, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32,
32, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46, 99, 58,115,
101,110,100, 40, 99,109,100, 32, 46, 46, 32, 34, 92,114, 92,110, 34, 41, 10, 32,
32, 32, 32,101,110,100, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110,
32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,120, 58,115,105,110,107, 40,
115,110,107, 44, 32,112, 97,116, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,
99,104,117,110,107, 44, 32,101,114,114, 32, 61, 32, 99, 58,114,101, 99,101,105,
118,101, 40,112, 97,116, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,
110,107, 40, 99,104,117,110,107, 44, 32,101,114,114, 41, 10,101,110,100, 10, 10,
102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,
101,120, 58,115,101,110,100, 40,100, 97,116, 97, 41, 10, 32, 32, 32, 32,114,101,
116,117,114,110, 32,115,101,108,102, 46, 99, 58,115,101,110,100, 40,100, 97,116,
97, 41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116,
97,116, 46, 95, 95,105,110,100,101,120, 58,114,101, 99,101,105,118,101, 40,112,
97,116, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46,
99, 58,114,101, 99,101,105,118,101, 40,112, 97,116, 41, 10,101,110,100, 10, 10,
102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,
101,120, 58,103,101,116,102,100, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,
110, 32,115,101,108,102, 46, 99, 58,103,101,116,102,100, 40, 41, 10,101,110,100,
46,102,105,110,100, 40, 99,111,100,101, 44, 32,111,107, 41, 32,116,104,101,110,
32,114,101,116,117,114,110, 32, 98, 97,115,101, 46,116,111,110,117,109, 98,101,
114, 40, 99,111,100,101, 41, 44, 32,114,101,112,108,121, 10, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32,110,
105,108, 44, 32,114,101,112,108,121, 32,101,110,100, 10, 32, 32, 32, 32, 32, 32,
32, 32,101,110,100, 10, 32, 32, 32, 32,101,108,115,101, 32,114,101,116,117,114,
110, 32,111,107, 40, 98, 97,115,101, 46,116,111,110,117,109, 98,101,114, 40, 99,
111,100,101, 41, 44, 32,114,101,112,108,121, 41, 32,101,110,100, 10,101,110,100,
10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,
110,100,101,120, 58,100,105,114,116,121, 40, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32,115,101,108,102, 46, 99, 58,100,105,114,116,121, 40, 41, 10,101,
110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95,
95,105,110,100,101,120, 58,103,101,116, 99,111,110,116,114,111,108, 40, 41, 10,
32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46, 99, 10,101,110,
110,100,101,120, 58, 99,111,109,109, 97,110,100, 40, 99,109,100, 44, 32, 97,114,
103, 41, 10, 32, 32, 32, 32, 99,109,100, 32, 61, 32,115,116,114,105,110,103, 46,
117,112,112,101,114, 40, 99,109,100, 41, 10, 32, 32, 32, 32,105,102, 32, 97,114,
103, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,114,
110, 32,115,101,108,102, 46, 99, 58,115,101,110,100, 40, 99,109,100, 32, 46, 46,
32, 34, 32, 34, 32, 46, 46, 32, 97,114,103, 46, 46, 32, 34, 92,114, 92,110, 34,
41, 10, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,
101,116,117,114,110, 32,115,101,108,102, 46, 99, 58,115,101,110,100, 40, 99,109,
100, 32, 46, 46, 32, 34, 92,114, 92,110, 34, 41, 10, 32, 32, 32, 32,101,110,100,
10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116,
46, 95, 95,105,110,100,101,120, 58,115,105,110,107, 40,115,110,107, 44, 32,112,
97,116, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99,104,117,110,107, 44,
32,101,114,114, 32, 61, 32,115,101,108,102, 46, 99, 58,114,101, 99,101,105,118,
101, 40,112, 97,116, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,110,
107, 40, 99,104,117,110,107, 44, 32,101,114,114, 41, 10,101,110,100, 10, 10,102,
117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,
120, 58,115,101,110,100, 40,100, 97,116, 97, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32,115,101,108,102, 46, 99, 58,115,101,110,100, 40,100, 97,116, 97,
41, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,
116, 46, 95, 95,105,110,100,101,120, 58,114,101, 99,101,105,118,101, 40,112, 97,
116, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46, 99,
58,114,101, 99,101,105,118,101, 40,112, 97,116, 41, 10,101,110,100, 10, 10,102,
117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,100,101,
120, 58,103,101,116,102,100, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,114,110,
32,115,101,108,102, 46, 99, 58,103,101,116,102,100, 40, 41, 10,101,110,100, 10,
10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,110,
100,101,120, 58,100,105,114,116,121, 40, 41, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32,115,101,108,102, 46, 99, 58,100,105,114,116,121, 40, 41, 10,101,110,
100, 10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,
105,110,100,101,120, 58,115,111,117,114, 99,101, 40,115,111,117,114, 99,101, 44,
32,115,116,101,112, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,105,110,
107, 32, 61, 32,115,111, 99,107,101,116, 46,115,105,110,107, 40, 34,107,101,101,
112, 45,111,112,101,110, 34, 44, 32,115,101,108,102, 46, 99, 41, 10, 32, 32, 32,
32,108,111, 99, 97,108, 32,114,101,116, 44, 32,101,114,114, 32, 61, 32,108,116,
110, 49, 50, 46,112,117,109,112, 46, 97,108,108, 40,115,111,117,114, 99,101, 44,
32,115,105,110,107, 44, 32,115,116,101,112, 32,111,114, 32,108,116,110, 49, 50,
46,112,117,109,112, 46,115,116,101,112, 41, 10, 32, 32, 32, 32,114,101,116,117,
114,110, 32,114,101,116, 44, 32,101,114,114, 10,101,110,100, 10, 10, 45, 45, 32,
99,108,111,115,101,115, 32,116,104,101, 32,117,110,100,101,114,108,121,105,110,
103, 32, 99, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95,
95,105,110,100,101,120, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,115,
101,108,102, 46, 99, 58, 99,108,111,115,101, 40, 41, 10, 9,114,101,116,117,114,
110, 32, 49, 10,101,110,100, 10, 10, 45, 45, 32, 99,111,110,110,101, 99,116, 32,
119,105,116,104, 32,115,101,114,118,101,114, 32, 97,110,100, 32,114,101,116,117,
114,110, 32, 99, 32,111, 98,106,101, 99,116, 10,102,117,110, 99,116,105,111,110,
32, 99,111,110,110,101, 99,116, 40,104,111,115,116, 44, 32,112,111,114,116, 44,
32,116,105,109,101,111,117,116, 44, 32, 99,114,101, 97,116,101, 41, 10, 32, 32,
32, 32,108,111, 99, 97,108, 32, 99, 44, 32,101, 32, 61, 32, 40, 99,114,101, 97,
116,101, 32,111,114, 32,115,111, 99,107,101,116, 46,116, 99,112, 41, 40, 41, 10,
32, 32, 32, 32,105,102, 32,110,111,116, 32, 99, 32,116,104,101,110, 32,114,101,
116,117,114,110, 32,110,105,108, 44, 32,101, 32,101,110,100, 10, 32, 32, 32, 32,
99, 58,115,101,116,116,105,109,101,111,117,116, 40,116,105,109,101,111,117,116,
32,111,114, 32, 84, 73, 77, 69, 79, 85, 84, 41, 10, 32, 32, 32, 32,108,111, 99,
97,108, 32,114, 44, 32,101, 32, 61, 32, 99, 58, 99,111,110,110,101, 99,116, 40,
104,111,115,116, 44, 32,112,111,114,116, 41, 10, 32, 32, 32, 32,105,102, 32,110,
111,116, 32,114, 32,116,104,101,110, 10, 32, 32, 32, 32, 32, 32, 32, 32, 99, 58,
99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,
114,110, 32,110,105,108, 44, 32,101, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32,
32, 32,114,101,116,117,114,110, 32, 98, 97,115,101, 46,115,101,116,109,101,116,
97,116, 97, 98,108,101, 40,123, 99, 32, 61, 32, 99,125, 44, 32,109,101,116, 97,
116, 41, 10,101,110,100, 10, 10,
105,110,100,101,120, 58,103,101,116, 99,111,110,116,114,111,108, 40, 41, 10, 32,
32, 32, 32,114,101,116,117,114,110, 32,115,101,108,102, 46, 99, 10,101,110,100,
10, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,105,
110,100,101,120, 58,115,111,117,114, 99,101, 40,115,111,117,114, 99,101, 44, 32,
115,116,101,112, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32,115,105,110,107,
32, 61, 32,115,111, 99,107,101,116, 46,115,105,110,107, 40, 34,107,101,101,112,
45,111,112,101,110, 34, 44, 32,115,101,108,102, 46, 99, 41, 10, 32, 32, 32, 32,
108,111, 99, 97,108, 32,114,101,116, 44, 32,101,114,114, 32, 61, 32,108,116,110,
49, 50, 46,112,117,109,112, 46, 97,108,108, 40,115,111,117,114, 99,101, 44, 32,
115,105,110,107, 44, 32,115,116,101,112, 32,111,114, 32,108,116,110, 49, 50, 46,
112,117,109,112, 46,115,116,101,112, 41, 10, 32, 32, 32, 32,114,101,116,117,114,
110, 32,114,101,116, 44, 32,101,114,114, 10,101,110,100, 10, 10, 45, 45, 32, 99,
108,111,115,101,115, 32,116,104,101, 32,117,110,100,101,114,108,121,105,110,103,
32, 99, 10,102,117,110, 99,116,105,111,110, 32,109,101,116, 97,116, 46, 95, 95,
105,110,100,101,120, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,115,101,
108,102, 46, 99, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,114,101,116,
117,114,110, 32, 49, 10,101,110,100, 10, 10, 45, 45, 32, 99,111,110,110,101, 99,
116, 32,119,105,116,104, 32,115,101,114,118,101,114, 32, 97,110,100, 32,114,101,
116,117,114,110, 32, 99, 32,111, 98,106,101, 99,116, 10,102,117,110, 99,116,105,
111,110, 32, 95, 77, 46, 99,111,110,110,101, 99,116, 40,104,111,115,116, 44, 32,
112,111,114,116, 44, 32,116,105,109,101,111,117,116, 44, 32, 99,114,101, 97,116,
101, 41, 10, 32, 32, 32, 32,108,111, 99, 97,108, 32, 99, 44, 32,101, 32, 61, 32,
40, 99,114,101, 97,116,101, 32,111,114, 32,115,111, 99,107,101,116, 46,116, 99,
112, 41, 40, 41, 10, 32, 32, 32, 32,105,102, 32,110,111,116, 32, 99, 32,116,104,
101,110, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101, 32,101,110,100,
10, 32, 32, 32, 32, 99, 58,115,101,116,116,105,109,101,111,117,116, 40,116,105,
109,101,111,117,116, 32,111,114, 32, 95, 77, 46, 84, 73, 77, 69, 79, 85, 84, 41,
10, 32, 32, 32, 32,108,111, 99, 97,108, 32,114, 44, 32,101, 32, 61, 32, 99, 58,
99,111,110,110,101, 99,116, 40,104,111,115,116, 44, 32,112,111,114,116, 41, 10,
32, 32, 32, 32,105,102, 32,110,111,116, 32,114, 32,116,104,101,110, 10, 32, 32,
32, 32, 32, 32, 32, 32, 99, 58, 99,108,111,115,101, 40, 41, 10, 32, 32, 32, 32,
32, 32, 32, 32,114,101,116,117,114,110, 32,110,105,108, 44, 32,101, 10, 32, 32,
32, 32,101,110,100, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32, 98, 97,115,
101, 46,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,123, 99, 32, 61, 32,
99,125, 44, 32,109,101,116, 97,116, 41, 10,101,110,100, 10, 10,114,101,116,117,
114,110, 32, 95, 77, 10,
};
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"tp.lua")==0) lua_call(L, 0, 0);
if (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),"tp.lua")==0) lua_call(L, 0, LUA_MULTRET);
}
+216 -92
View File
@@ -1,13 +1,13 @@
/*=========================================================================*\
* UDP object
* UDP object
* LuaSocket toolkit
*
* RCS ID: $Id: udp.c,v 1.29 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "auxiliar.h"
#include "socket.h"
@@ -18,38 +18,42 @@
/* min and max macros */
#ifndef MIN
#define MIN(x, y) ((x) < (y) ? x : y)
#endif
#endif
#ifndef MAX
#define MAX(x, y) ((x) > (y) ? x : y)
#endif
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
#endif
/*=========================================================================*\
* Internal function prototypes
\*=========================================================================*/
static int global_create(lua_State *L);
static int global_create4(lua_State *L);
static int global_create6(lua_State *L);
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_gettimeout(lua_State *L);
static int meth_setsockname(lua_State *L);
static int meth_setpeername(lua_State *L);
static int meth_close(lua_State *L);
static int meth_setoption(lua_State *L);
static int meth_getoption(lua_State *L);
static int meth_settimeout(lua_State *L);
static int meth_getfd(lua_State *L);
static int meth_setfd(lua_State *L);
static int meth_dirty(lua_State *L);
/* udp object methods */
static luaL_reg udp[] = {
static luaL_Reg udp_methods[] = {
{"__gc", meth_close},
{"__tostring", auxiliar_tostring},
{"close", meth_close},
{"dirty", meth_dirty},
{"getfamily", meth_getfamily},
{"getfd", meth_getfd},
{"getpeername", meth_getpeername},
{"getsockname", meth_getsockname},
@@ -59,52 +63,83 @@ static luaL_reg udp[] = {
{"sendto", meth_sendto},
{"setfd", meth_setfd},
{"setoption", meth_setoption},
{"getoption", meth_getoption},
{"setpeername", meth_setpeername},
{"setsockname", meth_setsockname},
{"settimeout", meth_settimeout},
{"gettimeout", meth_gettimeout},
{NULL, NULL}
};
/* socket options */
static t_opt opt[] = {
{"dontroute", opt_dontroute},
{"broadcast", opt_broadcast},
{"reuseaddr", opt_reuseaddr},
{"ip-multicast-ttl", opt_ip_multicast_ttl},
{"ip-multicast-loop", opt_ip_multicast_loop},
{"ip-add-membership", opt_ip_add_membership},
{"ip-drop-membership", opt_ip_drop_membersip},
{NULL, NULL}
/* socket options for setoption */
static t_opt optset[] = {
{"dontroute", opt_set_dontroute},
{"broadcast", opt_set_broadcast},
{"reuseaddr", opt_set_reuseaddr},
{"reuseport", opt_set_reuseport},
{"ip-multicast-if", opt_set_ip_multicast_if},
{"ip-multicast-ttl", opt_set_ip_multicast_ttl},
{"ip-multicast-loop", opt_set_ip_multicast_loop},
{"ip-add-membership", opt_set_ip_add_membership},
{"ip-drop-membership", opt_set_ip_drop_membersip},
{"ipv6-unicast-hops", opt_set_ip6_unicast_hops},
{"ipv6-multicast-hops", opt_set_ip6_unicast_hops},
{"ipv6-multicast-loop", opt_set_ip6_multicast_loop},
{"ipv6-add-membership", opt_set_ip6_add_membership},
{"ipv6-drop-membership", opt_set_ip6_drop_membersip},
{"ipv6-v6only", opt_set_ip6_v6only},
{NULL, NULL}
};
/* socket options for getoption */
static t_opt optget[] = {
{"dontroute", opt_get_dontroute},
{"broadcast", opt_get_broadcast},
{"reuseaddr", opt_get_reuseaddr},
{"reuseport", opt_get_reuseport},
{"ip-multicast-if", opt_get_ip_multicast_if},
{"ip-multicast-loop", opt_get_ip_multicast_loop},
{"error", opt_get_error},
{"ipv6-unicast-hops", opt_get_ip6_unicast_hops},
{"ipv6-multicast-hops", opt_get_ip6_unicast_hops},
{"ipv6-multicast-loop", opt_get_ip6_multicast_loop},
{"ipv6-v6only", opt_get_ip6_v6only},
{NULL, NULL}
};
/* functions in library namespace */
static luaL_reg func[] = {
static luaL_Reg func[] = {
{"udp", global_create},
{"udp4", global_create4},
{"udp6", global_create6},
{NULL, NULL}
};
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int udp_open(lua_State *L)
{
int udp_open(lua_State *L) {
/* create classes */
auxiliar_newclass(L, "udp{connected}", udp);
auxiliar_newclass(L, "udp{unconnected}", udp);
auxiliar_newclass(L, "udp{connected}", udp_methods);
auxiliar_newclass(L, "udp{unconnected}", udp_methods);
/* create class groups */
auxiliar_add2group(L, "udp{connected}", "udp{any}");
auxiliar_add2group(L, "udp{unconnected}", "udp{any}");
auxiliar_add2group(L, "udp{connected}", "select{able}");
auxiliar_add2group(L, "udp{unconnected}", "select{able}");
/* define library functions */
luax_register(L, NULL, func);
luaL_setfuncs(L, func, 0);
/* export default UDP size */
lua_pushliteral(L, "_DATAGRAMSIZE");
lua_pushinteger(L, UDP_DATAGRAMSIZE);
lua_rawset(L, -3);
return 0;
}
/*=========================================================================*\
* Lua methods
\*=========================================================================*/
const char *udp_strerror(int err) {
static const char *udp_strerror(int err) {
/* a 'closed' error on an unconnected means the target address was not
* accepted by the transport layer */
if (err == IO_CLOSED) return "refused";
@@ -127,7 +162,7 @@ static int meth_send(lua_State *L) {
lua_pushstring(L, udp_strerror(err));
return 2;
}
lua_pushnumber(L, sent);
lua_pushnumber(L, (lua_Number) sent);
return 1;
}
@@ -139,24 +174,31 @@ static int meth_sendto(lua_State *L) {
size_t count, sent = 0;
const char *data = luaL_checklstring(L, 2, &count);
const char *ip = luaL_checkstring(L, 3);
unsigned short port = (unsigned short) luaL_checknumber(L, 4);
const char *port = luaL_checkstring(L, 4);
p_timeout tm = &udp->tm;
struct sockaddr_in addr;
int err;
memset(&addr, 0, sizeof(addr));
if (!inet_aton(ip, &addr.sin_addr))
luaL_argerror(L, 3, "invalid ip address");
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
struct addrinfo aihint;
struct addrinfo *ai;
memset(&aihint, 0, sizeof(aihint));
aihint.ai_family = udp->family;
aihint.ai_socktype = SOCK_DGRAM;
aihint.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
err = getaddrinfo(ip, port, &aihint, &ai);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
return 2;
}
timeout_markstart(tm);
err = socket_sendto(&udp->sock, data, count, &sent,
(SA *) &addr, sizeof(addr), tm);
err = socket_sendto(&udp->sock, data, count, &sent, ai->ai_addr,
(socklen_t) ai->ai_addrlen, tm);
freeaddrinfo(ai);
if (err != IO_DONE) {
lua_pushnil(L);
lua_pushstring(L, udp_strerror(err));
return 2;
}
lua_pushnumber(L, sent);
lua_pushnumber(L, (lua_Number) sent);
return 1;
}
@@ -165,19 +207,27 @@ static int meth_sendto(lua_State *L) {
\*-------------------------------------------------------------------------*/
static int meth_receive(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
char buffer[UDP_DATAGRAMSIZE];
size_t got, count = (size_t) luaL_optnumber(L, 2, sizeof(buffer));
char buf[UDP_DATAGRAMSIZE];
size_t got, wanted = (size_t) luaL_optnumber(L, 2, sizeof(buf));
char *dgram = wanted > sizeof(buf)? (char *) malloc(wanted): buf;
int err;
p_timeout tm = &udp->tm;
count = MIN(count, sizeof(buffer));
timeout_markstart(tm);
err = socket_recv(&udp->sock, buffer, count, &got, tm);
if (err != IO_DONE) {
if (!dgram) {
lua_pushnil(L);
lua_pushstring(L, udp_strerror(err));
lua_pushliteral(L, "out of memory");
return 2;
}
lua_pushlstring(L, buffer, got);
err = socket_recv(&udp->sock, dgram, wanted, &got, tm);
/* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */
if (err != IO_DONE && err != IO_CLOSED) {
lua_pushnil(L);
lua_pushstring(L, udp_strerror(err));
if (wanted > sizeof(buf)) free(dgram);
return 2;
}
lua_pushlstring(L, dgram, got);
if (wanted > sizeof(buf)) free(dgram);
return 1;
}
@@ -186,26 +236,57 @@ static int meth_receive(lua_State *L) {
\*-------------------------------------------------------------------------*/
static int meth_receivefrom(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{unconnected}", 1);
struct sockaddr_in addr;
char buf[UDP_DATAGRAMSIZE];
size_t got, wanted = (size_t) luaL_optnumber(L, 2, sizeof(buf));
char *dgram = wanted > sizeof(buf)? (char *) malloc(wanted): buf;
struct sockaddr_storage addr;
socklen_t addr_len = sizeof(addr);
char buffer[UDP_DATAGRAMSIZE];
size_t got, count = (size_t) luaL_optnumber(L, 2, sizeof(buffer));
char addrstr[INET6_ADDRSTRLEN];
char portstr[6];
int err;
p_timeout tm = &udp->tm;
timeout_markstart(tm);
count = MIN(count, sizeof(buffer));
err = socket_recvfrom(&udp->sock, buffer, count, &got,
(SA *) &addr, &addr_len, tm);
if (err == IO_DONE) {
lua_pushlstring(L, buffer, got);
lua_pushstring(L, inet_ntoa(addr.sin_addr));
lua_pushnumber(L, ntohs(addr.sin_port));
return 3;
} else {
if (!dgram) {
lua_pushnil(L);
lua_pushliteral(L, "out of memory");
return 2;
}
err = socket_recvfrom(&udp->sock, dgram, wanted, &got, (SA *) &addr,
&addr_len, tm);
/* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */
if (err != IO_DONE && err != IO_CLOSED) {
lua_pushnil(L);
lua_pushstring(L, udp_strerror(err));
if (wanted > sizeof(buf)) free(dgram);
return 2;
}
err = getnameinfo((struct sockaddr *)&addr, addr_len, addrstr,
INET6_ADDRSTRLEN, portstr, 6, NI_NUMERICHOST | NI_NUMERICSERV);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
if (wanted > sizeof(buf)) free(dgram);
return 2;
}
lua_pushlstring(L, dgram, got);
lua_pushstring(L, addrstr);
lua_pushinteger(L, (int) strtol(portstr, (char **) NULL, 10));
if (wanted > sizeof(buf)) free(dgram);
return 3;
}
/*-------------------------------------------------------------------------*\
* 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 == AF_INET6) {
lua_pushliteral(L, "inet6");
return 1;
} else {
lua_pushliteral(L, "inet4");
return 1;
}
}
/*-------------------------------------------------------------------------*\
@@ -236,12 +317,12 @@ static int meth_dirty(lua_State *L) {
\*-------------------------------------------------------------------------*/
static int meth_getpeername(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{connected}", 1);
return inet_meth_getpeername(L, &udp->sock);
return inet_meth_getpeername(L, &udp->sock, udp->family);
}
static int meth_getsockname(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
return inet_meth_getsockname(L, &udp->sock);
return inet_meth_getsockname(L, &udp->sock, udp->family);
}
/*-------------------------------------------------------------------------*\
@@ -249,7 +330,15 @@ static int meth_getsockname(lua_State *L) {
\*-------------------------------------------------------------------------*/
static int meth_setoption(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
return opt_meth_setoption(L, opt, &udp->sock);
return opt_meth_setoption(L, optset, &udp->sock);
}
/*-------------------------------------------------------------------------*\
* Just call option handler
\*-------------------------------------------------------------------------*/
static int meth_getoption(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
return opt_meth_getoption(L, optget, &udp->sock);
}
/*-------------------------------------------------------------------------*\
@@ -260,32 +349,47 @@ static int meth_settimeout(lua_State *L) {
return timeout_meth_settimeout(L, &udp->tm);
}
static int meth_gettimeout(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
return timeout_meth_gettimeout(L, &udp->tm);
}
/*-------------------------------------------------------------------------*\
* Turns a master udp object into a client object.
\*-------------------------------------------------------------------------*/
static int meth_setpeername(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
p_timeout tm = &udp->tm;
const char *address = luaL_checkstring(L, 2);
const char *address = luaL_checkstring(L, 2);
int connecting = strcmp(address, "*");
unsigned short port = connecting ?
(unsigned short) luaL_checknumber(L, 3) :
(unsigned short) luaL_optnumber(L, 3, 0);
const char *err = inet_tryconnect(&udp->sock, address, port, tm);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
const char *port = connecting? luaL_checkstring(L, 3): "0";
struct addrinfo connecthints;
const char *err;
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->family;
if (connecting) {
err = inet_tryconnect(&udp->sock, &udp->family, address,
port, tm, &connecthints);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
auxiliar_setclass(L, "udp{connected}", 1);
} else {
/* we ignore possible errors because Mac OS X always
* returns EAFNOSUPPORT */
inet_trydisconnect(&udp->sock, udp->family, tm);
auxiliar_setclass(L, "udp{unconnected}", 1);
}
/* change class to connected or unconnected depending on address */
if (connecting) auxiliar_setclass(L, "udp{connected}", 1);
else auxiliar_setclass(L, "udp{unconnected}", 1);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Closes socket used by object
* Closes socket used by object
\*-------------------------------------------------------------------------*/
static int meth_close(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
@@ -300,8 +404,14 @@ static int meth_close(lua_State *L) {
static int meth_setsockname(lua_State *L) {
p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{unconnected}", 1);
const char *address = luaL_checkstring(L, 2);
unsigned short port = (unsigned short) luaL_checknumber(L, 3);
const char *err = inet_trybind(&udp->sock, address, port);
const char *port = luaL_checkstring(L, 3);
const char *err;
struct addrinfo bindhints;
memset(&bindhints, 0, sizeof(bindhints));
bindhints.ai_socktype = SOCK_DGRAM;
bindhints.ai_family = udp->family;
bindhints.ai_flags = AI_PASSIVE;
err = inet_trybind(&udp->sock, &udp->family, address, port, &bindhints);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
@@ -315,24 +425,38 @@ static int meth_setsockname(lua_State *L) {
* Library functions
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Creates a master udp object
* Creates a master udp object
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L) {
t_socket sock;
const char *err = inet_trycreate(&sock, SOCK_DGRAM);
/* try to allocate a system socket */
if (!err) {
/* allocate tcp object */
p_udp udp = (p_udp) lua_newuserdata(L, sizeof(t_udp));
auxiliar_setclass(L, "udp{unconnected}", -1);
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
udp->sock = sock;
timeout_init(&udp->tm, -1, -1);
return 1;
} else {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
static int udp_create(lua_State *L, int family) {
/* allocate udp object */
p_udp udp = (p_udp) lua_newuserdata(L, sizeof(t_udp));
auxiliar_setclass(L, "udp{unconnected}", -1);
/* if family is AF_UNSPEC, we leave the socket invalid and
* store AF_UNSPEC into family. This will allow it to later be
* replaced with an AF_INET6 or AF_INET socket upon first use. */
udp->sock = SOCKET_INVALID;
timeout_init(&udp->tm, -1, -1);
udp->family = family;
if (family != AF_UNSPEC) {
const char *err = inet_trycreate(&udp->sock, family, SOCK_DGRAM, 0);
if (err != NULL) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
socket_setnonblocking(&udp->sock);
}
return 1;
}
static int global_create(lua_State *L) {
return udp_create(L, AF_UNSPEC);
}
static int global_create4(lua_State *L) {
return udp_create(L, AF_INET);
}
static int global_create6(lua_State *L) {
return udp_create(L, AF_INET6);
}
+2 -4
View File
@@ -8,23 +8,21 @@
* (AF_INET, SOCK_DGRAM).
*
* Two classes are defined: connected and unconnected. UDP objects are
* originally unconnected. They can be "connected" to a given address
* originally unconnected. They can be "connected" to a given address
* with a call to the setpeername function. The same function can be used to
* break the connection.
*
* RCS ID: $Id: udp.h,v 1.10 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
#include "lua.h"
#include "timeout.h"
#include "socket.h"
/* can't be larger than wsocket.c MAXCHUNK!!! */
#define UDP_DATAGRAMSIZE 8192
typedef struct t_udp_ {
t_socket sock;
t_timeout tm;
int family;
} t_udp;
typedef t_udp *p_udp;
+15 -348
View File
@@ -1,363 +1,30 @@
/*=========================================================================*\
* Unix domain socket
* Unix domain socket
* LuaSocket toolkit
*
* RCS ID: $Id: unix.c,v 1.13 2006/03/13 07:16:39 diego Exp $
\*=========================================================================*/
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "auxiliar.h"
#include "socket.h"
#include "options.h"
#include "unix.h"
#include <sys/un.h>
#include "unixtcp.h"
#include "unixudp.h"
extern void luax_register(lua_State *L, const char *name, const luaL_Reg *l);
extern int luax_c_insistglobal(lua_State *L, const char *k);
/*=========================================================================*\
* Internal function prototypes
\*=========================================================================*/
static int global_create(lua_State *L);
static int meth_connect(lua_State *L);
static int meth_listen(lua_State *L);
static int meth_bind(lua_State *L);
static int meth_send(lua_State *L);
static int meth_shutdown(lua_State *L);
static int meth_receive(lua_State *L);
static int meth_accept(lua_State *L);
static int meth_close(lua_State *L);
static int meth_setoption(lua_State *L);
static int meth_settimeout(lua_State *L);
static int meth_getfd(lua_State *L);
static int meth_setfd(lua_State *L);
static int meth_dirty(lua_State *L);
static int meth_getstats(lua_State *L);
static int meth_setstats(lua_State *L);
static const char *unix_tryconnect(p_unix un, const char *path);
static const char *unix_trybind(p_unix un, const char *path);
/* unix object methods */
static luaL_reg un[] = {
{"__gc", meth_close},
{"__tostring", auxiliar_tostring},
{"accept", meth_accept},
{"bind", meth_bind},
{"close", meth_close},
{"connect", meth_connect},
{"dirty", meth_dirty},
{"getfd", meth_getfd},
{"getstats", meth_getstats},
{"setstats", meth_setstats},
{"listen", meth_listen},
{"receive", meth_receive},
{"send", meth_send},
{"setfd", meth_setfd},
{"setoption", meth_setoption},
{"setpeername", meth_connect},
{"setsockname", meth_bind},
{"settimeout", meth_settimeout},
{"shutdown", meth_shutdown},
{NULL, NULL}
/*-------------------------------------------------------------------------*\
* Modules and functions
\*-------------------------------------------------------------------------*/
static const luaL_Reg mod[] = {
{"tcp", unixtcp_open},
{"udp", unixudp_open},
{NULL, NULL}
};
/* socket option handlers */
static t_opt opt[] = {
{"keepalive", opt_keepalive},
{"reuseaddr", opt_reuseaddr},
{"linger", opt_linger},
{NULL, NULL}
};
/* our socket creation function */
static luaL_reg func[] = {
{"unix", global_create},
{NULL, NULL}
};
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int luaopen_socket_unix(lua_State *L) {
/* create classes */
auxiliar_newclass(L, "unix{master}", un);
auxiliar_newclass(L, "unix{client}", un);
auxiliar_newclass(L, "unix{server}", un);
/* create class groups */
auxiliar_add2group(L, "unix{master}", "unix{any}");
auxiliar_add2group(L, "unix{client}", "unix{any}");
auxiliar_add2group(L, "unix{server}", "unix{any}");
/* make sure the function ends up in the package table */
lua_pushcfunction(L, global_create);
luax_c_insistglobal(L, "socket");
lua_pushstring(L, "unix");
lua_pushvalue(L, -3);
lua_settable(L, -3);
/* return the function instead of the 'socket' table */
return 1;
}
/*=========================================================================*\
* Lua methods
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Just call buffered IO methods
\*-------------------------------------------------------------------------*/
static int meth_send(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
return buffer_meth_send(L, &un->buf);
}
static int meth_receive(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
return buffer_meth_receive(L, &un->buf);
}
static int meth_getstats(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
return buffer_meth_getstats(L, &un->buf);
}
static int meth_setstats(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
return buffer_meth_setstats(L, &un->buf);
}
/*-------------------------------------------------------------------------*\
* Just call option handler
\*-------------------------------------------------------------------------*/
static int meth_setoption(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
return opt_meth_setoption(L, opt, &un->sock);
}
/*-------------------------------------------------------------------------*\
* Select support methods
\*-------------------------------------------------------------------------*/
static int meth_getfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
lua_pushnumber(L, (int) un->sock);
return 1;
}
/* this is very dangerous, but can be handy for those that are brave enough */
static int meth_setfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
un->sock = (t_socket) luaL_checknumber(L, 2);
return 0;
}
static int meth_dirty(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
lua_pushboolean(L, !buffer_isempty(&un->buf));
return 1;
}
/*-------------------------------------------------------------------------*\
* Waits for and returns a client object attempting connection to the
* server object
\*-------------------------------------------------------------------------*/
static int meth_accept(lua_State *L) {
p_unix server = (p_unix) auxiliar_checkclass(L, "unix{server}", 1);
p_timeout tm = timeout_markstart(&server->tm);
t_socket sock;
int err = socket_accept(&server->sock, &sock, NULL, NULL, tm);
/* if successful, push client socket */
if (err == IO_DONE) {
p_unix clnt = (p_unix) lua_newuserdata(L, sizeof(t_unix));
auxiliar_setclass(L, "unix{client}", -1);
/* initialize structure fields */
socket_setnonblocking(&sock);
clnt->sock = sock;
io_init(&clnt->io, (p_send)socket_send, (p_recv)socket_recv,
(p_error) socket_ioerror, &clnt->sock);
timeout_init(&clnt->tm, -1, -1);
buffer_init(&clnt->buf, &clnt->io, &clnt->tm);
return 1;
} else {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(err));
return 2;
}
}
/*-------------------------------------------------------------------------*\
* Binds an object to an address
\*-------------------------------------------------------------------------*/
static const char *unix_trybind(p_unix un, const char *path) {
struct sockaddr_un local;
size_t len = strlen(path);
int err;
if (len >= sizeof(local.sun_path)) return "path too long";
memset(&local, 0, sizeof(local));
strcpy(local.sun_path, path);
local.sun_family = AF_UNIX;
#ifdef UNIX_HAS_SUN_LEN
local.sun_len = sizeof(local.sun_family) + sizeof(local.sun_len)
+ len + 1;
err = socket_bind(&un->sock, (SA *) &local, local.sun_len);
#else
err = socket_bind(&un->sock, (SA *) &local,
sizeof(local.sun_family) + len);
#endif
if (err != IO_DONE) socket_destroy(&un->sock);
return socket_strerror(err);
}
static int meth_bind(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unix{master}", 1);
const char *path = luaL_checkstring(L, 2);
const char *err = unix_trybind(un, path);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Turns a master unix object into a client object.
\*-------------------------------------------------------------------------*/
static const char *unix_tryconnect(p_unix un, const char *path)
int luaopen_socket_unix(lua_State *L)
{
struct sockaddr_un remote;
int err;
size_t len = strlen(path);
if (len >= sizeof(remote.sun_path)) return "path too long";
memset(&remote, 0, sizeof(remote));
strcpy(remote.sun_path, path);
remote.sun_family = AF_UNIX;
timeout_markstart(&un->tm);
#ifdef UNIX_HAS_SUN_LEN
remote.sun_len = sizeof(remote.sun_family) + sizeof(remote.sun_len)
+ len + 1;
err = socket_connect(&un->sock, (SA *) &remote, remote.sun_len, &un->tm);
#else
err = socket_connect(&un->sock, (SA *) &remote,
sizeof(remote.sun_family) + len, &un->tm);
#endif
if (err != IO_DONE) socket_destroy(&un->sock);
return socket_strerror(err);
int i;
lua_newtable(L);
for (i = 0; mod[i].name; i++) mod[i].func(L);
return 1;
}
static int meth_connect(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkclass(L, "unix{master}", 1);
const char *path = luaL_checkstring(L, 2);
const char *err = unix_tryconnect(un, path);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
/* turn master object into a client object */
auxiliar_setclass(L, "unix{client}", 1);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Closes socket used by object
\*-------------------------------------------------------------------------*/
static int meth_close(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
socket_destroy(&un->sock);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Puts the sockt in listen mode
\*-------------------------------------------------------------------------*/
static int meth_listen(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkclass(L, "unix{master}", 1);
int backlog = (int) luaL_optnumber(L, 2, 32);
int err = socket_listen(&un->sock, backlog);
if (err != IO_DONE) {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(err));
return 2;
}
/* turn master object into a server object */
auxiliar_setclass(L, "unix{server}", 1);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Shuts the connection down partially
\*-------------------------------------------------------------------------*/
static int meth_shutdown(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1);
const char *how = luaL_optstring(L, 2, "both");
switch (how[0]) {
case 'b':
if (strcmp(how, "both")) goto error;
socket_shutdown(&un->sock, 2);
break;
case 's':
if (strcmp(how, "send")) goto error;
socket_shutdown(&un->sock, 1);
break;
case 'r':
if (strcmp(how, "receive")) goto error;
socket_shutdown(&un->sock, 0);
break;
}
lua_pushnumber(L, 1);
return 1;
error:
luaL_argerror(L, 2, "invalid shutdown method");
return 0;
}
/*-------------------------------------------------------------------------*\
* Just call tm methods
\*-------------------------------------------------------------------------*/
static int meth_settimeout(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1);
return timeout_meth_settimeout(L, &un->tm);
}
/*=========================================================================*\
* Library functions
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Creates a master unix object
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L) {
t_socket sock;
int err = socket_create(&sock, AF_UNIX, SOCK_STREAM, 0);
/* try to allocate a system socket */
if (err == IO_DONE) {
/* allocate unix object */
p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix));
/* set its type as master object */
auxiliar_setclass(L, "unix{master}", -1);
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
un->sock = sock;
io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv,
(p_error) socket_ioerror, &un->sock);
timeout_init(&un->tm, -1, -1);
buffer_init(&un->buf, &un->io, &un->tm);
return 1;
} else {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(err));
return 2;
}
}
+5 -3
View File
@@ -6,8 +6,6 @@
*
* This module is just an example of how to extend LuaSocket with a new
* domain.
*
* RCS ID: $Id: unix.h,v 1.9 2006/03/13 07:16:39 diego Exp $
\*=========================================================================*/
#include "lua.h"
@@ -15,6 +13,10 @@
#include "timeout.h"
#include "socket.h"
#ifndef UNIX_API
#define UNIX_API extern
#endif
typedef struct t_unix_ {
t_socket sock;
t_io io;
@@ -23,6 +25,6 @@ typedef struct t_unix_ {
} t_unix;
typedef t_unix *p_unix;
int luaopen_socket_unix(lua_State *L);
UNIX_API int luaopen_socket_unix(lua_State *L);
#endif /* UNIX_H */
@@ -0,0 +1,357 @@
/*=========================================================================*\
* Unix domain socket tcp sub module
* LuaSocket toolkit
\*=========================================================================*/
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "auxiliar.h"
#include "socket.h"
#include "options.h"
#include "unixtcp.h"
#include <sys/un.h>
/*=========================================================================*\
* Internal function prototypes
\*=========================================================================*/
static int global_create(lua_State *L);
static int meth_connect(lua_State *L);
static int meth_listen(lua_State *L);
static int meth_bind(lua_State *L);
static int meth_send(lua_State *L);
static int meth_shutdown(lua_State *L);
static int meth_receive(lua_State *L);
static int meth_accept(lua_State *L);
static int meth_close(lua_State *L);
static int meth_setoption(lua_State *L);
static int meth_settimeout(lua_State *L);
static int meth_getfd(lua_State *L);
static int meth_setfd(lua_State *L);
static int meth_dirty(lua_State *L);
static int meth_getstats(lua_State *L);
static int meth_setstats(lua_State *L);
static int meth_getsockname(lua_State *L);
static const char *unixtcp_tryconnect(p_unix un, const char *path);
static const char *unixtcp_trybind(p_unix un, const char *path);
/* unixtcp object methods */
static luaL_Reg unixtcp_methods[] = {
{"__gc", meth_close},
{"__tostring", auxiliar_tostring},
{"accept", meth_accept},
{"bind", meth_bind},
{"close", meth_close},
{"connect", meth_connect},
{"dirty", meth_dirty},
{"getfd", meth_getfd},
{"getstats", meth_getstats},
{"setstats", meth_setstats},
{"listen", meth_listen},
{"receive", meth_receive},
{"send", meth_send},
{"setfd", meth_setfd},
{"setoption", meth_setoption},
{"setpeername", meth_connect},
{"setsockname", meth_bind},
{"getsockname", meth_getsockname},
{"settimeout", meth_settimeout},
{"shutdown", meth_shutdown},
{NULL, NULL}
};
/* socket option handlers */
static t_opt optset[] = {
{"keepalive", opt_set_keepalive},
{"reuseaddr", opt_set_reuseaddr},
{"linger", opt_set_linger},
{NULL, NULL}
};
/* functions in library namespace */
static luaL_Reg func[] = {
{"tcp", global_create},
{NULL, NULL}
};
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int unixtcp_open(lua_State *L)
{
/* create classes */
auxiliar_newclass(L, "unixtcp{master}", unixtcp_methods);
auxiliar_newclass(L, "unixtcp{client}", unixtcp_methods);
auxiliar_newclass(L, "unixtcp{server}", unixtcp_methods);
/* create class groups */
auxiliar_add2group(L, "unixtcp{master}", "unixtcp{any}");
auxiliar_add2group(L, "unixtcp{client}", "unixtcp{any}");
auxiliar_add2group(L, "unixtcp{server}", "unixtcp{any}");
luaL_setfuncs(L, func, 0);
return 0;
}
/*=========================================================================*\
* Lua methods
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Just call buffered IO methods
\*-------------------------------------------------------------------------*/
static int meth_send(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unixtcp{client}", 1);
return buffer_meth_send(L, &un->buf);
}
static int meth_receive(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unixtcp{client}", 1);
return buffer_meth_receive(L, &un->buf);
}
static int meth_getstats(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unixtcp{client}", 1);
return buffer_meth_getstats(L, &un->buf);
}
static int meth_setstats(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unixtcp{client}", 1);
return buffer_meth_setstats(L, &un->buf);
}
/*-------------------------------------------------------------------------*\
* Just call option handler
\*-------------------------------------------------------------------------*/
static int meth_setoption(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixtcp{any}", 1);
return opt_meth_setoption(L, optset, &un->sock);
}
/*-------------------------------------------------------------------------*\
* Select support methods
\*-------------------------------------------------------------------------*/
static int meth_getfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixtcp{any}", 1);
lua_pushnumber(L, (int) un->sock);
return 1;
}
/* this is very dangerous, but can be handy for those that are brave enough */
static int meth_setfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixtcp{any}", 1);
un->sock = (t_socket) luaL_checknumber(L, 2);
return 0;
}
static int meth_dirty(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixtcp{any}", 1);
lua_pushboolean(L, !buffer_isempty(&un->buf));
return 1;
}
/*-------------------------------------------------------------------------*\
* Waits for and returns a client object attempting connection to the
* server object
\*-------------------------------------------------------------------------*/
static int meth_accept(lua_State *L) {
p_unix server = (p_unix) auxiliar_checkclass(L, "unixtcp{server}", 1);
p_timeout tm = timeout_markstart(&server->tm);
t_socket sock;
int err = socket_accept(&server->sock, &sock, NULL, NULL, tm);
/* if successful, push client socket */
if (err == IO_DONE) {
p_unix clnt = (p_unix) lua_newuserdata(L, sizeof(t_unix));
auxiliar_setclass(L, "unixtcp{client}", -1);
/* initialize structure fields */
socket_setnonblocking(&sock);
clnt->sock = sock;
io_init(&clnt->io, (p_send)socket_send, (p_recv)socket_recv,
(p_error) socket_ioerror, &clnt->sock);
timeout_init(&clnt->tm, -1, -1);
buffer_init(&clnt->buf, &clnt->io, &clnt->tm);
return 1;
} else {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(err));
return 2;
}
}
/*-------------------------------------------------------------------------*\
* Binds an object to an address
\*-------------------------------------------------------------------------*/
static const char *unixtcp_trybind(p_unix un, const char *path) {
struct sockaddr_un local;
size_t len = strlen(path);
int err;
if (len >= sizeof(local.sun_path)) return "path too long";
memset(&local, 0, sizeof(local));
strcpy(local.sun_path, path);
local.sun_family = AF_UNIX;
#ifdef UNIX_HAS_SUN_LEN
local.sun_len = sizeof(local.sun_family) + sizeof(local.sun_len)
+ len + 1;
err = socket_bind(&un->sock, (SA *) &local, local.sun_len);
#else
err = socket_bind(&un->sock, (SA *) &local,
sizeof(local.sun_family) + len);
#endif
if (err != IO_DONE) socket_destroy(&un->sock);
return socket_strerror(err);
}
static int meth_bind(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unixtcp{master}", 1);
const char *path = luaL_checkstring(L, 2);
const char *err = unixtcp_trybind(un, path);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
lua_pushnumber(L, 1);
return 1;
}
static int meth_getsockname(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixtcp{any}", 1);
struct sockaddr_un peer = {0};
socklen_t peer_len = sizeof(peer);
if (getsockname(un->sock, (SA *) &peer, &peer_len) < 0) {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(errno));
return 2;
}
lua_pushstring(L, peer.sun_path);
return 1;
}
/*-------------------------------------------------------------------------*\
* Turns a master unixtcp object into a client object.
\*-------------------------------------------------------------------------*/
static const char *unixtcp_tryconnect(p_unix un, const char *path)
{
struct sockaddr_un remote;
int err;
size_t len = strlen(path);
if (len >= sizeof(remote.sun_path)) return "path too long";
memset(&remote, 0, sizeof(remote));
strcpy(remote.sun_path, path);
remote.sun_family = AF_UNIX;
timeout_markstart(&un->tm);
#ifdef UNIX_HAS_SUN_LEN
remote.sun_len = sizeof(remote.sun_family) + sizeof(remote.sun_len)
+ len + 1;
err = socket_connect(&un->sock, (SA *) &remote, remote.sun_len, &un->tm);
#else
err = socket_connect(&un->sock, (SA *) &remote,
sizeof(remote.sun_family) + len, &un->tm);
#endif
if (err != IO_DONE) socket_destroy(&un->sock);
return socket_strerror(err);
}
static int meth_connect(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkclass(L, "unixtcp{master}", 1);
const char *path = luaL_checkstring(L, 2);
const char *err = unixtcp_tryconnect(un, path);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
/* turn master object into a client object */
auxiliar_setclass(L, "unixtcp{client}", 1);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Closes socket used by object
\*-------------------------------------------------------------------------*/
static int meth_close(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixtcp{any}", 1);
socket_destroy(&un->sock);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Puts the sockt in listen mode
\*-------------------------------------------------------------------------*/
static int meth_listen(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkclass(L, "unixtcp{master}", 1);
int backlog = (int) luaL_optnumber(L, 2, 32);
int err = socket_listen(&un->sock, backlog);
if (err != IO_DONE) {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(err));
return 2;
}
/* turn master object into a server object */
auxiliar_setclass(L, "unixtcp{server}", 1);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Shuts the connection down partially
\*-------------------------------------------------------------------------*/
static int meth_shutdown(lua_State *L)
{
/* SHUT_RD, SHUT_WR, SHUT_RDWR have the value 0, 1, 2, so we can use method index directly */
static const char* methods[] = { "receive", "send", "both", NULL };
p_unix tcp = (p_unix) auxiliar_checkclass(L, "unixtcp{client}", 1);
int how = luaL_checkoption(L, 2, "both", methods);
socket_shutdown(&tcp->sock, how);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Just call tm methods
\*-------------------------------------------------------------------------*/
static int meth_settimeout(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixtcp{any}", 1);
return timeout_meth_settimeout(L, &un->tm);
}
/*=========================================================================*\
* Library functions
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Creates a master unixtcp object
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L) {
t_socket sock;
int err = socket_create(&sock, AF_UNIX, SOCK_STREAM, 0);
/* try to allocate a system socket */
if (err == IO_DONE) {
/* allocate unixtcp object */
p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix));
/* set its type as master object */
auxiliar_setclass(L, "unixtcp{master}", -1);
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
un->sock = sock;
io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv,
(p_error) socket_ioerror, &un->sock);
timeout_init(&un->tm, -1, -1);
buffer_init(&un->buf, &un->io, &un->tm);
return 1;
} else {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(err));
return 2;
}
}
@@ -0,0 +1,21 @@
#ifndef UNIXTCP_H
#define UNIXTCP_H
/*=========================================================================*\
* UNIX TCP object
* LuaSocket toolkit
*
* The unixtcp.h module is basicly a glue that puts together modules buffer.h,
* timeout.h socket.h and inet.h to provide the LuaSocket UNIX TCP (AF_UNIX,
* SOCK_STREAM) support.
*
* Three classes are defined: master, client and server. The master class is
* a newly created unixtcp object, that has not been bound or connected. Server
* objects are unixtcp objects bound to some local address. Client objects are
* unixtcp objects either connected to some address or returned by the accept
* method of a server object.
\*=========================================================================*/
#include "unix.h"
int unixtcp_open(lua_State *L);
#endif /* UNIXTCP_H */
@@ -0,0 +1,407 @@
/*=========================================================================*\
* Unix domain socket udp submodule
* LuaSocket toolkit
\*=========================================================================*/
#include <string.h>
#include <stdlib.h>
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "auxiliar.h"
#include "socket.h"
#include "options.h"
#include "unix.h"
#include <sys/un.h>
#define UNIXUDP_DATAGRAMSIZE 8192
/*=========================================================================*\
* Internal function prototypes
\*=========================================================================*/
static int global_create(lua_State *L);
static int meth_connect(lua_State *L);
static int meth_bind(lua_State *L);
static int meth_send(lua_State *L);
static int meth_receive(lua_State *L);
static int meth_close(lua_State *L);
static int meth_setoption(lua_State *L);
static int meth_settimeout(lua_State *L);
static int meth_gettimeout(lua_State *L);
static int meth_getfd(lua_State *L);
static int meth_setfd(lua_State *L);
static int meth_dirty(lua_State *L);
static int meth_receivefrom(lua_State *L);
static int meth_sendto(lua_State *L);
static int meth_getsockname(lua_State *L);
static const char *unixudp_tryconnect(p_unix un, const char *path);
static const char *unixudp_trybind(p_unix un, const char *path);
/* unixudp object methods */
static luaL_Reg unixudp_methods[] = {
{"__gc", meth_close},
{"__tostring", auxiliar_tostring},
{"bind", meth_bind},
{"close", meth_close},
{"connect", meth_connect},
{"dirty", meth_dirty},
{"getfd", meth_getfd},
{"send", meth_send},
{"sendto", meth_sendto},
{"receive", meth_receive},
{"receivefrom", meth_receivefrom},
{"setfd", meth_setfd},
{"setoption", meth_setoption},
{"setpeername", meth_connect},
{"setsockname", meth_bind},
{"getsockname", meth_getsockname},
{"settimeout", meth_settimeout},
{"gettimeout", meth_gettimeout},
{NULL, NULL}
};
/* socket option handlers */
static t_opt optset[] = {
{"reuseaddr", opt_set_reuseaddr},
{NULL, NULL}
};
/* functions in library namespace */
static luaL_Reg func[] = {
{"udp", global_create},
{NULL, NULL}
};
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int unixudp_open(lua_State *L)
{
/* create classes */
auxiliar_newclass(L, "unixudp{connected}", unixudp_methods);
auxiliar_newclass(L, "unixudp{unconnected}", unixudp_methods);
/* create class groups */
auxiliar_add2group(L, "unixudp{connected}", "unixudp{any}");
auxiliar_add2group(L, "unixudp{unconnected}", "unixudp{any}");
auxiliar_add2group(L, "unixudp{connected}", "select{able}");
auxiliar_add2group(L, "unixudp{unconnected}", "select{able}");
luaL_setfuncs(L, func, 0);
return 0;
}
/*=========================================================================*\
* Lua methods
\*=========================================================================*/
static const char *unixudp_strerror(int err)
{
/* a 'closed' error on an unconnected means the target address was not
* accepted by the transport layer */
if (err == IO_CLOSED) return "refused";
else return socket_strerror(err);
}
static int meth_send(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkclass(L, "unixudp{connected}", 1);
p_timeout tm = &un->tm;
size_t count, sent = 0;
int err;
const char *data = luaL_checklstring(L, 2, &count);
timeout_markstart(tm);
err = socket_send(&un->sock, data, count, &sent, tm);
if (err != IO_DONE) {
lua_pushnil(L);
lua_pushstring(L, unixudp_strerror(err));
return 2;
}
lua_pushnumber(L, (lua_Number) sent);
return 1;
}
/*-------------------------------------------------------------------------*\
* Send data through unconnected unixudp socket
\*-------------------------------------------------------------------------*/
static int meth_sendto(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkclass(L, "unixudp{unconnected}", 1);
size_t count, sent = 0;
const char *data = luaL_checklstring(L, 2, &count);
const char *path = luaL_checkstring(L, 3);
p_timeout tm = &un->tm;
int err;
struct sockaddr_un remote;
size_t len = strlen(path);
if (len >= sizeof(remote.sun_path)) {
lua_pushnil(L);
lua_pushstring(L, "path too long");
return 2;
}
memset(&remote, 0, sizeof(remote));
strcpy(remote.sun_path, path);
remote.sun_family = AF_UNIX;
timeout_markstart(tm);
#ifdef UNIX_HAS_SUN_LEN
remote.sun_len = sizeof(remote.sun_family) + sizeof(remote.sun_len)
+ len + 1;
err = socket_sendto(&un->sock, data, count, &sent, (SA *) &remote, remote.sun_len, tm);
#else
err = socket_sendto(&un->sock, data, count, &sent, (SA *) &remote,
sizeof(remote.sun_family) + len, tm);
#endif
if (err != IO_DONE) {
lua_pushnil(L);
lua_pushstring(L, unixudp_strerror(err));
return 2;
}
lua_pushnumber(L, (lua_Number) sent);
return 1;
}
static int meth_receive(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
char buf[UNIXUDP_DATAGRAMSIZE];
size_t got, wanted = (size_t) luaL_optnumber(L, 2, sizeof(buf));
char *dgram = wanted > sizeof(buf)? (char *) malloc(wanted): buf;
int err;
p_timeout tm = &un->tm;
timeout_markstart(tm);
if (!dgram) {
lua_pushnil(L);
lua_pushliteral(L, "out of memory");
return 2;
}
err = socket_recv(&un->sock, dgram, wanted, &got, tm);
/* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */
if (err != IO_DONE && err != IO_CLOSED) {
lua_pushnil(L);
lua_pushstring(L, unixudp_strerror(err));
if (wanted > sizeof(buf)) free(dgram);
return 2;
}
lua_pushlstring(L, dgram, got);
if (wanted > sizeof(buf)) free(dgram);
return 1;
}
/*-------------------------------------------------------------------------*\
* Receives data and sender from a UDP socket
\*-------------------------------------------------------------------------*/
static int meth_receivefrom(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkclass(L, "unixudp{unconnected}", 1);
char buf[UNIXUDP_DATAGRAMSIZE];
size_t got, wanted = (size_t) luaL_optnumber(L, 2, sizeof(buf));
char *dgram = wanted > sizeof(buf)? (char *) malloc(wanted): buf;
struct sockaddr_un addr;
socklen_t addr_len = sizeof(addr);
int err;
p_timeout tm = &un->tm;
timeout_markstart(tm);
if (!dgram) {
lua_pushnil(L);
lua_pushliteral(L, "out of memory");
return 2;
}
err = socket_recvfrom(&un->sock, dgram, wanted, &got, (SA *) &addr,
&addr_len, tm);
/* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */
if (err != IO_DONE && err != IO_CLOSED) {
lua_pushnil(L);
lua_pushstring(L, unixudp_strerror(err));
if (wanted > sizeof(buf)) free(dgram);
return 2;
}
lua_pushlstring(L, dgram, got);
/* the path may be empty, when client send without bind */
lua_pushstring(L, addr.sun_path);
if (wanted > sizeof(buf)) free(dgram);
return 2;
}
/*-------------------------------------------------------------------------*\
* Just call option handler
\*-------------------------------------------------------------------------*/
static int meth_setoption(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
return opt_meth_setoption(L, optset, &un->sock);
}
/*-------------------------------------------------------------------------*\
* Select support methods
\*-------------------------------------------------------------------------*/
static int meth_getfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
lua_pushnumber(L, (int) un->sock);
return 1;
}
/* this is very dangerous, but can be handy for those that are brave enough */
static int meth_setfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
un->sock = (t_socket) luaL_checknumber(L, 2);
return 0;
}
static int meth_dirty(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
(void) un;
lua_pushboolean(L, 0);
return 1;
}
/*-------------------------------------------------------------------------*\
* Binds an object to an address
\*-------------------------------------------------------------------------*/
static const char *unixudp_trybind(p_unix un, const char *path) {
struct sockaddr_un local;
size_t len = strlen(path);
int err;
if (len >= sizeof(local.sun_path)) return "path too long";
memset(&local, 0, sizeof(local));
strcpy(local.sun_path, path);
local.sun_family = AF_UNIX;
#ifdef UNIX_HAS_SUN_LEN
local.sun_len = sizeof(local.sun_family) + sizeof(local.sun_len)
+ len + 1;
err = socket_bind(&un->sock, (SA *) &local, local.sun_len);
#else
err = socket_bind(&un->sock, (SA *) &local,
sizeof(local.sun_family) + len);
#endif
if (err != IO_DONE) socket_destroy(&un->sock);
return socket_strerror(err);
}
static int meth_bind(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkclass(L, "unixudp{unconnected}", 1);
const char *path = luaL_checkstring(L, 2);
const char *err = unixudp_trybind(un, path);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
lua_pushnumber(L, 1);
return 1;
}
static int meth_getsockname(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
struct sockaddr_un peer = {0};
socklen_t peer_len = sizeof(peer);
if (getsockname(un->sock, (SA *) &peer, &peer_len) < 0) {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(errno));
return 2;
}
lua_pushstring(L, peer.sun_path);
return 1;
}
/*-------------------------------------------------------------------------*\
* Turns a master unixudp object into a client object.
\*-------------------------------------------------------------------------*/
static const char *unixudp_tryconnect(p_unix un, const char *path)
{
struct sockaddr_un remote;
int err;
size_t len = strlen(path);
if (len >= sizeof(remote.sun_path)) return "path too long";
memset(&remote, 0, sizeof(remote));
strcpy(remote.sun_path, path);
remote.sun_family = AF_UNIX;
timeout_markstart(&un->tm);
#ifdef UNIX_HAS_SUN_LEN
remote.sun_len = sizeof(remote.sun_family) + sizeof(remote.sun_len)
+ len + 1;
err = socket_connect(&un->sock, (SA *) &remote, remote.sun_len, &un->tm);
#else
err = socket_connect(&un->sock, (SA *) &remote,
sizeof(remote.sun_family) + len, &un->tm);
#endif
if (err != IO_DONE) socket_destroy(&un->sock);
return socket_strerror(err);
}
static int meth_connect(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
const char *path = luaL_checkstring(L, 2);
const char *err = unixudp_tryconnect(un, path);
if (err) {
lua_pushnil(L);
lua_pushstring(L, err);
return 2;
}
/* turn unconnected object into a connected object */
auxiliar_setclass(L, "unixudp{connected}", 1);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Closes socket used by object
\*-------------------------------------------------------------------------*/
static int meth_close(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
socket_destroy(&un->sock);
lua_pushnumber(L, 1);
return 1;
}
/*-------------------------------------------------------------------------*\
* Just call tm methods
\*-------------------------------------------------------------------------*/
static int meth_settimeout(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
return timeout_meth_settimeout(L, &un->tm);
}
static int meth_gettimeout(lua_State *L)
{
p_unix un = (p_unix) auxiliar_checkgroup(L, "unixudp{any}", 1);
return timeout_meth_gettimeout(L, &un->tm);
}
/*=========================================================================*\
* Library functions
\*=========================================================================*/
/*-------------------------------------------------------------------------*\
* Creates a master unixudp object
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L)
{
t_socket sock;
int err = socket_create(&sock, AF_UNIX, SOCK_DGRAM, 0);
/* try to allocate a system socket */
if (err == IO_DONE) {
/* allocate unixudp object */
p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix));
/* set its type as master object */
auxiliar_setclass(L, "unixudp{unconnected}", -1);
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
un->sock = sock;
io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv,
(p_error) socket_ioerror, &un->sock);
timeout_init(&un->tm, -1, -1);
buffer_init(&un->buf, &un->io, &un->tm);
return 1;
} else {
lua_pushnil(L);
lua_pushstring(L, socket_strerror(err));
return 2;
}
}
@@ -0,0 +1,20 @@
#ifndef UNIXUDP_H
#define UNIXUDP_H
/*=========================================================================*\
* UDP object
* LuaSocket toolkit
*
* The udp.h module provides LuaSocket with support for UDP protocol
* (AF_INET, SOCK_DGRAM).
*
* Two classes are defined: connected and unconnected. UDP objects are
* originally unconnected. They can be "connected" to a given address
* with a call to the setpeername function. The same function can be used to
* break the connection.
\*=========================================================================*/
#include "unix.h"
int unixudp_open(lua_State *L);
#endif /* UNIXUDP_H */
+93 -82
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 $
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
@@ -11,12 +10,15 @@
local string = require("string")
local base = _G
local table = require("table")
module("socket.url")
local socket = require("socket")
socket.url = {}
local _M = socket.url
-----------------------------------------------------------------------------
-- Module version
-----------------------------------------------------------------------------
_VERSION = "URL 1.0.1"
_M._VERSION = "URL 1.0.3"
-----------------------------------------------------------------------------
-- Encodes a string into its escaped hexadecimal representation
@@ -25,10 +27,10 @@ _VERSION = "URL 1.0.1"
-- Returns
-- escaped representation of string binary
-----------------------------------------------------------------------------
function escape(s)
return string.gsub(s, "([^A-Za-z0-9_])", function(c)
function _M.escape(s)
return (string.gsub(s, "([^A-Za-z0-9_])", function(c)
return string.format("%%%02x", string.byte(c))
end)
end))
end
-----------------------------------------------------------------------------
@@ -40,38 +42,38 @@ end
-- escaped representation of string binary
-----------------------------------------------------------------------------
local function make_set(t)
local s = {}
for i,v in base.ipairs(t) do
s[t[i]] = 1
end
return s
local s = {}
for i,v in base.ipairs(t) do
s[t[i]] = 1
end
return s
end
-- these are allowed withing a path segment, along with alphanum
-- other characters must be escaped
local segment_set = make_set {
"-", "_", ".", "!", "~", "*", "'", "(",
")", ":", "@", "&", "=", "+", "$", ",",
")", ":", "@", "&", "=", "+", "$", ",",
}
local function protect_segment(s)
return string.gsub(s, "([^A-Za-z0-9_])", function (c)
if segment_set[c] then return c
else return string.format("%%%02x", string.byte(c)) end
end)
return string.gsub(s, "([^A-Za-z0-9_])", function (c)
if segment_set[c] then return c
else return string.format("%%%02x", string.byte(c)) end
end)
end
-----------------------------------------------------------------------------
-- Encodes a string into its escaped hexadecimal representation
-- Unencodes a escaped hexadecimal string into its binary representation
-- Input
-- s: binary string to be encoded
-- s: escaped hexadecimal string to be unencoded
-- Returns
-- escaped representation of string binary
-- unescaped binary representation of escaped hexadecimal binary
-----------------------------------------------------------------------------
function unescape(s)
return string.gsub(s, "%%(%x%x)", function(hex)
function _M.unescape(s)
return (string.gsub(s, "%%(%x%x)", function(hex)
return string.char(base.tonumber(hex, 16))
end)
end))
end
-----------------------------------------------------------------------------
@@ -121,7 +123,7 @@ end
-- Obs:
-- the leading '/' in {/<path>} is considered part of <path>
-----------------------------------------------------------------------------
function parse(url, default)
function _M.parse(url, default)
-- initialize default parameters
local parsed = {}
for i,v in base.pairs(default or parsed) do parsed[i] = v end
@@ -142,7 +144,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 +160,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, ":([^:]*)$",
@@ -177,24 +182,27 @@ end
-- Returns
-- a stringing with the corresponding URL
-----------------------------------------------------------------------------
function build(parsed)
local ppath = parse_path(parsed.path or "")
local url = build_path(ppath)
function _M.build(parsed)
local ppath = _M.parse_path(parsed.path or "")
local url = _M.build_path(ppath)
if parsed.params then url = url .. ";" .. parsed.params end
if parsed.query then url = url .. "?" .. parsed.query end
local authority = parsed.authority
if parsed.host then
authority = parsed.host
if parsed.port then authority = authority .. ":" .. parsed.port end
local userinfo = parsed.userinfo
if parsed.user then
userinfo = parsed.user
if parsed.password then
userinfo = userinfo .. ":" .. parsed.password
end
end
if userinfo then authority = userinfo .. "@" .. authority end
end
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
userinfo = parsed.user
if parsed.password then
userinfo = userinfo .. ":" .. parsed.password
end
end
if userinfo then authority = userinfo .. "@" .. authority end
end
if authority then url = "//" .. authority .. url end
if parsed.scheme then url = parsed.scheme .. ":" .. url end
if parsed.fragment then url = url .. "#" .. parsed.fragment end
@@ -210,14 +218,15 @@ end
-- Returns
-- corresponding absolute url
-----------------------------------------------------------------------------
function absolute(base_url, relative_url)
function _M.absolute(base_url, relative_url)
local base_parsed
if base.type(base_url) == "table" then
base_parsed = base_url
base_url = build(base_parsed)
base_url = _M.build(base_parsed)
else
base_parsed = parse(base_url)
base_parsed = _M.parse(base_url)
end
local relative_parsed = parse(relative_url)
local relative_parsed = _M.parse(relative_url)
if not base_parsed then return relative_url
elseif not relative_parsed then return base_url
elseif relative_parsed.scheme then return relative_url
@@ -238,7 +247,7 @@ function absolute(base_url, relative_url)
relative_parsed.path)
end
end
return build(relative_parsed)
return _M.build(relative_parsed)
end
end
@@ -249,17 +258,17 @@ end
-- Returns
-- segment: a table with one entry per segment
-----------------------------------------------------------------------------
function parse_path(path)
local parsed = {}
path = path or ""
--path = string.gsub(path, "%s", "")
string.gsub(path, "([^/]+)", function (s) table.insert(parsed, s) end)
for i = 1, table.getn(parsed) do
parsed[i] = unescape(parsed[i])
end
if string.sub(path, 1, 1) == "/" then parsed.is_absolute = 1 end
if string.sub(path, -1, -1) == "/" then parsed.is_directory = 1 end
return parsed
function _M.parse_path(path)
local parsed = {}
path = path or ""
--path = string.gsub(path, "%s", "")
string.gsub(path, "([^/]+)", function (s) table.insert(parsed, s) end)
for i = 1, #parsed do
parsed[i] = _M.unescape(parsed[i])
end
if string.sub(path, 1, 1) == "/" then parsed.is_absolute = 1 end
if string.sub(path, -1, -1) == "/" then parsed.is_directory = 1 end
return parsed
end
-----------------------------------------------------------------------------
@@ -270,28 +279,30 @@ end
-- Returns
-- path: corresponding path stringing
-----------------------------------------------------------------------------
function build_path(parsed, unsafe)
local path = ""
local n = table.getn(parsed)
if unsafe then
for i = 1, n-1 do
path = path .. parsed[i]
path = path .. "/"
end
if n > 0 then
path = path .. parsed[n]
if parsed.is_directory then path = path .. "/" end
end
else
for i = 1, n-1 do
path = path .. protect_segment(parsed[i])
path = path .. "/"
end
if n > 0 then
path = path .. protect_segment(parsed[n])
if parsed.is_directory then path = path .. "/" end
end
end
if parsed.is_absolute then path = "/" .. path end
return path
function _M.build_path(parsed, unsafe)
local path = ""
local n = #parsed
if unsafe then
for i = 1, n-1 do
path = path .. parsed[i]
path = path .. "/"
end
if n > 0 then
path = path .. parsed[n]
if parsed.is_directory then path = path .. "/" end
end
else
for i = 1, n-1 do
path = path .. protect_segment(parsed[i])
path = path .. "/"
end
if n > 0 then
path = path .. protect_segment(parsed[n])
if parsed.is_directory then path = path .. "/" end
end
end
if parsed.is_absolute then path = "/" .. path end
return path
end
return _M
File diff suppressed because it is too large Load Diff
+135 -54
View File
@@ -4,19 +4,18 @@
*
* 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 $
* the I/O call fail in the first place.
\*=========================================================================*/
#include <string.h>
#include <string.h>
#include <signal.h>
#include "socket.h"
#include "pierror.h"
/*-------------------------------------------------------------------------*\
* Wait for readable/writable/connected socket with timeout
\*-------------------------------------------------------------------------*/
#ifdef SOCKET_POLL
#ifndef SOCKET_SELECT
#include <sys/poll.h>
#define WAITFD_R POLLIN
@@ -30,9 +29,9 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
pfd.revents = 0;
if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */
do {
int t = (int)(timeout_getretry(tm)*1e3);
ret = poll(&pfd, 1, t >= 0? t: -1);
} while (ret == -1 && errno == EINTR);
int t = (int)(timeout_getretry(tm)*1e3);
ret = poll(&pfd, 1, t >= 0? t: -1);
} while (ret == -1 && errno == EINTR);
if (ret == -1) return errno;
if (ret == 0) return IO_TIMEOUT;
if (sw == WAITFD_C && (pfd.revents & (POLLIN|POLLERR))) return IO_CLOSED;
@@ -49,6 +48,7 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
fd_set rfds, wfds, *rp, *wp;
struct timeval tv, *tp;
double t;
if (*ps >= FD_SETSIZE) return EINVAL;
if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */
do {
/* must set bits within loop, because select may have modifed them */
@@ -73,7 +73,7 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
/*-------------------------------------------------------------------------*\
* Initializes module
* Initializes module
\*-------------------------------------------------------------------------*/
int socket_open(void) {
/* instals a handler to ignore sigpipe or it will crash us */
@@ -82,7 +82,7 @@ int socket_open(void) {
}
/*-------------------------------------------------------------------------*\
* Close module
* Close module
\*-------------------------------------------------------------------------*/
int socket_close(void) {
return 1;
@@ -93,7 +93,6 @@ int socket_close(void) {
\*-------------------------------------------------------------------------*/
void socket_destroy(p_socket ps) {
if (*ps != SOCKET_INVALID) {
socket_setblocking(ps);
close(*ps);
*ps = SOCKET_INVALID;
}
@@ -102,7 +101,7 @@ void socket_destroy(p_socket ps) {
/*-------------------------------------------------------------------------*\
* Select with timeout control
\*-------------------------------------------------------------------------*/
int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
p_timeout tm) {
int ret;
do {
@@ -121,8 +120,8 @@ int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
\*-------------------------------------------------------------------------*/
int socket_create(p_socket ps, int domain, int type, int protocol) {
*ps = socket(domain, type, protocol);
if (*ps != SOCKET_INVALID) return IO_DONE;
else return errno;
if (*ps != SOCKET_INVALID) return IO_DONE;
else return errno;
}
/*-------------------------------------------------------------------------*\
@@ -131,29 +130,25 @@ int socket_create(p_socket ps, int domain, int type, int protocol) {
int socket_bind(p_socket ps, SA *addr, socklen_t len) {
int err = IO_DONE;
socket_setblocking(ps);
if (bind(*ps, addr, len) < 0) err = errno;
if (bind(*ps, addr, len) < 0) err = errno;
socket_setnonblocking(ps);
return err;
}
/*-------------------------------------------------------------------------*\
*
*
\*-------------------------------------------------------------------------*/
int socket_listen(p_socket ps, int backlog) {
int err = IO_DONE;
socket_setblocking(ps);
if (listen(*ps, backlog)) err = errno;
socket_setnonblocking(ps);
int err = IO_DONE;
if (listen(*ps, backlog)) err = errno;
return err;
}
/*-------------------------------------------------------------------------*\
*
*
\*-------------------------------------------------------------------------*/
void socket_shutdown(p_socket ps, int how) {
socket_setblocking(ps);
shutdown(*ps, how);
socket_setnonblocking(ps);
}
/*-------------------------------------------------------------------------*\
@@ -167,7 +162,7 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
do if (connect(*ps, addr, len) == 0) return IO_DONE;
while ((err = errno) == EINTR);
/* if connection failed immediately, return error code */
if (err != EINPROGRESS && err != EAGAIN) return err;
if (err != EINPROGRESS && err != EAGAIN) return err;
/* zero timeout case optimization */
if (timeout_iszero(tm)) return IO_TIMEOUT;
/* wait until we have the result of the connection attempt or timeout */
@@ -182,11 +177,7 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
* Accept with timeout
\*-------------------------------------------------------------------------*/
int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len, p_timeout tm) {
SA daddr;
socklen_t dlen = sizeof(daddr);
if (*ps == SOCKET_INVALID) return IO_CLOSED;
if (!addr) addr = &daddr;
if (!len) len = &dlen;
if (*ps == SOCKET_INVALID) return IO_CLOSED;
for ( ;; ) {
int err;
if ((*pa = accept(*ps, addr, len)) != SOCKET_INVALID) return IO_DONE;
@@ -202,7 +193,7 @@ int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len, p_timeout
/*-------------------------------------------------------------------------*\
* Send with timeout
\*-------------------------------------------------------------------------*/
int socket_send(p_socket ps, const char *data, size_t count,
int socket_send(p_socket ps, const char *data, size_t count,
size_t *sent, p_timeout tm)
{
int err;
@@ -213,14 +204,15 @@ int socket_send(p_socket ps, const char *data, size_t count,
for ( ;; ) {
long put = (long) send(*ps, data, count, 0);
/* if we sent anything, we are done */
if (put > 0) {
if (put >= 0) {
*sent = put;
return IO_DONE;
}
err = errno;
/* send can't really return 0, but EPIPE means the connection was
closed */
if (put == 0 || err == EPIPE) return IO_CLOSED;
/* EPIPE means the connection was closed */
if (err == EPIPE) return IO_CLOSED;
/* EPROTOTYPE means the connection is being closed (on Yosemite!)*/
if (err == EPROTOTYPE) continue;
/* we call was interrupted, just try again */
if (err == EINTR) continue;
/* if failed fatal reason, report error */
@@ -235,20 +227,21 @@ int socket_send(p_socket ps, const char *data, size_t count,
/*-------------------------------------------------------------------------*\
* Sendto with timeout
\*-------------------------------------------------------------------------*/
int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
SA *addr, socklen_t len, p_timeout tm)
{
int err;
*sent = 0;
if (*ps == SOCKET_INVALID) return IO_CLOSED;
for ( ;; ) {
long put = (long) sendto(*ps, data, count, 0, addr, len);
if (put > 0) {
long put = (long) sendto(*ps, data, count, 0, addr, len);
if (put >= 0) {
*sent = put;
return IO_DONE;
}
err = errno;
if (put == 0 || err == EPIPE) return IO_CLOSED;
if (err == EPIPE) return IO_CLOSED;
if (err == EPROTOTYPE) continue;
if (err == EINTR) continue;
if (err != EAGAIN) return err;
if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err;
@@ -272,8 +265,8 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm
err = errno;
if (taken == 0) return IO_CLOSED;
if (err == EINTR) continue;
if (err != EAGAIN) return err;
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
if (err != EAGAIN) return err;
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
}
return IO_UNKNOWN;
}
@@ -281,7 +274,7 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm
/*-------------------------------------------------------------------------*\
* Recvfrom with timeout
\*-------------------------------------------------------------------------*/
int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
SA *addr, socklen_t *len, p_timeout tm) {
int err;
*got = 0;
@@ -295,8 +288,70 @@ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
err = errno;
if (taken == 0) return IO_CLOSED;
if (err == EINTR) continue;
if (err != EAGAIN) return err;
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
if (err != EAGAIN) return err;
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
}
return IO_UNKNOWN;
}
/*-------------------------------------------------------------------------*\
* Write with timeout
*
* socket_read and socket_write are cut-n-paste of socket_send and socket_recv,
* with send/recv replaced with write/read. We can't just use write/read
* in the socket version, because behaviour when size is zero is different.
\*-------------------------------------------------------------------------*/
int socket_write(p_socket ps, const char *data, size_t count,
size_t *sent, p_timeout tm)
{
int err;
*sent = 0;
/* avoid making system calls on closed sockets */
if (*ps == SOCKET_INVALID) return IO_CLOSED;
/* loop until we send something or we give up on error */
for ( ;; ) {
long put = (long) write(*ps, data, count);
/* if we sent anything, we are done */
if (put >= 0) {
*sent = put;
return IO_DONE;
}
err = errno;
/* EPIPE means the connection was closed */
if (err == EPIPE) return IO_CLOSED;
/* EPROTOTYPE means the connection is being closed (on Yosemite!)*/
if (err == EPROTOTYPE) continue;
/* we call was interrupted, just try again */
if (err == EINTR) continue;
/* if failed fatal reason, report error */
if (err != EAGAIN) return err;
/* wait until we can send something or we timeout */
if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err;
}
/* can't reach here */
return IO_UNKNOWN;
}
/*-------------------------------------------------------------------------*\
* Read with timeout
* See note for socket_write
\*-------------------------------------------------------------------------*/
int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm) {
int err;
*got = 0;
if (*ps == SOCKET_INVALID) return IO_CLOSED;
for ( ;; ) {
long taken = (long) read(*ps, data, count);
if (taken > 0) {
*got = taken;
return IO_DONE;
}
err = errno;
if (taken == 0) return IO_CLOSED;
if (err == EINTR) continue;
if (err != EAGAIN) return err;
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
}
return IO_UNKNOWN;
}
@@ -320,7 +375,7 @@ void socket_setnonblocking(p_socket ps) {
}
/*-------------------------------------------------------------------------*\
* DNS helpers
* DNS helpers
\*-------------------------------------------------------------------------*/
int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp) {
*hp = gethostbyaddr(addr, len, AF_INET);
@@ -345,7 +400,7 @@ int socket_gethostbyname(const char *addr, struct hostent **hp) {
const char *socket_hoststrerror(int err) {
if (err <= 0) return io_strerror(err);
switch (err) {
case HOST_NOT_FOUND: return "host not found";
case HOST_NOT_FOUND: return PIE_HOST_NOT_FOUND;
default: return hstrerror(err);
}
}
@@ -353,18 +408,44 @@ const char *socket_hoststrerror(int err) {
const char *socket_strerror(int err) {
if (err <= 0) return io_strerror(err);
switch (err) {
case EADDRINUSE: return "address already in use";
case EISCONN: return "already connected";
case EACCES: return "permission denied";
case ECONNREFUSED: return "connection refused";
case ECONNABORTED: return "closed";
case ECONNRESET: return "closed";
case ETIMEDOUT: return "timeout";
default: return strerror(errno);
case EADDRINUSE: return PIE_ADDRINUSE;
case EISCONN: return PIE_ISCONN;
case EACCES: return PIE_ACCESS;
case ECONNREFUSED: return PIE_CONNREFUSED;
case ECONNABORTED: return PIE_CONNABORTED;
case ECONNRESET: return PIE_CONNRESET;
case ETIMEDOUT: return PIE_TIMEDOUT;
default: {
return strerror(err);
}
}
}
const char *socket_ioerror(p_socket ps, int err) {
(void) ps;
return socket_strerror(err);
}
}
const char *socket_gaistrerror(int err) {
if (err == 0) return NULL;
switch (err) {
case EAI_AGAIN: return PIE_AGAIN;
case EAI_BADFLAGS: return PIE_BADFLAGS;
#ifdef EAI_BADHINTS
case EAI_BADHINTS: return PIE_BADHINTS;
#endif
case EAI_FAIL: return PIE_FAIL;
case EAI_FAMILY: return PIE_FAMILY;
case EAI_MEMORY: return PIE_MEMORY;
case EAI_NONAME: return PIE_NONAME;
case EAI_OVERFLOW: return PIE_OVERFLOW;
#ifdef EAI_PROTOCOL
case EAI_PROTOCOL: return PIE_PROTOCOL;
#endif
case EAI_SERVICE: return PIE_SERVICE;
case EAI_SOCKTYPE: return PIE_SOCKTYPE;
case EAI_SYSTEM: return strerror(errno);
default: return gai_strerror(err);
}
}
+21 -2
View File
@@ -3,8 +3,6 @@
/*=========================================================================*\
* Socket compatibilization module for Unix
* LuaSocket toolkit
*
* RCS ID: $Id: usocket.h,v 1.7 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
/*=========================================================================*\
@@ -31,9 +29,30 @@
#include <arpa/inet.h>
/* TCP options (nagle algorithm disable) */
#include <netinet/tcp.h>
#include <net/if.h>
#ifndef SO_REUSEPORT
#define SO_REUSEPORT SO_REUSEADDR
#endif
/* Some platforms use IPV6_JOIN_GROUP instead if
* IPV6_ADD_MEMBERSHIP. The semantics are same, though. */
#ifndef IPV6_ADD_MEMBERSHIP
#ifdef IPV6_JOIN_GROUP
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
#endif /* IPV6_JOIN_GROUP */
#endif /* !IPV6_ADD_MEMBERSHIP */
/* Same with IPV6_DROP_MEMBERSHIP / IPV6_LEAVE_GROUP. */
#ifndef IPV6_DROP_MEMBERSHIP
#ifdef IPV6_LEAVE_GROUP
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
#endif /* IPV6_LEAVE_GROUP */
#endif /* !IPV6_DROP_MEMBERSHIP */
typedef int t_socket;
typedef t_socket *p_socket;
typedef struct sockaddr_storage t_sockaddr_storage;
#define SOCKET_INVALID (-1)
+103 -71
View File
@@ -3,35 +3,34 @@
* LuaSocket toolkit
*
* 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 $
* the I/O call fail in the first place.
\*=========================================================================*/
#include <string.h>
#include "socket.h"
#include "pierror.h"
/* WinSock doesn't have a strerror... */
static const char *wstrerror(int err);
/*-------------------------------------------------------------------------*\
* Initializes module
* Initializes module
\*-------------------------------------------------------------------------*/
int socket_open(void) {
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(2, 0);
WORD wVersionRequested = MAKEWORD(2, 0);
int err = WSAStartup(wVersionRequested, &wsaData );
if (err != 0) return 0;
if ((LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 0) &&
(LOBYTE(wsaData.wVersion) != 1 || HIBYTE(wsaData.wVersion) != 1)) {
WSACleanup();
return 0;
return 0;
}
return 1;
}
/*-------------------------------------------------------------------------*\
* Close module
* Close module
\*-------------------------------------------------------------------------*/
int socket_close(void) {
WSACleanup();
@@ -52,10 +51,10 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
struct timeval tv, *tp = NULL;
double t;
if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */
if (sw & WAITFD_R) {
FD_ZERO(&rfds);
FD_SET(*ps, &rfds);
rp = &rfds;
if (sw & WAITFD_R) {
FD_ZERO(&rfds);
FD_SET(*ps, &rfds);
rp = &rfds;
}
if (sw & WAITFD_W) { FD_ZERO(&wfds); FD_SET(*ps, &wfds); wp = &wfds; }
if (sw & WAITFD_C) { FD_ZERO(&efds); FD_SET(*ps, &efds); ep = &efds; }
@@ -74,9 +73,9 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
/*-------------------------------------------------------------------------*\
* Select with int timeout in ms
\*-------------------------------------------------------------------------*/
int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
p_timeout tm) {
struct timeval tv;
struct timeval tv;
double t = timeout_get(tm);
tv.tv_sec = (int) t;
tv.tv_usec = (int) ((t - tv.tv_sec) * 1.0e6);
@@ -98,7 +97,7 @@ void socket_destroy(p_socket ps) {
}
/*-------------------------------------------------------------------------*\
*
*
\*-------------------------------------------------------------------------*/
void socket_shutdown(p_socket ps, int how) {
socket_setblocking(ps);
@@ -136,10 +135,10 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
/* give windows time to set the error (yes, disgusting) */
Sleep(10);
/* find out why we failed */
getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &len);
getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &len);
/* we KNOW there was an error. if 'why' is 0, we will return
* "unknown error", but it's not really our fault */
return err > 0? err: IO_UNKNOWN;
return err > 0? err: IO_UNKNOWN;
} else return err;
}
@@ -156,7 +155,7 @@ int socket_bind(p_socket ps, SA *addr, socklen_t len) {
}
/*-------------------------------------------------------------------------*\
*
*
\*-------------------------------------------------------------------------*/
int socket_listen(p_socket ps, int backlog) {
int err = IO_DONE;
@@ -169,35 +168,29 @@ int socket_listen(p_socket ps, int backlog) {
/*-------------------------------------------------------------------------*\
* Accept with timeout
\*-------------------------------------------------------------------------*/
int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len,
int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len,
p_timeout tm) {
SA daddr;
socklen_t dlen = sizeof(daddr);
if (*ps == SOCKET_INVALID) return IO_CLOSED;
if (!addr) addr = &daddr;
if (!len) len = &dlen;
for ( ;; ) {
int err;
/* try to get client socket */
if ((*pa = accept(*ps, addr, len)) != SOCKET_INVALID) return IO_DONE;
/* find out why we failed */
err = WSAGetLastError();
err = WSAGetLastError();
/* if we failed because there was no connectoin, keep trying */
if (err != WSAEWOULDBLOCK && err != WSAECONNABORTED) return err;
/* call select to avoid busy wait */
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
}
/* can't reach here */
return IO_UNKNOWN;
}
}
/*-------------------------------------------------------------------------*\
* Send with timeout
* On windows, if you try to send 10MB, the OS will buffer EVERYTHING
* this can take an awful lot of time and we will end up blocked.
* On windows, if you try to send 10MB, the OS will buffer EVERYTHING
* this can take an awful lot of time and we will end up blocked.
* Therefore, whoever calls this function should not pass a huge buffer.
\*-------------------------------------------------------------------------*/
int socket_send(p_socket ps, const char *data, size_t count,
int socket_send(p_socket ps, const char *data, size_t count,
size_t *sent, p_timeout tm)
{
int err;
@@ -207,27 +200,25 @@ int socket_send(p_socket ps, const char *data, size_t count,
/* loop until we send something or we give up on error */
for ( ;; ) {
/* try to send something */
int put = send(*ps, data, (int) count, 0);
int put = send(*ps, data, (int) count, 0);
/* if we sent something, we are done */
if (put > 0) {
*sent = put;
return IO_DONE;
}
/* deal with failure */
err = WSAGetLastError();
err = WSAGetLastError();
/* we can only proceed if there was no serious error */
if (err != WSAEWOULDBLOCK) return err;
/* avoid busy wait */
if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err;
}
/* can't reach here */
return IO_UNKNOWN;
}
}
/*-------------------------------------------------------------------------*\
* Sendto with timeout
\*-------------------------------------------------------------------------*/
int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
SA *addr, socklen_t len, p_timeout tm)
{
int err;
@@ -239,18 +230,19 @@ int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
*sent = put;
return IO_DONE;
}
err = WSAGetLastError();
err = WSAGetLastError();
if (err != WSAEWOULDBLOCK) return err;
if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err;
}
return IO_UNKNOWN;
}
}
/*-------------------------------------------------------------------------*\
* Receive with timeout
\*-------------------------------------------------------------------------*/
int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm) {
int err;
int socket_recv(p_socket ps, char *data, size_t count, size_t *got,
p_timeout tm)
{
int err, prev = IO_DONE;
*got = 0;
if (*ps == SOCKET_INVALID) return IO_CLOSED;
for ( ;; ) {
@@ -261,18 +253,25 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm
}
if (taken == 0) return IO_CLOSED;
err = WSAGetLastError();
if (err != WSAEWOULDBLOCK) return err;
/* On UDP, a connreset simply means the previous send failed.
* So we try again.
* On TCP, it means our socket is now useless, so the error passes.
* (We will loop again, exiting because the same error will happen) */
if (err != WSAEWOULDBLOCK) {
if (err != WSAECONNRESET || prev == WSAECONNRESET) return err;
prev = err;
}
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
}
return IO_UNKNOWN;
}
/*-------------------------------------------------------------------------*\
* Recvfrom with timeout
\*-------------------------------------------------------------------------*/
int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
SA *addr, socklen_t *len, p_timeout tm) {
int err;
int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
SA *addr, socklen_t *len, p_timeout tm)
{
int err, prev = IO_DONE;
*got = 0;
if (*ps == SOCKET_INVALID) return IO_CLOSED;
for ( ;; ) {
@@ -283,10 +282,16 @@ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
}
if (taken == 0) return IO_CLOSED;
err = WSAGetLastError();
if (err != WSAEWOULDBLOCK) return err;
/* On UDP, a connreset simply means the previous send failed.
* So we try again.
* On TCP, it means our socket is now useless, so the error passes.
* (We will loop again, exiting because the same error will happen) */
if (err != WSAEWOULDBLOCK) {
if (err != WSAECONNRESET || prev == WSAECONNRESET) return err;
prev = err;
}
if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
}
return IO_UNKNOWN;
}
/*-------------------------------------------------------------------------*\
@@ -306,7 +311,7 @@ void socket_setnonblocking(p_socket ps) {
}
/*-------------------------------------------------------------------------*\
* DNS helpers
* DNS helpers
\*-------------------------------------------------------------------------*/
int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp) {
*hp = gethostbyaddr(addr, len, AF_INET);
@@ -326,34 +331,34 @@ int socket_gethostbyname(const char *addr, struct hostent **hp) {
const char *socket_hoststrerror(int err) {
if (err <= 0) return io_strerror(err);
switch (err) {
case WSAHOST_NOT_FOUND: return "host not found";
default: return wstrerror(err);
case WSAHOST_NOT_FOUND: return PIE_HOST_NOT_FOUND;
default: return wstrerror(err);
}
}
const char *socket_strerror(int err) {
if (err <= 0) return io_strerror(err);
switch (err) {
case WSAEADDRINUSE: return "address already in use";
case WSAECONNREFUSED: return "connection refused";
case WSAEISCONN: return "already connected";
case WSAEACCES: return "permission denied";
case WSAECONNABORTED: return "closed";
case WSAECONNRESET: return "closed";
case WSAETIMEDOUT: return "timeout";
case WSAEADDRINUSE: return PIE_ADDRINUSE;
case WSAECONNREFUSED : return PIE_CONNREFUSED;
case WSAEISCONN: return PIE_ISCONN;
case WSAEACCES: return PIE_ACCESS;
case WSAECONNABORTED: return PIE_CONNABORTED;
case WSAECONNRESET: return PIE_CONNRESET;
case WSAETIMEDOUT: return PIE_TIMEDOUT;
default: return wstrerror(err);
}
}
const char *socket_ioerror(p_socket ps, int err) {
(void) ps;
return socket_strerror(err);
(void) ps;
return socket_strerror(err);
}
static const char *wstrerror(int err) {
switch (err) {
case WSAEINTR: return "Interrupted function call";
case WSAEACCES: return "Permission denied";
case WSAEACCES: return PIE_ACCESS; // "Permission denied";
case WSAEFAULT: return "Bad address";
case WSAEINVAL: return "Invalid argument";
case WSAEMFILE: return "Too many open files";
@@ -366,36 +371,63 @@ static const char *wstrerror(int err) {
case WSAEPROTOTYPE: return "Protocol wrong type for socket";
case WSAENOPROTOOPT: return "Bad protocol option";
case WSAEPROTONOSUPPORT: return "Protocol not supported";
case WSAESOCKTNOSUPPORT: return "Socket type not supported";
case WSAESOCKTNOSUPPORT: return PIE_SOCKTYPE; // "Socket type not supported";
case WSAEOPNOTSUPP: return "Operation not supported";
case WSAEPFNOSUPPORT: return "Protocol family not supported";
case WSAEAFNOSUPPORT:
return "Address family not supported by protocol family";
case WSAEADDRINUSE: return "Address already in use";
case WSAEAFNOSUPPORT: return PIE_FAMILY; // "Address family not supported by protocol family";
case WSAEADDRINUSE: return PIE_ADDRINUSE; // "Address already in use";
case WSAEADDRNOTAVAIL: return "Cannot assign requested address";
case WSAENETDOWN: return "Network is down";
case WSAENETUNREACH: return "Network is unreachable";
case WSAENETRESET: return "Network dropped connection on reset";
case WSAECONNABORTED: return "Software caused connection abort";
case WSAECONNRESET: return "Connection reset by peer";
case WSAECONNRESET: return PIE_CONNRESET; // "Connection reset by peer";
case WSAENOBUFS: return "No buffer space available";
case WSAEISCONN: return "Socket is already connected";
case WSAEISCONN: return PIE_ISCONN; // "Socket is already connected";
case WSAENOTCONN: return "Socket is not connected";
case WSAESHUTDOWN: return "Cannot send after socket shutdown";
case WSAETIMEDOUT: return "Connection timed out";
case WSAECONNREFUSED: return "Connection refused";
case WSAETIMEDOUT: return PIE_TIMEDOUT; // "Connection timed out";
case WSAECONNREFUSED: return PIE_CONNREFUSED; // "Connection refused";
case WSAEHOSTDOWN: return "Host is down";
case WSAEHOSTUNREACH: return "No route to host";
case WSAEPROCLIM: return "Too many processes";
case WSASYSNOTREADY: return "Network subsystem is unavailable";
case WSAVERNOTSUPPORTED: return "Winsock.dll version out of range";
case WSANOTINITIALISED:
case WSANOTINITIALISED:
return "Successful WSAStartup not yet performed";
case WSAEDISCON: return "Graceful shutdown in progress";
case WSAHOST_NOT_FOUND: return "Host not found";
case WSAHOST_NOT_FOUND: return PIE_HOST_NOT_FOUND; // "Host not found";
case WSATRY_AGAIN: return "Nonauthoritative host not found";
case WSANO_RECOVERY: return "Nonrecoverable name lookup error";
case WSANO_RECOVERY: return PIE_FAIL; // "Nonrecoverable name lookup error";
case WSANO_DATA: return "Valid name, no data record of requested type";
default: return "Unknown error";
}
}
const char *socket_gaistrerror(int err) {
if (err == 0) return NULL;
switch (err) {
case EAI_AGAIN: return PIE_AGAIN;
case EAI_BADFLAGS: return PIE_BADFLAGS;
#ifdef EAI_BADHINTS
case EAI_BADHINTS: return PIE_BADHINTS;
#endif
case EAI_FAIL: return PIE_FAIL;
case EAI_FAMILY: return PIE_FAMILY;
case EAI_MEMORY: return PIE_MEMORY;
case EAI_NONAME: return PIE_NONAME;
#ifdef EAI_OVERFLOW
case EAI_OVERFLOW: return PIE_OVERFLOW;
#endif
#ifdef EAI_PROTOCOL
case EAI_PROTOCOL: return PIE_PROTOCOL;
#endif
case EAI_SERVICE: return PIE_SERVICE;
case EAI_SOCKTYPE: return PIE_SOCKTYPE;
#ifdef EAI_SYSTEM
case EAI_SYSTEM: return strerror(errno);
#endif
default: return gai_strerror(err);
}
}
+15 -3
View File
@@ -3,19 +3,31 @@
/*=========================================================================*\
* Socket compatibilization module for Win32
* LuaSocket toolkit
*
* RCS ID: $Id: wsocket.h,v 1.4 2005/10/07 04:40:59 diego Exp $
\*=========================================================================*/
/*=========================================================================*\
* WinSock include files
\*=========================================================================*/
#include <winsock.h>
#include <winsock2.h>
#include <ws2tcpip.h>
typedef int socklen_t;
typedef SOCKADDR_STORAGE t_sockaddr_storage;
typedef SOCKET t_socket;
typedef t_socket *p_socket;
#ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 27
#endif
#define SOCKET_INVALID (INVALID_SOCKET)
#ifndef SO_REUSEPORT
#define SO_REUSEPORT SO_REUSEADDR
#endif
#ifndef AI_NUMERICSERV
#define AI_NUMERICSERV (0)
#endif
#endif /* WSOCKET_H */
+14 -8
View File
@@ -55,6 +55,8 @@ int __open(lua_State * L)
PRELOAD("socket.smtp", __open_luasocket_smtp);
PRELOAD("socket.tp", __open_luasocket_tp)
PRELOAD("socket.url", __open_luasocket_url)
PRELOAD("socket.headers", __open_luasocket_headers)
PRELOAD("mbox", __open_luasocket_mbox)
// No need to register garbage collector function.
@@ -64,56 +66,60 @@ int __open(lua_State * L)
int __open_luasocket_socket(lua_State * L)
{
#include "libluasocket/socket.lua.h"
lua_getglobal(L, "socket");
return 1;
}
int __open_luasocket_ftp(lua_State * L)
{
#include "libluasocket/ftp.lua.h"
lua_getglobal(L, "socket.ftp");
return 1;
}
int __open_luasocket_http(lua_State * L)
{
#include "libluasocket/http.lua.h"
lua_getglobal(L, "socket.http");
return 1;
}
int __open_luasocket_ltn12(lua_State * L)
{
#include "libluasocket/ltn12.lua.h"
lua_getglobal(L, "ltn12");
return 1;
}
int __open_luasocket_mime(lua_State * L)
{
#include "libluasocket/mime.lua.h"
lua_getglobal(L, "mime");
return 1;
}
int __open_luasocket_smtp(lua_State * L)
{
#include "libluasocket/smtp.lua.h"
lua_getglobal(L, "socket.smtp");
return 1;
}
int __open_luasocket_tp(lua_State * L)
{
#include "libluasocket/tp.lua.h"
lua_getglobal(L, "socket.tp");
return 1;
}
int __open_luasocket_url(lua_State * L)
{
#include "libluasocket/url.lua.h"
lua_getglobal(L, "socket.url");
return 1;
}
int __open_luasocket_headers(lua_State * L)
{
#include "libluasocket/headers.lua.h"
return 1;
}
int __open_luasocket_mbox(lua_State * L)
{
#include "libluasocket/mbox.lua.h"
return 1;
}
+2
View File
@@ -42,6 +42,8 @@ int __open_luasocket_mime(lua_State * L);
int __open_luasocket_smtp(lua_State * L);
int __open_luasocket_tp(lua_State * L);
int __open_luasocket_url(lua_State * L);
int __open_luasocket_headers(lua_State * L);
int __open_luasocket_mbox(lua_State * L);
} // luasocket
} // love