"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "fcgi.h":
2.4.6_vs_2.4.7-0910052141.
1 /*
2 * $Id: fcgi.h,v 1.48 2008/09/22 10:36:06 robs Exp $
3 */
4
5 #ifndef FCGI_H
6 #define FCGI_H
7
8 #if defined(DEBUG) && ! defined(NDEBUG)
9 #define ASSERT(a) ap_assert(a)
10 #else
11 #define ASSERT(a) ((void) 0)
12 #endif
13
14 #ifdef WIN32
15 /* warning C4115: named type definition in parentheses */
16 #pragma warning(disable : 4115)
17 /* warning C4514: unreferenced inline function has been removed */
18 #pragma warning(disable:4514)
19 #endif
20
21 /* Apache header files */
22 #include "httpd.h"
23 #include "http_config.h"
24 #include "http_request.h"
25 #include "http_core.h"
26 #include "http_protocol.h"
27 #include "http_main.h"
28 #include "http_log.h"
29 #include "util_script.h"
30 #include "util_md5.h"
31
32 /* AP2TODO there's probably a better way */
33 #ifdef STANDARD20_MODULE_STUFF
34 #define APACHE2
35 #endif
36
37 #ifdef APACHE2
38
39 #include <sys/stat.h>
40 #include "ap_compat.h"
41 #include "apr_strings.h"
42
43 #ifdef WIN32
44 #if MODULE_MAGIC_NUMBER < 20020903
45 #error "mod_fastcgi is incompatible with Apache versions older than 2.0.41 under WIN"
46 #endif
47 #endif
48
49 typedef struct apr_array_header_t array_header;
50 typedef struct apr_table_t table;
51 typedef struct apr_pool_t pool;
52 #define NET_SIZE_T apr_socklen_t
53
54 typedef apr_status_t apcb_t;
55 #define APCB_OK APR_SUCCESS
56
57 #define XtOffsetOf APR_OFFSETOF
58 #define ap_select select
59
60 #define ap_user_id unixd_config.user_id
61 #define ap_group_id unixd_config.group_id
62 #define ap_user_name unixd_config.user_name
63 #define ap_suexec_enabled unixd_config.suexec_enabled
64
65 #ifndef S_ISDIR
66 #define S_ISDIR(m) (((m)&(S_IFMT)) == (S_IFDIR))
67 #endif
68
69 /* obsolete fns */
70 #define ap_hard_timeout(a,b)
71 #define ap_kill_timeout(a)
72 #define ap_block_alarms()
73 #define ap_reset_timeout(a)
74 #define ap_unblock_alarms()
75
76 /* starting with apache 2.2 the backward-compatibility defines for
77 * 1.3 APIs are not available anymore. Define them ourselves here.
78 */
79 #ifndef ap_copy_table
80
81 #define ap_copy_table apr_table_copy
82 #define ap_cpystrn apr_cpystrn
83 #define ap_destroy_pool apr_pool_destroy
84 #define ap_isalnum apr_isalnum
85 #define ap_isspace apr_isspace
86 #define ap_make_array apr_array_make
87 #define ap_make_table apr_table_make
88 #define ap_null_cleanup apr_pool_cleanup_null
89 #define ap_palloc apr_palloc
90 #define ap_pcalloc apr_pcalloc
91 #define ap_psprintf apr_psprintf
92 #define ap_pstrcat apr_pstrcat
93 #define ap_pstrdup apr_pstrdup
94 #define ap_pstrndup apr_pstrndup
95 #define ap_push_array apr_array_push
96 #define ap_register_cleanup apr_pool_cleanup_register
97 #define ap_snprintf apr_snprintf
98 #define ap_table_add apr_table_add
99 #define ap_table_do apr_table_do
100 #define ap_table_get apr_table_get
101 #define ap_table_set apr_table_set
102 #define ap_table_setn apr_table_setn
103 #define ap_table_unset apr_table_unset
104 #define ap_toupper apr_toupper
105
106 #endif /* defined(ap_copy_table) */
107
108 #if (defined(HAVE_WRITEV) && !HAVE_WRITEV && !defined(NO_WRITEV)) || defined WIN32
109 #define NO_WRITEV
110 #endif
111
112 #else /* !APACHE2 */
113
114 #include "http_conf_globals.h"
115 typedef void apcb_t;
116 #define APCB_OK
117
118 #if MODULE_MAGIC_NUMBER < 19990320
119 #error "This version of mod_fastcgi is incompatible with Apache versions older than 1.3.6."
120 #endif
121
122 #endif /* !APACHE2 */
123
124 #ifndef NO_WRITEV
125 #include <sys/uio.h>
126 #endif
127
128 #ifdef WIN32
129 #ifndef APACHE2
130 #include "multithread.h"
131 #endif
132 #pragma warning(default : 4115)
133 #else
134 #include <sys/un.h>
135 #endif
136
137 /* FastCGI header files */
138 #include "mod_fastcgi.h"
139 /* @@@ This should go away when fcgi_protocol is re-written */
140 #include "fcgi_protocol.h"
141
142 typedef struct {
143 int size; /* size of entire buffer */
144 int length; /* number of bytes in current buffer */
145 char *begin; /* begining of valid data */
146 char *end; /* end of valid data */
147 char data[1]; /* buffer data */
148 } Buffer;
149
150 #ifdef WIN32
151 #define READER 0
152 #define WRITER 1
153
154 #define MBOX_EVENT 0 /* mboc is ready to be read */
155 #define TERM_EVENT 1 /* termination event */
156 #define WAKE_EVENT 2 /* notification of child Fserver dieing */
157
158 typedef struct _fcgi_pm_job {
159 char id;
160 char *fs_path;
161 char *user;
162 char * group;
163 unsigned long qsec;
164 unsigned long start_time;
165 struct _fcgi_pm_job *next;
166 } fcgi_pm_job;
167 #endif
168
169 enum process_state {
170 FCGI_RUNNING_STATE, /* currently running */
171 FCGI_START_STATE, /* needs to be started by PM */
172 FCGI_VICTIM_STATE, /* SIGTERM was sent by PM */
173 FCGI_KILLED_STATE, /* a wait() collected VICTIM */
174 FCGI_READY_STATE /* empty cell, init state */
175 };
176
177 /*
178 * ServerProcess holds data for each process associated with
179 * a class. It is embedded in fcgi_server below.
180 */
181 typedef struct _FcgiProcessInfo {
182 #ifdef WIN32
183 HANDLE handle; /* process handle */
184 HANDLE terminationEvent; /* Event used to signal process termination */
185 #endif
186 pid_t pid; /* pid of associated process */
187 enum process_state state; /* state of the process */
188 time_t start_time; /* time the process was started */
189 } ServerProcess;
190
191 /*
192 * fcgi_server holds info for each AppClass specified in this
193 * Web server's configuration.
194 */
195 typedef struct _FastCgiServerInfo {
196 int flush;
197 char *fs_path; /* pathname of executable */
198 array_header *pass_headers; /* names of headers to pass in the env */
199 u_int idle_timeout; /* fs idle secs allowed before aborting */
200 char **envp; /* if NOT NULL, this is the env to send
201 * to the fcgi app when starting a server
202 * managed app. */
203 u_int listenQueueDepth; /* size of listen queue for IPC */
204 u_int appConnectTimeout; /* timeout (sec) for connect() requests */
205 u_int numProcesses; /* max allowed processes of this class,
206 * or for dynamic apps, the number of
207 * processes actually running */
208 time_t startTime; /* the time the application was started */
209 time_t restartTime; /* most recent time when the process
210 * manager started a process in this
211 * class. */
212 int initStartDelay; /* min number of seconds to wait between
213 * starting of AppClass processes at init */
214 u_int restartDelay; /* number of seconds to wait between
215 * restarts after failure. Can be zero. */
216 u_int minServerLife; /* minimum number of seconds a server must
217 * live before it's considered borked. */
218 int restartOnExit; /* = TRUE = restart. else terminate/free */
219 u_int numFailures; /* num restarts due to exit failure */
220 int bad; /* is [not] having start problems */
221 struct sockaddr *socket_addr; /* Socket Address of FCGI app server class */
222 #ifdef WIN32
223 struct sockaddr *dest_addr; /* for local apps on NT need socket address */
224 /* bound to localhost */
225 const char *mutex_env_string; /* string holding the accept mutex handle */
226 #endif
227 int socket_addr_len; /* Length of socket */
228 enum {APP_CLASS_UNKNOWN,
229 APP_CLASS_STANDARD,
230 APP_CLASS_EXTERNAL,
231 APP_CLASS_DYNAMIC}
232 directive; /* AppClass or ExternalAppClass */
233 const char *socket_path; /* Name used to create a socket */
234 const char *host; /* Hostname for externally managed
235 * FastCGI application processes */
236 unsigned short port; /* Port number either for externally
237 * managed FastCGI applications or for
238 * server managed FastCGI applications,
239 * where server became application mngr. */
240 int listenFd; /* Listener socket of FCGI app server
241 * class. Passed to app server process
242 * at process creation. */
243 u_int processPriority; /* If locally server managed process,
244 * this is the priority to run the
245 * processes in this class at. */
246 struct _FcgiProcessInfo *procs; /* Pointer to array of
247 * processes belonging to this class. */
248 int keepConnection; /* = 1 = maintain connection to app. */
249 uid_t uid; /* uid this app should run as (suexec) */
250 gid_t gid; /* gid this app should run as (suexec) */
251 const char *username; /* suexec user arg */
252 const char *group; /* suexec group arg, AND used in comm
253 * between RH and PM */
254 const char *user; /* used in comm between RH and PM */
255 /* Dynamic FastCGI apps configuration parameters */
256 u_long totalConnTime; /* microseconds spent by the web server
257 * waiting while fastcgi app performs
258 * request processing since the last
259 * dynamicUpdateInterval */
260 u_long smoothConnTime; /* exponentially decayed values of the
261 * connection times. */
262 u_long totalQueueTime; /* microseconds spent by the web server
263 * waiting to connect to the fastcgi app
264 * since the last dynamicUpdateInterval. */
265 int nph;
266 struct _FastCgiServerInfo *next;
267 } fcgi_server;
268
269
270 /*
271 * fcgi_request holds the state of a particular FastCGI request.
272 */
273 typedef struct {
274 #ifdef WIN32
275 SOCKET fd;
276 #else
277 int fd; /* connection to FastCGI server */
278 #endif
279 int gotHeader; /* TRUE if reading content bytes */
280 unsigned char packetType; /* type of packet */
281 int dataLen; /* length of data bytes */
282 int paddingLen; /* record padding after content */
283 fcgi_server *fs; /* FastCGI server info */
284 const char *fs_path; /* fcgi_server path */
285 Buffer *serverInputBuffer; /* input buffer from FastCgi server */
286 Buffer *serverOutputBuffer; /* output buffer to FastCgi server */
287 Buffer *clientInputBuffer; /* client input buffer */
288 Buffer *clientOutputBuffer; /* client output buffer */
289 table *authHeaders; /* headers received from an auth fs */
290 int auth_compat; /* whether the auth request is spec compat */
291 table *saved_subprocess_env; /* subprocess_env before auth handling */
292 int expectingClientContent; /* >0 => more content, <=0 => no more */
293 array_header *header;
294 char *fs_stderr;
295 int fs_stderr_len;
296 int parseHeader; /* TRUE iff parsing response headers */
297 request_rec *r;
298 int readingEndRequestBody;
299 FCGI_EndRequestBody endRequestBody;
300 Buffer *erBufPtr;
301 int exitStatus;
302 int exitStatusSet;
303 unsigned int requestId;
304 int eofSent;
305 int role; /* FastCGI Role: Authorizer or Responder */
306 int dynamic; /* whether or not this is a dynamic app */
307 struct timeval startTime; /* dynamic app's connect() attempt start time */
308 struct timeval queueTime; /* dynamic app's connect() complete time */
309 struct timeval completeTime; /* dynamic app's connection close() time */
310 int keepReadingFromFcgiApp; /* still more to read from fcgi app? */
311 const char *user; /* user used to invoke app (suexec) */
312 const char *group; /* group used to invoke app (suexec) */
313 #ifdef WIN32
314 BOOL using_npipe_io; /* named pipe io */
315 #endif
316 int nph;
317 } fcgi_request;
318
319 /* Values of parseHeader field */
320 #define SCAN_CGI_READING_HEADERS 1
321 #define SCAN_CGI_FINISHED 0
322 #define SCAN_CGI_BAD_HEADER -1
323 #define SCAN_CGI_INT_REDIRECT -2
324 #define SCAN_CGI_SRV_REDIRECT -3
325
326 /* Opcodes for Server->ProcMgr communication */
327 #define FCGI_SERVER_START_JOB 83 /* 'S' - start */
328 #define FCGI_SERVER_RESTART_JOB 82 /* 'R' - restart */
329 #define FCGI_REQUEST_TIMEOUT_JOB 84 /* 'T' - timeout */
330 #define FCGI_REQUEST_COMPLETE_JOB 67 /* 'C' - complete */
331
332 /* Authorizer types, for auth directives handling */
333 #define FCGI_AUTH_TYPE_AUTHENTICATOR 0
334 #define FCGI_AUTH_TYPE_AUTHORIZER 1
335 #define FCGI_AUTH_TYPE_ACCESS_CHECKER 2
336
337 /* Bits for auth_options */
338 #define FCGI_AUTHORITATIVE 1
339 #define FCGI_COMPAT 2
340
341 typedef struct
342 {
343 const char *authorizer;
344 u_char authorizer_options;
345 const char *authenticator;
346 u_char authenticator_options;
347 const char *access_checker;
348 u_char access_checker_options;
349 } fcgi_dir_config;
350
351 #define FCGI_OK 0
352 #define FCGI_FAILED 1
353
354 #ifdef APACHE2
355
356 #ifdef WIN32
357 #define FCGI_LOG_EMERG __FILE__,__LINE__,APLOG_EMERG,APR_FROM_OS_ERROR(GetLastError())
358 #define FCGI_LOG_ALERT __FILE__,__LINE__,APLOG_ALERT,APR_FROM_OS_ERROR(GetLastError())
359 #define FCGI_LOG_CRIT __FILE__,__LINE__,APLOG_CRIT,APR_FROM_OS_ERROR(GetLastError())
360 #define FCGI_LOG_ERR __FILE__,__LINE__,APLOG_ERR,APR_FROM_OS_ERROR(GetLastError())
361 #define FCGI_LOG_WARN __FILE__,__LINE__,APLOG_WARNING,APR_FROM_OS_ERROR(GetLastError())
362 #define FCGI_LOG_NOTICE __FILE__,__LINE__,APLOG_NOTICE,APR_FROM_OS_ERROR(GetLastError())
363 #define FCGI_LOG_INFO __FILE__,__LINE__,APLOG_INFO,APR_FROM_OS_ERROR(GetLastError())
364 #define FCGI_LOG_DEBUG __FILE__,__LINE__,APLOG_DEBUG,APR_FROM_OS_ERROR(GetLastError())
365 #else /* !WIN32 */
366 #define FCGI_LOG_EMERG __FILE__,__LINE__,APLOG_EMERG,APR_FROM_OS_ERROR(errno)
367 #define FCGI_LOG_ALERT __FILE__,__LINE__,APLOG_ALERT,APR_FROM_OS_ERROR(errno)
368 #define FCGI_LOG_CRIT __FILE__,__LINE__,APLOG_CRIT,APR_FROM_OS_ERROR(errno)
369 #define FCGI_LOG_ERR __FILE__,__LINE__,APLOG_ERR,APR_FROM_OS_ERROR(errno)
370 #define FCGI_LOG_WARN __FILE__,__LINE__,APLOG_WARNING,APR_FROM_OS_ERROR(errno)
371 #define FCGI_LOG_NOTICE __FILE__,__LINE__,APLOG_NOTICE,APR_FROM_OS_ERROR(errno)
372 #define FCGI_LOG_INFO __FILE__,__LINE__,APLOG_INFO,APR_FROM_OS_ERROR(errno)
373 #define FCGI_LOG_DEBUG __FILE__,__LINE__,APLOG_DEBUG,APR_FROM_OS_ERROR(errno)
374 #endif
375
376 #define FCGI_LOG_EMERG_ERRNO __FILE__,__LINE__,APLOG_EMERG,APR_FROM_OS_ERROR(errno)
377 #define FCGI_LOG_ALERT_ERRNO __FILE__,__LINE__,APLOG_ALERT,APR_FROM_OS_ERROR(errno)
378 #define FCGI_LOG_CRIT_ERRNO __FILE__,__LINE__,APLOG_CRIT,APR_FROM_OS_ERROR(errno)
379 #define FCGI_LOG_ERR_ERRNO __FILE__,__LINE__,APLOG_ERR,APR_FROM_OS_ERROR(errno)
380 #define FCGI_LOG_WARN_ERRNO __FILE__,__LINE__,APLOG_WARNING,APR_FROM_OS_ERROR(errno)
381 #define FCGI_LOG_NOTICE_ERRNO __FILE__,__LINE__,APLOG_NOTICE,APR_FROM_OS_ERROR(errno)
382 #define FCGI_LOG_INFO_ERRNO __FILE__,__LINE__,APLOG_INFO,APR_FROM_OS_ERROR(errno)
383 #define FCGI_LOG_DEBUG_ERRNO __FILE__,__LINE__,APLOG_DEBUG,APR_FROM_OS_ERROR(errno)
384
385 #define FCGI_LOG_EMERG_NOERRNO __FILE__,__LINE__,APLOG_EMERG,0
386 #define FCGI_LOG_ALERT_NOERRNO __FILE__,__LINE__,APLOG_ALERT,0
387 #define FCGI_LOG_CRIT_NOERRNO __FILE__,__LINE__,APLOG_CRIT,0
388 #define FCGI_LOG_ERR_NOERRNO __FILE__,__LINE__,APLOG_ERR,0
389 #define FCGI_LOG_WARN_NOERRNO __FILE__,__LINE__,APLOG_WARNING,0
390 #define FCGI_LOG_NOTICE_NOERRNO __FILE__,__LINE__,APLOG_NOTICE,0
391 #define FCGI_LOG_INFO_NOERRNO __FILE__,__LINE__,APLOG_INFO,0
392 #define FCGI_LOG_DEBUG_NOERRNO __FILE__,__LINE__,APLOG_DEBUG,0
393
394 #else /* !APACHE2 */
395
396 #ifdef WIN32
397 #define FCGI_LOG_EMERG __FILE__,__LINE__,APLOG_EMERG|APLOG_WIN32ERROR
398 #define FCGI_LOG_ALERT __FILE__,__LINE__,APLOG_ALERT|APLOG_WIN32ERROR
399 #define FCGI_LOG_CRIT __FILE__,__LINE__,APLOG_CRIT|APLOG_WIN32ERROR
400 #define FCGI_LOG_ERR __FILE__,__LINE__,APLOG_ERR|APLOG_WIN32ERROR
401 #define FCGI_LOG_WARN __FILE__,__LINE__,APLOG_WARNING|APLOG_WIN32ERROR
402 #define FCGI_LOG_NOTICE __FILE__,__LINE__,APLOG_NOTICE|APLOG_WIN32ERROR
403 #define FCGI_LOG_INFO __FILE__,__LINE__,APLOG_INFO|APLOG_WIN32ERROR
404 #define FCGI_LOG_DEBUG __FILE__,__LINE__,APLOG_DEBUG|APLOG_WIN32ERROR
405 #else /* !WIN32 */
406 #define FCGI_LOG_EMERG __FILE__,__LINE__,APLOG_EMERG
407 #define FCGI_LOG_ALERT __FILE__,__LINE__,APLOG_ALERT
408 #define FCGI_LOG_CRIT __FILE__,__LINE__,APLOG_CRIT
409 #define FCGI_LOG_ERR __FILE__,__LINE__,APLOG_ERR
410 #define FCGI_LOG_WARN __FILE__,__LINE__,APLOG_WARNING
411 #define FCGI_LOG_NOTICE __FILE__,__LINE__,APLOG_NOTICE
412 #define FCGI_LOG_INFO __FILE__,__LINE__,APLOG_INFO
413 #define FCGI_LOG_DEBUG __FILE__,__LINE__,APLOG_DEBUG
414 #endif
415
416 #define FCGI_LOG_EMERG_ERRNO __FILE__,__LINE__,APLOG_EMERG /* system is unusable */
417 #define FCGI_LOG_ALERT_ERRNO __FILE__,__LINE__,APLOG_ALERT /* action must be taken immediately */
418 #define FCGI_LOG_CRIT_ERRNO __FILE__,__LINE__,APLOG_CRIT /* critical conditions */
419 #define FCGI_LOG_ERR_ERRNO __FILE__,__LINE__,APLOG_ERR /* error conditions */
420 #define FCGI_LOG_WARN_ERRNO __FILE__,__LINE__,APLOG_WARNING /* warning conditions */
421 #define FCGI_LOG_NOTICE_ERRNO __FILE__,__LINE__,APLOG_NOTICE /* normal but significant condition */
422 #define FCGI_LOG_INFO_ERRNO __FILE__,__LINE__,APLOG_INFO /* informational */
423 #define FCGI_LOG_DEBUG_ERRNO __FILE__,__LINE__,APLOG_DEBUG /* debug-level messages */
424
425 #define FCGI_LOG_EMERG_NOERRNO __FILE__,__LINE__,APLOG_EMERG|APLOG_NOERRNO
426 #define FCGI_LOG_ALERT_NOERRNO __FILE__,__LINE__,APLOG_ALERT|APLOG_NOERRNO
427 #define FCGI_LOG_CRIT_NOERRNO __FILE__,__LINE__,APLOG_CRIT|APLOG_NOERRNO
428 #define FCGI_LOG_ERR_NOERRNO __FILE__,__LINE__,APLOG_ERR|APLOG_NOERRNO
429 #define FCGI_LOG_WARN_NOERRNO __FILE__,__LINE__,APLOG_WARNING|APLOG_NOERRNO
430 #define FCGI_LOG_NOTICE_NOERRNO __FILE__,__LINE__,APLOG_NOTICE|APLOG_NOERRNO
431 #define FCGI_LOG_INFO_NOERRNO __FILE__,__LINE__,APLOG_INFO|APLOG_NOERRNO
432 #define FCGI_LOG_DEBUG_NOERRNO __FILE__,__LINE__,APLOG_DEBUG|APLOG_NOERRNO
433
434 #endif /* !APACHE2 */
435
436 #ifdef FCGI_DEBUG
437 #define FCGIDBG1(a) ap_log_error(FCGI_LOG_DEBUG,fcgi_apache_main_server,a);
438 #define FCGIDBG2(a,b) ap_log_error(FCGI_LOG_DEBUG,fcgi_apache_main_server,a,b);
439 #define FCGIDBG3(a,b,c) ap_log_error(FCGI_LOG_DEBUG,fcgi_apache_main_server,a,b,c);
440 #define FCGIDBG4(a,b,c,d) ap_log_error(FCGI_LOG_DEBUG,fcgi_apache_main_server,a,b,c,d);
441 #define FCGIDBG5(a,b,c,d,e) ap_log_error(FCGI_LOG_DEBUG,fcgi_apache_main_server,a,b,c,d,e);
442 #define FCGIDBG6(a,b,c,d,e,f) ap_log_error(FCGI_LOG_DEBUG,fcgi_apache_main_server,a,b,c,d,e,f);
443 #define FCGIDBG7(a,b,c,d,e,f,g) ap_log_error(FCGI_LOG_DEBUG,fcgi_apache_main_server,a,b,c,d,e,f,g);
444 #else
445 #define FCGIDBG1(a)
446 #define FCGIDBG2(a,b)
447 #define FCGIDBG3(a,b,c)
448 #define FCGIDBG4(a,b,c,d)
449 #define FCGIDBG5(a,b,c,d,e)
450 #define FCGIDBG6(a,b,c,d,e,f)
451 #define FCGIDBG7(a,b,c,d,e,f,g)
452 #endif
453
454 /*
455 * Holds the status of the sending of the environment.
456 * A quick hack to dump the static vars for the NT port.
457 */
458 typedef struct {
459 enum { PREP, HEADER, NAME, VALUE } pass;
460 char **envp;
461 int headerLen, nameLen, valueLen, totalLen;
462 char *equalPtr;
463 unsigned char headerBuff[8];
464 } env_status;
465
466 /*
467 * fcgi_config.c
468 */
469 void *fcgi_config_create_dir_config(pool *p, char *dummy);
470 const char *fcgi_config_make_dir(pool *tp, char *path);
471 const char *fcgi_config_make_dynamic_dir(pool *p, const int wax);
472 const char *fcgi_config_new_static_server(cmd_parms *cmd, void *dummy, const char *arg);
473 const char *fcgi_config_new_external_server(cmd_parms *cmd, void *dummy, const char *arg);
474 const char *fcgi_config_set_config(cmd_parms *cmd, void *dummy, const char *arg);
475 const char *fcgi_config_set_fcgi_uid_n_gid(int set);
476
477 const char *fcgi_config_new_auth_server(cmd_parms * cmd,
478 void *dir_config, const char *fs_path, const char * compat);
479
480 const char *fcgi_config_set_authoritative_slot(cmd_parms * cmd,
481 void * dir_config, int arg);
482 const char *fcgi_config_set_socket_dir(cmd_parms *cmd, void *dummy, const char *arg);
483 const char *fcgi_config_set_wrapper(cmd_parms *cmd, void *dummy, const char *arg);
484 apcb_t fcgi_config_reset_globals(void * dummy);
485 const char *fcgi_config_set_env_var(pool *p, char **envp, unsigned int *envc, char * var);
486
487 /*
488 * fcgi_pm.c
489 */
490 #if defined(WIN32) || defined(APACHE2)
491 void fcgi_pm_main(void *dummy);
492 #else
493 int fcgi_pm_main(void *dummy, child_info *info);
494 #endif
495
496 /*
497 * fcgi_protocol.c
498 */
499 void fcgi_protocol_queue_begin_request(fcgi_request *fr);
500 void fcgi_protocol_queue_client_buffer(fcgi_request *fr);
501 int fcgi_protocol_queue_env(request_rec *r, fcgi_request *fr, env_status *env);
502 int fcgi_protocol_dequeue(pool *p, fcgi_request *fr);
503
504 /*
505 * fcgi_buf.c
506 */
507 #define BufferLength(b) ((b)->length)
508 #define BufferFree(b) ((b)->size - (b)->length)
509
510 void fcgi_buf_reset(Buffer *bufPtr);
511 Buffer *fcgi_buf_new(pool *p, int size);
512
513 #ifndef WIN32
514 typedef int SOCKET;
515 #endif
516
517 int fcgi_buf_socket_recv(Buffer *b, SOCKET socket);
518 int fcgi_buf_socket_send(Buffer *b, SOCKET socket);
519
520 void fcgi_buf_added(Buffer * const b, const unsigned int len);
521 void fcgi_buf_removed(Buffer * const b, unsigned int len);
522 void fcgi_buf_get_block_info(Buffer *bufPtr, char **beginPtr, int *countPtr);
523 void fcgi_buf_toss(Buffer *bufPtr, int count);
524 void fcgi_buf_get_free_block_info(Buffer *bufPtr, char **endPtr, int *countPtr);
525 void fcgi_buf_add_update(Buffer *bufPtr, int count);
526 int fcgi_buf_add_block(Buffer *bufPtr, char *data, int datalen);
527 int fcgi_buf_add_string(Buffer *bufPtr, char *str);
528 int fcgi_buf_get_to_block(Buffer *bufPtr, char *data, int datalen);
529 void fcgi_buf_get_to_buf(Buffer *toPtr, Buffer *fromPtr, int len);
530 void fcgi_buf_get_to_array(Buffer *buf, array_header *arr, int len);
531
532 /*
533 * fcgi_util.c
534 */
535
536 char *fcgi_util_socket_hash_filename(pool *p, const char *path,
537 const char *user, const char *group);
538 const char *fcgi_util_socket_make_path_absolute(pool * const p,
539 const char *const file, const int dynamic);
540 #ifndef WIN32
541 const char *fcgi_util_socket_make_domain_addr(pool *p, struct sockaddr_un **socket_addr,
542 int *socket_addr_len, const char *socket_path);
543 #endif
544 const char *fcgi_util_socket_make_inet_addr(pool *p, struct sockaddr_in **socket_addr,
545 int *socket_addr_len, const char *host, unsigned short port);
546 const char *fcgi_util_check_access(pool *tp,
547 const char * const path, const struct stat *statBuf,
548 const int mode, const uid_t uid, const gid_t gid);
549 fcgi_server *fcgi_util_fs_get_by_id(const char *ePath, uid_t uid, gid_t gid);
550 fcgi_server *fcgi_util_fs_get(const char *ePath, const char *user, const char *group);
551 const char *fcgi_util_fs_is_path_ok(pool * const p, const char * const fs_path, struct stat *finfo);
552 fcgi_server *fcgi_util_fs_new(pool *p);
553 void fcgi_util_fs_add(fcgi_server *s);
554 const char *fcgi_util_fs_set_uid_n_gid(pool *p, fcgi_server *s, uid_t uid, gid_t gid);
555 ServerProcess *fcgi_util_fs_create_procs(pool *p, int num);
556
557 int fcgi_util_ticks(struct timeval *);
558
559 #ifdef WIN32
560 int fcgi_pm_add_job(fcgi_pm_job *new_job);
561 #endif
562
563 uid_t fcgi_util_get_server_uid(const server_rec * const s);
564 gid_t fcgi_util_get_server_gid(const server_rec * const s);
565
566 /*
567 * Globals
568 */
569
570 extern pool *fcgi_config_pool;
571
572 extern server_rec *fcgi_apache_main_server;
573
574 extern const char *fcgi_wrapper; /* wrapper path */
575 extern uid_t fcgi_user_id; /* the run uid of Apache & PM */
576 extern gid_t fcgi_group_id; /* the run gid of Apache & PM */
577
578 extern fcgi_server *fcgi_servers;
579
580 extern char *fcgi_socket_dir; /* default FastCgiIpcDir */
581
582 /* pipe used for comm between the request handlers and the PM */
583 extern int fcgi_pm_pipe[];
584
585 extern pid_t fcgi_pm_pid;
586
587 extern char *fcgi_dynamic_dir; /* directory for the dynamic
588 * fastcgi apps' sockets */
589
590 extern char *fcgi_empty_env;
591
592 extern int fcgi_dynamic_total_proc_count;
593 extern time_t fcgi_dynamic_epoch;
594 extern time_t fcgi_dynamic_last_analyzed;
595
596 #ifdef WIN32
597 extern HANDLE *fcgi_dynamic_mbox_mutex;
598 extern HANDLE fcgi_event_handles[3];
599 extern fcgi_pm_job *fcgi_dynamic_mbox;
600 #endif
601
602 extern u_int dynamicMaxProcs;
603 extern int dynamicMinProcs;
604 extern int dynamicMaxClassProcs;
605 extern u_int dynamicKillInterval;
606 extern u_int dynamicUpdateInterval;
607 extern float dynamicGain;
608 extern int dynamicThreshold1;
609 extern int dynamicThresholdN;
610 extern u_int dynamicPleaseStartDelay;
611 extern u_int dynamicAppConnectTimeout;
612 extern char **dynamicEnvp;
613 extern u_int dynamicProcessSlack;
614 extern int dynamicAutoRestart;
615 extern int dynamicAutoUpdate;
616 extern u_int dynamicListenQueueDepth;
617 extern u_int dynamicInitStartDelay;
618 extern u_int dynamicRestartDelay;
619 extern array_header *dynamic_pass_headers;
620 extern u_int dynamic_idle_timeout;
621 extern int dynamicMinServerLife;
622 extern int dynamicFlush;
623
624
625 extern module MODULE_VAR_EXPORT fastcgi_module;
626
627 #endif /* FCGI_H */
628