Changeset 1774a2db88a0c683623716a678d38d508802f8eb
- Timestamp:
- 02/02/11 01:45:35 (2 years ago)
- git-parent:
- Files:
-
- src/modules/lua_noit.c (modified) (3 diffs)
- src/utils/Makefile.in (modified) (1 diff)
- src/utils/noit_b32.c (added)
- src/utils/noit_b32.h (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/modules/lua_noit.c
r68fdcd3 r1774a2d 55 55 #include "utils/noit_log.h" 56 56 #include "utils/noit_str.h" 57 #include "utils/noit_b32.h" 57 58 #include "utils/noit_b64.h" 58 59 #include "eventer/eventer.h" … … 984 985 lua_pop(L, 1); /* "string" table */ 985 986 return 0; 987 } 988 static int 989 nl_base32_decode(lua_State *L) { 990 size_t inlen, decoded_len; 991 const char *message; 992 unsigned char *decoded; 993 994 if(lua_gettop(L) != 1) luaL_error(L, "bad call to noit.decode"); 995 996 message = lua_tolstring(L, 1, &inlen); 997 decoded = malloc(MAX(1,inlen)); 998 if(!decoded) luaL_error(L, "out-of-memory"); 999 decoded_len = noit_b32_decode(message, inlen, decoded, MAX(1,inlen)); 1000 lua_pushlstring(L, (char *)decoded, decoded_len); 1001 return 1; 1002 } 1003 static int 1004 nl_base32_encode(lua_State *L) { 1005 size_t inlen, encoded_len; 1006 const unsigned char *message; 1007 char *encoded; 1008 1009 if(lua_gettop(L) != 1) luaL_error(L, "bad call to noit.encode"); 1010 1011 message = (const unsigned char *)lua_tolstring(L, 1, &inlen); 1012 encoded_len = (((inlen + 7) / 5) * 8) + 1; 1013 encoded = malloc(encoded_len); 1014 if(!encoded) luaL_error(L, "out-of-memory"); 1015 encoded_len = noit_b32_encode(message, inlen, encoded, encoded_len); 1016 lua_pushlstring(L, (char *)encoded, encoded_len); 1017 return 1; 986 1018 } 987 1019 static int … … 1825 1857 { "dns", nl_dns_lookup }, 1826 1858 { "log", nl_log }, 1859 { "base32_decode", nl_base32_decode }, 1860 { "base32_encode", nl_base32_encode }, 1827 1861 { "base64_decode", nl_base64_decode }, 1828 1862 { "base64_encode", nl_base64_encode }, src/utils/Makefile.in
r5fbae1c r1774a2d 11 11 12 12 OBJS=noit_hash.o noit_skiplist.o noit_log.o noit_sem.o noit_str.o \ 13 noit_b64.o noit_ security.o noit_watchdog.o noit_mkdir.o \13 noit_b64.o noit_b32.o noit_security.o noit_watchdog.o noit_mkdir.o \ 14 14 noit_getip.o noit_lockfile.o \ 15 15 @ATOMIC_OBJS@
