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

Annotation of /hydra/src/globals.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide annotations)
Sun Sep 29 11:00:04 2002 UTC (21 years, 6 months ago) by nmav
Branch: MAIN
Changes since 1.16: +8 -1 lines
File MIME type: text/plain
Added support for If-Range, If-Match, If-None-Match HTTP/1.1 header
fields. The server also generates ETag headers for static content using
the last modified field of the file, and the file size.

Fixed the behaviour of the range parser, when a bogus range was received.
Now it does not send any message, it silently ignores the bogus range.

1 nmav 1.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 nmav 1.17 /* $Id: globals.h,v 1.16 2002/09/28 17:49:13 nmav Exp $*/
24 nmav 1.1
25     #ifndef _GLOBALS_H
26     #define _GLOBALS_H
27    
28 nmav 1.15 #ifdef ENABLE_SSL
29     # include <gnutls/gnutls.h>
30     #endif
31 nmav 1.1
32     typedef struct {
33     int socket;
34 nmav 1.3 int secure; /* ssl or not. NOTE: 0 or 1. Nothing else. */
35 nmav 1.5 int port;
36 nmav 1.1 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 nmav 1.2 int times_used;
47 nmav 1.1 };
48 nmav 1.12
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 nmav 1.13 char* content_type; /* ie. "application/x-httpd-php" */
56     int content_type_len;
57 nmav 1.12 } hic_module_st;
58 nmav 1.1
59 nmav 1.8 struct alias {
60     char *fakename; /* URI path to file */
61     char *realname; /* Actual path to file */
62     int type; /* ALIAS, SCRIPTALIAS, REDIRECT */
63     int fake_len; /* strlen of fakename */
64     int real_len; /* strlen of realname */
65     struct alias *next;
66     };
67    
68     typedef struct alias alias;
69    
70 nmav 1.6 typedef struct _virthost {
71     char *ip; /* This virthost will be visible in this IP */
72     char *host; /* The hostname of the virtual host */
73     char* document_root; /* The document root of this virtual host */
74     char* user_dir; /* The user dir of this virtual host */
75     int user_dir_len; /* strlen of user_dir */
76     int ip_len; /* strlen of IP */
77     int host_len; /* strlen of hostname */
78     int document_root_len; /* strlen of document root */
79 nmav 1.8 alias *alias_hashtable[ALIAS_HASHTABLE_SIZE]; /* aliases in this virthost */
80 nmav 1.6 struct _virthost *next;
81     } virthost;
82    
83 nmav 1.1 struct request { /* pending requests */
84     int fd; /* client's socket fd */
85 nmav 1.15 #ifdef ENABLE_SSL
86 nmav 1.1 GNUTLS_STATE ssl_state;
87 nmav 1.15 #endif
88 nmav 1.1 int secure; /* whether ssl or not */
89     int alert_to_send; /* in SEND_ALERT state */
90    
91     int status; /* see #defines.h */
92     time_t time_last; /* time of last succ. op. */
93     char *pathname; /* pathname of requested file */
94 nmav 1.4 size_t range_start; /* send file from byte ... */
95     size_t range_stop; /* to byte */
96     size_t pipe_range_stop; /* This is used only if the file is sent by the pipe_read() method.
97     * Indicates how many bytes to send from a file (actually a copy of range_stop,
98     * but it is modified. */
99 nmav 1.1 int simple; /* simple request? */
100     int keepalive; /* keepalive status */
101     int kacount; /* keepalive count */
102    
103     int data_fd; /* fd of data */
104     unsigned long filesize; /* filesize */
105     unsigned long filepos; /* position in file */
106     char *data_mem; /* mmapped/malloced char array */
107     int method; /* M_GET, M_POST, etc. */
108    
109     char *logline; /* line to log file */
110    
111     char *header_line; /* beginning of un or incompletely processed header line */
112     char *header_end; /* last known end of header, or end of processed data */
113     int parse_pos; /* how much have we parsed */
114     int client_stream_pos; /* how much have we read... */
115    
116     int buffer_start; /* where the buffer starts */
117     int buffer_end; /* where the buffer ends */
118    
119     char *http_version; /* HTTP/?.? of req */
120     int response_status; /* R_NOT_FOUND etc. */
121    
122     char *if_modified_since; /* If-Modified-Since */
123     time_t last_modified; /* Last-modified: */
124 nmav 1.17
125     char *etag; /* This is the Etag sent by the client
126     * In a If-* request.
127     */
128     int if_type; /* If-Match, If-None-Match, If-Range
129     * use the MATCH_* definitions.
130     */
131 nmav 1.1
132     char local_ip_addr[NI_MAXHOST]; /* for virtualhost */
133 nmav 1.8 char *hostname;
134 nmav 1.7 char document_root[MAX_PATH_LENGTH + 1];
135 nmav 1.8 char user_dir[MAX_USER_DIR_LENGTH + 1];
136 nmav 1.1
137     /* CGI vars */
138    
139     int remote_port; /* could be used for ident */
140    
141     char remote_ip_addr[NI_MAXHOST]; /* after inet_ntoa */
142    
143     int is_cgi; /* true if CGI/NPH */
144     int cgi_status;
145     int cgi_env_index; /* index into array */
146    
147     /* Agent and referer for logfiles */
148     char *header_user_agent;
149     char *header_referer;
150    
151     int post_data_fd; /* fd for post data tmpfile */
152    
153     char *path_info; /* env variable */
154     char *path_translated; /* env variable */
155     char *script_name; /* env variable */
156     char *query_string; /* env variable */
157     char *content_type; /* env variable */
158     char *content_length; /* env variable */
159    
160     struct mmap_entry *mmap_entry_var;
161    
162     struct request *next; /* next */
163     struct request *prev; /* previous */
164    
165     /* everything below this line is kept regardless */
166     char buffer[BUFFER_SIZE + 1]; /* generic I/O buffer */
167     char request_uri[MAX_HEADER_LENGTH + 1]; /* uri */
168     char client_stream[CLIENT_STREAM_SIZE]; /* data from client - fit or be hosed */
169     char *cgi_env[CGI_ENV_MAX + 4]; /* CGI environment */
170    
171     #ifdef ACCEPT_ON
172     char accept[MAX_ACCEPT_LENGTH]; /* Accept: fields */
173     #endif
174     };
175    
176     typedef struct request request;
177    
178     struct status {
179     long requests;
180     long errors;
181     };
182    
183    
184     extern char *optarg; /* For getopt */
185     extern FILE *yyin; /* yacc input */
186    
187     extern request **_request_ready; /* first in ready list */
188     extern request **_request_block; /* first in blocked list */
189     extern request **_request_free; /* first in free list */
190    
191     typedef struct {
192     #ifdef ENABLE_SMP
193     pthread_t tid;
194     #endif
195     request* request_ready;
196     request* request_block;
197     request* request_free;
198     socket_type server_s[2];
199     fd_set block_read_fdset;
200     fd_set block_write_fdset;
201     struct timeval req_timeout;
202     int sighup_flag; /* 1 => signal has happened, needs attention */
203     int sigchld_flag; /* 1 => signal has happened, needs attention */
204     int sigalrm_flag; /* 1 => signal has happened, needs attention */
205     int sigusr1_flag; /* 1 => signal has happened, needs attention */
206     int sigterm_flag; /* lame duck mode */
207    
208     int max_fd;
209    
210     int sockbufsize;
211     struct status status;
212     int total_connections;
213    
214     /* for SIGBUS handling */
215     jmp_buf env;
216     int handle_sigbus;
217    
218     } server_params;
219    
220     /* global server variables */
221    
222     extern char *access_log_name;
223     extern char *error_log_name;
224     extern char *cgi_log_name;
225     extern int cgi_log_fd;
226     extern int use_localtime;
227 nmav 1.9
228     extern int max_files_cache;
229     extern int max_file_size_cache;
230 nmav 1.5
231     extern int boa_ssl;
232 nmav 1.1
233     extern int server_port;
234     extern int ssl_port;
235     extern uid_t server_uid;
236     extern gid_t server_gid;
237     extern char *server_admin;
238     extern char *server_root;
239     extern char *server_name;
240     extern char *server_ip;
241     extern int max_fd;
242     extern int devnullfd;
243    
244     extern char *default_type;
245 nmav 1.11 extern char *default_charset;
246 nmav 1.1 extern char *dirmaker;
247     extern char *mime_types;
248     extern char *cachedir;
249    
250 nmav 1.6 extern char *default_document_root;
251 nmav 1.7 extern int default_document_root_size;
252 nmav 1.6
253 nmav 1.1 extern char *tempdir;
254 nmav 1.16 extern int tempdir_len;
255 nmav 1.1
256     extern char *cgi_path;
257     extern int single_post_limit;
258    
259     extern int ka_timeout;
260     extern int ka_max;
261    
262 nmav 1.14 extern int hic_sigchld_flag;
263 nmav 1.1 extern time_t start_time;
264    
265     extern int pending_requests;
266     extern long int max_connections;
267    
268     extern int verbose_cgi_logs;
269    
270     extern int backlog;
271     extern time_t current_time;
272    
273 nmav 1.14 #ifdef ENABLE_HIC
274     extern pthread_t hic_tid;
275     #endif
276 nmav 1.1
277     #endif

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26