diff options
Diffstat (limited to 'l_cmd.c')
-rw-r--r-- | l_cmd.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -22,6 +22,7 @@ #include <lua.h> #include <lauxlib.h> +#include <unistd.h> #include <sys/socket.h> #include <errno.h> @@ -33,6 +34,7 @@ #include "command_queue.h" #include "client_list.h" #include "log.h" +#include "utils.h" int cmd_fd; read_buffer_t cmd_buffer; @@ -43,7 +45,7 @@ static int l_cmd_getfd(lua_State *L) luaL_error(L, "can't retreive signal fd"); lua_pushliteral(L, "fd"); - lua_gettable(L, -2); + lua_gettable(L, -2); return 1; } @@ -84,7 +86,7 @@ static int cmd_recv_data(lua_State* L) if(cmd_buffer.buf[cmd_buffer.offset] == '\n') { cmd_buffer.buf[cmd_buffer.offset] = 0; - lua_pushstring(L, cmd_buffer.buf); + lua_pushstring(L, (char *)(cmd_buffer.buf)); ret = lua_pcall(L, 1, 1, 0); if(ret) { @@ -96,7 +98,7 @@ static int cmd_recv_data(lua_State* L) } return -1; } - + ret = lua_tointeger(L, 1); cmd_buffer.offset = 0; break; @@ -130,20 +132,20 @@ static int l_cmd_send_string(lua_State* L) if(ret > 0) ret = 0; - + lua_pushinteger(L, ret); return 1; } static const struct luaL_reg cmd_funcs [] = { - { "init", l_cmd_init }, + { "init", l_cmd_init }, { "recv_data", l_cmd_recv_data }, { "send_string", l_cmd_send_string }, { NULL, NULL } }; -LUALIB_API int luaopen_cmd(lua_State *L) +LUALIB_API int luaopen_cmd(lua_State *L) { luaL_register(L, LUA_CMDLIBNAME, cmd_funcs); return 1; |