2 * Copyright (c) 2007, Cameron Rich
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of the axTLS project nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #define VERSION "1.0.0"
35 #ifdef CONFIG_HTTP_HAS_IPV6
39 #define MAXPOSTDATASIZE 30000
40 #define MAXREQUESTLENGTH 256
41 #define BLOCKSIZE 4096
43 #define INITIAL_CONNECTION_SLOTS 10
44 #define CONFIG_HTTP_DEFAULT_SSL_OPTIONS SSL_DISPLAY_CERTS
46 #define STATE_WANT_TO_READ_HEAD 1
47 #define STATE_WANT_TO_SEND_HEAD 2
48 #define STATE_WANT_TO_READ_FILE 3
49 #define STATE_WANT_TO_SEND_FILE 4
50 #define STATE_DOING_DIR 5
61 struct connstruct *next;
68 #if defined(CONFIG_HTTP_DIRECTORIES)
71 WIN32_FIND_DATA file_data;
78 char actualfile[MAXREQUESTLENGTH];
79 char filereq[MAXREQUESTLENGTH];
80 char dirname[MAXREQUESTLENGTH];
81 char server_name[MAXREQUESTLENGTH];
83 char databuf[BLOCKSIZE];
85 uint8_t close_when_done;
86 time_t if_modified_since;
88 #if defined(CONFIG_HTTP_HAS_CGI)
90 #ifdef CONFIG_HTTP_ENABLE_LUA
94 char remote_addr[MAXREQUESTLENGTH];
95 char uri_request[MAXREQUESTLENGTH];
96 char uri_path_info[MAXREQUESTLENGTH];
97 char uri_query[MAXREQUESTLENGTH];
98 char cookie[MAXREQUESTLENGTH];
100 #if defined(CONFIG_HTTP_HAS_AUTHORIZATION)
101 char authorization[MAXREQUESTLENGTH];
110 struct serverstruct *next;
116 #if defined(CONFIG_HTTP_HAS_CGI)
119 struct cgiextstruct *next;
124 /* global prototypes */
125 extern struct serverstruct *servers;
126 extern struct connstruct *usedconns;
127 extern struct connstruct *freeconns;
128 extern const char * const server_version;
130 #if defined(CONFIG_HTTP_HAS_CGI)
131 extern struct cgiextstruct *cgiexts;
134 /* conn.c prototypes */
135 void removeconnection(struct connstruct *cn);
137 /* proc.c prototypes */
138 void procdodir(struct connstruct *cn);
139 void procreadhead(struct connstruct *cn);
140 void procsendhead(struct connstruct *cn);
141 void procreadfile(struct connstruct *cn);
142 void procsendfile(struct connstruct *cn);
143 #if defined(CONFIG_HTTP_HAS_CGI)
144 void read_post_data(struct connstruct *cn);
147 /* misc.c prototypes */
148 char *my_strncpy(char *dest, const char *src, size_t n);
149 int isdir(const char *name);
151 /* tdate prototypes */
152 void tdate_init(void);
153 time_t tdate_parse(const char* str);