Annotation of embedaddon/php/sapi/cgi/fastcgi.h, revision 1.1.1.3

1.1       misho       1: /*
                      2:    +----------------------------------------------------------------------+
                      3:    | PHP Version 5                                                        |
                      4:    +----------------------------------------------------------------------+
1.1.1.3 ! misho       5:    | Copyright (c) 1997-2013 The PHP Group                                |
1.1       misho       6:    +----------------------------------------------------------------------+
                      7:    | This source file is subject to version 3.01 of the PHP license,      |
                      8:    | that is bundled with this package in the file LICENSE, and is        |
                      9:    | available through the world-wide-web at the following url:           |
                     10:    | http://www.php.net/license/3_01.txt                                  |
                     11:    | If you did not receive a copy of the PHP license and are unable to   |
                     12:    | obtain it through the world-wide-web, please send a note to          |
                     13:    | license@php.net so we can mail you a copy immediately.               |
                     14:    +----------------------------------------------------------------------+
                     15:    | Authors: Dmitry Stogov <dmitry@zend.com>                             |
                     16:    +----------------------------------------------------------------------+
                     17: */
                     18: 
1.1.1.2   misho      19: /* $Id$ */
1.1       misho      20: 
                     21: /* FastCGI protocol */
                     22: 
                     23: #define FCGI_VERSION_1 1
                     24: 
                     25: #define FCGI_MAX_LENGTH 0xffff
                     26: 
                     27: #define FCGI_KEEP_CONN  1
                     28: 
1.1.1.2   misho      29: /* this is near the perfect hash function for most useful FastCGI variables
                     30:  * which combines efficiency and minimal hash collisions
                     31:  */
                     32: 
                     33: #define FCGI_HASH_FUNC(var, var_len) \
                     34:        (UNEXPECTED(var_len < 3) ? var_len : \
                     35:                (((unsigned int)var[3]) << 2) + \
                     36:                (((unsigned int)var[var_len-2]) << 4) + \
                     37:                (((unsigned int)var[var_len-1]) << 2) + \
                     38:                var_len)
                     39: 
                     40: #define FCGI_GETENV(request, name) \
                     41:        fcgi_quick_getenv(request, name, sizeof(name)-1, FCGI_HASH_FUNC(name, sizeof(name)-1))
                     42: 
                     43: #define FCGI_PUTENV(request, name, value) \
                     44:        fcgi_quick_putenv(request, name, sizeof(name)-1, FCGI_HASH_FUNC(name, sizeof(name)-1), value)
                     45: 
1.1       misho      46: typedef enum _fcgi_role {
                     47:        FCGI_RESPONDER  = 1,
                     48:        FCGI_AUTHORIZER = 2,
                     49:        FCGI_FILTER             = 3
                     50: } fcgi_role;
                     51: 
                     52: typedef enum _fcgi_request_type {
                     53:        FCGI_BEGIN_REQUEST              =  1, /* [in]                              */
                     54:        FCGI_ABORT_REQUEST              =  2, /* [in]  (not supported)             */
                     55:        FCGI_END_REQUEST                =  3, /* [out]                             */
                     56:        FCGI_PARAMS                             =  4, /* [in]  environment variables       */
                     57:        FCGI_STDIN                              =  5, /* [in]  post data                   */
                     58:        FCGI_STDOUT                             =  6, /* [out] response                    */
                     59:        FCGI_STDERR                             =  7, /* [out] errors                      */
                     60:        FCGI_DATA                               =  8, /* [in]  filter data (not supported) */
                     61:        FCGI_GET_VALUES                 =  9, /* [in]                              */
                     62:        FCGI_GET_VALUES_RESULT  = 10  /* [out]                             */
                     63: } fcgi_request_type;
                     64: 
                     65: typedef enum _fcgi_protocol_status {
                     66:        FCGI_REQUEST_COMPLETE   = 0,
                     67:        FCGI_CANT_MPX_CONN              = 1,
                     68:        FCGI_OVERLOADED                 = 2,
                     69:        FCGI_UNKNOWN_ROLE               = 3
                     70: } dcgi_protocol_status;
                     71: 
                     72: typedef struct _fcgi_header {
                     73:        unsigned char version;
                     74:        unsigned char type;
                     75:        unsigned char requestIdB1;
                     76:        unsigned char requestIdB0;
                     77:        unsigned char contentLengthB1;
                     78:        unsigned char contentLengthB0;
                     79:        unsigned char paddingLength;
                     80:        unsigned char reserved;
                     81: } fcgi_header;
                     82: 
                     83: typedef struct _fcgi_begin_request {
                     84:        unsigned char roleB1;
                     85:        unsigned char roleB0;
                     86:        unsigned char flags;
                     87:        unsigned char reserved[5];
                     88: } fcgi_begin_request;
                     89: 
                     90: typedef struct _fcgi_begin_request_rec {
                     91:        fcgi_header hdr;
                     92:        fcgi_begin_request body;
                     93: } fcgi_begin_request_rec;
                     94: 
                     95: typedef struct _fcgi_end_request {
                     96:     unsigned char appStatusB3;
                     97:     unsigned char appStatusB2;
                     98:     unsigned char appStatusB1;
                     99:     unsigned char appStatusB0;
                    100:     unsigned char protocolStatus;
                    101:     unsigned char reserved[3];
                    102: } fcgi_end_request;
                    103: 
                    104: typedef struct _fcgi_end_request_rec {
                    105:        fcgi_header hdr;
                    106:        fcgi_end_request body;
                    107: } fcgi_end_request_rec;
                    108: 
                    109: /* FastCGI client API */
                    110: 
1.1.1.2   misho     111: typedef void (*fcgi_apply_func)(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg TSRMLS_DC);
1.1       misho     112: 
1.1.1.2   misho     113: typedef struct _fcgi_request fcgi_request;
1.1       misho     114: 
                    115: int fcgi_init(void);
                    116: void fcgi_shutdown(void);
                    117: int fcgi_is_fastcgi(void);
                    118: int fcgi_in_shutdown(void);
1.1.1.2   misho     119: void fcgi_terminate(void);
1.1       misho     120: int fcgi_listen(const char *path, int backlog);
1.1.1.2   misho     121: fcgi_request* fcgi_init_request(int listen_socket);
                    122: void fcgi_destroy_request(fcgi_request *req);
1.1       misho     123: int fcgi_accept_request(fcgi_request *req);
                    124: int fcgi_finish_request(fcgi_request *req, int force_close);
                    125: 
                    126: char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
                    127: char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
1.1.1.2   misho     128: char* fcgi_quick_getenv(fcgi_request *req, const char* var, int var_len, unsigned int hash_value);
                    129: char* fcgi_quick_putenv(fcgi_request *req, char* var, int var_len, unsigned int hash_value, char* val);
                    130: void  fcgi_loadenv(fcgi_request *req, fcgi_apply_func load_func, zval *array TSRMLS_DC);
1.1       misho     131: 
                    132: int fcgi_read(fcgi_request *req, char *str, int len);
                    133: 
                    134: int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
                    135: int fcgi_flush(fcgi_request *req, int close);
                    136: 
                    137: #ifdef PHP_WIN32
                    138: void fcgi_impersonate(void);
                    139: #endif
                    140: 
                    141: void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
                    142: void fcgi_free_mgmt_var_cb(void * ptr);
                    143: 
                    144: /*
                    145:  * Local variables:
                    146:  * tab-width: 4
                    147:  * c-basic-offset: 4
                    148:  * End:
                    149:  * vim600: sw=4 ts=4 fdm=marker
                    150:  * vim<600: sw=4 ts=4
                    151:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>