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