acl  3.5.3.0
acl_server_api.h
浏览该文件的文档.
1 #ifndef ACL_MASTER_SERVER_API_INCLUDE_H
2 #define ACL_MASTER_SERVER_API_INCLUDE_H
3 
4 #include "../stdlib/acl_define.h"
5 
6  /*
7  * Utility library.
8  */
9 #include "../stdlib/acl_vstream.h"
10 #include "../ioctl/acl_ioctl.h"
11 #include "../aio/acl_aio.h"
12 #include "../event/acl_events.h"
13 
14 #ifndef ACL_CLIENT_ONLY
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define ACL_MASTER_SERVER_END 0
21 #define ACL_MASTER_SERVER_INT_TABLE 1
22 #define ACL_MASTER_SERVER_STR_TABLE 2
23 #define ACL_MASTER_SERVER_BOOL_TABLE 3
24 #define ACL_MASTER_SERVER_TIME_TABLE 4
25 #define ACL_MASTER_SERVER_RAW_TABLE 5
26 #define ACL_MASTER_SERVER_INT64_TABLE 6
27 #define ACL_MASTER_SERVER_IN_FLOW_DELAY 8
28 
29 #define ACL_MASTER_SERVER_PRE_INIT 10
30 #define ACL_MASTER_SERVER_POST_INIT 11
31 #define ACL_MASTER_SERVER_LOOP 12
32 #define ACL_MASTER_SERVER_EXIT 13
33 #define ACL_MASTER_SERVER_SOLITARY 14
34 #define ACL_MASTER_SERVER_UNLIMITED 15
35 #define ACL_MASTER_SERVER_ON_CLOSE 16
36 #define ACL_MASTER_SERVER_ON_ACCEPT 17
37 #define ACL_MASTER_SERVER_ON_TIMEOUT 18
38 #define ACL_MASTER_SERVER_ON_HANDSHAKE 19
39 
40 #define ACL_MASTER_SERVER_THREAD_INIT 20
41 #define ACL_MASTER_SERVER_THREAD_INIT_CTX 21
42 #define ACL_MASTER_SERVER_THREAD_EXIT 22
43 #define ACL_MASTER_SERVER_THREAD_EXIT_CTX 23
44 #define ACL_MASTER_SERVER_CTX 24
45 #define ACL_MASTER_SERVER_DENY_INFO 25
46 
47 #define ACL_MASTER_SERVER_EXIT_TIMER 26
48 #define ACL_MASTER_SERVER_ON_LISTEN 27
49 #define ACL_MASTER_SERVER_ON_BIND ACL_MASTER_SERVER_ON_LISTEN
50 #define ACL_MASTER_SERVER_SIGHUP 28
51 #define ACL_MASTER_SERVER_ON_UNBIND 29
52 
53 #define ACL_APP_CTL_END ACL_MASTER_SERVER_END
54 #define ACL_APP_CTL_CFG_INT ACL_MASTER_SERVER_INT_TABLE
55 #define ACL_APP_CTL_CFG_STR ACL_MASTER_SERVER_STR_TABLE
56 #define ACL_APP_CTL_CFG_BOOL ACL_MASTER_SERVER_BOOL_TABLE
57 #define ACL_APP_CTL_CFG_INT64 ACL_MASTER_SERVER_INT64_TABLE
58 #define ACL_APP_CTL_INIT_FN ACL_MASTER_SERVER_POST_INIT
59 #define ACL_APP_CTL_PRE_JAIL ACL_MASTER_SERVER_PRE_INIT
60 #define ACL_APP_CTL_EXIT_FN ACL_MASTER_SERVER_EXIT
61 #define ACL_APP_CTL_THREAD_INIT ACL_MASTER_SERVER_THREAD_INIT
62 #define ACL_APP_CTL_THREAD_INIT_CTX ACL_MASTER_SERVER_THREAD_INIT_CTX
63 #define ACL_APP_CTL_THREAD_EXIT ACL_MASTER_SERVER_THREAD_EXIT
64 #define ACL_APP_CTL_THREAD_EXIT_CTX ACL_MASTER_SERVER_THREAD_EXIT_CTX
65 #define ACL_APP_CTL_DENY_INFO ACL_MASTER_DENY_INFO
66 #define ACL_APP_CTL_ON_ACCEPT ACL_MASTER_SERVER_ON_ACCEPT
67 #define ACL_APP_CTL_ON_CLOSE ACL_MASTER_SERVER_ON_CLOSE
68 #define ACL_APP_CTL_ON_TIMEOUT ACL_MASTER_SERVER_ON_TIMEOUT
69 #define ACL_APP_CTL_ON_SIGHUP ACL_MASTER_SERVER_SIGHUP
70 
71 typedef void (*ACL_MASTER_SERVER_INIT_FN) (void *);
72 typedef int (*ACL_MASTER_SERVER_LOOP_FN) (void *);
73 typedef void (*ACL_MASTER_SERVER_EXIT_FN) (void *);
74 typedef void (*ACL_MASTER_SERVER_ON_LISTEN_FN) (void *, ACL_VSTREAM *);
75 typedef void (*ACL_MASTER_SERVER_ON_BIND_FN) (void *, ACL_VSTREAM *);
76 typedef void (*ACL_MASTER_SERVER_ON_UNBIND_FN) (void *, ACL_VSTREAM *);
77 typedef int (*ACL_MASTER_SERVER_ON_ACCEPT_FN) (void *, ACL_VSTREAM *);
78 typedef int (*ACL_MASTER_SERVER_HANDSHAKE_FN) (void *, ACL_VSTREAM *);
79 typedef void (*ACL_MASTER_SERVER_DISCONN_FN) (void *, ACL_VSTREAM *);
80 typedef int (*ACL_MASTER_SERVER_TIMEOUT_FN) (void *, ACL_VSTREAM *);
81 typedef int (*ACL_MASTER_SERVER_EXIT_TIMER_FN)(void *, size_t, size_t);
82 
83 typedef int (*ACL_MASTER_SERVER_THREAD_INIT_FN)(void *);
84 typedef void (*ACL_MASTER_SERVER_THREAD_EXIT_FN)(void *);
85 typedef int (*ACL_MASTER_SERVER_SIGHUP_FN)(void *, ACL_VSTRING *);
86 
87  /*
88  * acl_single_server.c
89  */
90 typedef void (*ACL_SINGLE_SERVER_FN) (void*, ACL_VSTREAM *);
91 
92 ACL_API const char *acl_single_server_conf(void);
93 ACL_API void acl_single_server_main(int, char **, ACL_SINGLE_SERVER_FN, ...);
94 ACL_API ACL_EVENT *acl_single_server_event(void);
96 
97  /*
98  * acl_threads_server.c
99  */
100 typedef int (*ACL_THREADS_SERVER_FN) (void *, ACL_VSTREAM*);
101 
102 ACL_API const char *acl_threads_server_conf(void);
103 ACL_API void acl_threads_server_main(int argc, char *argv[],
104  ACL_THREADS_SERVER_FN, void *service_ctx, int name, ...);
105 #define acl_ioctl_app_main acl_threads_server_main
106 
107 ACL_API ACL_EVENT *acl_threads_server_event(void);
110 
111 ACL_API void acl_threads_server_enable_read(ACL_EVENT *event,
112  acl_pthread_pool_t *threads, ACL_VSTREAM *stream);
113 ACL_API void acl_threads_server_disable_read(ACL_EVENT *event,
114  ACL_VSTREAM *stream);
115 
116  /*
117  * acl_aio_server.c
118  */
119 typedef void (*ACL_AIO_SERVER_FN) (ACL_ASTREAM *, void *);
120 typedef void (*ACL_AIO_SERVER2_FN) (ACL_SOCKET, void *);
121 
122 ACL_API const char *acl_aio_server_conf(void);
123 ACL_API void acl_aio_server_main(int, char **, ACL_AIO_SERVER_FN, ...);
124 ACL_API void acl_aio_server2_main(int, char **, ACL_AIO_SERVER2_FN, ...);
125 
126 typedef int (*ACL_AIO_RUN_FN)(ACL_ASTREAM *stream, void *run_ctx);
127 typedef int (*ACL_AIO_RUN2_FN)(ACL_SOCKET fd, void *run_ctx);
128 
129 ACL_DEPRECATED void acl_aio_app_main(int argc, char *argv[],
130  ACL_AIO_RUN_FN run_fn, void *run_ctx, ...);
131 ACL_DEPRECATED void acl_aio_app2_main(int argc, char *argv[],
132  ACL_AIO_RUN2_FN run2_fn, void *run_ctx, ...);
133 
135  void *arg, int delay);
136 ACL_API void acl_aio_server_cancel_timer(ACL_EVENT_NOTIFY_TIME timer_fn, void *arg);
139 ACL_API ACL_AIO *acl_aio_server_handle(void);
140 ACL_API ACL_EVENT *acl_aio_server_event(void);
141 ACL_API int acl_aio_server_read(ACL_ASTREAM *astream, int timeout,
142  ACL_AIO_READ_FN notify_fn, void *context);
143 ACL_API int acl_aio_server_readn(ACL_ASTREAM *astream, int count, int timeout,
144  ACL_AIO_READ_FN notify_fn, void *context);
145 ACL_API int acl_aio_server_gets(ACL_ASTREAM *astream, int timeout,
146  ACL_AIO_READ_FN notify_fn, void *context);
147 ACL_API int acl_aio_server_gets_nonl(ACL_ASTREAM *astream, int timeout,
148  ACL_AIO_READ_FN notify_fn, void *context);
149 ACL_API int acl_aio_server_writen(ACL_ASTREAM *astream, ACL_AIO_WRITE_FN notify_fn,
150  void *context, const char *data, int dlen);
151 ACL_API int acl_aio_server_vfprintf(ACL_ASTREAM *astream, ACL_AIO_WRITE_FN notify_fn,
152  void *context, const char *fmt, va_list ap);
153 ACL_API int acl_aio_server_fprintf(ACL_ASTREAM *astream, ACL_AIO_WRITE_FN notify_fn,
154  void *context, const char *fmt, ...);
155 ACL_API int acl_aio_server_connect(const char *saddr, int timeout,
156  ACL_AIO_CONNECT_FN connect_fn, void *context);
157 ACL_API ACL_ASTREAM **acl_aio_server_streams(void);
158 ACL_API void acl_aio_server_on_close(ACL_ASTREAM *stream);
159 
160  /*
161  * acl_udp_server.c
162  */
163 typedef void (*ACL_UDP_SERVER_FN) (void* ctx, ACL_VSTREAM *);
164 
165 ACL_API const char *acl_udp_server_conf(void);
166 ACL_API void acl_udp_server_request_timer(ACL_EVENT_NOTIFY_TIME timer_fn, void *arg,
167  acl_int64 delay, int keep);
168 ACL_API void acl_udp_server_cancel_timer(ACL_EVENT_NOTIFY_TIME timer_fn, void *arg);
169 ACL_API void acl_udp_server_main(int, char **, ACL_UDP_SERVER_FN, ...);
170 ACL_API ACL_EVENT *acl_udp_server_event(void);
171 ACL_API ACL_VSTREAM **acl_udp_server_streams(void);
172 
173  /*
174  * acl_trigger_server.c
175  */
176 typedef void (*ACL_TRIGGER_SERVER_FN) (void *);
177 ACL_API const char *acl_trigger_server_conf(void);
178 ACL_API void acl_trigger_server_main(int, char **, ACL_TRIGGER_SERVER_FN, ...);
179 ACL_API ACL_EVENT *acl_trigger_server_event(void);
180 
181 #define ACL_TRIGGER_BUF_SIZE 1024
182 
183  /*
184  * acl_server_sig.c
185  */
186 extern ACL_API int acl_var_server_gotsighup;
187 ACL_API void acl_server_sighup_setup(void);
188 ACL_API void acl_server_sigterm_setup(void);
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* ACL_CLIENT_ONLY */
195 #endif
int(* ACL_MASTER_SERVER_LOOP_FN)(void *)
void(* ACL_MASTER_SERVER_DISCONN_FN)(void *, ACL_VSTREAM *)
int(* ACL_MASTER_SERVER_ON_ACCEPT_FN)(void *, ACL_VSTREAM *)
ACL_API int acl_aio_server_fprintf(ACL_ASTREAM *astream, ACL_AIO_WRITE_FN notify_fn, void *context, const char *fmt,...)
ACL_DEPRECATED void acl_aio_app_main(int argc, char *argv[], ACL_AIO_RUN_FN run_fn, void *run_ctx,...)
void(* ACL_UDP_SERVER_FN)(void *ctx, ACL_VSTREAM *)
void(* ACL_SINGLE_SERVER_FN)(void *, ACL_VSTREAM *)
ACL_API ACL_EVENT * acl_aio_server_event(void)
HTTP_API void const char * name
Definition: lib_http.h:620
int(* ACL_MASTER_SERVER_EXIT_TIMER_FN)(void *, size_t, size_t)
void(* ACL_MASTER_SERVER_INIT_FN)(void *)
void(* ACL_AIO_SERVER_FN)(ACL_ASTREAM *, void *)
ACL_API int acl_var_server_gotsighup
ACL_API acl_pthread_pool_t * acl_threads_server_threads(void)
int(* ACL_AIO_RUN2_FN)(ACL_SOCKET fd, void *run_ctx)
ACL_API ACL_EVENT * acl_udp_server_event(void)
ACL_API ACL_EVENT * acl_threads_server_event(void)
ACL_API ACL_EVENT * acl_trigger_server_event(void)
ACL_DEPRECATED void acl_aio_app2_main(int argc, char *argv[], ACL_AIO_RUN2_FN run2_fn, void *run_ctx,...)
ACL_API void acl_udp_server_cancel_timer(ACL_EVENT_NOTIFY_TIME timer_fn, void *arg)
int(* ACL_THREADS_SERVER_FN)(void *, ACL_VSTREAM *)
int(* ACL_MASTER_SERVER_TIMEOUT_FN)(void *, ACL_VSTREAM *)
int(* ACL_AIO_CONNECT_FN)(ACL_ASTREAM *cstream, void *context)
Definition: acl_aio.h:96
#define ACL_DEPRECATED
Definition: acl_define.h:85
int(* ACL_AIO_RUN_FN)(ACL_ASTREAM *stream, void *run_ctx)
void(* ACL_MASTER_SERVER_THREAD_EXIT_FN)(void *)
void(* ACL_MASTER_SERVER_EXIT_FN)(void *)
void(* ACL_MASTER_SERVER_ON_BIND_FN)(void *, ACL_VSTREAM *)
ACL_API ACL_EVENT * acl_single_server_event(void)
ACL_API int acl_aio_server_connect(const char *saddr, int timeout, ACL_AIO_CONNECT_FN connect_fn, void *context)
ACL_API void acl_aio_server_cancel_rw_timer(ACL_ASTREAM *)
ACL_API ACL_VSTREAM ** acl_single_server_sstreams(void)
void(* ACL_MASTER_SERVER_ON_UNBIND_FN)(void *, ACL_VSTREAM *)
int(* ACL_AIO_WRITE_FN)(ACL_ASTREAM *astream, void *context)
Definition: acl_aio.h:67
ACL_API ACL_VSTREAM ** acl_udp_server_streams(void)
ACL_API void acl_aio_server_request_timer(ACL_EVENT_NOTIFY_TIME timer_fn, void *arg, int delay)
void(* ACL_MASTER_SERVER_ON_LISTEN_FN)(void *, ACL_VSTREAM *)
int(* ACL_AIO_READ_FN)(ACL_ASTREAM *astream, void *context, char *data, int dlen)
Definition: acl_aio.h:48
ACL_API const char * acl_udp_server_conf(void)
ACL_API int acl_aio_server_writen(ACL_ASTREAM *astream, ACL_AIO_WRITE_FN notify_fn, void *context, const char *data, int dlen)
ACL_API ACL_AIO * acl_aio_server_handle(void)
ACL_API int acl_aio_server_gets(ACL_ASTREAM *astream, int timeout, ACL_AIO_READ_FN notify_fn, void *context)
struct ACL_AIO ACL_AIO
Definition: acl_aio.h:31
ACL_API void acl_server_sighup_setup(void)
ACL_API const char * acl_threads_server_conf(void)
struct acl_pthread_pool_t acl_pthread_pool_t
ACL_API void acl_aio_server_on_close(ACL_ASTREAM *stream)
ACL_API void acl_server_sigterm_setup(void)
int(* ACL_MASTER_SERVER_SIGHUP_FN)(void *, ACL_VSTRING *)
void(* ACL_AIO_SERVER2_FN)(ACL_SOCKET, void *)
ACL_API void acl_udp_server_request_timer(ACL_EVENT_NOTIFY_TIME timer_fn, void *arg, acl_int64 delay, int keep)
struct ACL_EVENT ACL_EVENT
Definition: acl_events.h:43
ACL_API void acl_threads_server_enable_read(ACL_EVENT *event, acl_pthread_pool_t *threads, ACL_VSTREAM *stream)
ACL_API int acl_aio_server_readn(ACL_ASTREAM *astream, int count, int timeout, ACL_AIO_READ_FN notify_fn, void *context)
int(* ACL_MASTER_SERVER_HANDSHAKE_FN)(void *, ACL_VSTREAM *)
ACL_API void acl_aio_server_cancel_timer(ACL_EVENT_NOTIFY_TIME timer_fn, void *arg)
ACL_API ACL_VSTREAM ** acl_threads_server_streams(void)
ACL_API const char * acl_single_server_conf(void)
ACL_API void acl_threads_server_disable_read(ACL_EVENT *event, ACL_VSTREAM *stream)
ACL_API void acl_single_server_main(int, char **, ACL_SINGLE_SERVER_FN,...)
ACL_API void acl_aio_server_main(int, char **, ACL_AIO_SERVER_FN,...)
ACL_API void const char * fmt
Definition: acl_aio.h:771
ACL_API void acl_udp_server_main(int, char **, ACL_UDP_SERVER_FN,...)
void(* ACL_TRIGGER_SERVER_FN)(void *)
ACL_API void acl_trigger_server_main(int, char **, ACL_TRIGGER_SERVER_FN,...)
ACL_API int acl_aio_server_read(ACL_ASTREAM *astream, int timeout, ACL_AIO_READ_FN notify_fn, void *context)
ACL_API const char * acl_aio_server_conf(void)
ACL_API int acl_aio_server_gets_nonl(ACL_ASTREAM *astream, int timeout, ACL_AIO_READ_FN notify_fn, void *context)
int(* ACL_MASTER_SERVER_THREAD_INIT_FN)(void *)
ACL_API void acl_threads_server_main(int argc, char *argv[], ACL_THREADS_SERVER_FN, void *service_ctx, int name,...)
void(* ACL_EVENT_NOTIFY_TIME)(int event_type, ACL_EVENT *event, void *context)
Definition: acl_events.h:56
ACL_API void acl_aio_server2_main(int, char **, ACL_AIO_SERVER2_FN,...)
ACL_API ACL_ASTREAM ** acl_aio_server_streams(void)
ACL_API void acl_aio_server_request_rw_timer(ACL_ASTREAM *)
ACL_API const char * acl_trigger_server_conf(void)
ACL_API int acl_aio_server_vfprintf(ACL_ASTREAM *astream, ACL_AIO_WRITE_FN notify_fn, void *context, const char *fmt, va_list ap)