aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2008-11-27 21:47:13 +0500
committerWaqas Hussain <waqas20@gmail.com>2008-11-27 21:47:13 +0500
commit2fdb13c54d3257984b8e1e6885d5f7c6d5580f18 (patch)
treea86ae2f9327530d0418115d88f11136df5149e8a
parenta153b3c26704686bf9a3f2255d9aeb3c5f6aa2b1 (diff)
downloadprosody-2fdb13c54d3257984b8e1e6885d5f7c6d5580f18.tar.gz
prosody-2fdb13c54d3257984b8e1e6885d5f7c6d5580f18.zip
Minor changes to C files (to prevent compiler warnings)
-rw-r--r--util-src/encodings.c12
-rw-r--r--util-src/hashes.c2
2 files changed, 9 insertions, 5 deletions
diff --git a/util-src/encodings.c b/util-src/encodings.c
index 27955601..ac24ebcf 100644
--- a/util-src/encodings.c
+++ b/util-src/encodings.c
@@ -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 <string.h>
+#include <malloc.h>
#include "lua.h"
#include "lauxlib.h"
@@ -51,9 +55,9 @@ static void base64_decode(luaL_Buffer *b, int c1, int c2, int c3, int c4, int n)
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 @@ static int Lbase64_decode(lua_State *L) /** decode(s) */
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 --git a/util-src/hashes.c b/util-src/hashes.c
index f57e6b55..41cf6f50 100644
--- a/util-src/hashes.c
+++ b/util-src/hashes.c
@@ -26,7 +26,7 @@ static int myFunc(lua_State *L) { \
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); \