-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxyserver.h
57 lines (45 loc) · 1.33 KB
/
proxyserver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* proxyserver_server.h
* All rights reserved.
*/
#ifndef _PROXYSERVER_SERVER_H
#define _PROXYSERVER_SERVER_H
struct proxyserver_socket {
/* Socket */
int s;
enum { NOTINIT = 0, CONNECTED = 1 } state;
enum { CLIENT = 0, SERVER = 1 } type;
int client, server;
};
struct proxyserver_server {
/* Sockets, indexed by fd. */
struct proxyserver_socket *sockets;
int maxsockets;
/* epoll descriptor */
int epfd;
/* Master socket */
int ms;
};
void* runserver(void *ctx);
#define FATAL_ERROR_CHECK(x) ({ \
int _retval = (x); \
if (_retval < 0) { \
printf("Fatal error at %s:%d: %s: %s\n", __FILE__, __LINE__, #x, strerror(errno)); \
exit(1); \
} \
_retval; \
})
#define ERROR_CHECK(x) ({ \
int _retval = (x); \
if (_retval < 0) { \
printf("Error at %s:%d: %s: %s\n", __FILE__, __LINE__, #x, strerror(errno)); \
} \
_retval; \
})
#define TEMP_FAILURE_RETRY(expression) \
(__extension__ \
({ long int __result; \
do __result = (long int) (expression); \
while (__result == -1L && errno == EINTR); \
__result; }))
#endif /* _PROXYSERVER_SERVER_H */