fixed eventloop endless restart when wmii goes away
[wmiirc-lua.git] / luaeventloop / lel_instance.h
blob85ab372f05c82d301a68f9edd693b4d93147b3a4
1 #ifndef __LUAIXP_INSTANCE_H__
2 #define __LUAIXP_INSTANCE_H__
4 #include <lua.h>
6 #define L_EVENTLOOP_MT "eventloop.eventloop_mt"
8 /* the C representation of a eventloop instance object */
9 struct lel_program;
10 struct lel_eventloop {
11 struct lel_program **progs; // array of programs, sorted by fd
12 size_t progs_size; // number allocated entries
13 size_t progs_count; // first unused entry
15 fd_set all_fds;
16 int max_fd;
18 #define LEL_PROGS_ARRAY_GROWS_BY 32
20 struct lel_program {
21 char *cmd;
22 int fd;
23 int pid;
24 int read_rc;
25 int read_errno;
26 size_t buf_pos;
27 size_t buf_len;
28 char buf[0]; // this has to be last in the structure
30 #define LEL_PROGRAM_IO_BUF_SIZE 4096
32 extern struct lel_eventloop *lel_checkeventloop (lua_State *L, int narg);
33 extern int l_eventloop_tostring (lua_State *L);
35 /* exported api */
36 extern int l_eventloop_add_exec (lua_State *L);
37 extern int l_eventloop_check_exec (lua_State *L);
38 extern int l_eventloop_kill_exec (lua_State *L);
39 extern int l_eventloop_run_loop (lua_State *L);
40 extern int l_eventloop_kill_all (lua_State *L);
42 #endif // __LUAIXP_INSTANCE_H__