1 |
/* |
2 |
* Boa, an http server |
3 |
* Copyright (C) 1995 Paul Phillips <paulp@go2net.com> |
4 |
* Some changes Copyright (C) 1997 Jon Nelson <jnelson@boa.org> |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 1, or (at your option) |
9 |
* any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
* |
20 |
*/ |
21 |
|
22 |
/* $Id: defines.h,v 1.14 2002/09/27 21:09:11 nmav Exp $*/ |
23 |
|
24 |
#ifndef _DEFINES_H |
25 |
#define _DEFINES_H |
26 |
|
27 |
/***** Change this, or use -c on the command line to specify it *****/ |
28 |
|
29 |
#ifndef SERVER_ROOT |
30 |
#define SERVER_ROOT "/etc/boa" |
31 |
#endif |
32 |
|
33 |
/***** Change this via the CGIPath configuration value in hydra.conf *****/ |
34 |
#define DEFAULT_PATH "/bin:/usr/bin:/usr/local/bin" |
35 |
|
36 |
/***** Change this via the SinglePostLimit configuration value in hydra.conf *****/ |
37 |
#define SINGLE_POST_LIMIT_DEFAULT 1024 * 1024 /* 1 MB */ |
38 |
|
39 |
/***** BOA error codes for socket operations */ |
40 |
#define BOA_E_AGAIN -1 |
41 |
#define BOA_E_PIPE -2 |
42 |
#define BOA_E_INTR -3 |
43 |
#define BOA_E_UNKNOWN -255 |
44 |
|
45 |
/***** Various stuff that you may want to tweak, but probably shouldn't *****/ |
46 |
|
47 |
#define SOCKETBUF_SIZE 16*1024 |
48 |
#define MAX_HEADER_LENGTH 1024 |
49 |
#define CLIENT_STREAM_SIZE SOCKETBUF_SIZE |
50 |
#define BUFFER_SIZE CLIENT_STREAM_SIZE |
51 |
|
52 |
#define MODULE_TABLE_SIZE 8 |
53 |
#define MIME_HASHTABLE_SIZE 47 |
54 |
#define ALIAS_HASHTABLE_SIZE 17 |
55 |
#define PASSWD_HASHTABLE_SIZE 47 |
56 |
#define VIRTHOST_HASHTABLE_SIZE 20 |
57 |
#define DIRECTORY_INDEX_TABLE_SIZE 30 |
58 |
|
59 |
#define REQUEST_TIMEOUT 60 |
60 |
|
61 |
#define CGI_MIME_TYPE "application/x-httpd-cgi" |
62 |
#define HIC_MIME_TYPE "application/x-httpd-hic" |
63 |
|
64 |
/***** CHANGE ANYTHING BELOW THIS LINE AT YOUR OWN PERIL *****/ |
65 |
/***** You will probably introduce buffer overruns unless you know |
66 |
what you are doing *****/ |
67 |
|
68 |
#define MAX_SITENAME_LENGTH 256 |
69 |
#define MAX_LOG_LENGTH MAX_HEADER_LENGTH + 1024 |
70 |
#define MAX_FILE_LENGTH NAME_MAX |
71 |
#define MAX_PATH_LENGTH PATH_MAX |
72 |
|
73 |
#define MAX_USER_DIR_LENGTH 60 |
74 |
|
75 |
#ifdef ACCEPT_ON |
76 |
#define MAX_ACCEPT_LENGTH MAX_HEADER_LENGTH |
77 |
#else |
78 |
#define MAX_ACCEPT_LENGTH 0 |
79 |
#endif |
80 |
|
81 |
#define CGI_VERSION "CGI/1.1" |
82 |
#define COMMON_CGI_COUNT 4 |
83 |
#define CGI_ENV_MAX 50 |
84 |
#define CGI_ARGC_MAX 128 |
85 |
|
86 |
/******************* RESPONSE CLASSES *****************/ |
87 |
|
88 |
#define R_INFORMATIONAL 1 |
89 |
#define R_SUCCESS 2 |
90 |
#define R_REDIRECTION 3 |
91 |
#define R_CLIENT_ERROR 4 |
92 |
#define R_SERVER_ERROR 5 |
93 |
|
94 |
/******************* RESPONSE CODES ******************/ |
95 |
|
96 |
#define R_REQUEST_OK 200 |
97 |
#define R_CREATED 201 |
98 |
#define R_ACCEPTED 202 |
99 |
#define R_PROVISIONAL 203 /* provisional information */ |
100 |
#define R_NO_CONTENT 204 |
101 |
#define R_REQUEST_PARTIAL 206 |
102 |
|
103 |
#define R_MULTIPLE 300 /* multiple choices */ |
104 |
#define R_MOVED_PERM 301 |
105 |
#define R_MOVED_TEMP 302 |
106 |
#define R_NOT_MODIFIED 304 |
107 |
|
108 |
#define R_BAD_REQUEST 400 |
109 |
#define R_UNAUTHORIZED 401 |
110 |
#define R_PAYMENT 402 /* payment required */ |
111 |
#define R_FORBIDDEN 403 |
112 |
#define R_NOT_FOUND 404 |
113 |
#define R_METHOD_NA 405 /* method not allowed */ |
114 |
#define R_NONE_ACC 406 /* none acceptable */ |
115 |
#define R_PROXY 407 /* proxy authentication required */ |
116 |
#define R_REQUEST_TO 408 /* request timeout */ |
117 |
#define R_CONFLICT 409 |
118 |
#define R_GONE 410 |
119 |
#define R_RANGE_UNSATISFIABLE 410 |
120 |
|
121 |
#define R_ERROR 500 /* internal server error */ |
122 |
#define R_NOT_IMP 501 /* not implemented */ |
123 |
#define R_BAD_GATEWAY 502 |
124 |
#define R_SERVICE_UNAV 503 /* service unavailable */ |
125 |
#define R_GATEWAY_TO 504 /* gateway timeout */ |
126 |
#define R_BAD_VERSION 505 |
127 |
|
128 |
/****************** METHODS *****************/ |
129 |
|
130 |
#define M_GET 1 |
131 |
#define M_HEAD 2 |
132 |
#define M_PUT 3 |
133 |
#define M_POST 4 |
134 |
#define M_DELETE 5 |
135 |
#define M_LINK 6 |
136 |
#define M_UNLINK 7 |
137 |
|
138 |
/************** REQUEST STATUS (req->status) ***************/ |
139 |
|
140 |
#define READ_HEADER 0 |
141 |
#define ONE_CR 1 |
142 |
#define ONE_LF 2 |
143 |
#define TWO_CR 3 |
144 |
#define BODY_READ 4 |
145 |
#define BODY_WRITE 5 |
146 |
#define WRITE 6 |
147 |
#define PIPE_READ 7 |
148 |
#define PIPE_WRITE 8 |
149 |
#define DONE 9 |
150 |
#define DEAD 10 |
151 |
#define FINISH_HANDSHAKE 11 |
152 |
#define SEND_ALERT 12 |
153 |
|
154 |
/************** CGI TYPE (req->is_cgi) ******************/ |
155 |
|
156 |
#define CGI 1 |
157 |
#define NPH 2 |
158 |
#define INDEXER_CGI 3 |
159 |
#define HIC_CGI 4 |
160 |
|
161 |
/************* ALIAS TYPES (aliasp->type) ***************/ |
162 |
|
163 |
#define ALIAS 0 |
164 |
#define SCRIPTALIAS 1 |
165 |
#define REDIRECT 2 |
166 |
|
167 |
/*********** KEEPALIVE CONSTANTS (req->keepalive) *******/ |
168 |
|
169 |
#define KA_INACTIVE 0 |
170 |
#define KA_STOPPED 1 |
171 |
#define KA_ACTIVE 2 |
172 |
|
173 |
/********* SSL stuff */ |
174 |
#define DEFAULT_SSL_PARAMS_REFRESH 1800 /* half an hour */ |
175 |
|
176 |
/********* CGI STATUS CONSTANTS (req->cgi_status) *******/ |
177 |
#define CGI_PARSE 1 |
178 |
#define CGI_BUFFER 2 |
179 |
#define CGI_DONE 3 |
180 |
|
181 |
/*********** MMAP_LIST CONSTANTS ************************/ |
182 |
#define USE_MMAP_LIST /* undefine it in constraint environments |
183 |
* to save memory, from mmaped files. |
184 |
*/ |
185 |
|
186 |
#define MMAP_LIST_NEXT(i) (((i)+1)%max_files_cache) |
187 |
#define MMAP_LIST_HASH(dev,ino,size) ((ino)%max_files_cache) |
188 |
|
189 |
/***************** HTTP HEADER STUFF ***************************/ |
190 |
|
191 |
#define TEXT_HTML "text/html; charset=ISO-8859-1" |
192 |
#define CRLF "\r\n" |
193 |
#define HTTP_VERSION "HTTP/1.0" |
194 |
|
195 |
|
196 |
/***************** USEFUL MACROS ************************/ |
197 |
|
198 |
#define SQUASH_KA(req) (req->keepalive=KA_STOPPED) |
199 |
|
200 |
#define BOA_FD_SET(fd, where) { FD_SET(fd, where); \ |
201 |
if (fd > params->max_fd) params->max_fd = fd; \ |
202 |
} |
203 |
|
204 |
/* If and when everyone has a modern gcc or other near-C99 compiler, |
205 |
* change these to static inline functions. Also note that since |
206 |
* we never fuss with O_APPEND append or O_ASYNC, we shouldn't have |
207 |
* to perform an extra system call to F_GETFL first. |
208 |
*/ |
209 |
|
210 |
#ifdef BOA_USE_GETFL |
211 |
#define set_block_fd(fd) real_set_block_fd(fd) |
212 |
#define set_nonblock_fd(fd) real_set_nonblock_fd(fd) |
213 |
#else |
214 |
#define set_block_fd(fd) fcntl(fd, F_SETFL, 0) |
215 |
#define set_nonblock_fd(fd) fcntl(fd, F_SETFL, NOBLOCK) |
216 |
#endif |
217 |
|
218 |
#define DIE(mesg) log_error_mesg(__FILE__, __LINE__, mesg), exit(1) |
219 |
#define WARN(mesg) log_error_mesg(__FILE__, __LINE__, mesg) |
220 |
|
221 |
#endif |