Apply http://prosody.im/patches/luaevent-catch-errors-1.patch
[luaevent.git] / include / luaevent.h
blobddd4ce481259c3f361867033a65f94b72f2420f9
1 /* LuaEvent - Copyright (C) 2007,2012 Thomas Harning <harningt@gmail.com>
2 * Licensed as LGPL - See doc/COPYING for details */
3 #ifndef LUAEVENT_H
4 #define LUAEVENT_H
6 #include <lua.h>
8 /* Workarounds for Lua 5.2 */
9 #if (LUA_VERSION_NUM == 502)
11 #undef lua_equal
12 #define lua_equal(L,idx1,idx2) lua_compare(L, (idx1), (idx2), LUA_OPEQ)
14 #undef lua_getfenv
15 #define lua_getfenv lua_getuservalue
16 #undef lua_setfenv
17 #define lua_setfenv lua_setuservalue
19 #undef lua_objlen
20 #define lua_objlen lua_rawlen
22 #undef luaL_register
23 #define luaL_register(L, n, f) \
24 { if ((n) == NULL) luaL_setfuncs(L, f, 0); else luaL_newlib(L, f); }
26 #endif
28 #include <sys/types.h>
29 #ifdef _WIN32
30 #include <winsock2.h>
31 #else
32 #include <sys/time.h>
33 #endif
34 #include <event.h>
36 typedef struct {
37 struct event_base* base;
38 lua_State* loop_L;
39 int errorMessage;
40 } le_base;
42 le_base* event_base_get(lua_State* L, int idx);
43 void load_timeval(double time, struct timeval *tv);
44 int getSocketFd(lua_State* L, int idx);
46 int luaopen_luaevent(lua_State* L);
48 #endif