test server pthreads
[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 extern void test_server_lock(int care);
39 extern void test_server_unlock(int care);
40
41 #ifndef __func__
42 #define __func__ __FUNCTION__
43 #endif
44
45 struct per_session_data__http {
46         int fd;
47 };
48
49 /*
50  * one of these is auto-created for each connection and a pointer to the
51  * appropriate instance is passed to the callback in the user parameter
52  *
53  * for this example protocol we use it to individualize the count for each
54  * connection.
55  */
56
57 struct per_session_data__dumb_increment {
58         int number;
59 };
60
61 struct per_session_data__lws_mirror {
62         struct libwebsocket *wsi;
63         int ringbuffer_tail;
64 };
65
66 extern int callback_http(struct libwebsocket_context *context,
67                          struct libwebsocket *wsi,
68                          enum libwebsocket_callback_reasons reason,
69                          void *user, void *in, size_t len);
70 extern int callback_lws_mirror(struct libwebsocket_context *context,
71                                struct libwebsocket *wsi,
72                                enum libwebsocket_callback_reasons reason,
73                                void *user, void *in, size_t len);
74 extern int callback_dumb_increment(struct libwebsocket_context *context,
75                                struct libwebsocket *wsi,
76                                enum libwebsocket_callback_reasons reason,
77                                void *user, void *in, size_t len);
78
79 extern void
80 dump_handshake_info(struct libwebsocket *wsi);