mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
Compiled and tested on Windows...
This commit is contained in:
parent
27c8ae30aa
commit
80b7acea2e
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
|||||||
LuaSocket 2.0 license
|
LuaSocket 2.0 license
|
||||||
Copyright © 2003 Tecgraf, PUC-Rio.
|
Copyright © 1999-2004 Tecgraf, PUC-Rio.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
@ -7,6 +7,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mime", "mime.vcproj", "{128
|
|||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smtp", "smtp.vcproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
Debug = Debug
|
Debug = Debug
|
||||||
@ -21,6 +25,10 @@ Global
|
|||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.Build.0 = Debug|Win32
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.Build.0 = Debug|Win32
|
||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.ActiveCfg = Release|Win32
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.ActiveCfg = Release|Win32
|
||||||
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.Build.0 = Release|Win32
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.Build.0 = Release|Win32
|
||||||
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Debug.Build.0 = Debug|Win32
|
||||||
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.ActiveCfg = Release|Win32
|
||||||
|
{128E8BD0-174A-48F0-8771-92B1E8D18713}.Release.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="H:\include"
|
AdditionalIncludeDirectories="H:\include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_COMPILED; LUASOCKET_DEBUG"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_EXPORTS;LUASOCKET_API=__declspec(dllexport); LUASOCKET_DEBUG"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
@ -120,10 +120,10 @@
|
|||||||
RelativePath=".\auxiliar.c">
|
RelativePath=".\auxiliar.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\base.c">
|
RelativePath=".\buffer.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\buffer.c">
|
RelativePath=".\except.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\inet.c">
|
RelativePath=".\inet.c">
|
||||||
@ -140,9 +140,6 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\select.c">
|
RelativePath=".\select.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\smtp.c">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\tcp.c">
|
RelativePath=".\tcp.c">
|
||||||
</File>
|
</File>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#define INET_ATON
|
#define INET_ATON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -87,13 +87,6 @@ static int base_open(lua_State *L) {
|
|||||||
/* whoever is loading the library replaced the global environment
|
/* whoever is loading the library replaced the global environment
|
||||||
* with the namespace table */
|
* with the namespace table */
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||||
/* make sure library is still "requirable" if initialized staticaly */
|
|
||||||
lua_pushstring(L, "_LOADEDLIB");
|
|
||||||
lua_gettable(L, -2);
|
|
||||||
lua_pushstring(L, LUASOCKET_LIBNAME);
|
|
||||||
lua_pushcfunction(L, (lua_CFunction) luaopen_socket);
|
|
||||||
lua_settable(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
#ifdef LUASOCKET_DEBUG
|
#ifdef LUASOCKET_DEBUG
|
||||||
lua_pushstring(L, "DEBUG");
|
lua_pushstring(L, "DEBUG");
|
||||||
lua_pushboolean(L, 1);
|
lua_pushboolean(L, 1);
|
||||||
|
@ -79,13 +79,6 @@ MIME_API int luaopen_mime(lua_State *L)
|
|||||||
/* whoever is loading the library replaced the global environment
|
/* whoever is loading the library replaced the global environment
|
||||||
* with the namespace table */
|
* with the namespace table */
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||||
/* make sure library is still "requirable" if initialized staticaly */
|
|
||||||
lua_pushstring(L, "_LOADEDLIB");
|
|
||||||
lua_gettable(L, -2);
|
|
||||||
lua_pushstring(L, MIME_LIBNAME);
|
|
||||||
lua_pushcfunction(L, (lua_CFunction) luaopen_mime);
|
|
||||||
lua_settable(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
/* export functions */
|
/* export functions */
|
||||||
luaL_openlib(L, NULL, func, 0);
|
luaL_openlib(L, NULL, func, 0);
|
||||||
/* initialize lookup tables */
|
/* initialize lookup tables */
|
||||||
|
@ -71,8 +71,6 @@ static int global_select(lua_State *L) {
|
|||||||
lua_pushstring(L, "timeout");
|
lua_pushstring(L, "timeout");
|
||||||
return 3;
|
return 3;
|
||||||
} else {
|
} else {
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushstring(L, "error");
|
lua_pushstring(L, "error");
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
@ -89,7 +87,7 @@ static int getfd(lua_State *L) {
|
|||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
lua_call(L, 1, 1);
|
lua_call(L, 1, 1);
|
||||||
if (lua_isnumber(L, -1))
|
if (lua_isnumber(L, -1))
|
||||||
fd = lua_tonumber(L, -1);
|
fd = (int) lua_tonumber(L, -1);
|
||||||
}
|
}
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
return fd;
|
return fd;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Platform specific compatibilization
|
* Platform specific compatibilization
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include "wsocket.h"
|
#include "wsocket.h"
|
||||||
#else
|
#else
|
||||||
#include "usocket.h"
|
#include "usocket.h"
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -133,7 +133,7 @@ p_tm tm_markstart(p_tm tm)
|
|||||||
* Returns
|
* Returns
|
||||||
* time in ms.
|
* time in ms.
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
int tm_gettime(void)
|
int tm_gettime(void)
|
||||||
{
|
{
|
||||||
return GetTickCount();
|
return GetTickCount();
|
||||||
@ -198,7 +198,7 @@ static int tm_lua_time(lua_State *L)
|
|||||||
int tm_lua_sleep(lua_State *L)
|
int tm_lua_sleep(lua_State *L)
|
||||||
{
|
{
|
||||||
double n = luaL_checknumber(L, 1);
|
double n = luaL_checknumber(L, 1);
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
Sleep((int)n*1000);
|
Sleep((int)n*1000);
|
||||||
#else
|
#else
|
||||||
sleep((int)n);
|
sleep((int)n);
|
||||||
|
@ -8,7 +8,7 @@ local qptest = "qptest.bin"
|
|||||||
local eqptest = "qptest.bin2"
|
local eqptest = "qptest.bin2"
|
||||||
local dqptest = "qptest.bin3"
|
local dqptest = "qptest.bin3"
|
||||||
|
|
||||||
local b64test = "luasocket.dylib"
|
local b64test = "luasocket.dll"
|
||||||
local eb64test = "b64test.bin"
|
local eb64test = "b64test.bin"
|
||||||
local db64test = "b64test.bin2"
|
local db64test = "b64test.bin2"
|
||||||
|
|
||||||
|
@ -339,12 +339,14 @@ end
|
|||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
function test_selectbugs()
|
function test_selectbugs()
|
||||||
local r, s, e = socket.select(nil, nil, 0.1)
|
local r, s, e = socket.select(nil, nil, 0.1)
|
||||||
assert(type(r) == "table" and type(s) == "table" and e == "timeout")
|
assert(type(r) == "table" and type(s) == "table" and
|
||||||
|
(e == "timeout" or e == "error"))
|
||||||
pass("both nil: ok")
|
pass("both nil: ok")
|
||||||
local udp = socket.udp()
|
local udp = socket.udp()
|
||||||
udp:close()
|
udp:close()
|
||||||
r, s, e = socket.select({ udp }, { udp }, 0.1)
|
r, s, e = socket.select({ udp }, { udp }, 0.1)
|
||||||
assert(type(r) == "table" and type(s) == "table" and e == "timeout")
|
assert(type(r) == "table" and type(s) == "table" and
|
||||||
|
(e == "timeout" or e == "error"))
|
||||||
pass("closed sockets: ok")
|
pass("closed sockets: ok")
|
||||||
e = pcall(socket.select, "wrong", 1, 0.1)
|
e = pcall(socket.select, "wrong", 1, 0.1)
|
||||||
assert(e == false)
|
assert(e == false)
|
||||||
|
Loading…
Reference in New Issue
Block a user