# HG changeset patch # User Matthew Wild # Date 1227805925 0 # Node ID bd1397b1dfc9d1b9ad291655cd575067836306b9 # Parent dee02bf4656a23330f4214bfdc73c35ed032d773# Parent 722f63c70a7712ab67b8a97fdef1781457fcd478 Merge from waqas diff -r dee02bf4656a -r bd1397b1dfc9 util-src/Makefile --- a/util-src/Makefile Thu Nov 27 17:09:21 2008 +0000 +++ b/util-src/Makefile Thu Nov 27 17:12:05 2008 +0000 @@ -1,3 +1,7 @@ + +!IFDEF WINDIR +!INCLUDE Makefile.win +!ELSE LUA_INCLUDE=/usr/include/lua5.1 LUA_LIB=lua5.1 @@ -22,3 +26,4 @@ hashes.so: hashes.c gcc -shared hashes.c -I$(LUA_INCLUDE) -l$(LUA_LIB) -l$(OPENSSL_LIB) -o hashes.so +!ENDIF diff -r dee02bf4656a -r bd1397b1dfc9 util-src/Makefile.win --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util-src/Makefile.win Thu Nov 27 17:12:05 2008 +0000 @@ -0,0 +1,29 @@ + +LUA_PATH=$(LUA_DEV) +IDN_PATH=.\libidn-1.9 +OPENSSL_PATH=.\openssl-0.9.8i + +LUA_INCLUDE=$(LUA_PATH)\include +LUA_LIB=$(LUA_PATH)\lib\lua5.1.lib + +IDN_LIB=$(IDN_PATH)\win32\lib\libidn.lib +IDN_INCLUDE1=$(IDN_PATH)\lib +IDN_INCLUDE2=$(IDN_PATH)\win32\include +OPENSSL_LIB=$(OPENSSL_PATH)\out32dll\libeay32.lib +OPENSSL_INCLUDE=$(OPENSSL_PATH)\include + +all: encodings.dll hashes.dll + +install: encodings.dll hashes.dll + copy /Y *.dll ..\util\ + +clean: + del encodings.dll encodings.exp encodings.lib encodings.obj + del hashes.dll hashes.exp hashes.lib hashes.obj + +encodings.dll: encodings.c + cl /LD /nologo encodings.c /I"$(LUA_INCLUDE)" /I"$(IDN_INCLUDE1)" /I"$(IDN_INCLUDE2)" /link "$(LUA_LIB)" "$(IDN_LIB)" /export:luaopen_util_encodings + +hashes.dll: hashes.c + cl /LD /nologo hashes.c /I"$(LUA_INCLUDE)" /I"$(OPENSSL_INCLUDE)" /link "$(LUA_LIB)" "$(OPENSSL_LIB)" /export:luaopen_util_hashes + diff -r dee02bf4656a -r bd1397b1dfc9 util-src/encodings.c --- a/util-src/encodings.c Thu Nov 27 17:09:21 2008 +0000 +++ b/util-src/encodings.c Thu Nov 27 17:12:05 2008 +0000 @@ -3,7 +3,11 @@ * Lua library for base64, stringprep and idna encodings */ +// Newer MSVC compilers deprecate strcpy as unsafe, but we use it in a safe way +#define _CRT_SECURE_NO_DEPRECATE + #include +#include #include "lua.h" #include "lauxlib.h" @@ -51,9 +55,9 @@ char s[3]; switch (--n) { - case 3: s[2]=tuple; - case 2: s[1]=tuple >> 8; - case 1: s[0]=tuple >> 16; + case 3: s[2]=(char) tuple; + case 2: s[1]=(char) (tuple >> 8); + case 1: s[0]=(char) (tuple >> 16); } luaL_addlstring(b,s,n); } @@ -74,7 +78,7 @@ const char *p; default: p=strchr(code,c); if (p==NULL) return 0; - t[n++]= p-code; + t[n++]= (char) (p-code); if (n==4) { base64_decode(&b,t[0],t[1],t[2],t[3],4); diff -r dee02bf4656a -r bd1397b1dfc9 util-src/hashes.c --- a/util-src/hashes.c Thu Nov 27 17:09:21 2008 +0000 +++ b/util-src/hashes.c Thu Nov 27 17:12:05 2008 +0000 @@ -26,7 +26,7 @@ int hex_out = lua_toboolean(L, 2); \ char hash[size]; \ char result[size*2]; \ - func(s, len, hash); \ + func((const unsigned char*)s, len, (unsigned char*)hash); \ if (hex_out) { \ toHex(hash, size, result); \ lua_pushlstring(L, result, size*2); \