uhttpd: only enable Lua runtime if a handler was specified
[project/luci.git] / contrib / package / uhttpd / src / uhttpd.h
1 #ifndef _UHTTPD_
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <unistd.h>
7 #include <signal.h>
8 #include <sys/types.h>
9 #include <sys/socket.h>
10 #include <sys/select.h>
11 #include <netinet/in.h>
12 #include <arpa/inet.h>
13 #include <linux/limits.h>
14 #include <netdb.h>
15 #include <ctype.h>
16
17 #ifdef HAVE_TLS
18 #include <openssl/ssl.h>
19 #endif
20
21
22 #define UH_LIMIT_MSGHEAD        4096
23 #define UH_LIMIT_HEADERS        64
24
25 #define UH_LIMIT_LISTENERS      16
26 #define UH_LIMIT_CLIENTS        64
27
28 #define UH_HTTP_MSG_GET         0
29 #define UH_HTTP_MSG_HEAD        1
30 #define UH_HTTP_MSG_POST        2
31
32
33 struct config {
34         char docroot[PATH_MAX];
35 #ifdef HAVE_CGI
36         char *cgi_prefix;
37 #endif
38 #ifdef HAVE_LUA
39         char *lua_prefix;
40         char *lua_handler;
41 #endif
42 #ifdef HAVE_TLS
43         char *cert;
44         char *key;
45         SSL_CTX *tls;
46 #endif
47 };
48
49 struct listener {
50         int socket;
51         struct sockaddr_in6 addr;
52         struct config *conf;
53 #ifdef HAVE_TLS
54         SSL_CTX *tls;
55 #endif
56 };
57
58 struct client {
59         int socket;
60         int peeklen;
61         char peekbuf[UH_LIMIT_MSGHEAD];
62         struct listener *server;
63         struct sockaddr_in6 servaddr;
64         struct sockaddr_in6 peeraddr;
65 #ifdef HAVE_TLS
66         SSL *tls;
67 #endif
68 };
69
70 struct http_request {
71         int     method;
72         float version;
73         char *url;
74         char *headers[UH_LIMIT_HEADERS];
75 };
76
77 struct http_response {
78         int statuscode;
79         char *statusmsg;
80         char *headers[UH_LIMIT_HEADERS];
81 };
82
83 #endif
84