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

Contents of /hydra/src/boa.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.31 - (show annotations)
Sun Oct 27 08:45:51 2002 UTC (21 years, 5 months ago) by nmav
Branch: MAIN
CVS Tags: hydra_0_0_10, hydra_0_0_9, hydra_0_1_1, hydra_0_1_0
Branch point for: hydra_0_1_0_patches
Changes since 1.30: +2 -1 lines
File MIME type: text/plain
SSLParamsRefresh was renamed to MaintenanceInterval and is more
generic, since it includes some server cleanups.

1 /*
2 * Boa, an http server
3 * Copyright (C) 1995 Paul Phillips <paulp@go2net.com>
4 * Some changes Copyright (C) 1996-99 Larry Doolittle <ldoolitt@jlab.org>
5 * Some changes Copyright (C) 1997-99 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: boa.h,v 1.30 2002/10/26 20:58:48 nmav Exp $*/
24
25 #ifndef _BOA_H
26 #define _BOA_H
27
28 #include <errno.h>
29 #include <stdlib.h> /* malloc, free, etc. */
30 #include <stdio.h> /* stdin, stdout, stderr */
31 #include <string.h> /* strdup */
32 #include <ctype.h>
33 #include <time.h> /* localtime, time */
34 #include <pwd.h>
35 #include <grp.h>
36 #include <unistd.h>
37 #include <fcntl.h>
38 #include <limits.h> /* OPEN_MAX */
39 #include <setjmp.h>
40
41 #include <netdb.h>
42 #include <netinet/in.h>
43
44 #include <sys/mman.h>
45 #include <sys/types.h> /* socket, bind, accept */
46 #include <sys/socket.h> /* socket, bind, accept, setsockopt, */
47 #include <sys/stat.h> /* open */
48
49 #include "compat.h" /* oh what fun is porting */
50 #include "defines.h"
51 #include "hic.h"
52
53 #ifdef ENABLE_SMP
54 # include <pthread.h>
55 #endif
56
57 #ifdef HAVE_NETINET_TCP_H
58 # include <netinet/tcp.h>
59 #endif
60
61 #include "globals.h"
62
63
64 /* alias */
65 void add_alias(char* hostname, char *fakename, char *realname, int script);
66 int translate_uri(request * req);
67 int init_script_alias(request * req, alias * current, int uri_len);
68 void dump_alias( virthost*);
69
70 /* virthost */
71 void add_virthost(const char *host, const char *ip, const char* document_root, const char* user_dir);
72 virthost *find_virthost(const char *host, int hostlen);
73 void dump_virthost(void);
74
75 /* directory_index */
76 char *find_and_open_directory_index(const char *directory, int dirlen, int* fd);
77 void dump_directory_index(void);
78 void add_directory_index( const char* index);
79 char* find_default_directory_index( void);
80
81 /* config */
82 void read_config_files(void);
83
84 /* escape */
85 #include "escape.h"
86
87 /* get */
88
89 int init_get(server_params*, request * req);
90 int process_get(server_params*, request * req);
91 int get_dir(request * req, stat_st *statbuf);
92 const char* hydra_method_str( int method);
93
94 /* hash */
95 unsigned get_mime_hash_value(char *extension);
96 char *get_mime_type(const char *filename);
97 char *get_home_dir(char *name);
98 void dump_mime(void);
99 void dump_passwd(void);
100 void show_hash_stats(void);
101
102 int get_hash_value( const char* str);
103
104 #define get_alias_hash_value(x) (get_hash_value(x)%ALIAS_HASHTABLE_SIZE)
105 #define get_host_hash_value(x) (get_hash_value(x)%VIRTHOST_HASHTABLE_SIZE)
106 #define get_hic_module_hash_value(x) (get_hash_value(x)%MODULE_HASHTABLE_SIZE)
107
108 /* log */
109 void open_logs(void);
110 void log_access(request * req);
111 void log_error_doc(request * req);
112 void boa_perror(request * req, char *message);
113 void log_error_time(void);
114 void log_error_mesg(char *file, int line, char *mesg);
115
116 /* queue */
117 void block_request(server_params*, request * req);
118 void ready_request(server_params*, request * req);
119 void dequeue(request ** head, request * req);
120 void enqueue(request ** head, request * req);
121
122 /* read */
123 int read_header(server_params*, request * req);
124 int read_body(request * req);
125 int write_body(request * req);
126
127 /* request */
128 request *new_request(server_params* params);
129 void get_request(server_params* params, socket_type*);
130 void process_requests(server_params* params, socket_type* server_s);
131 int process_header_end(server_params*, request * req);
132 int process_header_line(request * req);
133 int process_logline(request * req);
134 int process_option_line(request * req);
135 void add_accept_header(request * req, char *mime_type);
136 void free_requests(server_params* params);
137
138 /* response */
139 void print_ka_phrase(request * req);
140 void print_content_type(request * req);
141 void print_content_length(request * req);
142 void print_last_modified(request * req);
143 void print_http_headers(request * req);
144
145 void send_r_request_file_ok(request * req); /* 200 */
146 void send_r_request_cgi_status(request * req, char* status, char* desc);
147 void send_r_request_partial(request * req); /* 206 */
148 void send_r_moved_perm(request * req, char *url); /* 301 */
149 void send_r_moved_temp(request * req, char *url, char *more_hdr); /* 302 */
150 void send_r_not_modified(request * req); /* 304 */
151 void send_r_bad_request(request * req); /* 400 */
152 void send_r_unauthorized(request * req, char *name); /* 401 */
153 void send_r_forbidden(request * req); /* 403 */
154 void send_r_not_found(request * req); /* 404 */
155 void send_r_precondition_failed(request * req); /* 412 */
156 void send_r_range_unsatisfiable(request * req); /* 416 */
157 void send_r_error(request * req); /* 500 */
158 void send_r_not_implemented(request * req); /* 501 */
159 void send_r_bad_gateway(request * req); /* 502 */
160 void send_r_service_unavailable(request * req); /* 503 */
161 void send_r_bad_version(request * req); /* 505 */
162
163 /* cgi */
164 void create_common_env(void);
165 void clear_common_env(void);
166 int add_cgi_env(request * req, const char *key, const char *value, int http_prefix);
167 int complete_env_ssl( request* req);
168 int complete_env(request * req);
169 void create_argv(request * req, char **aargv);
170 int init_cgi(request * req);
171 int is_executable_cgi( request* req, const char* filename);
172
173 /* signals */
174 void init_signals(void);
175 void block_main_signals(void);
176 void unblock_main_signals(void);
177 void block_sigusr2(void);
178 void unblock_sigusr2(void);
179 void sighup_run(void);
180 void sigchld_run(void);
181 void sigalrm_run(void);
182 void sigusr1_run(void);
183 void sigterm_stage1_run(void);
184 void sigterm_stage2_run(void);
185
186 /* smp */
187 void smp_reinit();
188 void hic_init();
189
190 /* util.c */
191 void clean_pathname(char *pathname);
192 void get_commonlog_time(char buf[30]);
193 void rfc822_time_buf(char *buf, time_t s);
194 int simple_itoa(large_int i, char buf[22]);
195 int boa_atoi(const char *s);
196 large_int boa_atoll(const char *s);
197 int create_etag(unsigned long int size, unsigned long int mod_time,
198 char buf[MAX_ETAG_LENGTH]);
199 char *escape_string(char *inp, char *buf);
200 int month2int(char *month);
201 int modified_since(time_t mtime, char *if_modified_since);
202 char *to_upper(char *str);
203 int unescape_uri(char *uri, char **query_string);
204 tmp_fd create_temporary_file(short want_unlink, int size);
205 void close_tmp_fd( tmp_fd* fds);
206 char * normalize_path(char *path);
207 int set_block_fd(int fd);
208 int set_nonblock_fd(int fd);
209 int set_cloexec_fd(int fd);
210 void strlower(char *s);
211 int check_host(char *r);
212 void create_url( char * buffer, int buffer_size, int secure,
213 const char* hostname, int port, const char* request_uri);
214 void break_comma_list(char *list,
215 char *broken_list[MAX_COMMA_SEP_ELEMENTS], int *elements);
216
217 /* buffer */
218 int req_write(request * req, const char *msg);
219 void reset_output_buffer(request *req);
220 int req_write_escape_http(request * req, char *msg);
221 int req_write_escape_html(request * req, char *msg);
222 int req_flush(request * req);
223 char *escape_uri(char *uri);
224
225 /* timestamp */
226 void timestamp(void);
227
228 /* mmap_cache */
229 struct mmap_entry *find_mmap( int data_fd, stat_st *s);
230 void release_mmap( struct mmap_entry *e);
231 void initialize_mmap( void);
232 void mmap_reinit( void);
233 int cleanup_mmap_list(int all);
234
235 /* sublog */
236 int open_gen_fd(char *spec);
237 int process_cgi_header(request * req);
238
239 /* pipe */
240 int read_from_pipe(request * req);
241 int write_from_pipe(request * req);
242 int io_shuffle(request * req);
243
244 /* ip */
245 int bind_server(int server_s, char *ip, int port);
246 char *ascii_sockaddr(struct SOCKADDR *s, char *dest, int len);
247 int net_port(struct SOCKADDR *s);
248
249 /* select */
250 void* select_loop(void*);
251
252 /* HIC stuff */
253 void* hic_main_loop(void*);
254
255 void dump_hic_modules( void);
256 void add_hic_module(const char *module, const char* sym_prefix, const char* file_suffix);
257 hic_module_st *find_hic_appr_module(const char *content_type, int content_type_len);
258
259 int hic_send_command( request *req, int out_fd);
260
261 /* SSL */
262 void ssl_reinit();
263
264 #endif

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26