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.3 2002/09/23 07:43:32 nmav Exp $*/ |
24 |
|
25 |
#ifndef _GLOBALS_H |
26 |
#define _GLOBALS_H |
27 |
|
28 |
#include <gnutls/gnutls.h> |
29 |
|
30 |
typedef struct { |
31 |
int socket; |
32 |
int secure; /* ssl or not. NOTE: 0 or 1. Nothing else. */ |
33 |
int pending_requests; |
34 |
} socket_type; |
35 |
|
36 |
struct mmap_entry { |
37 |
dev_t dev; |
38 |
ino_t ino; |
39 |
char *mmap; |
40 |
int use_count; |
41 |
size_t len; |
42 |
int available; |
43 |
int times_used; |
44 |
}; |
45 |
|
46 |
struct alias { |
47 |
char *fakename; /* URI path to file */ |
48 |
char *realname; /* Actual path to file */ |
49 |
int type; /* ALIAS, SCRIPTALIAS, REDIRECT */ |
50 |
int fake_len; /* strlen of fakename */ |
51 |
int real_len; /* strlen of realname */ |
52 |
struct alias *next; |
53 |
}; |
54 |
|
55 |
typedef struct alias alias; |
56 |
|
57 |
struct request { /* pending requests */ |
58 |
int fd; /* client's socket fd */ |
59 |
GNUTLS_STATE ssl_state; |
60 |
int secure; /* whether ssl or not */ |
61 |
int alert_to_send; /* in SEND_ALERT state */ |
62 |
|
63 |
int status; /* see #defines.h */ |
64 |
time_t time_last; /* time of last succ. op. */ |
65 |
char *pathname; /* pathname of requested file */ |
66 |
size_t range_start; /* send file from byte ... */ |
67 |
size_t range_stop; /* to byte */ |
68 |
size_t pipe_range_stop; /* This is used only if the file is sent by the pipe_read() method. |
69 |
* Indicates how many bytes to send from a file (actually a copy of range_stop, |
70 |
* but it is modified. */ |
71 |
int simple; /* simple request? */ |
72 |
int keepalive; /* keepalive status */ |
73 |
int kacount; /* keepalive count */ |
74 |
|
75 |
int data_fd; /* fd of data */ |
76 |
unsigned long filesize; /* filesize */ |
77 |
unsigned long filepos; /* position in file */ |
78 |
char *data_mem; /* mmapped/malloced char array */ |
79 |
int method; /* M_GET, M_POST, etc. */ |
80 |
|
81 |
char *logline; /* line to log file */ |
82 |
|
83 |
char *header_line; /* beginning of un or incompletely processed header line */ |
84 |
char *header_end; /* last known end of header, or end of processed data */ |
85 |
int parse_pos; /* how much have we parsed */ |
86 |
int client_stream_pos; /* how much have we read... */ |
87 |
|
88 |
int buffer_start; /* where the buffer starts */ |
89 |
int buffer_end; /* where the buffer ends */ |
90 |
|
91 |
char *http_version; /* HTTP/?.? of req */ |
92 |
int response_status; /* R_NOT_FOUND etc. */ |
93 |
|
94 |
char *if_modified_since; /* If-Modified-Since */ |
95 |
time_t last_modified; /* Last-modified: */ |
96 |
|
97 |
char local_ip_addr[NI_MAXHOST]; /* for virtualhost */ |
98 |
|
99 |
/* CGI vars */ |
100 |
|
101 |
int remote_port; /* could be used for ident */ |
102 |
|
103 |
char remote_ip_addr[NI_MAXHOST]; /* after inet_ntoa */ |
104 |
|
105 |
int is_cgi; /* true if CGI/NPH */ |
106 |
int cgi_status; |
107 |
int cgi_env_index; /* index into array */ |
108 |
|
109 |
/* Agent and referer for logfiles */ |
110 |
char *header_user_agent; |
111 |
char *header_referer; |
112 |
|
113 |
int post_data_fd; /* fd for post data tmpfile */ |
114 |
|
115 |
char *path_info; /* env variable */ |
116 |
char *path_translated; /* env variable */ |
117 |
char *script_name; /* env variable */ |
118 |
char *query_string; /* env variable */ |
119 |
char *content_type; /* env variable */ |
120 |
char *content_length; /* env variable */ |
121 |
|
122 |
struct mmap_entry *mmap_entry_var; |
123 |
|
124 |
struct request *next; /* next */ |
125 |
struct request *prev; /* previous */ |
126 |
|
127 |
/* everything below this line is kept regardless */ |
128 |
char buffer[BUFFER_SIZE + 1]; /* generic I/O buffer */ |
129 |
char request_uri[MAX_HEADER_LENGTH + 1]; /* uri */ |
130 |
char client_stream[CLIENT_STREAM_SIZE]; /* data from client - fit or be hosed */ |
131 |
char *cgi_env[CGI_ENV_MAX + 4]; /* CGI environment */ |
132 |
|
133 |
#ifdef ACCEPT_ON |
134 |
char accept[MAX_ACCEPT_LENGTH]; /* Accept: fields */ |
135 |
#endif |
136 |
}; |
137 |
|
138 |
typedef struct request request; |
139 |
|
140 |
struct status { |
141 |
long requests; |
142 |
long errors; |
143 |
}; |
144 |
|
145 |
|
146 |
extern char *optarg; /* For getopt */ |
147 |
extern FILE *yyin; /* yacc input */ |
148 |
|
149 |
extern request **_request_ready; /* first in ready list */ |
150 |
extern request **_request_block; /* first in blocked list */ |
151 |
extern request **_request_free; /* first in free list */ |
152 |
|
153 |
typedef struct { |
154 |
#ifdef ENABLE_SMP |
155 |
pthread_t tid; |
156 |
#endif |
157 |
request* request_ready; |
158 |
request* request_block; |
159 |
request* request_free; |
160 |
socket_type server_s[2]; |
161 |
fd_set block_read_fdset; |
162 |
fd_set block_write_fdset; |
163 |
struct timeval req_timeout; |
164 |
int sighup_flag; /* 1 => signal has happened, needs attention */ |
165 |
int sigchld_flag; /* 1 => signal has happened, needs attention */ |
166 |
int sigalrm_flag; /* 1 => signal has happened, needs attention */ |
167 |
int sigusr1_flag; /* 1 => signal has happened, needs attention */ |
168 |
int sigterm_flag; /* lame duck mode */ |
169 |
|
170 |
int max_fd; |
171 |
|
172 |
int sockbufsize; |
173 |
struct status status; |
174 |
int total_connections; |
175 |
|
176 |
/* for SIGBUS handling */ |
177 |
jmp_buf env; |
178 |
int handle_sigbus; |
179 |
|
180 |
} server_params; |
181 |
|
182 |
/* global server variables */ |
183 |
|
184 |
extern char *access_log_name; |
185 |
extern char *error_log_name; |
186 |
extern char *cgi_log_name; |
187 |
extern int cgi_log_fd; |
188 |
extern int use_localtime; |
189 |
|
190 |
extern int server_port; |
191 |
extern int ssl_port; |
192 |
extern uid_t server_uid; |
193 |
extern gid_t server_gid; |
194 |
extern char *server_admin; |
195 |
extern char *server_root; |
196 |
extern char *server_name; |
197 |
extern char *server_ip; |
198 |
extern int max_fd; |
199 |
extern int devnullfd; |
200 |
|
201 |
extern char *document_root; |
202 |
extern char *user_dir; |
203 |
extern char *directory_index; |
204 |
extern char *default_type; |
205 |
extern char *dirmaker; |
206 |
extern char *mime_types; |
207 |
extern char *cachedir; |
208 |
|
209 |
extern char *tempdir; |
210 |
|
211 |
extern char *cgi_path; |
212 |
extern int single_post_limit; |
213 |
|
214 |
extern int ka_timeout; |
215 |
extern int ka_max; |
216 |
|
217 |
extern int sighup_flag; |
218 |
extern int sigchld_flag; |
219 |
extern int sigalrm_flag; |
220 |
extern int sigusr1_flag; |
221 |
extern int sigterm_flag; |
222 |
extern time_t start_time; |
223 |
|
224 |
extern int pending_requests; |
225 |
extern long int max_connections; |
226 |
|
227 |
extern int verbose_cgi_logs; |
228 |
|
229 |
extern int backlog; |
230 |
extern time_t current_time; |
231 |
|
232 |
extern int virtualhost; |
233 |
|
234 |
|
235 |
#endif |