/[hydra]/hydra/src/globals.h
ViewVC logotype

Contents of /hydra/src/globals.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.31.2.2 - (show annotations)
Wed Jan 8 17:10:11 2003 UTC (21 years, 2 months ago) by nmav
Branch: hydra_0_1_0_patches
CVS Tags: hydra_0_1_2
Changes since 1.31.2.1: +4 -1 lines
File MIME type: text/plain
Renamed HICActiondirective to CGIAction. The server now requires the Host header field in HTTP/1.1 requests.

1 /*
2 * Boa, an http server
3 * Copyright (C) 1995 Paul Phillips <paulp@go2net.com>
4 * Some changes Copyright (C) 1996,97 Larry Doolittle <ldoolitt@jlab.org>
5 * Some changes Copyright (C) 1997 Jon Nelson <jnelson@boa.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 1, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23 /* $Id: globals.h,v 1.31.2.1 2003/01/07 17:08:18 nmav Exp $*/
24
25 #ifndef _GLOBALS_H
26 #define _GLOBALS_H
27
28 #ifdef ENABLE_SSL
29 # include <gnutls/gnutls.h>
30 #endif
31
32 typedef struct {
33 int socket;
34 int secure; /* ssl or not. NOTE: 0 or 1. Nothing else. */
35 int port;
36 int pending_requests;
37 } socket_type;
38
39 struct mmap_entry {
40 dev_t dev;
41 ino_t ino;
42 char *mmap;
43 int use_count;
44 size_t len;
45 int available;
46 int times_used;
47 };
48
49 typedef struct {
50 hic_shutdown_func shutdown;
51 hic_init_func init;
52 hic_request_func request;
53 void *dl_handle;
54 char* sym_prefix; /* ie. "_php" */
55 char* content_type; /* ie. "application/x-httpd-php" */
56 char* action; /* ie. "/usr/bin/php4" */
57 int content_type_len;
58 } hic_module_st;
59
60 struct alias {
61 char *fakename; /* URI path to file */
62 char *realname; /* Actual path to file */
63 int type; /* ALIAS, SCRIPTALIAS, REDIRECT */
64 int fake_len; /* strlen of fakename */
65 int real_len; /* strlen of realname */
66 struct alias *next;
67 };
68
69 typedef struct alias alias;
70
71 typedef struct {
72 /* We use this, in order to store data to pipes if the
73 * given POST data length, is smaller that PIPE_BUF;
74 */
75 int fds[2]; /* 0 is for reading, 1 for writing */
76 int pipe; /* non zero if it's a pipe */
77 } tmp_fd;
78
79 struct access_node
80 {
81 char *pattern;
82 char type;
83 };
84
85 typedef struct _virthost {
86 char *ip; /* This virthost will be visible in this IP */
87 char *host; /* The hostname of the virtual host */
88 char* document_root; /* The document root of this virtual host */
89 char* user_dir; /* The user dir of this virtual host */
90 int user_dir_len; /* strlen of user_dir */
91 int ip_len; /* strlen of IP */
92 int host_len; /* strlen of hostname */
93 int document_root_len; /* strlen of document root */
94 alias *alias_hashtable[ALIAS_HASHTABLE_SIZE]; /* aliases in this virthost */
95
96 int n_access;
97 struct access_node *access_nodes;
98 struct _virthost *next;
99 } virthost;
100
101 struct request { /* pending requests */
102 int fd; /* client's socket fd */
103 #ifdef USE_POLL
104 int pollfd_id;
105 #endif
106 #ifdef ENABLE_SSL
107 gnutls_session ssl_state;
108 char * certificate_verified; /* a string that describes the output of the
109 * certificate verification function. Needed
110 * in CGIs.
111 */
112 #endif
113 int secure; /* whether ssl or not */
114 int alert_to_send; /* in SEND_ALERT state */
115
116 int status; /* see #defines.h */
117 time_t time_last; /* time of last succ. op. */
118 char *pathname; /* pathname of requested file */
119 large_int range_start; /* send file from byte ... */
120 large_int range_stop; /* to byte */
121 large_int pipe_range_stop; /* This is used only if the file is sent by the pipe_read() method.
122 * Indicates how many bytes to send from a file (actually a copy of range_stop,
123 * but it is modified. */
124 int simple; /* simple request? */
125 int keepalive; /* keepalive status */
126 int kacount; /* keepalive count */
127
128 int data_fd; /* fd of data */
129 large_int filesize; /* filesize */
130 large_int filepos; /* position in file */
131 char *data_mem; /* mmapped/malloced char array */
132 int method; /* M_GET, M_POST, etc. */
133
134 char *logline; /* line to log file */
135
136 char *header_line; /* beginning of un or incompletely processed header line */
137 char *header_end; /* last known end of header, or end of processed data */
138 int parse_pos; /* how much have we parsed */
139 int client_stream_pos; /* how much have we read... */
140
141 int buffer_start; /* where the buffer starts */
142 int buffer_end; /* where the buffer ends */
143
144 char *http_version; /* HTTP/?.? of req */
145 int response_status; /* R_NOT_FOUND etc. */
146
147 char *if_modified_since; /* If-Modified-Since */
148 time_t last_modified; /* Last-modified: */
149
150 char *if_none_match_etag;
151 char *if_match_etag;
152 char *if_range_etag; /* These are the Etags sent by the client
153 * In If-* requests.
154 */
155 int if_types; /* If-Match, If-None-Match, If-Range
156 * and OR of the MATCH_* definitions.
157 */
158
159 char local_ip_addr[NI_MAXHOST]; /* for virtualhost */
160 int hostname_given; /* For HTTP/1.1 checks. 0 if the
161 * Host header was not found.
162 */
163 char *hostname; /* The hostname used in this request */
164 char document_root[MAX_PATH_LENGTH + 1];
165 char user_dir[MAX_USER_DIR_LENGTH + 1];
166
167 /* CGI vars */
168
169 int remote_port; /* could be used for ident */
170
171 char remote_ip_addr[NI_MAXHOST]; /* after inet_ntoa */
172
173 char* action; /* the action to run if HIC_ACTION cgi */
174 int is_cgi; /* true if CGI/NPH */
175 int cgi_status;
176 int cgi_env_index; /* index into array */
177
178 /* Agent and referer for logfiles */
179 char *header_user_agent;
180 char *header_referer;
181
182 tmp_fd post_data_fd; /* fd for post data tmpfile */
183
184 char *path_info; /* env variable */
185 char *path_translated; /* env variable */
186 char *script_name; /* env variable */
187 char *query_string; /* env variable */
188 char *content_type; /* env variable */
189 char *content_length; /* env variable */
190
191 struct mmap_entry *mmap_entry_var;
192
193 struct request *next; /* next */
194 struct request *prev; /* previous */
195
196 /* everything below this line is kept regardless */
197 char buffer[BUFFER_SIZE + 1]; /* generic I/O buffer */
198 char request_uri[MAX_HEADER_LENGTH + 1]; /* uri */
199 char client_stream[CLIENT_STREAM_SIZE]; /* data from client - fit or be hosed */
200 char *cgi_env[CGI_ENV_MAX + 4]; /* CGI environment */
201
202 #ifdef ACCEPT_ON
203 char accept[MAX_ACCEPT_LENGTH]; /* Accept: fields */
204 #endif
205 };
206
207 typedef struct request request;
208
209 struct status {
210 long requests;
211 long errors;
212 };
213
214
215 extern char *optarg; /* For getopt */
216 extern FILE *yyin; /* yacc input */
217
218 typedef struct {
219 #ifdef ENABLE_SMP
220 pthread_t tid;
221 #endif
222 request* request_ready;
223 request* request_block;
224 request* request_free;
225
226 socket_type server_s[2];
227
228 #ifdef USE_POLL
229 struct pollfd *pfds;
230 int pfd_len;
231 #else
232 fd_set block_read_fdset; /* fds blocked on read */
233 fd_set block_write_fdset; /* fds blocked on write */
234 #endif
235
236 struct timeval req_timeout;
237 int sighup_flag; /* 1 => signal has happened, needs attention */
238 int sigchld_flag; /* 1 => signal has happened, needs attention */
239 int sigalrm_flag; /* 1 => signal has happened, needs attention */
240 int sigusr1_flag; /* 1 => signal has happened, needs attention */
241 int sigterm_flag; /* lame duck mode */
242
243 int max_fd;
244
245 int sockbufsize;
246 struct status status;
247 int total_connections;
248
249 /* for SIGBUS handling */
250 jmp_buf env;
251 int handle_sigbus;
252
253 } server_params;
254
255 /* HIC request stuff
256 */
257 typedef struct _hic_request {
258 struct _hic_request *next;
259 struct _hic_request *prev;
260 hic_stuff command;
261 } hic_request;
262
263 /* parameters passed to a hic thread */
264 typedef struct {
265 #ifdef ENABLE_SMP
266 pthread_t tid;
267 pthread_mutex_t lock;
268 #endif
269 int sigchld_flag; /* 1 => signal has happened, needs attention */
270 int sighup_flag;
271 hic_request* request_head;
272 } hic_params;
273
274 /* global server variables */
275
276 extern int maintenance_interval;
277 extern int mmap_list_entries_used;
278 extern char *access_log_name;
279 extern char *error_log_name;
280 extern char *cgi_log_name;
281 extern int cgi_log_fd;
282 extern int use_localtime;
283
284 extern int max_files_cache;
285 extern int max_file_size_cache;
286
287 extern int boa_ssl;
288
289 extern int server_port;
290 extern int ssl_port;
291 extern uid_t server_uid;
292 extern gid_t server_gid;
293 extern char *server_admin;
294 extern char *server_root;
295 extern char *server_name;
296 extern char *server_ip;
297 extern int max_fd;
298
299 extern char *default_type;
300 extern char *default_charset;
301 extern char *dirmaker;
302 extern char *mime_types;
303 extern char *pid_file;
304 extern char *cachedir;
305
306 extern char *default_document_root;
307 extern int default_document_root_size;
308
309 extern int system_bufsize; /* Default size of SNDBUF given by system */
310
311 extern char *tempdir;
312 extern int tempdir_len;
313
314 extern char *cgi_path;
315 extern int single_post_limit;
316
317 extern int ka_timeout;
318 extern int ka_max;
319
320 extern time_t start_time;
321
322 extern int max_server_threads;
323 extern int max_hic_threads;
324
325 extern int cgi_umask;
326
327 extern long int max_connections;
328
329 extern int verbose_cgi_logs;
330
331 extern int backlog;
332 extern time_t current_time;
333
334 /* Global stuff that is shared by all threads.
335 * Use with extreme care, or don't use.
336 */
337 extern server_params *global_server_params;
338 extern int global_server_params_size;
339
340 #ifdef ENABLE_HIC
341 extern hic_params *global_hic_params;
342 extern int global_hic_params_size;
343 #endif
344
345 /* These contain a string of the form: "Server: Hydra/0.0.x\r\n"
346 */
347 extern char boa_tls_version[];
348 extern char boa_version[];
349
350 #endif

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26