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.2 |
/* $Id: globals.h,v 1.1.1.1 2002/09/21 13:53:54 nmav Exp $*/ |
24 |
nmav |
1.1 |
|
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 */ |
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 |
nmav |
1.2 |
int times_used; |
44 |
nmav |
1.1 |
}; |
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 |
|
|
int simple; /* simple request? */ |
67 |
|
|
int keepalive; /* keepalive status */ |
68 |
|
|
int kacount; /* keepalive count */ |
69 |
|
|
|
70 |
|
|
int data_fd; /* fd of data */ |
71 |
|
|
unsigned long filesize; /* filesize */ |
72 |
|
|
unsigned long filepos; /* position in file */ |
73 |
|
|
char *data_mem; /* mmapped/malloced char array */ |
74 |
|
|
int method; /* M_GET, M_POST, etc. */ |
75 |
|
|
|
76 |
|
|
char *logline; /* line to log file */ |
77 |
|
|
|
78 |
|
|
char *header_line; /* beginning of un or incompletely processed header line */ |
79 |
|
|
char *header_end; /* last known end of header, or end of processed data */ |
80 |
|
|
int parse_pos; /* how much have we parsed */ |
81 |
|
|
int client_stream_pos; /* how much have we read... */ |
82 |
|
|
|
83 |
|
|
int buffer_start; /* where the buffer starts */ |
84 |
|
|
int buffer_end; /* where the buffer ends */ |
85 |
|
|
|
86 |
|
|
char *http_version; /* HTTP/?.? of req */ |
87 |
|
|
int response_status; /* R_NOT_FOUND etc. */ |
88 |
|
|
|
89 |
|
|
char *if_modified_since; /* If-Modified-Since */ |
90 |
|
|
time_t last_modified; /* Last-modified: */ |
91 |
|
|
|
92 |
|
|
char local_ip_addr[NI_MAXHOST]; /* for virtualhost */ |
93 |
|
|
|
94 |
|
|
/* CGI vars */ |
95 |
|
|
|
96 |
|
|
int remote_port; /* could be used for ident */ |
97 |
|
|
|
98 |
|
|
char remote_ip_addr[NI_MAXHOST]; /* after inet_ntoa */ |
99 |
|
|
|
100 |
|
|
int is_cgi; /* true if CGI/NPH */ |
101 |
|
|
int cgi_status; |
102 |
|
|
int cgi_env_index; /* index into array */ |
103 |
|
|
|
104 |
|
|
/* Agent and referer for logfiles */ |
105 |
|
|
char *header_user_agent; |
106 |
|
|
char *header_referer; |
107 |
|
|
|
108 |
|
|
int post_data_fd; /* fd for post data tmpfile */ |
109 |
|
|
|
110 |
|
|
char *path_info; /* env variable */ |
111 |
|
|
char *path_translated; /* env variable */ |
112 |
|
|
char *script_name; /* env variable */ |
113 |
|
|
char *query_string; /* env variable */ |
114 |
|
|
char *content_type; /* env variable */ |
115 |
|
|
char *content_length; /* env variable */ |
116 |
|
|
|
117 |
|
|
struct mmap_entry *mmap_entry_var; |
118 |
|
|
|
119 |
|
|
struct request *next; /* next */ |
120 |
|
|
struct request *prev; /* previous */ |
121 |
|
|
|
122 |
|
|
/* everything below this line is kept regardless */ |
123 |
|
|
char buffer[BUFFER_SIZE + 1]; /* generic I/O buffer */ |
124 |
|
|
char request_uri[MAX_HEADER_LENGTH + 1]; /* uri */ |
125 |
|
|
char client_stream[CLIENT_STREAM_SIZE]; /* data from client - fit or be hosed */ |
126 |
|
|
char *cgi_env[CGI_ENV_MAX + 4]; /* CGI environment */ |
127 |
|
|
|
128 |
|
|
#ifdef ACCEPT_ON |
129 |
|
|
char accept[MAX_ACCEPT_LENGTH]; /* Accept: fields */ |
130 |
|
|
#endif |
131 |
|
|
}; |
132 |
|
|
|
133 |
|
|
typedef struct request request; |
134 |
|
|
|
135 |
|
|
struct status { |
136 |
|
|
long requests; |
137 |
|
|
long errors; |
138 |
|
|
}; |
139 |
|
|
|
140 |
|
|
|
141 |
|
|
extern char *optarg; /* For getopt */ |
142 |
|
|
extern FILE *yyin; /* yacc input */ |
143 |
|
|
|
144 |
|
|
extern request **_request_ready; /* first in ready list */ |
145 |
|
|
extern request **_request_block; /* first in blocked list */ |
146 |
|
|
extern request **_request_free; /* first in free list */ |
147 |
|
|
|
148 |
|
|
typedef struct { |
149 |
|
|
#ifdef ENABLE_SMP |
150 |
|
|
pthread_t tid; |
151 |
|
|
#endif |
152 |
|
|
request* request_ready; |
153 |
|
|
request* request_block; |
154 |
|
|
request* request_free; |
155 |
|
|
socket_type server_s[2]; |
156 |
|
|
fd_set block_read_fdset; |
157 |
|
|
fd_set block_write_fdset; |
158 |
|
|
struct timeval req_timeout; |
159 |
|
|
int sighup_flag; /* 1 => signal has happened, needs attention */ |
160 |
|
|
int sigchld_flag; /* 1 => signal has happened, needs attention */ |
161 |
|
|
int sigalrm_flag; /* 1 => signal has happened, needs attention */ |
162 |
|
|
int sigusr1_flag; /* 1 => signal has happened, needs attention */ |
163 |
|
|
int sigterm_flag; /* lame duck mode */ |
164 |
|
|
|
165 |
|
|
int max_fd; |
166 |
|
|
|
167 |
|
|
int sockbufsize; |
168 |
|
|
struct status status; |
169 |
|
|
int total_connections; |
170 |
|
|
|
171 |
|
|
/* for SIGBUS handling */ |
172 |
|
|
jmp_buf env; |
173 |
|
|
int handle_sigbus; |
174 |
|
|
|
175 |
|
|
} server_params; |
176 |
|
|
|
177 |
|
|
/* global server variables */ |
178 |
|
|
|
179 |
|
|
extern char *access_log_name; |
180 |
|
|
extern char *error_log_name; |
181 |
|
|
extern char *cgi_log_name; |
182 |
|
|
extern int cgi_log_fd; |
183 |
|
|
extern int use_localtime; |
184 |
|
|
|
185 |
|
|
extern int server_port; |
186 |
|
|
extern int ssl_port; |
187 |
|
|
extern uid_t server_uid; |
188 |
|
|
extern gid_t server_gid; |
189 |
|
|
extern char *server_admin; |
190 |
|
|
extern char *server_root; |
191 |
|
|
extern char *server_name; |
192 |
|
|
extern char *server_ip; |
193 |
|
|
extern int max_fd; |
194 |
|
|
extern int devnullfd; |
195 |
|
|
|
196 |
|
|
extern char *document_root; |
197 |
|
|
extern char *user_dir; |
198 |
|
|
extern char *directory_index; |
199 |
|
|
extern char *default_type; |
200 |
|
|
extern char *dirmaker; |
201 |
|
|
extern char *mime_types; |
202 |
|
|
extern char *cachedir; |
203 |
|
|
|
204 |
|
|
extern char *tempdir; |
205 |
|
|
|
206 |
|
|
extern char *cgi_path; |
207 |
|
|
extern int single_post_limit; |
208 |
|
|
|
209 |
|
|
extern int ka_timeout; |
210 |
|
|
extern int ka_max; |
211 |
|
|
|
212 |
|
|
extern int sighup_flag; |
213 |
|
|
extern int sigchld_flag; |
214 |
|
|
extern int sigalrm_flag; |
215 |
|
|
extern int sigusr1_flag; |
216 |
|
|
extern int sigterm_flag; |
217 |
|
|
extern time_t start_time; |
218 |
|
|
|
219 |
|
|
extern int pending_requests; |
220 |
|
|
extern long int max_connections; |
221 |
|
|
|
222 |
|
|
extern int verbose_cgi_logs; |
223 |
|
|
|
224 |
|
|
extern int backlog; |
225 |
|
|
extern time_t current_time; |
226 |
|
|
|
227 |
|
|
extern int virtualhost; |
228 |
|
|
|
229 |
|
|
|
230 |
|
|
#endif |