refactor test server
[platform/upstream/libwebsockets.git] / test-server / test-server.h
1 #include "lws_config.h"
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <getopt.h>
6 #include <signal.h>
7 #include <string.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <assert.h>
11
12 #include "../lib/libwebsockets.h"
13
14 #ifdef _WIN32
15 #include <io.h>
16 #ifdef EXTERNAL_POLL
17 #define poll WSAPoll
18 #endif
19 #include "gettimeofday.h"
20 #else
21 #include <syslog.h>
22 #include <sys/time.h>
23 #include <unistd.h>
24 #endif
25
26 extern int close_testing;
27 extern int max_poll_elements;
28
29 #ifdef EXTERNAL_POLL
30 extern struct libwebsocket_pollfd *pollfds;
31 extern int *fd_lookup;
32 extern int count_pollfds;
33 #endif
34 extern volatile int force_exit;
35 extern struct libwebsocket_context *context;
36 extern char *resource_path;
37
38 struct per_session_data__http {
39         int fd;
40 };
41
42 /*
43  * one of these is auto-created for each connection and a pointer to the
44  * appropriate instance is passed to the callback in the user parameter
45  *
46  * for this example protocol we use it to individualize the count for each
47  * connection.
48  */
49
50 struct per_session_data__dumb_increment {
51         int number;
52 };
53
54 struct per_session_data__lws_mirror {
55         struct libwebsocket *wsi;
56         int ringbuffer_tail;
57 };
58
59 extern int callback_http(struct libwebsocket_context *context,
60                          struct libwebsocket *wsi,
61                          enum libwebsocket_callback_reasons reason,
62                          void *user, void *in, size_t len);
63 extern int callback_lws_mirror(struct libwebsocket_context *context,
64                                struct libwebsocket *wsi,
65                                enum libwebsocket_callback_reasons reason,
66                                void *user, void *in, size_t len);
67 extern int callback_dumb_increment(struct libwebsocket_context *context,
68                                struct libwebsocket *wsi,
69                                enum libwebsocket_callback_reasons reason,
70                                void *user, void *in, size_t len);
71
72 extern void
73 dump_handshake_info(struct libwebsocket *wsi);