diff --git a/src/api/api.h b/src/api/api.h index 4b0e14f0..51ebb9a8 100644 --- a/src/api/api.h +++ b/src/api/api.h @@ -7,6 +7,7 @@ #define API_TYPE_FONT "Font" #define API_TYPE_REPLACE "Replace" +#define API_TYPE_PROCESS "Process" void api_load_libs(lua_State *L); diff --git a/src/api/process.c b/src/api/process.c index 111667a1..1de6064f 100644 --- a/src/api/process.c +++ b/src/api/process.c @@ -5,12 +5,12 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include "api.h" + +#define READ_BUF_SIZE 4096 typedef struct { reproc_t * process; @@ -29,7 +29,7 @@ static int process_new(lua_State* L) self->process = NULL; self->L = L; - luaL_getmetatable(L, "PROCESS"); + luaL_getmetatable(L, API_TYPE_PROCESS); lua_setmetatable(L, -2); return 1; @@ -53,7 +53,7 @@ static int process_strerror(lua_State* L) static int process_gc(lua_State* L) { - process_t* self = (process_t*) luaL_checkudata(L, 1, "PROCESS"); + process_t* self = (process_t*) luaL_checkudata(L, 1, API_TYPE_PROCESS); if(self->process){ reproc_kill(self->process); @@ -151,7 +151,7 @@ static int process_read(lua_State* L) process_t* self = (process_t*) lua_touserdata(L, 1); if(self->process){ - int read_size = 4096; + int read_size = READ_BUF_SIZE; if (lua_type(L, 2) == LUA_TNUMBER){ read_size = (int) lua_tonumber(L, 2); } @@ -410,7 +410,7 @@ static const struct luaL_Reg process[] = { int luaopen_process(lua_State *L) { - luaL_newmetatable(L, "PROCESS"); + luaL_newmetatable(L, API_TYPE_PROCESS); luaL_setfuncs(L, process_methods, 0); lua_pushvalue(L, -1); lua_setfield(L, -2, "__index");