5a491c52bb781ccb9ac0dc8b30e2e4e73f665ac6
[project/luci.git] / libs / nixio / src / nixio.h
1 #ifndef NIXIO_H_
2 #define NIXIO_H_
3
4 #define NIXIO_META "nixio.socket"
5 #define NIXIO_FILE_META "nixio.file"
6 #define NIXIO_TLS_CTX_META "nixio.tls.ctx"
7 #define NIXIO_TLS_SOCK_META "nixio.tls.sock"
8 #define NIXIO_BUFFERSIZE 8096
9 #define _FILE_OFFSET_BITS 64
10
11 #define NIXIO_PUSH_CONSTANT(x) \
12         lua_pushinteger(L, x); \
13         lua_setfield(L, -2, #x);
14
15 /* uClibc: broken as always */
16 #define _LARGEFILE_SOURCE
17
18 #include <lua.h>
19 #include <lualib.h>
20 #include <lauxlib.h>
21
22 struct nixio_socket {
23         int fd;
24         int domain;
25         int type;
26         int protocol;
27 };
28
29 typedef struct nixio_socket nixio_sock;
30
31 int nixio__perror(lua_State *L);
32 int nixio__pstatus(lua_State *L, int condition);
33 nixio_sock* nixio__checksock(lua_State *L);
34 int nixio__checksockfd(lua_State *L);
35 int nixio__checkfd(lua_State *L, int ud);
36 int nixio__tofd(lua_State *L, int ud);
37 FILE* nixio__checkfile(lua_State *L);
38
39 /* Module functions */
40 void nixio_open_file(lua_State *L);
41 void nixio_open_socket(lua_State *L);
42 void nixio_open_sockopt(lua_State *L);
43 void nixio_open_bind(lua_State *L);
44 void nixio_open_address(lua_State *L);
45 void nixio_open_poll(lua_State *L);
46 void nixio_open_io(lua_State *L);
47 void nixio_open_splice(lua_State *L);
48 void nixio_open_tls_context(lua_State *L);
49 void nixio_open_tls_socket(lua_State *L);
50
51 /* Method functions */
52
53 #endif /* NIXIO_H_ */