diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2012-10-30 13:14:57 -0700 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2012-10-30 13:14:57 -0700 |
commit | c24f52acbfa05a785fdd1c0a68b043b9af8ed124 (patch) | |
tree | 73828d93ebd0c7f120b3cd3c4ebe85a9389366a6 | |
parent | b7bbcd557cb901e16f41f89a889627b96ecbdb59 (diff) | |
download | libnet-c24f52acbfa05a785fdd1c0a68b043b9af8ed124.tar.gz |
Build lua binding on win32.
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | lua/msvcbuild.bat | 20 | ||||
-rw-r--r-- | lua/net.c | 10 |
3 files changed, 34 insertions, 0 deletions
@@ -1,8 +1,12 @@ *.a +*.dll +*.exp *.la +*.lib *.lo *.loT *.o +*.obj *.out.dSYM *.so.dSYM *~ diff --git a/lua/msvcbuild.bat b/lua/msvcbuild.bat new file mode 100644 index 0000000..b03ba07 --- /dev/null +++ b/lua/msvcbuild.bat @@ -0,0 +1,20 @@ +@rem Script to build Lua under "Visual Studio .NET Command Prompt".
+@rem Dependencies are:
+@rem Lua
+@rem winpcap, specifically, the winpcap developer pack
+@rem dnet, Dug Song's net library, aka libdumbnet
+
+@setlocal
+@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE
+@set MYLINK=link /nologo
+@set MYMT=mt /nologo
+
+@set LUA=..\..\lua-5.1\src
+@set WINPCAP=..\..\WpdPack
+@set DNET=..\..\libdnet-1.11-win32
+
+%MYCOMPILE% /I..\libnet\include\win32 /I..\libnet\include /I%LUA% /I%WINPCAP%\Include /I%DNET%\include *.c
+%MYLINK% /DLL /libpath:%WINPCAP%\Lib /out:net.dll *.obj %LUA%\lua51.lib ..\libnet\win32\Debug\Libnet.lib %DNET%\lib\dnet.lib
+if exist net.dll.manifest^
+ %MYMT% -manifest net.dll.manifest -outputresource:net.dll;2
+
@@ -36,6 +36,9 @@ THE POSSIBILITY OF SUCH DAMAGE. #include "libnet_decode.h" #include <libnet.h> + +#define LUA_BUILD_AS_DLL /* To pull in LUA_API definitions for modules */ + #include "lua.h" #include "lauxlib.h" #include "lualib.h" @@ -1294,6 +1297,8 @@ static int lnet_chksum(lua_State *L) return 1; } +#ifndef _WIN32 +/* TODO see http://stackoverflow.com/questions/7827062/is-there-a-windows-equivalent-of-nanosleep */ /*- -- remaining = net.nanosleep(seconds) @@ -1324,6 +1329,7 @@ static int lnet_nanosleep(lua_State *L) } } +/* TODO use GetSystemTime or GetSystemTimeAsFileTime */ /*- t = net.gettimeofday() @@ -1343,6 +1349,8 @@ static int lnet_gettimeofday(lua_State *L) } } +#endif + /*- -- net.init(injection, device) @@ -1415,8 +1423,10 @@ static const luaL_reg net[] = {"pton", lnet_pton}, {"htons", lnet_htons}, {"checksum", lnet_chksum}, +#ifndef _WIN32 {"nanosleep", lnet_nanosleep}, {"gettimeofday", lnet_gettimeofday}, +#endif {"init", lnet_init}, {NULL, NULL} }; |