diff options
Diffstat (limited to 'src/unix.h')
-rw-r--r-- | src/unix.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/unix.h b/src/unix.h new file mode 100644 index 0000000..e317b06 --- /dev/null +++ b/src/unix.h | |||
@@ -0,0 +1,69 @@ | |||
1 | #ifndef COMPAT_H_ | ||
2 | #define COMPAT_H_ | ||
3 | |||
4 | #include "lspriv.h" | ||
5 | |||
6 | /*=========================================================================*\ | ||
7 | * BSD include files | ||
8 | \*=========================================================================*/ | ||
9 | /* error codes */ | ||
10 | #include <errno.h> | ||
11 | /* close function */ | ||
12 | #include <unistd.h> | ||
13 | /* fnctnl function and associated constants */ | ||
14 | #include <fcntl.h> | ||
15 | /* struct timeval and CLK_TCK */ | ||
16 | #include <sys/time.h> | ||
17 | /* times function and struct tms */ | ||
18 | #include <sys/times.h> | ||
19 | /* struct sockaddr */ | ||
20 | #include <sys/types.h> | ||
21 | /* socket function */ | ||
22 | #include <sys/socket.h> | ||
23 | /* gethostbyname and gethostbyaddr functions */ | ||
24 | #include <netdb.h> | ||
25 | /* sigpipe handling */ | ||
26 | #include <signal.h> | ||
27 | |||
28 | #include <netinet/in.h> | ||
29 | #include <arpa/inet.h> | ||
30 | |||
31 | #define COMPAT_FD int | ||
32 | #define COMPAT_INVALIDFD (-1) | ||
33 | |||
34 | /* we are lazy... */ | ||
35 | typedef struct sockaddr SA; | ||
36 | |||
37 | /*=========================================================================*\ | ||
38 | * Exported functions | ||
39 | \*=========================================================================*/ | ||
40 | void compat_open(lua_State *L); | ||
41 | |||
42 | #define compat_bind bind | ||
43 | #define compat_connect connect | ||
44 | #define compat_listen listen | ||
45 | #define compat_close close | ||
46 | #define compat_select select | ||
47 | |||
48 | COMPAT_FD compat_socket(int domain, int type, int protocol); | ||
49 | COMPAT_FD compat_accept(COMPAT_FD s, SA *addr, socklen_t *len, int deadline); | ||
50 | int compat_send(COMPAT_FD c, cchar *data, size_t count, size_t *done, | ||
51 | int deadline); | ||
52 | int compat_recv(COMPAT_FD c, uchar *data, size_t count, size_t *done, | ||
53 | int deadline); | ||
54 | int compat_sendto(COMPAT_FD c, cchar *data, size_t count, size_t *done, | ||
55 | int deadline, SA *addr, socklen_t len); | ||
56 | int compat_recvfrom(COMPAT_FD c, uchar *data, size_t count, size_t *got, | ||
57 | int deadline, SA *addr, socklen_t *len); | ||
58 | void compat_setnonblocking(COMPAT_FD sock); | ||
59 | void compat_setblocking(COMPAT_FD sock); | ||
60 | void compat_setreuseaddr(COMPAT_FD sock); | ||
61 | |||
62 | const char *compat_hoststrerror(void); | ||
63 | const char *compat_socketstrerror(void); | ||
64 | const char *compat_bindstrerror(void); | ||
65 | const char *compat_connectstrerror(void); | ||
66 | |||
67 | cchar *compat_trysetoptions(lua_State *L, COMPAT_FD sock); | ||
68 | |||
69 | #endif /* COMPAT_H_ */ | ||