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

Contents of /hydra/src/globals.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.33 - (show annotations)
Sun Jan 26 11:25:39 2003 UTC (21 years, 2 months ago) by nmav
Branch: MAIN
CVS Tags: hydra_0_1_7, hydra_0_1_6, hydra_0_1_4
Changes since 1.32: +6 -6 lines
File MIME type: text/plain
Better large file support (now uses the included autoconf macros).
(++some indentation)

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26