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