Compiled and tested on Windows...

This commit is contained in:
Diego Nehab 2004-06-17 00:18:48 +00:00
parent 27c8ae30aa
commit 80b7acea2e
11 changed files with 23 additions and 32 deletions

View File

@ -1,5 +1,5 @@
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
copy of this software and associated documentation files (the "Software"),

View File

@ -7,6 +7,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mime", "mime.vcproj", "{128
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smtp", "smtp.vcproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
@ -21,6 +25,10 @@ Global
{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
{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
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection

View File

@ -68,7 +68,7 @@
<Tool
Name="VCCLCompilerTool"
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"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -120,10 +120,10 @@
RelativePath=".\auxiliar.c">
</File>
<File
RelativePath=".\base.c">
RelativePath=".\buffer.c">
</File>
<File
RelativePath=".\buffer.c">
RelativePath=".\except.c">
</File>
<File
RelativePath=".\inet.c">
@ -140,9 +140,6 @@
<File
RelativePath=".\select.c">
</File>
<File
RelativePath=".\smtp.c">
</File>
<File
RelativePath=".\tcp.c">
</File>

View File

@ -20,7 +20,7 @@
#include "socket.h"
#include "timeout.h"
#ifdef WIN32
#ifdef _WIN32
#define INET_ATON
#endif

View File

@ -87,13 +87,6 @@ static int base_open(lua_State *L) {
/* whoever is loading the library replaced the global environment
* with the namespace table */
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
lua_pushstring(L, "DEBUG");
lua_pushboolean(L, 1);

View File

@ -79,13 +79,6 @@ MIME_API int luaopen_mime(lua_State *L)
/* whoever is loading the library replaced the global environment
* with the namespace table */
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 */
luaL_openlib(L, NULL, func, 0);
/* initialize lookup tables */

View File

@ -71,8 +71,6 @@ static int global_select(lua_State *L) {
lua_pushstring(L, "timeout");
return 3;
} else {
lua_pushnil(L);
lua_pushnil(L);
lua_pushstring(L, "error");
return 3;
}
@ -89,7 +87,7 @@ static int getfd(lua_State *L) {
lua_pushvalue(L, -2);
lua_call(L, 1, 1);
if (lua_isnumber(L, -1))
fd = lua_tonumber(L, -1);
fd = (int) lua_tonumber(L, -1);
}
lua_pop(L, 1);
return fd;

View File

@ -16,7 +16,7 @@
/*=========================================================================*\
* Platform specific compatibilization
\*=========================================================================*/
#ifdef WIN32
#ifdef _WIN32
#include "wsocket.h"
#else
#include "usocket.h"

View File

@ -13,7 +13,7 @@
#include "auxiliar.h"
#include "timeout.h"
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <time.h>
@ -133,7 +133,7 @@ p_tm tm_markstart(p_tm tm)
* Returns
* time in ms.
\*-------------------------------------------------------------------------*/
#ifdef WIN32
#ifdef _WIN32
int tm_gettime(void)
{
return GetTickCount();
@ -198,7 +198,7 @@ static int tm_lua_time(lua_State *L)
int tm_lua_sleep(lua_State *L)
{
double n = luaL_checknumber(L, 1);
#ifdef WIN32
#ifdef _WIN32
Sleep((int)n*1000);
#else
sleep((int)n);

View File

@ -8,7 +8,7 @@ local qptest = "qptest.bin"
local eqptest = "qptest.bin2"
local dqptest = "qptest.bin3"
local b64test = "luasocket.dylib"
local b64test = "luasocket.dll"
local eb64test = "b64test.bin"
local db64test = "b64test.bin2"

View File

@ -339,12 +339,14 @@ end
------------------------------------------------------------------------
function test_selectbugs()
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")
local udp = socket.udp()
udp:close()
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")
e = pcall(socket.select, "wrong", 1, 0.1)
assert(e == false)