From 80b7acea2eb19f7facddce17733b88cb50a56cea Mon Sep 17 00:00:00 2001
From: Diego Nehab <diego@tecgraf.puc-rio.br>
Date: Thu, 17 Jun 2004 00:18:48 +0000
Subject: Compiled and tested on Windows...

---
 LICENSE           | 2 +-
 luasocket.sln     | 8 ++++++++
 luasocket.vcproj  | 9 +++------
 src/inet.h        | 2 +-
 src/luasocket.c   | 7 -------
 src/mime.c        | 7 -------
 src/select.c      | 4 +---
 src/socket.h      | 2 +-
 src/timeout.c     | 6 +++---
 test/mimetest.lua | 2 +-
 test/testclnt.lua | 6 ++++--
 11 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/LICENSE b/LICENSE
index 2dfc82b..e7ccb70 100644
--- a/LICENSE
+++ b/LICENSE
@@ -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"),
diff --git a/luasocket.sln b/luasocket.sln
index 6a1d0b8..11d7824 100644
--- a/luasocket.sln
+++ b/luasocket.sln
@@ -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
diff --git a/luasocket.vcproj b/luasocket.vcproj
index f998a8d..6700611 100644
--- a/luasocket.vcproj
+++ b/luasocket.vcproj
@@ -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>
diff --git a/src/inet.h b/src/inet.h
index 92e16f8..4b3639a 100644
--- a/src/inet.h
+++ b/src/inet.h
@@ -20,7 +20,7 @@
 #include "socket.h"
 #include "timeout.h"
 
-#ifdef WIN32
+#ifdef _WIN32
 #define INET_ATON
 #endif
 
diff --git a/src/luasocket.c b/src/luasocket.c
index 2b0a1fa..6f7debe 100644
--- a/src/luasocket.c
+++ b/src/luasocket.c
@@ -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);
diff --git a/src/mime.c b/src/mime.c
index 825b666..7810580 100644
--- a/src/mime.c
+++ b/src/mime.c
@@ -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 */
diff --git a/src/select.c b/src/select.c
index 13f9d6e..49730d1 100644
--- a/src/select.c
+++ b/src/select.c
@@ -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;
diff --git a/src/socket.h b/src/socket.h
index 85e8848..3dac875 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -16,7 +16,7 @@
 /*=========================================================================*\
 * Platform specific compatibilization
 \*=========================================================================*/
-#ifdef WIN32
+#ifdef _WIN32
 #include "wsocket.h"
 #else
 #include "usocket.h"
diff --git a/src/timeout.c b/src/timeout.c
index 4f9a315..3472ca7 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -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);
diff --git a/test/mimetest.lua b/test/mimetest.lua
index 2d5bce6..66aeaf3 100644
--- a/test/mimetest.lua
+++ b/test/mimetest.lua
@@ -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"
 
diff --git a/test/testclnt.lua b/test/testclnt.lua
index 6735113..da6b2e8 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -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)
-- 
cgit v1.2.3-55-g6feb