Rename and update config. Update Makefile for this change.
[prosody.git] / util-src / encodings.c
index cc7beef72ab04597bac6b5d4a93c9e785c3e3339..ac24ebcfcce2280087aa4f2a7cedd2b2042f33d3 100644 (file)
@@ -3,7 +3,11 @@
 * Lua library for base64, stringprep and idna encodings\r
 */\r
 \r
+// Newer MSVC compilers deprecate strcpy as unsafe, but we use it in a safe way\r
+#define _CRT_SECURE_NO_DEPRECATE\r
+\r
 #include <string.h>\r
+#include <malloc.h>\r
 \r
 #include "lua.h"\r
 #include "lauxlib.h"\r
@@ -51,9 +55,9 @@ static void base64_decode(luaL_Buffer *b, int c1, int c2, int c3, int c4, int n)
        char s[3];\r
        switch (--n)\r
        {\r
-               case 3: s[2]=tuple;\r
-               case 2: s[1]=tuple >> 8;\r
-               case 1: s[0]=tuple >> 16;\r
+               case 3: s[2]=(char) tuple;\r
+               case 2: s[1]=(char) (tuple >> 8);\r
+               case 1: s[0]=(char) (tuple >> 16);\r
        }\r
        luaL_addlstring(b,s,n);\r
 }\r
@@ -74,7 +78,7 @@ static int Lbase64_decode(lua_State *L)               /** decode(s) */
                        const char *p;\r
                        default:\r
                                p=strchr(code,c); if (p==NULL) return 0;\r
-                               t[n++]= p-code;\r
+                               t[n++]= (char) (p-code);\r
                                if (n==4)\r
                                {\r
                                        base64_decode(&b,t[0],t[1],t[2],t[3],4);\r
@@ -199,7 +203,7 @@ static const luaL_Reg Reg[] =
        { NULL,         NULL    }\r
 };\r
 \r
-LUALIB_API int luaopen_encodings(lua_State *L)\r
+LUALIB_API int luaopen_util_encodings(lua_State *L)\r
 {\r
        luaL_register(L, "encodings", Reg);\r
 \r