mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-13 14:14:30 +02:00
Compare commits
93 Commits
revert-256
...
issue297
Author | SHA1 | Date | |
---|---|---|---|
3a66baed15 | |||
790a58112f | |||
d341493bbf | |||
0901c486ff | |||
68aeb39dc2 | |||
733af884f1 | |||
ab3b0ef5c9 | |||
9acb6dc81a | |||
c89a931cc3 | |||
21514304be | |||
3a37ab8890 | |||
33883e78c8 | |||
c8d0fdda54 | |||
8b2dcdcf7d | |||
4e363330a3 | |||
d27b1a7945 | |||
5d07d9b227 | |||
d71e6bc459 | |||
42a1a732b7 | |||
86e1b3f45f | |||
1fa10673f7 | |||
c8b9b40eda | |||
c2245f35c5 | |||
ce6a08d57d | |||
83648f8df2 | |||
2015290cb4 | |||
ee30e4643d | |||
611cdd19cc | |||
4bf3eb6db2 | |||
133774cd3d | |||
e3ac49efbd | |||
98800e9129 | |||
2af4872a40 | |||
03b72d8f7e | |||
c7215bef07 | |||
1e4255e2a9 | |||
5cc91ab600 | |||
297f9d0277 | |||
34d525984c | |||
d9afe3fd9c | |||
c0fba03e4f | |||
e2e43d62fa | |||
2d8f0d9901 | |||
f8183bab87 | |||
d7ffc2f4e6 | |||
fe437ee844 | |||
678d558c5f | |||
30a0a6003b | |||
87c2dee13e | |||
525d703e16 | |||
898f2df025 | |||
fae993c118 | |||
ef2a3fcedb | |||
3f19a052e8 | |||
731b23bc89 | |||
395729d431 | |||
2bf6730fd5 | |||
b95527e140 | |||
c0374dd46f | |||
16b0026e27 | |||
1f6035070f | |||
c23bf865ce | |||
efc4bb3e2d | |||
f06b17c4c9 | |||
9b3f7a4304 | |||
2a467001f6 | |||
e587800164 | |||
38865fad3a | |||
fa807f3ffd | |||
a9c75cb099 | |||
699c36c019 | |||
f6ba23d463 | |||
b8f088e868 | |||
c5cef32897 | |||
4b0f1d753d | |||
40f79c1961 | |||
e136dd3df3 | |||
09ff9b650c | |||
59c8aaac34 | |||
5858c8e776 | |||
686f2ce822 | |||
144fa01c2f | |||
024646de54 | |||
57e04f55dc | |||
531012df1a | |||
d1e35c9573 | |||
4950294c26 | |||
e2bb1d3b42 | |||
288219fd6b | |||
4a3504612c | |||
97bfe1e043 | |||
053c032a70 | |||
2906d6a522 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,7 +6,6 @@
|
|||||||
*.dll*
|
*.dll*
|
||||||
*.user
|
*.user
|
||||||
*.sdf
|
*.sdf
|
||||||
Lua.props
|
|
||||||
Debug
|
Debug
|
||||||
Release
|
Release
|
||||||
*.manifest
|
*.manifest
|
||||||
|
49
Lua.props
Executable file
49
Lua.props
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ImportGroup Label="PropertySheets" />
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='x64'" Label="LuaPlat">
|
||||||
|
<LUAPLAT>$(Platform)/$(Configuration)</LUAPLAT>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Platform)'=='Win32'" Label="LuaPlat">
|
||||||
|
<LUAPLAT>$(Configuration)</LUAPLAT>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Label="UserMacros">
|
||||||
|
<LUAV>5.3</LUAV>
|
||||||
|
<LUAPREFIX>z:\data\build\vc14\</LUAPREFIX>
|
||||||
|
<LUALIB>$(LUAPREFIX)\lib\lua\$(LUAV)\$(LUAPLAT)</LUALIB>
|
||||||
|
<LUACDIR>$(LUAPREFIX)\bin\lua\$(LUAV)\$(LUAPLAT)</LUACDIR>
|
||||||
|
<LUALDIR>$(LUAPREFIX)\bin\lua\$(LUAV)\$(LUAPLAT)\lua</LUALDIR>
|
||||||
|
<LUAINC>$(LUAPREFIX)\include\lua\$(LUAV);$(LUAPREFIX)\include\lua$(LUAV)</LUAINC>
|
||||||
|
<LUALIBNAME>lua$(LUAV.Replace('.', '')).lib</LUALIBNAME>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<_PropertySheetDisplayName>Lua</_PropertySheetDisplayName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<BuildMacro Include="LUAPLAT">
|
||||||
|
<Value>$(LUAPLAT)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
<BuildMacro Include="LUAPREFIX">
|
||||||
|
<Value>$(LUAPREFIX)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
<BuildMacro Include="LUAV">
|
||||||
|
<Value>$(LUAV)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
<BuildMacro Include="LUALIB">
|
||||||
|
<Value>$(LUALIB)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
<BuildMacro Include="LUAINC">
|
||||||
|
<Value>$(LUAINC)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
<BuildMacro Include="LUACDIR">
|
||||||
|
<Value>$(LUACDIR)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
<BuildMacro Include="LUALDIR">
|
||||||
|
<Value>$(LUALDIR)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
<BuildMacro Include="LUALIBNAME">
|
||||||
|
<Value>$(LUALIBNAME)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
28
Lua51.props
28
Lua51.props
@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ImportGroup Label="PropertySheets" />
|
|
||||||
<PropertyGroup Label="UserMacros">
|
|
||||||
<LUABIN_PATH>..\build\vc12\bin\lua\5.1\</LUABIN_PATH>
|
|
||||||
<LUALIB_PATH>..\build\vc12\bin\lua\5.1\</LUALIB_PATH>
|
|
||||||
<LUAINC_PATH>..\build\vc12\include\lua\5.1\</LUAINC_PATH>
|
|
||||||
<LUALIB>lua51.lib</LUALIB>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<_PropertySheetDisplayName>Lua51</_PropertySheetDisplayName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup />
|
|
||||||
<ItemGroup>
|
|
||||||
<BuildMacro Include="LUALIB_PATH">
|
|
||||||
<Value>$(LUALIB_PATH)</Value>
|
|
||||||
</BuildMacro>
|
|
||||||
<BuildMacro Include="LUABIN_PATH">
|
|
||||||
<Value>$(LUABIN_PATH)</Value>
|
|
||||||
</BuildMacro>
|
|
||||||
<BuildMacro Include="LUAINC_PATH">
|
|
||||||
<Value>$(LUAINC_PATH)</Value>
|
|
||||||
</BuildMacro>
|
|
||||||
<BuildMacro Include="LUALIB">
|
|
||||||
<Value>$(LUALIB)</Value>
|
|
||||||
</BuildMacro>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
28
Lua52.props
28
Lua52.props
@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ImportGroup Label="PropertySheets" />
|
|
||||||
<PropertyGroup Label="UserMacros">
|
|
||||||
<LUABIN_PATH>..\build\vc12\bin\lua\5.2\</LUABIN_PATH>
|
|
||||||
<LUALIB_PATH>..\build\vc12\bin\lua\5.2\</LUALIB_PATH>
|
|
||||||
<LUAINC_PATH>..\build\vc12\include\lua\5.2\</LUAINC_PATH>
|
|
||||||
<LUALIB>lua52.lib</LUALIB>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<_PropertySheetDisplayName>Lua52</_PropertySheetDisplayName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup />
|
|
||||||
<ItemGroup>
|
|
||||||
<BuildMacro Include="LUALIB_PATH">
|
|
||||||
<Value>$(LUALIB_PATH)</Value>
|
|
||||||
</BuildMacro>
|
|
||||||
<BuildMacro Include="LUABIN_PATH">
|
|
||||||
<Value>$(LUABIN_PATH)</Value>
|
|
||||||
</BuildMacro>
|
|
||||||
<BuildMacro Include="LUAINC_PATH">
|
|
||||||
<Value>$(LUAINC_PATH)</Value>
|
|
||||||
</BuildMacro>
|
|
||||||
<BuildMacro Include="LUALIB">
|
|
||||||
<Value>$(LUALIB)</Value>
|
|
||||||
</BuildMacro>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -135,7 +135,8 @@ http.<b>request{</b><br>
|
|||||||
[step = <i>LTN12 pump step</i>,]<br>
|
[step = <i>LTN12 pump step</i>,]<br>
|
||||||
[proxy = <i>string</i>,]<br>
|
[proxy = <i>string</i>,]<br>
|
||||||
[redirect = <i>boolean</i>,]<br>
|
[redirect = <i>boolean</i>,]<br>
|
||||||
[create = <i>function</i>]<br>
|
[create = <i>function</i>,]<br>
|
||||||
|
[maxredirects = <i>number</i>]<br>
|
||||||
<b>}</b>
|
<b>}</b>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -185,6 +186,7 @@ Defaults to the LTN12 <tt>pump.step</tt> function.
|
|||||||
function from automatically following 301 or 302 server redirect messages;
|
function from automatically following 301 or 302 server redirect messages;
|
||||||
<li><tt>create</tt>: An optional function to be used instead of
|
<li><tt>create</tt>: An optional function to be used instead of
|
||||||
<a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created.
|
<a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created.
|
||||||
|
<li><tt>maxredirects</tt>: An optional number specifying the maximum number of redirects to follow. Defaults to <tt>5</tt> if not specified. A boolean <tt>false</tt> value means no maximum (unlimited).
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p class=return>
|
<p class=return>
|
||||||
@ -324,8 +326,8 @@ r, c = http.request {
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<small>
|
<small>
|
||||||
Last modified by Diego Nehab on <br>
|
Last modified by Eric Westbrook on <br>
|
||||||
Thu Apr 20 00:25:26 EDT 2006
|
Sat Feb 23 19:09:42 UTC 2019
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
</center>
|
</center>
|
||||||
|
@ -477,6 +477,12 @@ used in validating addresses supplied in a call to
|
|||||||
<li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt>
|
<li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt>
|
||||||
disables the Nagle's algorithm for the connection;
|
disables the Nagle's algorithm for the connection;
|
||||||
|
|
||||||
|
<li> '<tt>tcp-keepidle</tt>': value in seconds for <tt>TCP_KEEPIDLE</tt> Linux only!!
|
||||||
|
|
||||||
|
<li> '<tt>tcp-keepcnt</tt>': value for <tt>TCP_KEEPCNT</tt> Linux only!!
|
||||||
|
|
||||||
|
<li> '<tt>tcp-keepintvl</tt>': value for <tt>TCP_KEEPINTVL</tt> Linux only!!
|
||||||
|
|
||||||
<li> '<tt>ipv6-v6only</tt>':
|
<li> '<tt>ipv6-v6only</tt>':
|
||||||
Setting this option to <tt>true</tt> restricts an <tt>inet6</tt> socket to
|
Setting this option to <tt>true</tt> restricts an <tt>inet6</tt> socket to
|
||||||
sending and receiving only IPv6 packets.
|
sending and receiving only IPv6 packets.
|
||||||
|
@ -1,105 +0,0 @@
|
|||||||
package = "LuaSocket"
|
|
||||||
version = "scm-0"
|
|
||||||
source = {
|
|
||||||
url = "https://github.com/diegonehab/luasocket/archive/master.zip",
|
|
||||||
dir = "luasocket-master",
|
|
||||||
}
|
|
||||||
description = {
|
|
||||||
summary = "Network support for the Lua language",
|
|
||||||
detailed = [[
|
|
||||||
LuaSocket is a Lua extension library that is composed by two parts: a C core
|
|
||||||
that provides support for the TCP and UDP transport layers, and a set of Lua
|
|
||||||
modules that add support for functionality commonly needed by applications
|
|
||||||
that deal with the Internet.
|
|
||||||
]],
|
|
||||||
homepage = "http://luaforge.net/projects/luasocket/",
|
|
||||||
license = "MIT"
|
|
||||||
}
|
|
||||||
dependencies = {
|
|
||||||
"lua >= 5.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
local function make_plat(plat)
|
|
||||||
local defines = {
|
|
||||||
unix = {
|
|
||||||
"LUASOCKET_DEBUG",
|
|
||||||
"LUASOCKET_API=__attribute__((visibility(\"default\")))",
|
|
||||||
"UNIX_API=__attribute__((visibility(\"default\")))",
|
|
||||||
"MIME_API=__attribute__((visibility(\"default\")))"
|
|
||||||
},
|
|
||||||
macosx = {
|
|
||||||
"LUASOCKET_DEBUG",
|
|
||||||
"UNIX_HAS_SUN_LEN",
|
|
||||||
"LUASOCKET_API=__attribute__((visibility(\"default\")))",
|
|
||||||
"UNIX_API=__attribute__((visibility(\"default\")))",
|
|
||||||
"MIME_API=__attribute__((visibility(\"default\")))"
|
|
||||||
},
|
|
||||||
win32 = {
|
|
||||||
"LUASOCKET_DEBUG",
|
|
||||||
"NDEBUG",
|
|
||||||
"LUASOCKET_API=__declspec(dllexport)",
|
|
||||||
"MIME_API=__declspec(dllexport)"
|
|
||||||
},
|
|
||||||
mingw32 = {
|
|
||||||
"LUASOCKET_DEBUG",
|
|
||||||
"LUASOCKET_INET_PTON",
|
|
||||||
"WINVER=0x0501",
|
|
||||||
"LUASOCKET_API=__declspec(dllexport)",
|
|
||||||
"MIME_API=__declspec(dllexport)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
local modules = {
|
|
||||||
["socket.core"] = {
|
|
||||||
sources = { "src/luasocket.c", "src/timeout.c", "src/buffer.c", "src/io.c", "src/auxiliar.c", "src/options.c", "src/inet.c", "src/except.c", "src/select.c", "src/tcp.c", "src/udp.c", "src/compat.c" },
|
|
||||||
defines = defines[plat],
|
|
||||||
incdir = "/src"
|
|
||||||
},
|
|
||||||
["mime.core"] = {
|
|
||||||
sources = { "src/mime.c", "src/compat.c" },
|
|
||||||
defines = defines[plat],
|
|
||||||
incdir = "/src"
|
|
||||||
},
|
|
||||||
["socket.http"] = "src/http.lua",
|
|
||||||
["socket.url"] = "src/url.lua",
|
|
||||||
["socket.tp"] = "src/tp.lua",
|
|
||||||
["socket.ftp"] = "src/ftp.lua",
|
|
||||||
["socket.headers"] = "src/headers.lua",
|
|
||||||
["socket.smtp"] = "src/smtp.lua",
|
|
||||||
ltn12 = "src/ltn12.lua",
|
|
||||||
socket = "src/socket.lua",
|
|
||||||
mime = "src/mime.lua"
|
|
||||||
}
|
|
||||||
if plat == "unix" or plat == "macosx" or plat == "haiku" then
|
|
||||||
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/usocket.c"
|
|
||||||
if plat == "haiku" then
|
|
||||||
modules["socket.core"].libraries = {"network"}
|
|
||||||
end
|
|
||||||
modules["socket.unix"] = {
|
|
||||||
sources = { "src/buffer.c", "src/auxiliar.c", "src/options.c", "src/timeout.c", "src/io.c", "src/usocket.c", "src/unix.c" },
|
|
||||||
defines = defines[plat],
|
|
||||||
incdir = "/src"
|
|
||||||
}
|
|
||||||
modules["socket.serial"] = {
|
|
||||||
sources = { "src/buffer.c", "src/auxiliar.c", "src/options.c", "src/timeout.c", "src/io.c", "src/usocket.c", "src/serial.c" },
|
|
||||||
defines = defines[plat],
|
|
||||||
incdir = "/src"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
if plat == "win32" or plat == "mingw32" then
|
|
||||||
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c"
|
|
||||||
modules["socket.core"].libraries = { "ws2_32" }
|
|
||||||
end
|
|
||||||
return { modules = modules }
|
|
||||||
end
|
|
||||||
|
|
||||||
build = {
|
|
||||||
type = "builtin",
|
|
||||||
platforms = {
|
|
||||||
unix = make_plat("unix"),
|
|
||||||
macosx = make_plat("macosx"),
|
|
||||||
haiku = make_plat("haiku"),
|
|
||||||
win32 = make_plat("win32"),
|
|
||||||
mingw32 = make_plat("mingw32")
|
|
||||||
},
|
|
||||||
copy_directories = { "doc", "samples", "etc", "test" }
|
|
||||||
}
|
|
@ -1 +1 @@
|
|||||||
make DEBUG=DEBUG PLAT=macosx LUAINC_macosx_base=/Users/diego/build/macosx/include LUAPREFIX_macosx=/Users/diego/build/macosx install-both
|
make DEBUG=DEBUG PLAT=macosx LUAINC_macosx_base=/Users/$USER/build/macosx/include LUAPREFIX_macosx=/Users/$USER/build/macosx install-both
|
||||||
|
2
makefile
Normal file → Executable file
2
makefile
Normal file → Executable file
@ -10,7 +10,7 @@
|
|||||||
# print print the build settings
|
# print print the build settings
|
||||||
|
|
||||||
PLAT?= linux
|
PLAT?= linux
|
||||||
PLATS= macosx linux win32 mingw freebsd solaris
|
PLATS= macosx linux win32 win64 mingw freebsd solaris
|
||||||
|
|
||||||
all: $(PLAT)
|
all: $(PLAT)
|
||||||
|
|
||||||
|
55
mime.vcxproj
55
mime.vcxproj
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
@ -21,19 +21,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\mime.c" />
|
<ClCompile Include="src\mime.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<CustomBuild Include="src\mime.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUALIB_PATH)$(Platform)\$(Configuration)</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUALIB_PATH)$(Platform)\$(Configuration)</Command>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
</CustomBuild>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{128E8BD0-174A-48F0-8771-92B1E8D18713}</ProjectGuid>
|
<ProjectGuid>{128E8BD0-174A-48F0-8771-92B1E8D18713}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
@ -41,22 +28,22 @@
|
|||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
@ -87,7 +74,7 @@
|
|||||||
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
|
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<OutDir>$(LUABIN_PATH)$(Configuration)\mime\</OutDir>
|
<OutDir>$(Configuration)\mime\</OutDir>
|
||||||
<IntDir>$(Configuration)\</IntDir>
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetName>core</TargetName>
|
<TargetName>core</TargetName>
|
||||||
@ -95,23 +82,23 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetName>core</TargetName>
|
<TargetName>core</TargetName>
|
||||||
<OutDir>$(LUABIN_PATH)$(Platform)\$(Configuration)\mime\</OutDir>
|
<OutDir>$(Platform)\$(Configuration)\mime\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(LUABIN_PATH)$(Configuration)\mime\</OutDir>
|
<OutDir>$(Configuration)\mime\</OutDir>
|
||||||
<IntDir>$(Configuration)\</IntDir>
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetName>core</TargetName>
|
<TargetName>core</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<OutDir>$(LUABIN_PATH)$(Platform)\$(Configuration)\mime\</OutDir>
|
<OutDir>$(Platform)\$(Configuration)\mime\</OutDir>
|
||||||
<TargetName>core</TargetName>
|
<TargetName>core</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LUAINC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
@ -122,9 +109,9 @@
|
|||||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>$(LUALIB);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(LUALIBNAME);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>$(LUALIB_PATH)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LUALIB);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile>
|
<ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -138,7 +125,7 @@
|
|||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LUAINC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
@ -149,9 +136,9 @@
|
|||||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>$(LUALIB);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(LUALIBNAME);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>$(LUALIB_PATH)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LUALIB);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile>
|
<ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -163,7 +150,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LUAINC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<PrecompiledHeader />
|
<PrecompiledHeader />
|
||||||
@ -172,9 +159,9 @@
|
|||||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>$(LUALIB);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(LUALIBNAME);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>$(LUALIB_PATH)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LUALIB);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
@ -187,7 +174,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LUAINC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
@ -198,9 +185,9 @@
|
|||||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>$(LUALIB);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(LUALIBNAME);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>$(LUALIB_PATH)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LUALIB);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="src\mime.c" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="cdir">
|
|
||||||
<UniqueIdentifier>{fad87a86-297c-4881-a114-73b967bb3c92}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<CustomBuild Include="src\mime.lua">
|
|
||||||
<Filter>cdir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -1,105 +1,134 @@
|
|||||||
package = "LuaSocket"
|
package = "LuaSocket"
|
||||||
version = "3.0rc2-1"
|
version = "3.0rc2-1"
|
||||||
source = {
|
source = {
|
||||||
url = "git://github.com/diegonehab/luasocket.git",
|
url = "git://github.com/diegonehab/luasocket.git",
|
||||||
tag = "v3.0-rc2",
|
tag = "v3.0-rc2",
|
||||||
}
|
}
|
||||||
description = {
|
description = {
|
||||||
summary = "Network support for the Lua language",
|
summary = "Network support for the Lua language",
|
||||||
detailed = [[
|
detailed = [[
|
||||||
LuaSocket is a Lua extension library that is composed by two parts: a C core
|
LuaSocket is a Lua extension library that is composed by two parts: a C core
|
||||||
that provides support for the TCP and UDP transport layers, and a set of Lua
|
that provides support for the TCP and UDP transport layers, and a set of Lua
|
||||||
modules that add support for functionality commonly needed by applications
|
modules that add support for functionality commonly needed by applications
|
||||||
that deal with the Internet.
|
that deal with the Internet.
|
||||||
]],
|
]],
|
||||||
homepage = "http://luaforge.net/projects/luasocket/",
|
homepage = "http://luaforge.net/projects/luasocket/",
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
}
|
}
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"lua >= 5.1"
|
"lua >= 5.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
local function make_plat(plat)
|
local function make_plat(plat)
|
||||||
local defines = {
|
local defines = {
|
||||||
unix = {
|
unix = {
|
||||||
"LUASOCKET_DEBUG",
|
"LUASOCKET_DEBUG"
|
||||||
"LUASOCKET_API=__attribute__((visibility(\"default\")))",
|
},
|
||||||
"UNIX_API=__attribute__((visibility(\"default\")))",
|
macosx = {
|
||||||
"MIME_API=__attribute__((visibility(\"default\")))"
|
"LUASOCKET_DEBUG",
|
||||||
},
|
"UNIX_HAS_SUN_LEN"
|
||||||
macosx = {
|
},
|
||||||
"LUASOCKET_DEBUG",
|
win32 = {
|
||||||
"UNIX_HAS_SUN_LEN",
|
"LUASOCKET_DEBUG",
|
||||||
"LUASOCKET_API=__attribute__((visibility(\"default\")))",
|
"NDEBUG"
|
||||||
"UNIX_API=__attribute__((visibility(\"default\")))",
|
},
|
||||||
"MIME_API=__attribute__((visibility(\"default\")))"
|
mingw32 = {
|
||||||
},
|
"LUASOCKET_DEBUG",
|
||||||
win32 = {
|
"LUASOCKET_INET_PTON",
|
||||||
"LUASOCKET_DEBUG",
|
"WINVER=0x0501"
|
||||||
"NDEBUG",
|
}
|
||||||
"LUASOCKET_API=__declspec(dllexport)",
|
}
|
||||||
"MIME_API=__declspec(dllexport)"
|
local modules = {
|
||||||
},
|
["socket.core"] = {
|
||||||
mingw32 = {
|
sources = {
|
||||||
"LUASOCKET_DEBUG",
|
"src/luasocket.c"
|
||||||
"LUASOCKET_INET_PTON",
|
, "src/timeout.c"
|
||||||
"WINVER=0x0501",
|
, "src/buffer.c"
|
||||||
"LUASOCKET_API=__declspec(dllexport)",
|
, "src/io.c"
|
||||||
"MIME_API=__declspec(dllexport)"
|
, "src/auxiliar.c"
|
||||||
}
|
, "src/options.c"
|
||||||
}
|
, "src/inet.c"
|
||||||
local modules = {
|
, "src/except.c"
|
||||||
["socket.core"] = {
|
, "src/select.c"
|
||||||
sources = { "src/luasocket.c", "src/timeout.c", "src/buffer.c", "src/io.c", "src/auxiliar.c", "src/options.c", "src/inet.c", "src/except.c", "src/select.c", "src/tcp.c", "src/udp.c", "src/compat.c" },
|
, "src/tcp.c"
|
||||||
defines = defines[plat],
|
, "src/udp.c"
|
||||||
incdir = "/src"
|
, "src/compat.c" },
|
||||||
},
|
defines = defines[plat],
|
||||||
["mime.core"] = {
|
incdir = "/src"
|
||||||
sources = { "src/mime.c", "src/compat.c" },
|
},
|
||||||
defines = defines[plat],
|
["mime.core"] = {
|
||||||
incdir = "/src"
|
sources = { "src/mime.c", "src/compat.c" },
|
||||||
},
|
defines = defines[plat],
|
||||||
["socket.http"] = "src/http.lua",
|
incdir = "/src"
|
||||||
["socket.url"] = "src/url.lua",
|
},
|
||||||
["socket.tp"] = "src/tp.lua",
|
["socket.http"] = "src/http.lua",
|
||||||
["socket.ftp"] = "src/ftp.lua",
|
["socket.url"] = "src/url.lua",
|
||||||
["socket.headers"] = "src/headers.lua",
|
["socket.tp"] = "src/tp.lua",
|
||||||
["socket.smtp"] = "src/smtp.lua",
|
["socket.ftp"] = "src/ftp.lua",
|
||||||
ltn12 = "src/ltn12.lua",
|
["socket.headers"] = "src/headers.lua",
|
||||||
socket = "src/socket.lua",
|
["socket.smtp"] = "src/smtp.lua",
|
||||||
mime = "src/mime.lua"
|
ltn12 = "src/ltn12.lua",
|
||||||
}
|
socket = "src/socket.lua",
|
||||||
if plat == "unix" or plat == "macosx" or plat == "haiku" then
|
mime = "src/mime.lua"
|
||||||
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/usocket.c"
|
}
|
||||||
if plat == "haiku" then
|
if plat == "unix"
|
||||||
modules["socket.core"].libraries = {"network"}
|
or plat == "macosx"
|
||||||
end
|
or plat == "haiku"
|
||||||
modules["socket.unix"] = {
|
then
|
||||||
sources = { "src/buffer.c", "src/auxiliar.c", "src/options.c", "src/timeout.c", "src/io.c", "src/usocket.c", "src/unix.c" },
|
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/usocket.c"
|
||||||
defines = defines[plat],
|
if plat == "haiku" then
|
||||||
incdir = "/src"
|
modules["socket.core"].libraries = {"network"}
|
||||||
}
|
end
|
||||||
modules["socket.serial"] = {
|
modules["socket.unix"] = {
|
||||||
sources = { "src/buffer.c", "src/auxiliar.c", "src/options.c", "src/timeout.c", "src/io.c", "src/usocket.c", "src/serial.c" },
|
sources = {
|
||||||
defines = defines[plat],
|
"src/buffer.c"
|
||||||
incdir = "/src"
|
, "src/compat.c"
|
||||||
}
|
, "src/auxiliar.c"
|
||||||
end
|
, "src/options.c"
|
||||||
if plat == "win32" or plat == "mingw32" then
|
, "src/timeout.c"
|
||||||
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c"
|
, "src/io.c"
|
||||||
modules["socket.core"].libraries = { "ws2_32" }
|
, "src/usocket.c"
|
||||||
end
|
, "src/unix.c"
|
||||||
return { modules = modules }
|
, "src/unixdgram.c"
|
||||||
|
, "src/unixstream.c" },
|
||||||
|
defines = defines[plat],
|
||||||
|
incdir = "/src"
|
||||||
|
}
|
||||||
|
modules["socket.serial"] = {
|
||||||
|
sources = {
|
||||||
|
"src/buffer.c"
|
||||||
|
, "src/compat.c"
|
||||||
|
, "src/auxiliar.c"
|
||||||
|
, "src/options.c"
|
||||||
|
, "src/timeout.c"
|
||||||
|
, "src/io.c"
|
||||||
|
, "src/usocket.c"
|
||||||
|
, "src/serial.c" },
|
||||||
|
defines = defines[plat],
|
||||||
|
incdir = "/src"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
if plat == "win32"
|
||||||
|
or plat == "mingw32"
|
||||||
|
then
|
||||||
|
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c"
|
||||||
|
modules["socket.core"].libraries = { "ws2_32" }
|
||||||
|
end
|
||||||
|
return { modules = modules }
|
||||||
end
|
end
|
||||||
|
|
||||||
build = {
|
build = {
|
||||||
type = "builtin",
|
type = "builtin",
|
||||||
platforms = {
|
platforms = {
|
||||||
unix = make_plat("unix"),
|
unix = make_plat("unix"),
|
||||||
macosx = make_plat("macosx"),
|
macosx = make_plat("macosx"),
|
||||||
haiku = make_plat("haiku"),
|
haiku = make_plat("haiku"),
|
||||||
win32 = make_plat("win32"),
|
win32 = make_plat("win32"),
|
||||||
mingw32 = make_plat("mingw32")
|
mingw32 = make_plat("mingw32")
|
||||||
},
|
},
|
||||||
copy_directories = { "doc", "samples", "etc", "test" }
|
copy_directories = {
|
||||||
|
"doc"
|
||||||
|
, "samples"
|
||||||
|
, "etc"
|
||||||
|
, "test" }
|
||||||
}
|
}
|
||||||
|
134
rockspec/luasocket-scm-2.rockspec
Normal file
134
rockspec/luasocket-scm-2.rockspec
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
package = "LuaSocket"
|
||||||
|
version = "scm-2"
|
||||||
|
source = {
|
||||||
|
url = "git://github.com/diegonehab/luasocket.git"
|
||||||
|
, branch="master"
|
||||||
|
}
|
||||||
|
description = {
|
||||||
|
summary = "Network support for the Lua language",
|
||||||
|
detailed = [[
|
||||||
|
LuaSocket is a Lua extension library that is composed by two parts: a C core
|
||||||
|
that provides support for the TCP and UDP transport layers, and a set of Lua
|
||||||
|
modules that add support for functionality commonly needed by applications
|
||||||
|
that deal with the Internet.
|
||||||
|
]],
|
||||||
|
homepage = "http://luaforge.net/projects/luasocket/",
|
||||||
|
license = "MIT"
|
||||||
|
}
|
||||||
|
dependencies = {
|
||||||
|
"lua >= 5.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
local function make_plat(plat)
|
||||||
|
local defines = {
|
||||||
|
unix = {
|
||||||
|
"LUASOCKET_DEBUG"
|
||||||
|
},
|
||||||
|
macosx = {
|
||||||
|
"LUASOCKET_DEBUG",
|
||||||
|
"UNIX_HAS_SUN_LEN"
|
||||||
|
},
|
||||||
|
win32 = {
|
||||||
|
"LUASOCKET_DEBUG",
|
||||||
|
"NDEBUG"
|
||||||
|
},
|
||||||
|
mingw32 = {
|
||||||
|
"LUASOCKET_DEBUG",
|
||||||
|
"LUASOCKET_INET_PTON",
|
||||||
|
"WINVER=0x0501"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
local modules = {
|
||||||
|
["socket.core"] = {
|
||||||
|
sources = {
|
||||||
|
"src/luasocket.c"
|
||||||
|
, "src/timeout.c"
|
||||||
|
, "src/buffer.c"
|
||||||
|
, "src/io.c"
|
||||||
|
, "src/auxiliar.c"
|
||||||
|
, "src/options.c"
|
||||||
|
, "src/inet.c"
|
||||||
|
, "src/except.c"
|
||||||
|
, "src/select.c"
|
||||||
|
, "src/tcp.c"
|
||||||
|
, "src/udp.c"
|
||||||
|
, "src/compat.c" },
|
||||||
|
defines = defines[plat],
|
||||||
|
incdir = "/src"
|
||||||
|
},
|
||||||
|
["mime.core"] = {
|
||||||
|
sources = { "src/mime.c", "src/compat.c" },
|
||||||
|
defines = defines[plat],
|
||||||
|
incdir = "/src"
|
||||||
|
},
|
||||||
|
["socket.http"] = "src/http.lua",
|
||||||
|
["socket.url"] = "src/url.lua",
|
||||||
|
["socket.tp"] = "src/tp.lua",
|
||||||
|
["socket.ftp"] = "src/ftp.lua",
|
||||||
|
["socket.headers"] = "src/headers.lua",
|
||||||
|
["socket.smtp"] = "src/smtp.lua",
|
||||||
|
ltn12 = "src/ltn12.lua",
|
||||||
|
socket = "src/socket.lua",
|
||||||
|
mime = "src/mime.lua"
|
||||||
|
}
|
||||||
|
if plat == "unix"
|
||||||
|
or plat == "macosx"
|
||||||
|
or plat == "haiku"
|
||||||
|
then
|
||||||
|
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/usocket.c"
|
||||||
|
if plat == "haiku" then
|
||||||
|
modules["socket.core"].libraries = {"network"}
|
||||||
|
end
|
||||||
|
modules["socket.unix"] = {
|
||||||
|
sources = {
|
||||||
|
"src/buffer.c"
|
||||||
|
, "src/compat.c"
|
||||||
|
, "src/auxiliar.c"
|
||||||
|
, "src/options.c"
|
||||||
|
, "src/timeout.c"
|
||||||
|
, "src/io.c"
|
||||||
|
, "src/usocket.c"
|
||||||
|
, "src/unix.c"
|
||||||
|
, "src/unixdgram.c"
|
||||||
|
, "src/unixstream.c" },
|
||||||
|
defines = defines[plat],
|
||||||
|
incdir = "/src"
|
||||||
|
}
|
||||||
|
modules["socket.serial"] = {
|
||||||
|
sources = {
|
||||||
|
"src/buffer.c"
|
||||||
|
, "src/compat.c"
|
||||||
|
, "src/auxiliar.c"
|
||||||
|
, "src/options.c"
|
||||||
|
, "src/timeout.c"
|
||||||
|
, "src/io.c"
|
||||||
|
, "src/usocket.c"
|
||||||
|
, "src/serial.c" },
|
||||||
|
defines = defines[plat],
|
||||||
|
incdir = "/src"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
if plat == "win32"
|
||||||
|
or plat == "mingw32"
|
||||||
|
then
|
||||||
|
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c"
|
||||||
|
modules["socket.core"].libraries = { "ws2_32" }
|
||||||
|
end
|
||||||
|
return { modules = modules }
|
||||||
|
end
|
||||||
|
|
||||||
|
build = {
|
||||||
|
type = "builtin",
|
||||||
|
platforms = {
|
||||||
|
unix = make_plat("unix"),
|
||||||
|
macosx = make_plat("macosx"),
|
||||||
|
haiku = make_plat("haiku"),
|
||||||
|
win32 = make_plat("win32"),
|
||||||
|
mingw32 = make_plat("mingw32")
|
||||||
|
},
|
||||||
|
copy_directories = {
|
||||||
|
"doc"
|
||||||
|
, "samples"
|
||||||
|
, "etc"
|
||||||
|
, "test" }
|
||||||
|
}
|
134
socket.vcxproj
134
socket.vcxproj
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
@ -32,98 +32,6 @@
|
|||||||
<ClCompile Include="src\udp.c" />
|
<ClCompile Include="src\udp.c" />
|
||||||
<ClCompile Include="src\wsocket.c" />
|
<ClCompile Include="src\wsocket.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<CustomBuild Include="src\ltn12.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)</Command>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\socket.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)</Command>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\%(Filename)%(Extension)</Outputs>
|
|
||||||
</CustomBuild>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<CustomBuild Include="src\ftp.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\headers.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\http.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\smtp.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\tp.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\url.lua">
|
|
||||||
<FileType>Document</FileType>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LUABIN_PATH)$(Configuration)\socket\%(Filename)%(Extension)</Outputs>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(LUABIN_PATH)$(Platform)\$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(LUABIN_PATH)$(Configuration)\socket</Command>
|
|
||||||
</CustomBuild>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}</ProjectGuid>
|
<ProjectGuid>{66E3CE14-884D-4AEA-9F20-15A0BEAF8C5A}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
@ -131,22 +39,22 @@
|
|||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
@ -177,7 +85,7 @@
|
|||||||
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
|
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<OutDir>$(LUALIB_PATH)$(Configuration)\socket\</OutDir>
|
<OutDir>$(Configuration)\socket\</OutDir>
|
||||||
<IntDir>$(Configuration)\</IntDir>
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetName>core</TargetName>
|
<TargetName>core</TargetName>
|
||||||
@ -185,23 +93,23 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetName>core</TargetName>
|
<TargetName>core</TargetName>
|
||||||
<OutDir>$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\</OutDir>
|
<OutDir>$(Platform)\$(Configuration)\socket\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(LUALIB_PATH)$(Configuration)\socket\</OutDir>
|
<OutDir>$(Configuration)\socket\</OutDir>
|
||||||
<IntDir>$(Configuration)\</IntDir>
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetName>core</TargetName>
|
<TargetName>core</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<OutDir>$(LUABIN_PATH)$(Platform)\$(Configuration)\socket\</OutDir>
|
<OutDir>$(Platform)\$(Configuration)\socket\</OutDir>
|
||||||
<TargetName>core</TargetName>
|
<TargetName>core</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LUAINC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUASOCKET_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUASOCKET_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
@ -212,9 +120,9 @@
|
|||||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>$(LUALIB);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(LUALIBNAME);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>$(LUALIB_PATH)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LUALIB);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile>
|
<ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -228,7 +136,7 @@
|
|||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LUAINC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUASOCKET_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;LUASOCKET_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
@ -239,9 +147,9 @@
|
|||||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>$(LUALIB);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(LUALIBNAME);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>$(LUALIB_PATH)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LUALIB);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile>
|
<ProgramDatabaseFile>$(OutDir)mime.pdb</ProgramDatabaseFile>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -253,7 +161,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LUAINC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<PrecompiledHeader />
|
<PrecompiledHeader />
|
||||||
@ -262,9 +170,9 @@
|
|||||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>$(LUALIB);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(LUALIBNAME);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>$(LUALIB_PATH)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LUALIB);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
@ -277,7 +185,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>$(LUAINC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LUAINC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
@ -288,9 +196,9 @@
|
|||||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>$(LUALIB);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(LUALIBNAME);ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
|
||||||
<AdditionalLibraryDirectories>$(LUALIB_PATH)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LUALIB);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="src\auxiliar.c" />
|
|
||||||
<ClCompile Include="src\buffer.c" />
|
|
||||||
<ClCompile Include="src\except.c" />
|
|
||||||
<ClCompile Include="src\inet.c" />
|
|
||||||
<ClCompile Include="src\io.c" />
|
|
||||||
<ClCompile Include="src\luasocket.c" />
|
|
||||||
<ClCompile Include="src\options.c" />
|
|
||||||
<ClCompile Include="src\select.c" />
|
|
||||||
<ClCompile Include="src\tcp.c" />
|
|
||||||
<ClCompile Include="src\timeout.c" />
|
|
||||||
<ClCompile Include="src\udp.c" />
|
|
||||||
<ClCompile Include="src\wsocket.c" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<CustomBuild Include="src\ltn12.lua">
|
|
||||||
<Filter>cdir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\socket.lua">
|
|
||||||
<Filter>cdir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\ftp.lua">
|
|
||||||
<Filter>ldir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\headers.lua">
|
|
||||||
<Filter>ldir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\http.lua">
|
|
||||||
<Filter>ldir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\smtp.lua">
|
|
||||||
<Filter>ldir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\tp.lua">
|
|
||||||
<Filter>ldir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
<CustomBuild Include="src\url.lua">
|
|
||||||
<Filter>ldir</Filter>
|
|
||||||
</CustomBuild>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="cdir">
|
|
||||||
<UniqueIdentifier>{b053460d-5439-4e3a-a2eb-c31a95b5691f}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="ldir">
|
|
||||||
<UniqueIdentifier>{b301b82c-37cb-4e05-9333-194e92ed7a62}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -2,14 +2,11 @@
|
|||||||
* Auxiliar routines for class hierarchy manipulation
|
* Auxiliar routines for class hierarchy manipulation
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
#include "luasocket.h"
|
||||||
|
#include "auxiliar.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "auxiliar.h"
|
|
||||||
|
|
||||||
/*=========================================================================*\
|
|
||||||
* Exported functions
|
|
||||||
\*=========================================================================*/
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes the module
|
* Initializes the module
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
@ -155,4 +152,3 @@ int auxiliar_typeerror (lua_State *L, int narg, const char *tname) {
|
|||||||
luaL_typename(L, narg));
|
luaL_typename(L, narg));
|
||||||
return luaL_argerror(L, narg, msg);
|
return luaL_argerror(L, narg, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,20 +29,26 @@
|
|||||||
* reverse mapping are done using lauxlib.
|
* reverse mapping are done using lauxlib.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int auxiliar_open(lua_State *L);
|
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);
|
||||||
|
int auxiliar_tostring(lua_State *L);
|
||||||
void auxiliar_add2group(lua_State *L, const char *classname, const char *group);
|
void auxiliar_add2group(lua_State *L, const char *classname, const char *group);
|
||||||
void auxiliar_setclass(lua_State *L, const char *classname, int objidx);
|
int auxiliar_checkboolean(lua_State *L, int objidx);
|
||||||
void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx);
|
void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx);
|
||||||
void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx);
|
void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx);
|
||||||
void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx);
|
void auxiliar_setclass(lua_State *L, const char *classname, int objidx);
|
||||||
void *auxiliar_getgroupudata(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);
|
void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx);
|
||||||
int auxiliar_tostring(lua_State *L);
|
|
||||||
int auxiliar_typeerror(lua_State *L, int narg, const char *tname);
|
int auxiliar_typeerror(lua_State *L, int narg, const char *tname);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* AUXILIAR_H */
|
#endif /* AUXILIAR_H */
|
||||||
|
@ -2,10 +2,7 @@
|
|||||||
* Input/Output interface for Lua programs
|
* Input/Output interface for Lua programs
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
|
15
src/buffer.h
15
src/buffer.h
@ -15,8 +15,7 @@
|
|||||||
* The module is built on top of the I/O abstraction defined in io.h and the
|
* 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.
|
* timeout management is done with the timeout.h interface.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
|
|
||||||
@ -34,12 +33,20 @@ typedef struct t_buffer_ {
|
|||||||
} t_buffer;
|
} t_buffer;
|
||||||
typedef t_buffer *p_buffer;
|
typedef t_buffer *p_buffer;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int buffer_open(lua_State *L);
|
int buffer_open(lua_State *L);
|
||||||
void buffer_init(p_buffer buf, p_io io, p_timeout tm);
|
void buffer_init(p_buffer buf, p_io io, p_timeout tm);
|
||||||
int buffer_meth_send(lua_State *L, p_buffer buf);
|
|
||||||
int buffer_meth_receive(lua_State *L, p_buffer buf);
|
|
||||||
int buffer_meth_getstats(lua_State *L, p_buffer buf);
|
int buffer_meth_getstats(lua_State *L, p_buffer buf);
|
||||||
int buffer_meth_setstats(lua_State *L, p_buffer buf);
|
int buffer_meth_setstats(lua_State *L, p_buffer buf);
|
||||||
|
int buffer_meth_send(lua_State *L, p_buffer buf);
|
||||||
|
int buffer_meth_receive(lua_State *L, p_buffer buf);
|
||||||
int buffer_isempty(p_buffer buf);
|
int buffer_isempty(p_buffer buf);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* BUF_H */
|
#endif /* BUF_H */
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
#include "luasocket.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
#if LUA_VERSION_NUM==501
|
#if LUA_VERSION_NUM==501
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Adapted from Lua 5.2
|
** Adapted from Lua 5.2
|
||||||
*/
|
*/
|
||||||
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
|
void luasocket_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
|
||||||
luaL_checkstack(L, nup+1, "too many upvalues");
|
luaL_checkstack(L, nup+1, "too many upvalues");
|
||||||
for (; l->name != NULL; l++) { /* fill the table with given functions */
|
for (; l->name != NULL; l++) { /* fill the table with given functions */
|
||||||
int i;
|
int i;
|
||||||
@ -20,7 +22,7 @@ void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
|
|||||||
/*
|
/*
|
||||||
** Duplicated from Lua 5.2
|
** Duplicated from Lua 5.2
|
||||||
*/
|
*/
|
||||||
void *luaL_testudata (lua_State *L, int ud, const char *tname) {
|
void *luasocket_testudata (lua_State *L, int ud, const char *tname) {
|
||||||
void *p = lua_touserdata(L, ud);
|
void *p = lua_touserdata(L, ud);
|
||||||
if (p != NULL) { /* value is a userdata? */
|
if (p != NULL) { /* value is a userdata? */
|
||||||
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
|
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
|
||||||
|
20
src/compat.h
20
src/compat.h
@ -1,12 +1,22 @@
|
|||||||
#ifndef COMPAT_H
|
#ifndef COMPAT_H
|
||||||
#define COMPAT_H
|
#define COMPAT_H
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
|
|
||||||
#if LUA_VERSION_NUM==501
|
#if LUA_VERSION_NUM==501
|
||||||
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
|
|
||||||
void *luaL_testudata ( lua_State *L, int arg, const char *tname);
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void luasocket_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
|
||||||
|
void *luasocket_testudata ( lua_State *L, int arg, const char *tname);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define luaL_setfuncs luasocket_setfuncs
|
||||||
|
#define luaL_testudata luasocket_testudata
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,13 +2,9 @@
|
|||||||
* Simple exception support
|
* Simple exception support
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <stdio.h>
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "except.h"
|
#include "except.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#if LUA_VERSION_NUM < 502
|
#if LUA_VERSION_NUM < 502
|
||||||
#define lua_pcallk(L, na, nr, err, ctx, cont) \
|
#define lua_pcallk(L, na, nr, err, ctx, cont) \
|
||||||
|
10
src/except.h
10
src/except.h
@ -31,8 +31,16 @@
|
|||||||
* exceptions on error, but that don't interrupt the user script.
|
* exceptions on error, but that don't interrupt the user script.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int except_open(lua_State *L);
|
int except_open(lua_State *L);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
80
src/http.lua
80
src/http.lua
@ -26,11 +26,24 @@ _M.TIMEOUT = 60
|
|||||||
-- user agent field sent in request
|
-- user agent field sent in request
|
||||||
_M.USERAGENT = socket._VERSION
|
_M.USERAGENT = socket._VERSION
|
||||||
|
|
||||||
-- supported schemes
|
-- supported schemes and their particulars
|
||||||
local SCHEMES = { ["http"] = true }
|
local SCHEMES = {
|
||||||
-- default port for document retrieval
|
http = {
|
||||||
local PORT = 80
|
port = 80
|
||||||
|
, create = function(t)
|
||||||
|
return socket.tcp end }
|
||||||
|
, https = {
|
||||||
|
port = 443
|
||||||
|
, create = function(t)
|
||||||
|
local https = assert(
|
||||||
|
require("ssl.https"), 'LuaSocket: LuaSec not found')
|
||||||
|
local tcp = assert(
|
||||||
|
https.tcp, 'LuaSocket: Function tcp() not available from LuaSec')
|
||||||
|
return tcp(t) end }}
|
||||||
|
|
||||||
|
-- default scheme and port for document retrieval
|
||||||
|
local SCHEME = 'http'
|
||||||
|
local PORT = SCHEMES[SCHEME].port
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Reads MIME headers from a connection, unfolding where needed
|
-- Reads MIME headers from a connection, unfolding where needed
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@ -111,13 +124,13 @@ local metat = { __index = {} }
|
|||||||
|
|
||||||
function _M.open(host, port, create)
|
function _M.open(host, port, create)
|
||||||
-- create socket with user connect function, or with default
|
-- create socket with user connect function, or with default
|
||||||
local c = socket.try((create or socket.tcp)())
|
local c = socket.try(create())
|
||||||
local h = base.setmetatable({ c = c }, metat)
|
local h = base.setmetatable({ c = c }, metat)
|
||||||
-- create finalized try
|
-- create finalized try
|
||||||
h.try = socket.newtry(function() h:close() end)
|
h.try = socket.newtry(function() h:close() end)
|
||||||
-- set timeout before connecting
|
-- set timeout before connecting
|
||||||
h.try(c:settimeout(_M.TIMEOUT))
|
h.try(c:settimeout(_M.TIMEOUT))
|
||||||
h.try(c:connect(host, port or PORT))
|
h.try(c:connect(host, port))
|
||||||
-- here everything worked
|
-- here everything worked
|
||||||
return h
|
return h
|
||||||
end
|
end
|
||||||
@ -147,10 +160,15 @@ function metat.__index:sendbody(headers, source, step)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function metat.__index:receivestatusline()
|
function metat.__index:receivestatusline()
|
||||||
local status = self.try(self.c:receive(5))
|
local status,ec = self.try(self.c:receive(5))
|
||||||
-- identify HTTP/0.9 responses, which do not contain a status line
|
-- identify HTTP/0.9 responses, which do not contain a status line
|
||||||
-- this is just a heuristic, but is what the RFC recommends
|
-- this is just a heuristic, but is what the RFC recommends
|
||||||
if status ~= "HTTP/" then return nil, status end
|
if status ~= "HTTP/" then
|
||||||
|
if ec == "timeout" then
|
||||||
|
return 408
|
||||||
|
end
|
||||||
|
return nil, status
|
||||||
|
end
|
||||||
-- otherwise proceed reading a status line
|
-- otherwise proceed reading a status line
|
||||||
status = self.try(self.c:receive("*l", status))
|
status = self.try(self.c:receive("*l", status))
|
||||||
local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)"))
|
local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)"))
|
||||||
@ -212,7 +230,10 @@ end
|
|||||||
|
|
||||||
local function adjustheaders(reqt)
|
local function adjustheaders(reqt)
|
||||||
-- default headers
|
-- default headers
|
||||||
local host = string.gsub(reqt.authority, "^.-@", "")
|
local host = reqt.host
|
||||||
|
local port = tostring(reqt.port)
|
||||||
|
if port ~= tostring(SCHEMES[reqt.scheme].port) then
|
||||||
|
host = host .. ':' .. port end
|
||||||
local lower = {
|
local lower = {
|
||||||
["user-agent"] = _M.USERAGENT,
|
["user-agent"] = _M.USERAGENT,
|
||||||
["host"] = host,
|
["host"] = host,
|
||||||
@ -243,10 +264,8 @@ end
|
|||||||
|
|
||||||
-- default url parts
|
-- default url parts
|
||||||
local default = {
|
local default = {
|
||||||
host = "",
|
path ="/"
|
||||||
port = PORT,
|
, scheme = "http"
|
||||||
path ="/",
|
|
||||||
scheme = "http"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local function adjustrequest(reqt)
|
local function adjustrequest(reqt)
|
||||||
@ -254,8 +273,13 @@ local function adjustrequest(reqt)
|
|||||||
local nreqt = reqt.url and url.parse(reqt.url, default) or {}
|
local nreqt = reqt.url and url.parse(reqt.url, default) or {}
|
||||||
-- explicit components override url
|
-- explicit components override url
|
||||||
for i,v in base.pairs(reqt) do nreqt[i] = v end
|
for i,v in base.pairs(reqt) do nreqt[i] = v end
|
||||||
if nreqt.port == "" then nreqt.port = PORT end
|
-- default to scheme particulars
|
||||||
if not (nreqt.host and nreqt.host ~= "") then
|
local schemedefs, host, port, method
|
||||||
|
= SCHEMES[nreqt.scheme], nreqt.host, nreqt.port, nreqt.method
|
||||||
|
if not nreqt.create then nreqt.create = schemedefs.create(nreqt) end
|
||||||
|
if not (port and port ~= '') then nreqt.port = schemedefs.port end
|
||||||
|
if not (method and method ~= '') then nreqt.method = 'GET' end
|
||||||
|
if not (host and host ~= "") then
|
||||||
socket.try(nil, "invalid host '" .. base.tostring(nreqt.host) .. "'")
|
socket.try(nil, "invalid host '" .. base.tostring(nreqt.host) .. "'")
|
||||||
end
|
end
|
||||||
-- compute uri if user hasn't overriden
|
-- compute uri if user hasn't overriden
|
||||||
@ -272,12 +296,16 @@ local function shouldredirect(reqt, code, headers)
|
|||||||
if not location then return false end
|
if not location then return false end
|
||||||
location = string.gsub(location, "%s", "")
|
location = string.gsub(location, "%s", "")
|
||||||
if location == "" then return false end
|
if location == "" then return false end
|
||||||
local scheme = string.match(location, "^([%w][%w%+%-%.]*)%:")
|
local scheme = url.parse(location).scheme
|
||||||
if scheme and not SCHEMES[scheme] then return false end
|
if scheme and (not SCHEMES[scheme]) then return false end
|
||||||
|
-- avoid https downgrades
|
||||||
|
if ('https' == reqt.scheme) and ('https' ~= scheme) then return false end
|
||||||
return (reqt.redirect ~= false) and
|
return (reqt.redirect ~= false) and
|
||||||
(code == 301 or code == 302 or code == 303 or code == 307) and
|
(code == 301 or code == 302 or code == 303 or code == 307) and
|
||||||
(not reqt.method or reqt.method == "GET" or reqt.method == "HEAD")
|
(not reqt.method or reqt.method == "GET" or reqt.method == "HEAD")
|
||||||
and (not reqt.nredirects or reqt.nredirects < 5)
|
and ((false == reqt.maxredirects)
|
||||||
|
or ((reqt.nredirects or 0)
|
||||||
|
< (reqt.maxredirects or 5)))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function shouldreceivebody(reqt, code)
|
local function shouldreceivebody(reqt, code)
|
||||||
@ -291,14 +319,21 @@ end
|
|||||||
local trequest, tredirect
|
local trequest, tredirect
|
||||||
|
|
||||||
--[[local]] function tredirect(reqt, location)
|
--[[local]] function tredirect(reqt, location)
|
||||||
|
-- the RFC says the redirect URL has to be absolute, but some
|
||||||
|
-- servers do not respect that
|
||||||
|
local newurl = url.absolute(reqt.url, location)
|
||||||
|
-- if switching schemes, reset port and create function
|
||||||
|
if url.parse(newurl).scheme ~= reqt.scheme then
|
||||||
|
reqt.port = nil
|
||||||
|
reqt.create = nil end
|
||||||
|
-- make new request
|
||||||
local result, code, headers, status = trequest {
|
local result, code, headers, status = trequest {
|
||||||
-- the RFC says the redirect URL has to be absolute, but some
|
url = newurl,
|
||||||
-- servers do not respect that
|
|
||||||
url = url.absolute(reqt.url, location),
|
|
||||||
source = reqt.source,
|
source = reqt.source,
|
||||||
sink = reqt.sink,
|
sink = reqt.sink,
|
||||||
headers = reqt.headers,
|
headers = reqt.headers,
|
||||||
proxy = reqt.proxy,
|
proxy = reqt.proxy,
|
||||||
|
maxredirects = reqt.maxredirects,
|
||||||
nredirects = (reqt.nredirects or 0) + 1,
|
nredirects = (reqt.nredirects or 0) + 1,
|
||||||
create = reqt.create
|
create = reqt.create
|
||||||
}
|
}
|
||||||
@ -325,6 +360,8 @@ end
|
|||||||
if not code then
|
if not code then
|
||||||
h:receive09body(status, nreqt.sink, nreqt.step)
|
h:receive09body(status, nreqt.sink, nreqt.step)
|
||||||
return 1, 200
|
return 1, 200
|
||||||
|
elseif code == 408 then
|
||||||
|
return 1, code
|
||||||
end
|
end
|
||||||
local headers
|
local headers
|
||||||
-- ignore any 100-continue messages
|
-- ignore any 100-continue messages
|
||||||
@ -379,4 +416,5 @@ _M.request = socket.protect(function(reqt, body)
|
|||||||
else return trequest(reqt) end
|
else return trequest(reqt) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
_M.schemes = SCHEMES
|
||||||
return _M
|
return _M
|
||||||
|
12
src/inet.c
12
src/inet.c
@ -2,16 +2,13 @@
|
|||||||
* Internet domain functions
|
* Internet domain functions
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
#include "luasocket.h"
|
||||||
|
#include "inet.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "inet.h"
|
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Internal function prototypes.
|
* Internal function prototypes.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
@ -32,9 +29,6 @@ static luaL_Reg func[] = {
|
|||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*=========================================================================*\
|
|
||||||
* Exported functions
|
|
||||||
\*=========================================================================*/
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes module
|
* Initializes module
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
|
26
src/inet.h
26
src/inet.h
@ -14,7 +14,7 @@
|
|||||||
*
|
*
|
||||||
* The Lua functions toip and tohostname are also implemented here.
|
* The Lua functions toip and tohostname are also implemented here.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
|
|
||||||
@ -22,21 +22,23 @@
|
|||||||
#define LUASOCKET_INET_ATON
|
#define LUASOCKET_INET_ATON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int inet_open(lua_State *L);
|
int inet_open(lua_State *L);
|
||||||
|
|
||||||
const char *inet_trycreate(p_socket ps, int family, int type, int protocol);
|
int inet_optfamily(lua_State* L, int narg, const char* def);
|
||||||
const char *inet_tryconnect(p_socket ps, int *family, const char *address,
|
int inet_optsocktype(lua_State* L, int narg, const char* def);
|
||||||
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 family);
|
int inet_meth_getpeername(lua_State *L, p_socket ps, int family);
|
||||||
int inet_meth_getsockname(lua_State *L, p_socket ps, int family);
|
int inet_meth_getsockname(lua_State *L, p_socket ps, int family);
|
||||||
|
|
||||||
int inet_optfamily(lua_State* L, int narg, const char* def);
|
const char *inet_trycreate(p_socket ps, int family, int type, int protocol);
|
||||||
int inet_optsocktype(lua_State* L, int narg, const char* def);
|
const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm);
|
||||||
|
const char *inet_tryconnect(p_socket ps, int *family, const char *address, const char *serv, p_timeout tm, struct addrinfo *connecthints);
|
||||||
|
const char *inet_tryaccept(p_socket server, int family, p_socket client, p_timeout tm);
|
||||||
|
const char *inet_trybind(p_socket ps, int *family, const char *address, const char *serv, struct addrinfo *bindhints);
|
||||||
|
|
||||||
#ifdef LUASOCKET_INET_ATON
|
#ifdef LUASOCKET_INET_ATON
|
||||||
int inet_aton(const char *cp, struct in_addr *inp);
|
int inet_aton(const char *cp, struct in_addr *inp);
|
||||||
@ -47,4 +49,8 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
|
|||||||
int inet_pton(int af, const char *src, void *dst);
|
int inet_pton(int af, const char *src, void *dst);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* INET_H */
|
#endif /* INET_H */
|
||||||
|
4
src/io.c
4
src/io.c
@ -2,11 +2,9 @@
|
|||||||
* Input/Output abstraction
|
* Input/Output abstraction
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
#include "luasocket.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
/*=========================================================================*\
|
|
||||||
* Exported functions
|
|
||||||
\*=========================================================================*/
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes C structure
|
* Initializes C structure
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
|
13
src/io.h
13
src/io.h
@ -12,9 +12,7 @@
|
|||||||
* The module socket.h implements this interface, and thus the module tcp.h
|
* The module socket.h implements this interface, and thus the module tcp.h
|
||||||
* is very simple.
|
* is very simple.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <stdio.h>
|
#include "luasocket.h"
|
||||||
#include "lua.h"
|
|
||||||
|
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
|
|
||||||
/* IO error codes */
|
/* IO error codes */
|
||||||
@ -58,8 +56,15 @@ typedef struct t_io_ {
|
|||||||
} t_io;
|
} t_io;
|
||||||
typedef t_io *p_io;
|
typedef t_io *p_io;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx);
|
void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx);
|
||||||
const char *io_strerror(int err);
|
const char *io_strerror(int err);
|
||||||
|
|
||||||
#endif /* IO_H */
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* IO_H */
|
||||||
|
12
src/luasocket.c
Normal file → Executable file
12
src/luasocket.c
Normal file → Executable file
@ -12,16 +12,6 @@
|
|||||||
* standard Lua read and write functions.
|
* standard Lua read and write functions.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
/*=========================================================================*\
|
|
||||||
* Standard include files
|
|
||||||
\*=========================================================================*/
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
/*=========================================================================*\
|
|
||||||
* LuaSocket includes
|
|
||||||
\*=========================================================================*/
|
|
||||||
#include "luasocket.h"
|
#include "luasocket.h"
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "except.h"
|
#include "except.h"
|
||||||
@ -64,7 +54,7 @@ static luaL_Reg func[] = {
|
|||||||
* Skip a few arguments
|
* Skip a few arguments
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int global_skip(lua_State *L) {
|
static int global_skip(lua_State *L) {
|
||||||
int amount = luaL_checkinteger(L, 1);
|
int amount = (int) luaL_checkinteger(L, 1);
|
||||||
int ret = lua_gettop(L) - amount - 1;
|
int ret = lua_gettop(L) - amount - 1;
|
||||||
return ret >= 0 ? ret : 0;
|
return ret >= 0 ? ret : 0;
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,8 @@
|
|||||||
* Diego Nehab
|
* Diego Nehab
|
||||||
* 9/11/1999
|
* 9/11/1999
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------* \
|
||||||
* Current socket library version
|
* Current socket library version
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
#define LUASOCKET_VERSION "LuaSocket 3.0-rc1"
|
#define LUASOCKET_VERSION "LuaSocket 3.0-rc1"
|
||||||
@ -18,8 +17,16 @@
|
|||||||
* This macro prefixes all exported API functions
|
* This macro prefixes all exported API functions
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
#ifndef LUASOCKET_API
|
#ifndef LUASOCKET_API
|
||||||
#define LUASOCKET_API extern
|
#ifdef _WIN32
|
||||||
|
#define LUASOCKET_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define LUASOCKET_API __attribute__ ((visibility ("default")))
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "lua.h"
|
||||||
|
#include "lauxlib.h"
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes the library.
|
* Initializes the library.
|
||||||
|
115
src/makefile
Normal file → Executable file
115
src/makefile
Normal file → Executable file
@ -12,7 +12,7 @@
|
|||||||
#
|
#
|
||||||
# make PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw
|
# make PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw
|
||||||
|
|
||||||
# PLAT: linux macosx win32 mingw
|
# PLAT: linux macosx win32 win64 mingw
|
||||||
# platform to build for
|
# platform to build for
|
||||||
PLAT?=linux
|
PLAT?=linux
|
||||||
|
|
||||||
@ -35,7 +35,8 @@ DEBUG?=NODEBUG
|
|||||||
# LUAINC_macosx:
|
# LUAINC_macosx:
|
||||||
# /opt/local/include
|
# /opt/local/include
|
||||||
LUAINC_macosx_base?=/opt/local/include
|
LUAINC_macosx_base?=/opt/local/include
|
||||||
LUAINC_macosx?=$(LUAINC_macosx_base)/lua/$(LUAV)
|
LUAINC_macosx?=$(LUAINC_macosx_base)/lua/$(LUAV) $(LUAINC_macosx_base)/lua$(LUAV) $(LUAINC_macosx_base)/lua-$(LUAV)
|
||||||
|
|
||||||
# FIXME default should this default to fink or to macports?
|
# FIXME default should this default to fink or to macports?
|
||||||
# What happens when more than one Lua version is installed?
|
# What happens when more than one Lua version is installed?
|
||||||
LUAPREFIX_macosx?=/opt/local
|
LUAPREFIX_macosx?=/opt/local
|
||||||
@ -48,7 +49,7 @@ LDIR_macosx?=share/lua/$(LUAV)
|
|||||||
# /usr/local/include/lua$(LUAV)
|
# /usr/local/include/lua$(LUAV)
|
||||||
# where lua headers are found for linux builds
|
# where lua headers are found for linux builds
|
||||||
LUAINC_linux_base?=/usr/include
|
LUAINC_linux_base?=/usr/include
|
||||||
LUAINC_linux?=$(LUAINC_linux_base)/lua/$(LUAV)
|
LUAINC_linux?=$(LUAINC_linux_base)/lua/$(LUAV) $(LUAINC_linux_base)/lua$(LUAV)
|
||||||
LUAPREFIX_linux?=/usr/local
|
LUAPREFIX_linux?=/usr/local
|
||||||
CDIR_linux?=lib/lua/$(LUAV)
|
CDIR_linux?=lib/lua/$(LUAV)
|
||||||
LDIR_linux?=share/lua/$(LUAV)
|
LDIR_linux?=share/lua/$(LUAV)
|
||||||
@ -57,7 +58,7 @@ LDIR_linux?=share/lua/$(LUAV)
|
|||||||
# /usr/local/include/lua$(LUAV)
|
# /usr/local/include/lua$(LUAV)
|
||||||
# where lua headers are found for freebsd builds
|
# where lua headers are found for freebsd builds
|
||||||
LUAINC_freebsd_base?=/usr/local/include/
|
LUAINC_freebsd_base?=/usr/local/include/
|
||||||
LUAINC_freebsd?=$(LUAINC_freebsd_base)/lua$(LUAV)
|
LUAINC_freebsd?=$(LUAINC_freebsd_base)/lua/$(LUAV) $(LUAINC_freebsd_base)/lua$(LUAV)
|
||||||
LUAPREFIX_freebsd?=/usr/local/
|
LUAPREFIX_freebsd?=/usr/local/
|
||||||
CDIR_freebsd?=lib/lua/$(LUAV)
|
CDIR_freebsd?=lib/lua/$(LUAV)
|
||||||
LDIR_freebsd?=share/lua/$(LUAV)
|
LDIR_freebsd?=share/lua/$(LUAV)
|
||||||
@ -66,7 +67,7 @@ LDIR_freebsd?=share/lua/$(LUAV)
|
|||||||
# LUAINC_mingw:
|
# LUAINC_mingw:
|
||||||
# /opt/local/include
|
# /opt/local/include
|
||||||
LUAINC_mingw_base?=/usr/include
|
LUAINC_mingw_base?=/usr/include
|
||||||
LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUAV)
|
LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUAV) $(LUAINC_mingw_base)/lua$(LUAV)
|
||||||
LUALIB_mingw_base?=/usr/bin
|
LUALIB_mingw_base?=/usr/bin
|
||||||
LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUAV)/lua$(subst .,,$(LUAV)).dll
|
LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUAV)/lua$(subst .,,$(LUAV)).dll
|
||||||
LUAPREFIX_mingw?=/usr
|
LUAPREFIX_mingw?=/usr
|
||||||
@ -78,17 +79,28 @@ LDIR_mingw?=lua/$(LUAV)/lua
|
|||||||
# LUALIB_win32:
|
# LUALIB_win32:
|
||||||
# where lua headers and libraries are found for win32 builds
|
# where lua headers and libraries are found for win32 builds
|
||||||
LUAPREFIX_win32?=
|
LUAPREFIX_win32?=
|
||||||
LUAINC_win32?=$(LUAPREFIX_win32)/include/lua/$(LUAV)
|
LUAINC_win32?=$(LUAPREFIX_win32)/include/lua/$(LUAV) $(LUAPREFIX_win32)/include/lua$(LUAV)
|
||||||
PLATFORM_win32?=Release
|
PLATFORM_win32?=Release
|
||||||
CDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)
|
CDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)
|
||||||
LDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)/lua
|
LDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)/lua
|
||||||
LUALIB_win32?=$(LUAPREFIX_win32)/lib/lua/$(LUAV)/$(PLATFORM_win32)
|
LUALIB_win32?=$(LUAPREFIX_win32)/lib/lua/$(LUAV)/$(PLATFORM_win32)
|
||||||
LUALIBNAME_win32?=lua$(subst .,,$(LUAV)).lib
|
LUALIBNAME_win32?=lua$(subst .,,$(LUAV)).lib
|
||||||
|
|
||||||
|
# LUAINC_win64:
|
||||||
|
# LUALIB_win64:
|
||||||
|
# where lua headers and libraries are found for win64 builds
|
||||||
|
LUAPREFIX_win64?=
|
||||||
|
LUAINC_win64?=$(LUAPREFIX_win64)/include/lua/$(LUAV) $(LUAPREFIX_win64)/include/lua$(LUAV)
|
||||||
|
PLATFORM_win64?=x64/Release
|
||||||
|
CDIR_win64?=bin/lua/$(LUAV)/$(PLATFORM_win64)
|
||||||
|
LDIR_win64?=bin/lua/$(LUAV)/$(PLATFORM_win64)/lua
|
||||||
|
LUALIB_win64?=$(LUAPREFIX_win64)/lib/lua/$(LUAV)/$(PLATFORM_win64)
|
||||||
|
LUALIBNAME_win64?=lua$(subst .,,$(LUAV)).lib
|
||||||
|
|
||||||
|
|
||||||
# LUAINC_solaris:
|
# LUAINC_solaris:
|
||||||
LUAINC_solaris_base?=/usr/include
|
LUAINC_solaris_base?=/usr/include
|
||||||
LUAINC_solaris?=$(LUAINC_solaris_base)/lua/$(LUAV)
|
LUAINC_solaris?=$(LUAINC_solaris_base)/lua/$(LUAV) $(LUAINC_solaris_base)/lua$(LUAV)
|
||||||
LUAPREFIX_solaris?=/usr/local
|
LUAPREFIX_solaris?=/usr/local
|
||||||
CDIR_solaris?=lib/lua/$(LUAV)
|
CDIR_solaris?=lib/lua/$(LUAV)
|
||||||
LDIR_solaris?=share/lua/$(LUAV)
|
LDIR_solaris?=share/lua/$(LUAV)
|
||||||
@ -141,7 +153,7 @@ print:
|
|||||||
#------
|
#------
|
||||||
# Supported platforms
|
# Supported platforms
|
||||||
#
|
#
|
||||||
PLATS= macosx linux win32 mingw solaris
|
PLATS= macosx linux win32 win64 mingw solaris
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# Compiler and linker settings
|
# Compiler and linker settings
|
||||||
@ -149,14 +161,10 @@ PLATS= macosx linux win32 mingw solaris
|
|||||||
SO_macosx=so
|
SO_macosx=so
|
||||||
O_macosx=o
|
O_macosx=o
|
||||||
CC_macosx=gcc
|
CC_macosx=gcc
|
||||||
DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN \
|
DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN
|
||||||
-DLUASOCKET_API='__attribute__((visibility("default")))' \
|
CFLAGS_macosx=$(LUAINC:%=-I%) $(DEF) -Wall -O2 -fno-common
|
||||||
-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
|
LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o
|
||||||
LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
|
LD_macosx=gcc
|
||||||
SOCKET_macosx=usocket.o
|
SOCKET_macosx=usocket.o
|
||||||
|
|
||||||
#------
|
#------
|
||||||
@ -165,12 +173,9 @@ SOCKET_macosx=usocket.o
|
|||||||
SO_linux=so
|
SO_linux=so
|
||||||
O_linux=o
|
O_linux=o
|
||||||
CC_linux=gcc
|
CC_linux=gcc
|
||||||
DEF_linux=-DLUASOCKET_$(DEBUG) \
|
DEF_linux=-DLUASOCKET_$(DEBUG)
|
||||||
-DLUASOCKET_API='__attribute__((visibility("default")))' \
|
CFLAGS_linux=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \
|
||||||
-DUNIX_API='__attribute__((visibility("default")))' \
|
-Wimplicit -O2 -ggdb3 -fpic
|
||||||
-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
|
LDFLAGS_linux=-O -shared -fpic -o
|
||||||
LD_linux=gcc
|
LD_linux=gcc
|
||||||
SOCKET_linux=usocket.o
|
SOCKET_linux=usocket.o
|
||||||
@ -181,12 +186,9 @@ SOCKET_linux=usocket.o
|
|||||||
SO_freebsd=so
|
SO_freebsd=so
|
||||||
O_freebsd=o
|
O_freebsd=o
|
||||||
CC_freebsd=gcc
|
CC_freebsd=gcc
|
||||||
DEF_freebsd=-DLUASOCKET_$(DEBUG) \
|
DEF_freebsd=-DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN
|
||||||
-DLUASOCKET_API='__attribute__((visibility("default")))' \
|
CFLAGS_freebsd=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \
|
||||||
-DUNIX_API='__attribute__((visibility("default")))' \
|
-Wimplicit -O2 -ggdb3 -fpic
|
||||||
-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
|
LDFLAGS_freebsd=-O -shared -fpic -o
|
||||||
LD_freebsd=gcc
|
LD_freebsd=gcc
|
||||||
SOCKET_freebsd=usocket.o
|
SOCKET_freebsd=usocket.o
|
||||||
@ -197,12 +199,9 @@ SOCKET_freebsd=usocket.o
|
|||||||
SO_solaris=so
|
SO_solaris=so
|
||||||
O_solaris=o
|
O_solaris=o
|
||||||
CC_solaris=gcc
|
CC_solaris=gcc
|
||||||
DEF_solaris=-DLUASOCKET_$(DEBUG) \
|
DEF_solaris=-DLUASOCKET_$(DEBUG)
|
||||||
-DLUASOCKET_API='__attribute__((visibility("default")))' \
|
CFLAGS_solaris=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \
|
||||||
-DUNIX_API='__attribute__((visibility("default")))' \
|
-Wimplicit -O2 -ggdb3 -fpic
|
||||||
-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
|
LDFLAGS_solaris=-lnsl -lsocket -lresolv -O -shared -fpic -o
|
||||||
LD_solaris=gcc
|
LD_solaris=gcc
|
||||||
SOCKET_solaris=usocket.o
|
SOCKET_solaris=usocket.o
|
||||||
@ -214,10 +213,8 @@ SO_mingw=dll
|
|||||||
O_mingw=o
|
O_mingw=o
|
||||||
CC_mingw=gcc
|
CC_mingw=gcc
|
||||||
DEF_mingw= -DLUASOCKET_INET_PTON -DLUASOCKET_$(DEBUG) \
|
DEF_mingw= -DLUASOCKET_INET_PTON -DLUASOCKET_$(DEBUG) \
|
||||||
-DWINVER=0x0501 -DLUASOCKET_API='__declspec(dllexport)' \
|
-DWINVER=0x0501
|
||||||
-DMIME_API='__declspec(dllexport)'
|
CFLAGS_mingw=$(LUAINC:%=-I%) $(DEF) -Wall -O2 -fno-common
|
||||||
CFLAGS_mingw= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \
|
|
||||||
-fvisibility=hidden
|
|
||||||
LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o
|
LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o
|
||||||
LD_mingw=gcc
|
LD_mingw=gcc
|
||||||
SOCKET_mingw=wsocket.o
|
SOCKET_mingw=wsocket.o
|
||||||
@ -230,19 +227,41 @@ SO_win32=dll
|
|||||||
O_win32=obj
|
O_win32=obj
|
||||||
CC_win32=cl
|
CC_win32=cl
|
||||||
DEF_win32= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \
|
DEF_win32= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \
|
||||||
//D "LUASOCKET_API=__declspec(dllexport)" //D "_CRT_SECURE_NO_WARNINGS" \
|
//D "_CRT_SECURE_NO_WARNINGS" \
|
||||||
//D "_WINDLL" //D "MIME_API=__declspec(dllexport)" \
|
//D "_WINDLL" \
|
||||||
//D "LUASOCKET_$(DEBUG)"
|
//D "LUASOCKET_$(DEBUG)"
|
||||||
CFLAGS_win32=//I "$(LUAINC)" $(DEF) //O2 //Ot //MD //W3 //nologo
|
CFLAGS_win32=$(LUAINC:%=//I "%") $(DEF) //O2 //Ot //MD //W3 //nologo
|
||||||
LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \
|
LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \
|
||||||
//MANIFEST //MANIFESTFILE:"intermediate.manifest" \
|
//MANIFEST //MANIFESTFILE:"intermediate.manifest" \
|
||||||
//MANIFESTUAC:"level='asInvoker' uiAccess='false'" \
|
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" \
|
||||||
//SUBSYSTEM:WINDOWS //OPT:REF //OPT:ICF //DYNAMICBASE:NO \
|
//SUBSYSTEM:WINDOWS //OPT:REF //OPT:ICF //DYNAMICBASE:NO \
|
||||||
//MACHINE:X86 /LIBPATH:"$(shell cmd //c echo $(LUALIB))" \
|
//MACHINE:X86 /LIBPATH:"$(LUALIB)" \
|
||||||
$(LUALIBNAME_win32) ws2_32.lib //OUT:
|
$(LUALIBNAME_win32) ws2_32.lib //OUT:
|
||||||
|
|
||||||
LD_win32=cl
|
LD_win32=cl
|
||||||
SOCKET_win32=wsocket.obj
|
SOCKET_win32=wsocket.obj
|
||||||
|
|
||||||
|
#------
|
||||||
|
# Compiler and linker settings
|
||||||
|
# for Win64
|
||||||
|
SO_win64=dll
|
||||||
|
O_win64=obj
|
||||||
|
CC_win64=cl
|
||||||
|
DEF_win64= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \
|
||||||
|
//D "_CRT_SECURE_NO_WARNINGS" \
|
||||||
|
//D "_WINDLL" \
|
||||||
|
//D "LUASOCKET_$(DEBUG)"
|
||||||
|
CFLAGS_win64=$(LUAINC:%=//I "%") $(DEF) //O2 //Ot //MD //W3 //nologo
|
||||||
|
LDFLAGS_win64= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \
|
||||||
|
//MANIFEST //MANIFESTFILE:"intermediate.manifest" \
|
||||||
|
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" \
|
||||||
|
//SUBSYSTEM:WINDOWS //OPT:REF //OPT:ICF //DYNAMICBASE:NO \
|
||||||
|
/LIBPATH:"$(LUALIB)" \
|
||||||
|
$(LUALIBNAME_win64) ws2_32.lib //OUT:
|
||||||
|
|
||||||
|
LD_win64=cl
|
||||||
|
SOCKET_win64=wsocket.obj
|
||||||
|
|
||||||
.SUFFIXES: .obj
|
.SUFFIXES: .obj
|
||||||
|
|
||||||
.c.obj:
|
.c.obj:
|
||||||
@ -317,6 +336,7 @@ UNIX_OBJS=\
|
|||||||
#
|
#
|
||||||
SERIAL_OBJS=\
|
SERIAL_OBJS=\
|
||||||
buffer.$(O) \
|
buffer.$(O) \
|
||||||
|
compat.$(O) \
|
||||||
auxiliar.$(O) \
|
auxiliar.$(O) \
|
||||||
options.$(O) \
|
options.$(O) \
|
||||||
timeout.$(O) \
|
timeout.$(O) \
|
||||||
@ -355,12 +375,15 @@ macosx:
|
|||||||
win32:
|
win32:
|
||||||
$(MAKE) all PLAT=win32
|
$(MAKE) all PLAT=win32
|
||||||
|
|
||||||
|
win64:
|
||||||
|
$(MAKE) all PLAT=win64
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
$(MAKE) all-unix PLAT=linux
|
$(MAKE) all-unix PLAT=linux
|
||||||
|
|
||||||
mingw:
|
mingw:
|
||||||
$(MAKE) all PLAT=mingw
|
$(MAKE) all PLAT=mingw
|
||||||
|
|
||||||
solaris:
|
solaris:
|
||||||
$(MAKE) all-unix PLAT=solaris
|
$(MAKE) all-unix PLAT=solaris
|
||||||
|
|
||||||
@ -386,7 +409,7 @@ $(UNIX_SO): $(UNIX_OBJS)
|
|||||||
$(SERIAL_SO): $(SERIAL_OBJS)
|
$(SERIAL_SO): $(SERIAL_OBJS)
|
||||||
$(LD) $(SERIAL_OBJS) $(LDFLAGS)$@
|
$(LD) $(SERIAL_OBJS) $(LDFLAGS)$@
|
||||||
|
|
||||||
install:
|
install:
|
||||||
$(INSTALL_DIR) $(INSTALL_TOP_LDIR)
|
$(INSTALL_DIR) $(INSTALL_TOP_LDIR)
|
||||||
$(INSTALL_DATA) $(TO_TOP_LDIR) $(INSTALL_TOP_LDIR)
|
$(INSTALL_DATA) $(TO_TOP_LDIR) $(INSTALL_TOP_LDIR)
|
||||||
$(INSTALL_DIR) $(INSTALL_SOCKET_LDIR)
|
$(INSTALL_DIR) $(INSTALL_SOCKET_LDIR)
|
||||||
|
164
src/mime.c
Normal file → Executable file
164
src/mime.c
Normal file → Executable file
@ -2,13 +2,10 @@
|
|||||||
* MIME support functions
|
* MIME support functions
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "mime.h"
|
#include "mime.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Don't want to trust escape character constants
|
* Don't want to trust escape character constants
|
||||||
@ -30,12 +27,12 @@ static int mime_global_eol(lua_State *L);
|
|||||||
static int mime_global_dot(lua_State *L);
|
static int mime_global_dot(lua_State *L);
|
||||||
|
|
||||||
static size_t dot(int c, size_t state, luaL_Buffer *buffer);
|
static size_t dot(int c, size_t state, luaL_Buffer *buffer);
|
||||||
static void b64setup(UC *base);
|
//static void b64setup(UC *base);
|
||||||
static size_t b64encode(UC c, UC *input, size_t size, luaL_Buffer *buffer);
|
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 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 size_t b64decode(UC c, UC *input, size_t size, luaL_Buffer *buffer);
|
||||||
|
|
||||||
static void qpsetup(UC *class, UC *unbase);
|
//static void qpsetup(UC *class, UC *unbase);
|
||||||
static void qpquote(UC c, luaL_Buffer *buffer);
|
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 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,
|
||||||
@ -58,17 +55,111 @@ static luaL_Reg func[] = {
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Quoted-printable globals
|
* Quoted-printable globals
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static UC qpclass[256];
|
|
||||||
static UC qpbase[] = "0123456789ABCDEF";
|
|
||||||
static UC qpunbase[256];
|
|
||||||
enum {QP_PLAIN, QP_QUOTED, QP_CR, QP_IF_LAST};
|
enum {QP_PLAIN, QP_QUOTED, QP_CR, QP_IF_LAST};
|
||||||
|
|
||||||
|
static const UC qpclass[] = {
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_IF_LAST, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_CR, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_IF_LAST, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_QUOTED, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN, QP_PLAIN,
|
||||||
|
QP_PLAIN, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED,
|
||||||
|
QP_QUOTED, QP_QUOTED, QP_QUOTED, QP_QUOTED
|
||||||
|
};
|
||||||
|
|
||||||
|
static const UC qpbase[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
static const UC qpunbase[] = {
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 10, 11, 12, 13, 14, 15,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 10, 11, 12, 13, 14, 15, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255
|
||||||
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Base64 globals
|
* Base64 globals
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static const UC b64base[] =
|
static const UC b64base[] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
static UC b64unbase[256];
|
|
||||||
|
static const UC b64unbase[] = {
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63,
|
||||||
|
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 0,
|
||||||
|
255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||||
|
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255,
|
||||||
|
255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
|
||||||
|
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
|
||||||
|
51, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
255, 255
|
||||||
|
};
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Exported functions
|
* Exported functions
|
||||||
@ -76,7 +167,7 @@ static UC b64unbase[256];
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes module
|
* Initializes module
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
MIME_API int luaopen_mime_core(lua_State *L)
|
LUASOCKET_API int luaopen_mime_core(lua_State *L)
|
||||||
{
|
{
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
luaL_setfuncs(L, func, 0);
|
luaL_setfuncs(L, func, 0);
|
||||||
@ -85,8 +176,8 @@ MIME_API int luaopen_mime_core(lua_State *L)
|
|||||||
lua_pushstring(L, MIME_VERSION);
|
lua_pushstring(L, MIME_VERSION);
|
||||||
lua_rawset(L, -3);
|
lua_rawset(L, -3);
|
||||||
/* initialize lookup tables */
|
/* initialize lookup tables */
|
||||||
qpsetup(qpclass, qpunbase);
|
// qpsetup(qpclass, qpunbase);
|
||||||
b64setup(b64unbase);
|
// b64setup(b64unbase);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +233,7 @@ static int mime_global_wrp(lua_State *L)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Fill base64 decode map.
|
* Fill base64 decode map.
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
@ -151,7 +243,14 @@ static void b64setup(UC *unbase)
|
|||||||
for (i = 0; i <= 255; i++) unbase[i] = (UC) 255;
|
for (i = 0; i <= 255; i++) unbase[i] = (UC) 255;
|
||||||
for (i = 0; i < 64; i++) unbase[b64base[i]] = (UC) i;
|
for (i = 0; i < 64; i++) unbase[b64base[i]] = (UC) i;
|
||||||
unbase['='] = 0;
|
unbase['='] = 0;
|
||||||
|
|
||||||
|
printf("static const UC b64unbase[] = {\n");
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
printf("%d, ", unbase[i]);
|
||||||
|
}
|
||||||
|
printf("\n}\n;");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Acumulates bytes in input buffer until 3 bytes are available.
|
* Acumulates bytes in input buffer until 3 bytes are available.
|
||||||
@ -345,12 +444,14 @@ static int mime_global_unb64(lua_State *L)
|
|||||||
* 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
|
* Worst case is when we see a space, and wonder if a CRLF is comming
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
|
#if 0
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Split quoted-printable characters into classes
|
* Split quoted-printable characters into classes
|
||||||
* Precompute reverse map for encoding
|
* Precompute reverse map for encoding
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static void qpsetup(UC *cl, UC *unbase)
|
static void qpsetup(UC *cl, UC *unbase)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 256; i++) cl[i] = QP_QUOTED;
|
for (i = 0; i < 256; i++) cl[i] = QP_QUOTED;
|
||||||
for (i = 33; i <= 60; i++) cl[i] = QP_PLAIN;
|
for (i = 33; i <= 60; i++) cl[i] = QP_PLAIN;
|
||||||
@ -367,7 +468,37 @@ static void qpsetup(UC *cl, UC *unbase)
|
|||||||
unbase['c'] = 12; unbase['D'] = 13; unbase['d'] = 13;
|
unbase['c'] = 12; unbase['D'] = 13; unbase['d'] = 13;
|
||||||
unbase['E'] = 14; unbase['e'] = 14; unbase['F'] = 15;
|
unbase['E'] = 14; unbase['e'] = 14; unbase['F'] = 15;
|
||||||
unbase['f'] = 15;
|
unbase['f'] = 15;
|
||||||
|
|
||||||
|
printf("static UC qpclass[] = {");
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
if (i % 6 == 0) {
|
||||||
|
printf("\n ");
|
||||||
|
}
|
||||||
|
switch(cl[i]) {
|
||||||
|
case QP_QUOTED:
|
||||||
|
printf("QP_QUOTED, ");
|
||||||
|
break;
|
||||||
|
case QP_PLAIN:
|
||||||
|
printf("QP_PLAIN, ");
|
||||||
|
break;
|
||||||
|
case QP_CR:
|
||||||
|
printf("QP_CR, ");
|
||||||
|
break;
|
||||||
|
case QP_IF_LAST:
|
||||||
|
printf("QP_IF_LAST, ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n};\n");
|
||||||
|
|
||||||
|
printf("static const UC qpunbase[] = {");
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
int c = qpunbase[i];
|
||||||
|
printf("%d, ", c);
|
||||||
|
}
|
||||||
|
printf("\";\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Output one character in form =XX
|
* Output one character in form =XX
|
||||||
@ -447,7 +578,6 @@ static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer)
|
|||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int mime_global_qp(lua_State *L)
|
static int mime_global_qp(lua_State *L)
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t asize = 0, isize = 0;
|
size_t asize = 0, isize = 0;
|
||||||
UC atom[3];
|
UC atom[3];
|
||||||
const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
|
const UC *input = (const UC *) luaL_optlstring(L, 1, NULL, &isize);
|
||||||
@ -654,7 +784,7 @@ static int eolprocess(int c, int last, const char *marker,
|
|||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int mime_global_eol(lua_State *L)
|
static int mime_global_eol(lua_State *L)
|
||||||
{
|
{
|
||||||
int ctx = luaL_checkinteger(L, 1);
|
int ctx = (int) luaL_checkinteger(L, 1);
|
||||||
size_t isize = 0;
|
size_t isize = 0;
|
||||||
const char *input = luaL_optlstring(L, 2, NULL, &isize);
|
const char *input = luaL_optlstring(L, 2, NULL, &isize);
|
||||||
const char *last = input + isize;
|
const char *last = input + isize;
|
||||||
|
11
src/mime.h
11
src/mime.h
@ -8,7 +8,7 @@
|
|||||||
* and formatting conforming to RFC 2045. It is used by mime.lua, which
|
* and formatting conforming to RFC 2045. It is used by mime.lua, which
|
||||||
* provide a higher level interface to this functionality.
|
* provide a higher level interface to this functionality.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Current MIME library version
|
* Current MIME library version
|
||||||
@ -17,13 +17,6 @@
|
|||||||
#define MIME_COPYRIGHT "Copyright (C) 2004-2013 Diego Nehab"
|
#define MIME_COPYRIGHT "Copyright (C) 2004-2013 Diego Nehab"
|
||||||
#define MIME_AUTHORS "Diego Nehab"
|
#define MIME_AUTHORS "Diego Nehab"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
LUASOCKET_API int luaopen_mime_core(lua_State *L);
|
||||||
* This macro prefixes all exported API functions
|
|
||||||
\*-------------------------------------------------------------------------*/
|
|
||||||
#ifndef MIME_API
|
|
||||||
#define MIME_API extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MIME_API int luaopen_mime_core(lua_State *L);
|
|
||||||
|
|
||||||
#endif /* MIME_H */
|
#endif /* MIME_H */
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
local base = _G
|
local base = _G
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
local mime = require("mime.core")
|
local mime = require("mime.core")
|
||||||
local io = require("io")
|
|
||||||
local string = require("string")
|
local string = require("string")
|
||||||
local _M = mime
|
local _M = mime
|
||||||
|
|
||||||
@ -87,4 +86,4 @@ function _M.stuff()
|
|||||||
return ltn12.filter.cycle(_M.dot, 2)
|
return ltn12.filter.cycle(_M.dot, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
return _M
|
return _M
|
||||||
|
120
src/options.c
120
src/options.c
@ -2,14 +2,11 @@
|
|||||||
* Common option interface
|
* Common option interface
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "lauxlib.h"
|
|
||||||
|
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "inet.h"
|
#include "inet.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Internal functions prototypes
|
* Internal functions prototypes
|
||||||
@ -57,6 +54,7 @@ int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps)
|
|||||||
return opt->func(L, ps);
|
return opt->func(L, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
/* enables reuse of local address */
|
/* enables reuse of local address */
|
||||||
int opt_set_reuseaddr(lua_State *L, p_socket ps)
|
int opt_set_reuseaddr(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
@ -68,6 +66,7 @@ int opt_get_reuseaddr(lua_State *L, p_socket ps)
|
|||||||
return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
|
return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
/* enables reuse of local port */
|
/* enables reuse of local port */
|
||||||
int opt_set_reuseport(lua_State *L, p_socket ps)
|
int opt_set_reuseport(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
@ -79,7 +78,8 @@ int opt_get_reuseport(lua_State *L, p_socket ps)
|
|||||||
return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEPORT);
|
return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disables the Naggle algorithm */
|
// -------------------------------------------------------
|
||||||
|
/* disables the Nagle algorithm */
|
||||||
int opt_set_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);
|
||||||
@ -90,6 +90,52 @@ int opt_get_tcp_nodelay(lua_State *L, p_socket ps)
|
|||||||
return opt_getboolean(L, ps, IPPROTO_TCP, TCP_NODELAY);
|
return opt_getboolean(L, ps, IPPROTO_TCP, TCP_NODELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
|
#ifdef TCP_KEEPIDLE
|
||||||
|
|
||||||
|
int opt_get_tcp_keepidle(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_getint(L, ps, IPPROTO_TCP, TCP_KEEPIDLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_set_tcp_keepidle(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_setint(L, ps, IPPROTO_TCP, TCP_KEEPIDLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
|
#ifdef TCP_KEEPCNT
|
||||||
|
|
||||||
|
int opt_get_tcp_keepcnt(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_getint(L, ps, IPPROTO_TCP, TCP_KEEPCNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_set_tcp_keepcnt(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_setint(L, ps, IPPROTO_TCP, TCP_KEEPCNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
|
#ifdef TCP_KEEPINTVL
|
||||||
|
|
||||||
|
int opt_get_tcp_keepintvl(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_getint(L, ps, IPPROTO_TCP, TCP_KEEPINTVL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_set_tcp_keepintvl(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_setint(L, ps, IPPROTO_TCP, TCP_KEEPINTVL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_keepalive(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);
|
return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE);
|
||||||
@ -100,6 +146,7 @@ int opt_get_keepalive(lua_State *L, p_socket ps)
|
|||||||
return opt_getboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE);
|
return opt_getboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_dontroute(lua_State *L, p_socket ps)
|
int opt_set_dontroute(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE);
|
return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE);
|
||||||
@ -110,6 +157,7 @@ int opt_get_dontroute(lua_State *L, p_socket ps)
|
|||||||
return opt_getboolean(L, ps, SOL_SOCKET, SO_DONTROUTE);
|
return opt_getboolean(L, ps, SOL_SOCKET, SO_DONTROUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_broadcast(lua_State *L, p_socket ps)
|
int opt_set_broadcast(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
|
return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
|
||||||
@ -120,6 +168,29 @@ int opt_get_broadcast(lua_State *L, p_socket ps)
|
|||||||
return opt_getboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
|
return opt_getboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
|
int opt_set_recv_buf_size(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_setint(L, ps, SOL_SOCKET, SO_RCVBUF);
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_get_recv_buf_size(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_getint(L, ps, SOL_SOCKET, SO_RCVBUF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
|
int opt_get_send_buf_size(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_getint(L, ps, SOL_SOCKET, SO_SNDBUF);
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_set_send_buf_size(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_setint(L, ps, SOL_SOCKET, SO_SNDBUF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps)
|
int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
|
return opt_setint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
|
||||||
@ -130,6 +201,7 @@ int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps)
|
|||||||
return opt_getint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
|
return opt_getint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps)
|
int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
|
return opt_setint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
|
||||||
@ -140,6 +212,7 @@ int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps)
|
|||||||
return opt_getint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
|
return opt_getint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps)
|
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
|
return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
|
||||||
@ -150,6 +223,7 @@ int opt_get_ip_multicast_loop(lua_State *L, p_socket ps)
|
|||||||
return opt_getboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
|
return opt_getboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps)
|
int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
|
return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
|
||||||
@ -160,6 +234,7 @@ int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps)
|
|||||||
return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
|
return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_linger(lua_State *L, p_socket ps)
|
int opt_set_linger(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
struct linger li; /* obj, name, table */
|
struct linger li; /* obj, name, table */
|
||||||
@ -192,11 +267,13 @@ int opt_get_linger(lua_State *L, p_socket ps)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_ip_multicast_ttl(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);
|
return opt_setint(L, ps, IPPROTO_IP, IP_MULTICAST_TTL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_ip_multicast_if(lua_State *L, p_socket ps)
|
int opt_set_ip_multicast_if(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
const char *address = luaL_checkstring(L, 3); /* obj, name, ip */
|
const char *address = luaL_checkstring(L, 3); /* obj, name, ip */
|
||||||
@ -221,6 +298,7 @@ int opt_get_ip_multicast_if(lua_State *L, p_socket ps)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_ip_add_membership(lua_State *L, p_socket ps)
|
int opt_set_ip_add_membership(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP);
|
return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP);
|
||||||
@ -231,6 +309,7 @@ int opt_set_ip_drop_membersip(lua_State *L, p_socket ps)
|
|||||||
return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP);
|
return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_set_ip6_add_membership(lua_State *L, p_socket ps)
|
int opt_set_ip6_add_membership(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_ip6_setmembership(L, ps, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP);
|
return opt_ip6_setmembership(L, ps, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP);
|
||||||
@ -240,7 +319,7 @@ int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps)
|
|||||||
{
|
{
|
||||||
return opt_ip6_setmembership(L, ps, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP);
|
return opt_ip6_setmembership(L, ps, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP);
|
||||||
}
|
}
|
||||||
|
// -------------------------------------------------------
|
||||||
int opt_get_ip6_v6only(lua_State *L, p_socket ps)
|
int opt_get_ip6_v6only(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
|
return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
|
||||||
@ -251,6 +330,20 @@ int opt_set_ip6_v6only(lua_State *L, p_socket ps)
|
|||||||
return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
|
return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Auxiliar functions
|
* Auxiliar functions
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
@ -337,19 +430,6 @@ static int opt_getboolean(lua_State *L, p_socket ps, int level, int name)
|
|||||||
return 1;
|
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)
|
static int opt_setboolean(lua_State *L, p_socket ps, int level, int name)
|
||||||
{
|
{
|
||||||
int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */
|
int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */
|
||||||
|
116
src/options.h
116
src/options.h
@ -8,7 +8,7 @@
|
|||||||
* modules UDP and TCP.
|
* modules UDP and TCP.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
|
||||||
/* option registry */
|
/* option registry */
|
||||||
@ -18,45 +18,85 @@ typedef struct t_opt {
|
|||||||
} t_opt;
|
} t_opt;
|
||||||
typedef t_opt *p_opt;
|
typedef t_opt *p_opt;
|
||||||
|
|
||||||
/* supported options for setoption */
|
#ifndef _WIN32
|
||||||
int opt_set_dontroute(lua_State *L, p_socket ps);
|
#pragma GCC visibility push(hidden)
|
||||||
int opt_set_broadcast(lua_State *L, p_socket ps);
|
#endif
|
||||||
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_setoption(lua_State *L, p_opt opt, p_socket ps);
|
||||||
int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps);
|
int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_reuseaddr(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_reuseaddr(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_reuseport(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_reuseport(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_tcp_nodelay(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_tcp_nodelay(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
#ifdef TCP_KEEPIDLE
|
||||||
|
int opt_set_tcp_keepidle(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_tcp_keepidle(lua_State *L, p_socket ps);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TCP_KEEPCNT
|
||||||
|
int opt_set_tcp_keepcnt(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_tcp_keepcnt(lua_State *L, p_socket ps);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TCP_KEEPINTVL
|
||||||
|
int opt_set_tcp_keepintvl(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_tcp_keepintvl(lua_State *L, p_socket ps);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int opt_set_keepalive(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_keepalive(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_dontroute(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_dontroute(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_broadcast(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_broadcast(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_recv_buf_size(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_recv_buf_size(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_send_buf_size(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_send_buf_size(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_ip_multicast_loop(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_linger(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_linger(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_set_ip_multicast_if(lua_State *L, p_socket ps);
|
||||||
|
int opt_get_ip_multicast_if(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_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);
|
||||||
|
int opt_get_ip6_v6only(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
int opt_get_error(lua_State *L, p_socket ps);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
src/select.c
12
src/select.c
@ -2,16 +2,14 @@
|
|||||||
* Select implementation
|
* Select implementation
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
#include "select.h"
|
#include "select.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Internal function prototypes.
|
* Internal function prototypes.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
@ -31,9 +29,6 @@ static luaL_Reg func[] = {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*=========================================================================*\
|
|
||||||
* Exported functions
|
|
||||||
\*=========================================================================*/
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes module
|
* Initializes module
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
@ -217,4 +212,3 @@ static void make_assoc(lua_State *L, int tab) {
|
|||||||
i = i+1;
|
i = i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,14 @@
|
|||||||
* true if there is data ready for reading (required for buffered input).
|
* true if there is data ready for reading (required for buffered input).
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int select_open(lua_State *L);
|
int select_open(lua_State *L);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* SELECT_H */
|
#endif /* SELECT_H */
|
||||||
|
@ -2,15 +2,14 @@
|
|||||||
* Serial stream
|
* Serial stream
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
|
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "unix.h"
|
#include "unix.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
55
src/socket.h
55
src/socket.h
@ -28,51 +28,46 @@
|
|||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
|
|
||||||
/* we are lazy... */
|
/* convenient shorthand */
|
||||||
typedef struct sockaddr SA;
|
typedef struct sockaddr SA;
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Functions bellow implement a comfortable platform independent
|
* Functions bellow implement a comfortable platform independent
|
||||||
* interface to sockets
|
* interface to sockets
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int socket_waitfd(p_socket ps, int sw, p_timeout tm);
|
||||||
int socket_open(void);
|
int socket_open(void);
|
||||||
int socket_close(void);
|
int socket_close(void);
|
||||||
void socket_destroy(p_socket ps);
|
void socket_destroy(p_socket ps);
|
||||||
void socket_shutdown(p_socket ps, int how);
|
int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_timeout tm);
|
||||||
int socket_sendto(p_socket ps, const char *data, size_t count,
|
|
||||||
size_t *sent, SA *addr, socklen_t addr_len, p_timeout tm);
|
|
||||||
int socket_recvfrom(p_socket ps, char *data, size_t count,
|
|
||||||
size_t *got, SA *addr, socklen_t *addr_len, p_timeout tm);
|
|
||||||
|
|
||||||
void socket_setnonblocking(p_socket ps);
|
|
||||||
void socket_setblocking(p_socket ps);
|
|
||||||
|
|
||||||
int socket_waitfd(p_socket ps, int sw, p_timeout tm);
|
|
||||||
int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
|
||||||
p_timeout tm);
|
|
||||||
|
|
||||||
int socket_connect(p_socket ps, SA *addr, socklen_t addr_len, p_timeout tm);
|
|
||||||
int socket_create(p_socket ps, int domain, int type, int protocol);
|
int socket_create(p_socket ps, int domain, int type, int protocol);
|
||||||
int socket_bind(p_socket ps, SA *addr, socklen_t addr_len);
|
int socket_bind(p_socket ps, SA *addr, socklen_t addr_len);
|
||||||
int socket_listen(p_socket ps, int backlog);
|
int socket_listen(p_socket ps, int backlog);
|
||||||
int socket_accept(p_socket ps, p_socket pa, SA *addr,
|
void socket_shutdown(p_socket ps, int how);
|
||||||
socklen_t *addr_len, p_timeout tm);
|
int socket_connect(p_socket ps, SA *addr, socklen_t addr_len, p_timeout tm);
|
||||||
|
int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *addr_len, p_timeout tm);
|
||||||
const char *socket_hoststrerror(int err);
|
int socket_send(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm);
|
||||||
const char *socket_gaistrerror(int err);
|
int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, SA *addr, socklen_t addr_len, p_timeout tm);
|
||||||
const char *socket_strerror(int err);
|
|
||||||
|
|
||||||
/* these are perfect to use with the io abstraction module
|
|
||||||
and the buffered input module */
|
|
||||||
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_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,
|
int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, SA *addr, socklen_t *addr_len, p_timeout tm);
|
||||||
size_t *sent, 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);
|
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);
|
void socket_setblocking(p_socket ps);
|
||||||
|
void socket_setnonblocking(p_socket ps);
|
||||||
int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp);
|
int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp);
|
||||||
int socket_gethostbyname(const char *addr, struct hostent **hp);
|
int socket_gethostbyname(const char *addr, struct hostent **hp);
|
||||||
|
const char *socket_hoststrerror(int err);
|
||||||
|
const char *socket_strerror(int err);
|
||||||
|
const char *socket_ioerror(p_socket ps, int err);
|
||||||
|
const char *socket_gaistrerror(int err);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* SOCKET_H */
|
#endif /* SOCKET_H */
|
||||||
|
30
src/tcp.c
30
src/tcp.c
@ -2,11 +2,7 @@
|
|||||||
* TCP object
|
* TCP object
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
@ -14,6 +10,8 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "tcp.h"
|
#include "tcp.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Internal function prototypes
|
* Internal function prototypes
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
@ -77,8 +75,19 @@ static t_opt optget[] = {
|
|||||||
{"reuseaddr", opt_get_reuseaddr},
|
{"reuseaddr", opt_get_reuseaddr},
|
||||||
{"reuseport", opt_get_reuseport},
|
{"reuseport", opt_get_reuseport},
|
||||||
{"tcp-nodelay", opt_get_tcp_nodelay},
|
{"tcp-nodelay", opt_get_tcp_nodelay},
|
||||||
|
#ifdef TCP_KEEPIDLE
|
||||||
|
{"tcp-keepidle", opt_get_tcp_keepidle},
|
||||||
|
#endif
|
||||||
|
#ifdef TCP_KEEPCNT
|
||||||
|
{"tcp-keepcnt", opt_get_tcp_keepcnt},
|
||||||
|
#endif
|
||||||
|
#ifdef TCP_KEEPINTVL
|
||||||
|
{"tcp-keepintvl", opt_get_tcp_keepintvl},
|
||||||
|
#endif
|
||||||
{"linger", opt_get_linger},
|
{"linger", opt_get_linger},
|
||||||
{"error", opt_get_error},
|
{"error", opt_get_error},
|
||||||
|
{"recv-buffer-size", opt_get_recv_buf_size},
|
||||||
|
{"send-buffer-size", opt_get_send_buf_size},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,8 +96,19 @@ static t_opt optset[] = {
|
|||||||
{"reuseaddr", opt_set_reuseaddr},
|
{"reuseaddr", opt_set_reuseaddr},
|
||||||
{"reuseport", opt_set_reuseport},
|
{"reuseport", opt_set_reuseport},
|
||||||
{"tcp-nodelay", opt_set_tcp_nodelay},
|
{"tcp-nodelay", opt_set_tcp_nodelay},
|
||||||
|
#ifdef TCP_KEEPIDLE
|
||||||
|
{"tcp-keepidle", opt_set_tcp_keepidle},
|
||||||
|
#endif
|
||||||
|
#ifdef TCP_KEEPCNT
|
||||||
|
{"tcp-keepcnt", opt_set_tcp_keepcnt},
|
||||||
|
#endif
|
||||||
|
#ifdef TCP_KEEPINTVL
|
||||||
|
{"tcp-keepintvl", opt_set_tcp_keepintvl},
|
||||||
|
#endif
|
||||||
{"ipv6-v6only", opt_set_ip6_v6only},
|
{"ipv6-v6only", opt_set_ip6_v6only},
|
||||||
{"linger", opt_set_linger},
|
{"linger", opt_set_linger},
|
||||||
|
{"recv-buffer-size", opt_set_recv_buf_size},
|
||||||
|
{"send-buffer-size", opt_set_send_buf_size},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
10
src/tcp.h
10
src/tcp.h
@ -14,7 +14,7 @@
|
|||||||
* tcp objects either connected to some address or returned by the accept
|
* tcp objects either connected to some address or returned by the accept
|
||||||
* method of a server object.
|
* method of a server object.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
@ -30,6 +30,14 @@ typedef struct t_tcp_ {
|
|||||||
|
|
||||||
typedef t_tcp *p_tcp;
|
typedef t_tcp *p_tcp;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int tcp_open(lua_State *L);
|
int tcp_open(lua_State *L);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* TCP_H */
|
#endif /* TCP_H */
|
||||||
|
@ -2,17 +2,15 @@
|
|||||||
* Timeout management functions
|
* Timeout management functions
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <stdio.h>
|
#include "luasocket.h"
|
||||||
#include <limits.h>
|
|
||||||
#include <float.h>
|
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Timeout management functions
|
* Timeout management functions
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
|
|
||||||
/* timeout control structure */
|
/* timeout control structure */
|
||||||
typedef struct t_timeout_ {
|
typedef struct t_timeout_ {
|
||||||
@ -14,16 +14,27 @@ typedef struct t_timeout_ {
|
|||||||
} t_timeout;
|
} t_timeout;
|
||||||
typedef t_timeout *p_timeout;
|
typedef t_timeout *p_timeout;
|
||||||
|
|
||||||
int timeout_open(lua_State *L);
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
void timeout_init(p_timeout tm, double block, double total);
|
void timeout_init(p_timeout tm, double block, double total);
|
||||||
double timeout_get(p_timeout tm);
|
double timeout_get(p_timeout tm);
|
||||||
|
double timeout_getstart(p_timeout tm);
|
||||||
double timeout_getretry(p_timeout tm);
|
double timeout_getretry(p_timeout tm);
|
||||||
p_timeout timeout_markstart(p_timeout tm);
|
p_timeout timeout_markstart(p_timeout tm);
|
||||||
double timeout_getstart(p_timeout tm);
|
|
||||||
double timeout_gettime(void);
|
double timeout_gettime(void);
|
||||||
|
|
||||||
|
int timeout_open(lua_State *L);
|
||||||
|
|
||||||
int timeout_meth_settimeout(lua_State *L, p_timeout tm);
|
int timeout_meth_settimeout(lua_State *L, p_timeout tm);
|
||||||
int timeout_meth_gettimeout(lua_State *L, p_timeout tm);
|
int timeout_meth_gettimeout(lua_State *L, p_timeout tm);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#define timeout_iszero(tm) ((tm)->block == 0.0)
|
#define timeout_iszero(tm) ((tm)->block == 0.0)
|
||||||
|
|
||||||
#endif /* TIMEOUT_H */
|
#endif /* TIMEOUT_H */
|
||||||
|
19
src/udp.c
19
src/udp.c
@ -2,12 +2,7 @@
|
|||||||
* UDP object
|
* UDP object
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
@ -15,6 +10,9 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* min and max macros */
|
/* min and max macros */
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(x, y) ((x) < (y) ? x : y)
|
#define MIN(x, y) ((x) < (y) ? x : y)
|
||||||
@ -88,6 +86,8 @@ static t_opt optset[] = {
|
|||||||
{"ipv6-add-membership", opt_set_ip6_add_membership},
|
{"ipv6-add-membership", opt_set_ip6_add_membership},
|
||||||
{"ipv6-drop-membership", opt_set_ip6_drop_membersip},
|
{"ipv6-drop-membership", opt_set_ip6_drop_membersip},
|
||||||
{"ipv6-v6only", opt_set_ip6_v6only},
|
{"ipv6-v6only", opt_set_ip6_v6only},
|
||||||
|
{"recv-buffer-size", opt_set_recv_buf_size},
|
||||||
|
{"send-buffer-size", opt_set_send_buf_size},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -104,6 +104,8 @@ static t_opt optget[] = {
|
|||||||
{"ipv6-multicast-hops", opt_get_ip6_unicast_hops},
|
{"ipv6-multicast-hops", opt_get_ip6_unicast_hops},
|
||||||
{"ipv6-multicast-loop", opt_get_ip6_multicast_loop},
|
{"ipv6-multicast-loop", opt_get_ip6_multicast_loop},
|
||||||
{"ipv6-v6only", opt_get_ip6_v6only},
|
{"ipv6-v6only", opt_get_ip6_v6only},
|
||||||
|
{"recv-buffer-size", opt_get_recv_buf_size},
|
||||||
|
{"send-buffer-size", opt_get_send_buf_size},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -182,7 +184,10 @@ static int meth_sendto(lua_State *L) {
|
|||||||
memset(&aihint, 0, sizeof(aihint));
|
memset(&aihint, 0, sizeof(aihint));
|
||||||
aihint.ai_family = udp->family;
|
aihint.ai_family = udp->family;
|
||||||
aihint.ai_socktype = SOCK_DGRAM;
|
aihint.ai_socktype = SOCK_DGRAM;
|
||||||
aihint.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
|
aihint.ai_flags = AI_NUMERICHOST;
|
||||||
|
#ifdef AI_NUMERICSERV
|
||||||
|
aihint.ai_flags |= AI_NUMERICSERV;
|
||||||
|
#endif
|
||||||
err = getaddrinfo(ip, port, &aihint, &ai);
|
err = getaddrinfo(ip, port, &aihint, &ai);
|
||||||
if (err) {
|
if (err) {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
10
src/udp.h
10
src/udp.h
@ -12,7 +12,7 @@
|
|||||||
* with a call to the setpeername function. The same function can be used to
|
* with a call to the setpeername function. The same function can be used to
|
||||||
* break the connection.
|
* break the connection.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
@ -26,6 +26,14 @@ typedef struct t_udp_ {
|
|||||||
} t_udp;
|
} t_udp;
|
||||||
typedef t_udp *p_udp;
|
typedef t_udp *p_udp;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int udp_open(lua_State *L);
|
int udp_open(lua_State *L);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* UDP_H */
|
#endif /* UDP_H */
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
* Unix domain socket
|
* Unix domain socket
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
#include "lauxlib.h"
|
|
||||||
|
|
||||||
#include "unixstream.h"
|
#include "unixstream.h"
|
||||||
#include "unixdgram.h"
|
#include "unixdgram.h"
|
||||||
@ -45,7 +44,7 @@ static int compat_socket_unix_call(lua_State *L)
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes module
|
* Initializes module
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
int luaopen_socket_unix(lua_State *L)
|
LUASOCKET_API int luaopen_socket_unix(lua_State *L)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
@ -7,16 +7,12 @@
|
|||||||
* This module is just an example of how to extend LuaSocket with a new
|
* This module is just an example of how to extend LuaSocket with a new
|
||||||
* domain.
|
* domain.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
|
||||||
#ifndef UNIX_API
|
|
||||||
#define UNIX_API extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct t_unix_ {
|
typedef struct t_unix_ {
|
||||||
t_socket sock;
|
t_socket sock;
|
||||||
t_io io;
|
t_io io;
|
||||||
@ -25,6 +21,6 @@ typedef struct t_unix_ {
|
|||||||
} t_unix;
|
} t_unix;
|
||||||
typedef t_unix *p_unix;
|
typedef t_unix *p_unix;
|
||||||
|
|
||||||
UNIX_API int luaopen_socket_unix(lua_State *L);
|
LUASOCKET_API int luaopen_socket_unix(lua_State *L);
|
||||||
|
|
||||||
#endif /* UNIX_H */
|
#endif /* UNIX_H */
|
||||||
|
@ -2,21 +2,27 @@
|
|||||||
* Unix domain socket dgram submodule
|
* Unix domain socket dgram submodule
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "unix.h"
|
#include "unix.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
#define UNIXDGRAM_DATAGRAMSIZE 8192
|
#define UNIXDGRAM_DATAGRAMSIZE 8192
|
||||||
|
|
||||||
|
// provide a SUN_LEN macro if sys/un.h doesn't (e.g. Android)
|
||||||
|
#ifndef SUN_LEN
|
||||||
|
#define SUN_LEN(ptr) \
|
||||||
|
((size_t) (((struct sockaddr_un *) 0)->sun_path) \
|
||||||
|
+ strlen ((ptr)->sun_path))
|
||||||
|
#endif
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Internal function prototypes
|
* Internal function prototypes
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
@ -261,20 +267,15 @@ static int meth_dirty(lua_State *L) {
|
|||||||
static const char *unixdgram_trybind(p_unix un, const char *path) {
|
static const char *unixdgram_trybind(p_unix un, const char *path) {
|
||||||
struct sockaddr_un local;
|
struct sockaddr_un local;
|
||||||
size_t len = strlen(path);
|
size_t len = strlen(path);
|
||||||
int err;
|
|
||||||
if (len >= sizeof(local.sun_path)) return "path too long";
|
if (len >= sizeof(local.sun_path)) return "path too long";
|
||||||
memset(&local, 0, sizeof(local));
|
memset(&local, 0, sizeof(local));
|
||||||
strcpy(local.sun_path, path);
|
strcpy(local.sun_path, path);
|
||||||
local.sun_family = AF_UNIX;
|
local.sun_family = AF_UNIX;
|
||||||
|
size_t addrlen = SUN_LEN(&local);
|
||||||
#ifdef UNIX_HAS_SUN_LEN
|
#ifdef UNIX_HAS_SUN_LEN
|
||||||
local.sun_len = sizeof(local.sun_family) + sizeof(local.sun_len)
|
local.sun_len = addrlen + 1;
|
||||||
+ 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
|
#endif
|
||||||
|
int err = socket_bind(&un->sock, (SA *) &local, addrlen);
|
||||||
if (err != IO_DONE) socket_destroy(&un->sock);
|
if (err != IO_DONE) socket_destroy(&un->sock);
|
||||||
return socket_strerror(err);
|
return socket_strerror(err);
|
||||||
}
|
}
|
||||||
@ -315,21 +316,17 @@ static int meth_getsockname(lua_State *L)
|
|||||||
static const char *unixdgram_tryconnect(p_unix un, const char *path)
|
static const char *unixdgram_tryconnect(p_unix un, const char *path)
|
||||||
{
|
{
|
||||||
struct sockaddr_un remote;
|
struct sockaddr_un remote;
|
||||||
int err;
|
|
||||||
size_t len = strlen(path);
|
size_t len = strlen(path);
|
||||||
if (len >= sizeof(remote.sun_path)) return "path too long";
|
if (len >= sizeof(remote.sun_path)) return "path too long";
|
||||||
memset(&remote, 0, sizeof(remote));
|
memset(&remote, 0, sizeof(remote));
|
||||||
strcpy(remote.sun_path, path);
|
strcpy(remote.sun_path, path);
|
||||||
remote.sun_family = AF_UNIX;
|
remote.sun_family = AF_UNIX;
|
||||||
timeout_markstart(&un->tm);
|
timeout_markstart(&un->tm);
|
||||||
|
size_t addrlen = SUN_LEN(&remote);
|
||||||
#ifdef UNIX_HAS_SUN_LEN
|
#ifdef UNIX_HAS_SUN_LEN
|
||||||
remote.sun_len = sizeof(remote.sun_family) + sizeof(remote.sun_len)
|
remote.sun_len = addrlen + 1;
|
||||||
+ 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
|
#endif
|
||||||
|
int err = socket_connect(&un->sock, (SA *) &remote, addrlen, &un->tm);
|
||||||
if (err != IO_DONE) socket_destroy(&un->sock);
|
if (err != IO_DONE) socket_destroy(&un->sock);
|
||||||
return socket_strerror(err);
|
return socket_strerror(err);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
|
|
||||||
#include "unix.h"
|
#include "unix.h"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int unixdgram_open(lua_State *L);
|
int unixdgram_open(lua_State *L);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* UNIXDGRAM_H */
|
#endif /* UNIXDGRAM_H */
|
||||||
|
@ -2,16 +2,14 @@
|
|||||||
* Unix domain socket stream sub module
|
* Unix domain socket stream sub module
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "unixstream.h"
|
#include "unixstream.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
|
@ -16,6 +16,14 @@
|
|||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "unix.h"
|
#include "unix.h"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility push(hidden)
|
||||||
|
#endif
|
||||||
|
|
||||||
int unixstream_open(lua_State *L);
|
int unixstream_open(lua_State *L);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* UNIXSTREAM_H */
|
#endif /* UNIXSTREAM_H */
|
||||||
|
64
src/url.lua
64
src/url.lua
@ -76,6 +76,34 @@ function _M.unescape(s)
|
|||||||
end))
|
end))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- Removes '..' and '.' components appropriately from a path.
|
||||||
|
-- Input
|
||||||
|
-- path
|
||||||
|
-- Returns
|
||||||
|
-- dot-normalized path
|
||||||
|
local function remove_dot_components(path)
|
||||||
|
local marker = string.char(1)
|
||||||
|
repeat
|
||||||
|
local was = path
|
||||||
|
path = path:gsub('//', '/'..marker..'/', 1)
|
||||||
|
until path == was
|
||||||
|
repeat
|
||||||
|
local was = path
|
||||||
|
path = path:gsub('/%./', '/', 1)
|
||||||
|
until path == was
|
||||||
|
repeat
|
||||||
|
local was = path
|
||||||
|
path = path:gsub('[^/]+/%.%./([^/]+)', '%1', 1)
|
||||||
|
until path == was
|
||||||
|
path = path:gsub('[^/]+/%.%./*$', '')
|
||||||
|
path = path:gsub('/%.%.$', '/')
|
||||||
|
path = path:gsub('/%.$', '/')
|
||||||
|
path = path:gsub('^/%.%./', '/')
|
||||||
|
path = path:gsub(marker, '')
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Builds a path from a base path and a relative path
|
-- Builds a path from a base path and a relative path
|
||||||
-- Input
|
-- Input
|
||||||
@ -85,23 +113,12 @@ end
|
|||||||
-- corresponding absolute path
|
-- corresponding absolute path
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local function absolute_path(base_path, relative_path)
|
local function absolute_path(base_path, relative_path)
|
||||||
if string.sub(relative_path, 1, 1) == "/" then return relative_path end
|
if string.sub(relative_path, 1, 1) == "/" then
|
||||||
local path = string.gsub(base_path, "[^/]*$", "")
|
return remove_dot_components(relative_path) end
|
||||||
path = path .. relative_path
|
base_path = base_path:gsub("[^/]*$", "")
|
||||||
path = string.gsub(path, "([^/]*%./)", function (s)
|
if not base_path:find'/$' then base_path = base_path .. '/' end
|
||||||
if s ~= "./" then return s else return "" end
|
local path = base_path .. relative_path
|
||||||
end)
|
path = remove_dot_components(path)
|
||||||
path = string.gsub(path, "/%.$", "/")
|
|
||||||
local reduced
|
|
||||||
while reduced ~= path do
|
|
||||||
reduced = path
|
|
||||||
path = string.gsub(reduced, "([^/]*/%.%./)", function (s)
|
|
||||||
if s ~= "../../" then return "" else return s end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
path = string.gsub(reduced, "([^/]*/%.%.)$", function (s)
|
|
||||||
if s ~= "../.." then return "" else return s end
|
|
||||||
end)
|
|
||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -227,10 +244,14 @@ function _M.absolute(base_url, relative_url)
|
|||||||
else
|
else
|
||||||
base_parsed = _M.parse(base_url)
|
base_parsed = _M.parse(base_url)
|
||||||
end
|
end
|
||||||
|
local result
|
||||||
local relative_parsed = _M.parse(relative_url)
|
local relative_parsed = _M.parse(relative_url)
|
||||||
if not base_parsed then return relative_url
|
if not base_parsed then
|
||||||
elseif not relative_parsed then return base_url
|
result = relative_url
|
||||||
elseif relative_parsed.scheme then return relative_url
|
elseif not relative_parsed then
|
||||||
|
result = base_url
|
||||||
|
elseif relative_parsed.scheme then
|
||||||
|
result = relative_url
|
||||||
else
|
else
|
||||||
relative_parsed.scheme = base_parsed.scheme
|
relative_parsed.scheme = base_parsed.scheme
|
||||||
if not relative_parsed.authority then
|
if not relative_parsed.authority then
|
||||||
@ -248,8 +269,9 @@ function _M.absolute(base_url, relative_url)
|
|||||||
relative_parsed.path)
|
relative_parsed.path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return _M.build(relative_parsed)
|
result = _M.build(relative_parsed)
|
||||||
end
|
end
|
||||||
|
return remove_dot_components(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -6,12 +6,14 @@
|
|||||||
* The penalty of calling select to avoid busy-wait is only paid when
|
* The penalty of calling select to avoid busy-wait is only paid when
|
||||||
* the I/O call fail in the first place.
|
* the I/O call fail in the first place.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include "luasocket.h"
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "pierror.h"
|
#include "pierror.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Wait for readable/writable/connected socket with timeout
|
* Wait for readable/writable/connected socket with timeout
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
@ -438,7 +440,9 @@ const char *socket_gaistrerror(int err) {
|
|||||||
case EAI_FAMILY: return PIE_FAMILY;
|
case EAI_FAMILY: return PIE_FAMILY;
|
||||||
case EAI_MEMORY: return PIE_MEMORY;
|
case EAI_MEMORY: return PIE_MEMORY;
|
||||||
case EAI_NONAME: return PIE_NONAME;
|
case EAI_NONAME: return PIE_NONAME;
|
||||||
|
#ifdef EAI_OVERFLOW
|
||||||
case EAI_OVERFLOW: return PIE_OVERFLOW;
|
case EAI_OVERFLOW: return PIE_OVERFLOW;
|
||||||
|
#endif
|
||||||
#ifdef EAI_PROTOCOL
|
#ifdef EAI_PROTOCOL
|
||||||
case EAI_PROTOCOL: return PIE_PROTOCOL;
|
case EAI_PROTOCOL: return PIE_PROTOCOL;
|
||||||
#endif
|
#endif
|
||||||
@ -448,4 +452,3 @@ const char *socket_gaistrerror(int err) {
|
|||||||
default: return gai_strerror(err);
|
default: return gai_strerror(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
src/wsocket.c
Normal file → Executable file
7
src/wsocket.c
Normal file → Executable file
@ -5,6 +5,8 @@
|
|||||||
* The penalty of calling select to avoid busy-wait is only paid when
|
* The penalty of calling select to avoid busy-wait is only paid when
|
||||||
* the I/O call fail in the first place.
|
* the I/O call fail in the first place.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
#include "luasocket.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
@ -131,11 +133,11 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
|
|||||||
/* we wait until something happens */
|
/* we wait until something happens */
|
||||||
err = socket_waitfd(ps, WAITFD_C, tm);
|
err = socket_waitfd(ps, WAITFD_C, tm);
|
||||||
if (err == IO_CLOSED) {
|
if (err == IO_CLOSED) {
|
||||||
int len = sizeof(err);
|
int elen = sizeof(err);
|
||||||
/* give windows time to set the error (yes, disgusting) */
|
/* give windows time to set the error (yes, disgusting) */
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
/* find out why we failed */
|
/* find out why we failed */
|
||||||
getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &len);
|
getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &elen);
|
||||||
/* we KNOW there was an error. if 'why' is 0, we will return
|
/* we KNOW there was an error. if 'why' is 0, we will return
|
||||||
* "unknown error", but it's not really our fault */
|
* "unknown error", but it's not really our fault */
|
||||||
return err > 0? err: IO_UNKNOWN;
|
return err > 0? err: IO_UNKNOWN;
|
||||||
@ -430,4 +432,3 @@ const char *socket_gaistrerror(int err) {
|
|||||||
default: return gai_strerror(err);
|
default: return gai_strerror(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ ulimit -n
|
|||||||
You'll probably need to be root to do this.
|
You'll probably need to be root to do this.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
require "socket"
|
socket = require "socket"
|
||||||
|
|
||||||
host = arg[1] or "google.com"
|
host = arg[1] or "google.com"
|
||||||
port = arg[2] or 80
|
port = arg[2] or 80
|
||||||
|
@ -1,19 +1,35 @@
|
|||||||
#!/usr/bin/env lua
|
#!/usr/bin/env lua
|
||||||
|
|
||||||
require"socket"
|
local socket = require"socket"
|
||||||
|
|
||||||
port = 8765
|
port = 8765
|
||||||
|
|
||||||
|
function pcalltest(msg, o, opt)
|
||||||
|
local a = { pcall(o.getoption, o, opt) }
|
||||||
|
if a[1] then
|
||||||
|
print(msg, opt, unpack(a))
|
||||||
|
else
|
||||||
|
print(msg, opt, 'fail: ' .. a[2])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function options(o)
|
function options(o)
|
||||||
print("options for", o)
|
print("options for", o)
|
||||||
|
|
||||||
for _, opt in ipairs{"keepalive", "reuseaddr", "tcp-nodelay"} do
|
for _, opt in ipairs{
|
||||||
print("getoption", opt, o:getoption(opt))
|
"keepalive", "reuseaddr",
|
||||||
|
"tcp-nodelay", "tcp-keepidle", "tcp-keepcnt", "tcp-keepintvl"} do
|
||||||
|
pcalltest("getoption", o, opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
print("getoption", "linger",
|
r = o:getoption'linger'
|
||||||
"on", o:getoption("linger").on,
|
if r then
|
||||||
"timeout", o:getoption("linger").timeout)
|
print("getoption", "linger",
|
||||||
|
"on", r.on,
|
||||||
|
"timeout", r.timeout)
|
||||||
|
else
|
||||||
|
print("getoption", "linger", "no result")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local m = socket.tcp()
|
local m = socket.tcp()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/lua
|
#!/usr/bin/env lua
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Show that luasocket returns an error message on zero-length UDP sends,
|
Show that luasocket returns an error message on zero-length UDP sends,
|
||||||
@ -12,7 +12,7 @@ listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
|
|||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
require"socket"
|
socket = require"socket"
|
||||||
|
|
||||||
s = assert(socket.udp())
|
s = assert(socket.udp())
|
||||||
r = assert(socket.udp())
|
r = assert(socket.udp())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/lua
|
#!/usr/bin/env lua
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Show that luasocket returns an error message on zero-length UDP sends,
|
Show that luasocket returns an error message on zero-length UDP sends,
|
||||||
@ -12,7 +12,7 @@ listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
|
|||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
require"socket"
|
socket = require"socket"
|
||||||
|
|
||||||
s = assert(socket.udp())
|
s = assert(socket.udp())
|
||||||
r = assert(socket.udp())
|
r = assert(socket.udp())
|
||||||
|
@ -61,7 +61,7 @@ end
|
|||||||
local check_absolute_url = function(base, relative, absolute)
|
local check_absolute_url = function(base, relative, absolute)
|
||||||
local res = socket.url.absolute(base, relative)
|
local res = socket.url.absolute(base, relative)
|
||||||
if res ~= absolute then
|
if res ~= absolute then
|
||||||
io.write("absolute: In test for '", relative, "' expected '",
|
io.write("absolute: In test for base='", base, "', rel='", relative, "' expected '",
|
||||||
absolute, "' but got '", res, "'\n")
|
absolute, "' but got '", res, "'\n")
|
||||||
os.exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
@ -627,25 +627,37 @@ check_absolute_url("http://a/b/c/d;p?q#f", "/g", "http://a/g")
|
|||||||
check_absolute_url("http://a/b/c/d;p?q#f", "//g", "http://g")
|
check_absolute_url("http://a/b/c/d;p?q#f", "//g", "http://g")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "?y", "http://a/b/c/d;p?y")
|
check_absolute_url("http://a/b/c/d;p?q#f", "?y", "http://a/b/c/d;p?y")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g?y", "http://a/b/c/g?y")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g?y", "http://a/b/c/g?y")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g?y/./x", "http://a/b/c/g?y/./x")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g?y/./x", "http://a/b/c/g?y/x")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "#s", "http://a/b/c/d;p?q#s")
|
check_absolute_url("http://a/b/c/d;p?q#f", "#s", "http://a/b/c/d;p?q#s")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g#s", "http://a/b/c/g#s")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g#s", "http://a/b/c/g#s")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g#s/./x", "http://a/b/c/g#s/./x")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g#s/./x", "http://a/b/c/g#s/x")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g?y#s", "http://a/b/c/g?y#s")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g?y#s", "http://a/b/c/g?y#s")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", ";x", "http://a/b/c/d;x")
|
check_absolute_url("http://a/b/c/d;p?q#f", ";x", "http://a/b/c/d;x")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g;x", "http://a/b/c/g;x")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g;x", "http://a/b/c/g;x")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g;x?y#s", "http://a/b/c/g;x?y#s")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g;x?y#s", "http://a/b/c/g;x?y#s")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", ".", "http://a/b/c/")
|
check_absolute_url("http://a/b/c/d;p?q#f", ".", "http://a/b/c/")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "./", "http://a/b/c/")
|
check_absolute_url("http://a/b/c/d;p?q#f", "./", "http://a/b/c/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "./g", "http://a/b/c/g")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "./g/", "http://a/b/c/g/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "././g", "http://a/b/c/g")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "././g/", "http://a/b/c/g/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "g/.", "http://a/b/c/g/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "g/./", "http://a/b/c/g/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "g/./.", "http://a/b/c/g/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "g/././", "http://a/b/c/g/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "./.", "http://a/b/c/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "././.", "http://a/b/c/")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "././g/./.", "http://a/b/c/g/")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "..", "http://a/b/")
|
check_absolute_url("http://a/b/c/d;p?q#f", "..", "http://a/b/")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "../", "http://a/b/")
|
check_absolute_url("http://a/b/c/d;p?q#f", "../", "http://a/b/")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "../g", "http://a/b/g")
|
check_absolute_url("http://a/b/c/d;p?q#f", "../g", "http://a/b/g")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "../..", "http://a/")
|
check_absolute_url("http://a/b/c/d;p?q#f", "../..", "http://a/")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "../../", "http://a/")
|
check_absolute_url("http://a/b/c/d;p?q#f", "../../", "http://a/")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "../../g", "http://a/g")
|
check_absolute_url("http://a/b/c/d;p?q#f", "../../g", "http://a/g")
|
||||||
|
check_absolute_url("http://a/b/c/d;p?q#f", "../../../g", "http://a/g")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "", "http://a/b/c/d;p?q#f")
|
check_absolute_url("http://a/b/c/d;p?q#f", "", "http://a/b/c/d;p?q#f")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "/./g", "http://a/./g")
|
check_absolute_url("http://a/b/c/d;p?q#f", "/./g", "http://a/g")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "/../g", "http://a/../g")
|
check_absolute_url("http://a/b/c/d;p?q#f", "/../g", "http://a/g")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g.", "http://a/b/c/g.")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g.", "http://a/b/c/g.")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", ".g", "http://a/b/c/.g")
|
check_absolute_url("http://a/b/c/d;p?q#f", ".g", "http://a/b/c/.g")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g..", "http://a/b/c/g..")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g..", "http://a/b/c/g..")
|
||||||
@ -655,6 +667,17 @@ check_absolute_url("http://a/b/c/d;p?q#f", "./g/.", "http://a/b/c/g/")
|
|||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g/./h", "http://a/b/c/g/h")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g/./h", "http://a/b/c/g/h")
|
||||||
check_absolute_url("http://a/b/c/d;p?q#f", "g/../h", "http://a/b/c/h")
|
check_absolute_url("http://a/b/c/d;p?q#f", "g/../h", "http://a/b/c/h")
|
||||||
|
|
||||||
|
check_absolute_url("http://a/b/c/d:p?q#f/", "../g/", "http://a/b/g/")
|
||||||
|
check_absolute_url("http://a/b/c/d:p?q#f/", "../g", "http://a/b/g")
|
||||||
|
check_absolute_url("http://a/b/c/d:p?q#f/", "../.g/", "http://a/b/.g/")
|
||||||
|
check_absolute_url("http://a/b/c/d:p?q#f/", "../.g", "http://a/b/.g")
|
||||||
|
check_absolute_url("http://a/b/c/d:p?q#f/", "../.g.h/", "http://a/b/.g.h/")
|
||||||
|
check_absolute_url("http://a/b/c/d:p?q#f/", "../.g.h", "http://a/b/.g.h")
|
||||||
|
|
||||||
|
check_absolute_url("http://a/b/c/d:p?q#f/", "g.h/", "http://a/b/c/g.h/")
|
||||||
|
check_absolute_url("http://a/b/c/d:p?q#f/", "../g.h/", "http://a/b/g.h/")
|
||||||
|
check_absolute_url("http://a/", "../g.h/", "http://a/g.h/")
|
||||||
|
|
||||||
-- extra tests
|
-- extra tests
|
||||||
check_absolute_url("//a/b/c/d;p?q#f", "d/e/f", "//a/b/c/d/e/f")
|
check_absolute_url("//a/b/c/d;p?q#f", "d/e/f", "//a/b/c/d/e/f")
|
||||||
check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f")
|
check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f")
|
||||||
@ -662,6 +685,17 @@ check_absolute_url("a/b/c/d", "d/e/f", "a/b/c/d/e/f")
|
|||||||
check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f")
|
check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f")
|
||||||
check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html",
|
check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html",
|
||||||
"http://velox.telemar.com.br/dashboard/index.html")
|
"http://velox.telemar.com.br/dashboard/index.html")
|
||||||
|
check_absolute_url("http://example.com/", "../.badhost.com/", "http://example.com/.badhost.com/")
|
||||||
|
check_absolute_url("http://example.com/", "...badhost.com/", "http://example.com/...badhost.com/")
|
||||||
|
check_absolute_url("http://example.com/a/b/c/d/", "../q", "http://example.com/a/b/c/q")
|
||||||
|
check_absolute_url("http://example.com/a/b/c/d/", "../../q", "http://example.com/a/b/q")
|
||||||
|
check_absolute_url("http://example.com/a/b/c/d/", "../../../q", "http://example.com/a/q")
|
||||||
|
check_absolute_url("http://example.com", ".badhost.com", "http://example.com/.badhost.com")
|
||||||
|
check_absolute_url("http://example.com/a/b/c/d/", "..//../../../q", "http://example.com/a/q")
|
||||||
|
check_absolute_url("http://example.com/a/b/c/d/", "..//a/../../../../q", "http://example.com/a/q")
|
||||||
|
check_absolute_url("http://example.com/a/b/c/d/", "..//a/..//../../../q", "http://example.com/a/b/q")
|
||||||
|
check_absolute_url("http://example.com/a/b/c/d/", "..//a/..///../../../../q", "http://example.com/a/b/q")
|
||||||
|
check_absolute_url("http://example.com/a/b/c/d/", "../x/a/../y/z/../../../../q", "http://example.com/a/b/q")
|
||||||
|
|
||||||
print("testing path parsing and composition")
|
print("testing path parsing and composition")
|
||||||
check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 })
|
check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 })
|
||||||
|
3
vc32.bat
Executable file
3
vc32.bat
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
|
||||||
|
cls
|
||||||
|
"c:\Program Files\Git\git-bash.exe" --cd-to-home
|
3
vc64.bat
Executable file
3
vc64.bat
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
|
||||||
|
cls
|
||||||
|
"c:\Program Files\Git\git-bash.exe" --cd-to-home
|
2
win32.cmd
Normal file → Executable file
2
win32.cmd
Normal file → Executable file
@ -1 +1 @@
|
|||||||
make LUAPREFIX_win32='c:\cygwin\home\diego\vc12' LUAV=5.1 PLAT=win32 LUALIBNAME_win32=lualib.lib PLATFORM_win32=Debug install-both
|
LUAV=5.3 PLAT=win32 LUAPREFIX_win32=/z/data/build/vc14 make
|
||||||
|
Reference in New Issue
Block a user