2006-02-02 16:17:23 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| PHP Version 5 |
|
|
|
|
+----------------------------------------------------------------------+
|
2008-12-31 19:15:49 +08:00
|
|
|
| Copyright (c) 1997-2009 The PHP Group |
|
2006-02-02 16:17:23 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.php.net/license/3_01.txt |
|
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Dmitry Stogov <dmitry@zend.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/* FastCGI protocol */
|
|
|
|
|
|
|
|
#define FCGI_VERSION_1 1
|
|
|
|
|
|
|
|
#define FCGI_MAX_LENGTH 0xffff
|
|
|
|
|
|
|
|
#define FCGI_KEEP_CONN 1
|
|
|
|
|
|
|
|
typedef enum _fcgi_role {
|
|
|
|
FCGI_RESPONDER = 1,
|
|
|
|
FCGI_AUTHORIZER = 2,
|
|
|
|
FCGI_FILTER = 3
|
|
|
|
} fcgi_role;
|
|
|
|
|
|
|
|
typedef enum _fcgi_request_type {
|
|
|
|
FCGI_BEGIN_REQUEST = 1, /* [in] */
|
|
|
|
FCGI_ABORT_REQUEST = 2, /* [in] (not supported) */
|
|
|
|
FCGI_END_REQUEST = 3, /* [out] */
|
|
|
|
FCGI_PARAMS = 4, /* [in] environment variables */
|
|
|
|
FCGI_STDIN = 5, /* [in] post data */
|
|
|
|
FCGI_STDOUT = 6, /* [out] response */
|
|
|
|
FCGI_STDERR = 7, /* [out] errors */
|
|
|
|
FCGI_DATA = 8, /* [in] filter data (not supported) */
|
|
|
|
FCGI_GET_VALUES = 9, /* [in] */
|
|
|
|
FCGI_GET_VALUES_RESULT = 10 /* [out] */
|
|
|
|
} fcgi_request_type;
|
|
|
|
|
|
|
|
typedef enum _fcgi_protocol_status {
|
|
|
|
FCGI_REQUEST_COMPLETE = 0,
|
|
|
|
FCGI_CANT_MPX_CONN = 1,
|
|
|
|
FCGI_OVERLOADED = 2,
|
|
|
|
FCGI_UNKNOWN_ROLE = 3
|
|
|
|
} dcgi_protocol_status;
|
|
|
|
|
|
|
|
typedef struct _fcgi_header {
|
|
|
|
unsigned char version;
|
|
|
|
unsigned char type;
|
|
|
|
unsigned char requestIdB1;
|
|
|
|
unsigned char requestIdB0;
|
|
|
|
unsigned char contentLengthB1;
|
|
|
|
unsigned char contentLengthB0;
|
|
|
|
unsigned char paddingLength;
|
|
|
|
unsigned char reserved;
|
|
|
|
} fcgi_header;
|
|
|
|
|
|
|
|
typedef struct _fcgi_begin_request {
|
|
|
|
unsigned char roleB1;
|
|
|
|
unsigned char roleB0;
|
|
|
|
unsigned char flags;
|
|
|
|
unsigned char reserved[5];
|
|
|
|
} fcgi_begin_request;
|
|
|
|
|
|
|
|
typedef struct _fcgi_begin_request_rec {
|
|
|
|
fcgi_header hdr;
|
|
|
|
fcgi_begin_request body;
|
|
|
|
} fcgi_begin_request_rec;
|
|
|
|
|
|
|
|
typedef struct _fcgi_end_request {
|
|
|
|
unsigned char appStatusB3;
|
|
|
|
unsigned char appStatusB2;
|
|
|
|
unsigned char appStatusB1;
|
|
|
|
unsigned char appStatusB0;
|
|
|
|
unsigned char protocolStatus;
|
|
|
|
unsigned char reserved[3];
|
|
|
|
} fcgi_end_request;
|
|
|
|
|
|
|
|
typedef struct _fcgi_end_request_rec {
|
|
|
|
fcgi_header hdr;
|
|
|
|
fcgi_end_request body;
|
|
|
|
} fcgi_end_request_rec;
|
|
|
|
|
|
|
|
/* FastCGI client API */
|
|
|
|
|
|
|
|
typedef struct _fcgi_request {
|
|
|
|
int listen_socket;
|
2007-03-28 23:39:22 +08:00
|
|
|
#ifdef _WIN32
|
|
|
|
int tcp;
|
|
|
|
#endif
|
2006-02-02 16:17:23 +08:00
|
|
|
int fd;
|
|
|
|
int id;
|
|
|
|
int keep;
|
2008-08-26 17:56:08 +08:00
|
|
|
int closed;
|
2006-02-02 16:17:23 +08:00
|
|
|
|
|
|
|
int in_len;
|
|
|
|
int in_pad;
|
|
|
|
|
|
|
|
fcgi_header *out_hdr;
|
|
|
|
unsigned char *out_pos;
|
|
|
|
unsigned char out_buf[1024*8];
|
|
|
|
unsigned char reserved[sizeof(fcgi_end_request_rec)];
|
|
|
|
|
2008-08-18 18:49:35 +08:00
|
|
|
HashTable *env;
|
2006-02-02 16:17:23 +08:00
|
|
|
} fcgi_request;
|
|
|
|
|
|
|
|
int fcgi_init(void);
|
2007-05-21 17:08:13 +08:00
|
|
|
void fcgi_shutdown(void);
|
2006-02-02 16:17:23 +08:00
|
|
|
int fcgi_is_fastcgi(void);
|
2007-02-15 20:33:16 +08:00
|
|
|
int fcgi_in_shutdown(void);
|
2006-02-02 16:17:23 +08:00
|
|
|
int fcgi_listen(const char *path, int backlog);
|
|
|
|
void fcgi_init_request(fcgi_request *req, int listen_socket);
|
|
|
|
int fcgi_accept_request(fcgi_request *req);
|
2008-08-26 17:56:08 +08:00
|
|
|
int fcgi_finish_request(fcgi_request *req, int force_close);
|
2006-02-02 16:17:23 +08:00
|
|
|
|
|
|
|
char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
|
2006-05-15 22:30:31 +08:00
|
|
|
char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
|
2006-02-02 16:17:23 +08:00
|
|
|
|
|
|
|
int fcgi_read(fcgi_request *req, char *str, int len);
|
|
|
|
|
|
|
|
int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
|
|
|
|
int fcgi_flush(fcgi_request *req, int close);
|
|
|
|
|
2006-05-15 22:30:31 +08:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
void fcgi_impersonate(void);
|
|
|
|
#endif
|
2008-10-21 11:19:28 +08:00
|
|
|
|
|
|
|
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
|
|
|
|
void fcgi_free_mgmt_var_cb(void * ptr);
|
|
|
|
|
2006-02-02 16:17:23 +08:00
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
|
|
|
*/
|