Back to index

php5  5.3.10
fastcgi.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2009 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Dmitry Stogov <dmitry@zend.com>                             |
00016    +----------------------------------------------------------------------+
00017 */
00018 
00019 /* $Id: fastcgi.h 272370 2008-12-31 11:15:49Z sebastian $ */
00020 
00021 /* FastCGI protocol */
00022 
00023 #define FCGI_VERSION_1 1
00024 
00025 #define FCGI_MAX_LENGTH 0xffff
00026 
00027 #define FCGI_KEEP_CONN  1
00028 
00029 typedef enum _fcgi_role {
00030        FCGI_RESPONDER       = 1,
00031        FCGI_AUTHORIZER      = 2,
00032        FCGI_FILTER          = 3
00033 } fcgi_role;
00034 
00035 typedef enum _fcgi_request_type {
00036        FCGI_BEGIN_REQUEST          =  1, /* [in]                              */
00037        FCGI_ABORT_REQUEST          =  2, /* [in]  (not supported)             */
00038        FCGI_END_REQUEST            =  3, /* [out]                             */
00039        FCGI_PARAMS                        =  4, /* [in]  environment variables       */
00040        FCGI_STDIN                         =  5, /* [in]  post data                   */
00041        FCGI_STDOUT                        =  6, /* [out] response                    */
00042        FCGI_STDERR                        =  7, /* [out] errors                      */
00043        FCGI_DATA                          =  8, /* [in]  filter data (not supported) */
00044        FCGI_GET_VALUES                    =  9, /* [in]                              */
00045        FCGI_GET_VALUES_RESULT      = 10  /* [out]                             */
00046 } fcgi_request_type;
00047 
00048 typedef enum _fcgi_protocol_status {
00049        FCGI_REQUEST_COMPLETE       = 0,
00050        FCGI_CANT_MPX_CONN          = 1,
00051        FCGI_OVERLOADED                    = 2,
00052        FCGI_UNKNOWN_ROLE           = 3
00053 } dcgi_protocol_status;
00054 
00055 typedef struct _fcgi_header {
00056        unsigned char version;
00057        unsigned char type;
00058        unsigned char requestIdB1;
00059        unsigned char requestIdB0;
00060        unsigned char contentLengthB1;
00061        unsigned char contentLengthB0;
00062        unsigned char paddingLength;
00063        unsigned char reserved;
00064 } fcgi_header;
00065 
00066 typedef struct _fcgi_begin_request {
00067        unsigned char roleB1;
00068        unsigned char roleB0;
00069        unsigned char flags;
00070        unsigned char reserved[5];
00071 } fcgi_begin_request;
00072 
00073 typedef struct _fcgi_begin_request_rec {
00074        fcgi_header hdr;
00075        fcgi_begin_request body;
00076 } fcgi_begin_request_rec;
00077 
00078 typedef struct _fcgi_end_request {
00079        unsigned char appStatusB3;
00080        unsigned char appStatusB2;
00081        unsigned char appStatusB1;
00082        unsigned char appStatusB0;
00083        unsigned char protocolStatus;
00084        unsigned char reserved[3];
00085 } fcgi_end_request;
00086 
00087 typedef struct _fcgi_end_request_rec {
00088        fcgi_header hdr;
00089        fcgi_end_request body;
00090 } fcgi_end_request_rec;
00091 
00092 /* FastCGI client API */
00093 
00094 typedef struct _fcgi_request {
00095        int            listen_socket;
00096 #ifdef _WIN32
00097        int            tcp;
00098 #endif
00099        int            fd;
00100        int            id;
00101        int            keep;
00102        int            closed;
00103 
00104        int            in_len;
00105        int            in_pad;
00106 
00107        fcgi_header   *out_hdr;
00108        unsigned char *out_pos;
00109        unsigned char  out_buf[1024*8];
00110        unsigned char  reserved[sizeof(fcgi_end_request_rec)];
00111 
00112        HashTable     *env;
00113 } fcgi_request;
00114 
00115 int fcgi_init(void);
00116 void fcgi_shutdown(void);
00117 void fcgi_init_request(fcgi_request *req, int listen_socket);
00118 int fcgi_accept_request(fcgi_request *req);
00119 int fcgi_finish_request(fcgi_request *req, int force_close);
00120 
00121 void fcgi_set_in_shutdown(int);
00122 void fcgi_set_allowed_clients(char *);
00123 void fcgi_close(fcgi_request *req, int force, int destroy);
00124 
00125 char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
00126 char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
00127 
00128 int fcgi_read(fcgi_request *req, char *str, int len);
00129 
00130 ssize_t fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
00131 int fcgi_flush(fcgi_request *req, int close);
00132 
00133 void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
00134 void fcgi_free_mgmt_var_cb(void * ptr);
00135 
00136 char *fcgi_get_last_client_ip();
00137 
00138 /*
00139  * Local variables:
00140  * tab-width: 4
00141  * c-basic-offset: 4
00142  * End:
00143  * vim600: sw=4 ts=4 fdm=marker
00144  * vim<600: sw=4 ts=4
00145  */