root/sapi/fpm/fpm/fastcgi.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2    +----------------------------------------------------------------------+
   3    | PHP Version 5                                                        |
   4    +----------------------------------------------------------------------+
   5    | Copyright (c) 1997-2016 The PHP Group                                |
   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 
  19 /* $Id: fastcgi.h 272370 2008-12-31 11:15:49Z sebastian $ */
  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 
  29 typedef enum _fcgi_role {
  30         FCGI_RESPONDER  = 1,
  31         FCGI_AUTHORIZER = 2,
  32         FCGI_FILTER             = 3
  33 } fcgi_role;
  34 
  35 typedef enum _fcgi_request_type {
  36         FCGI_BEGIN_REQUEST              =  1, /* [in]                              */
  37         FCGI_ABORT_REQUEST              =  2, /* [in]  (not supported)             */
  38         FCGI_END_REQUEST                =  3, /* [out]                             */
  39         FCGI_PARAMS                             =  4, /* [in]  environment variables       */
  40         FCGI_STDIN                              =  5, /* [in]  post data                   */
  41         FCGI_STDOUT                             =  6, /* [out] response                    */
  42         FCGI_STDERR                             =  7, /* [out] errors                      */
  43         FCGI_DATA                               =  8, /* [in]  filter data (not supported) */
  44         FCGI_GET_VALUES                 =  9, /* [in]                              */
  45         FCGI_GET_VALUES_RESULT  = 10  /* [out]                             */
  46 } fcgi_request_type;
  47 
  48 typedef enum _fcgi_protocol_status {
  49         FCGI_REQUEST_COMPLETE   = 0,
  50         FCGI_CANT_MPX_CONN              = 1,
  51         FCGI_OVERLOADED                 = 2,
  52         FCGI_UNKNOWN_ROLE               = 3
  53 } dcgi_protocol_status;
  54 
  55 typedef struct _fcgi_header {
  56         unsigned char version;
  57         unsigned char type;
  58         unsigned char requestIdB1;
  59         unsigned char requestIdB0;
  60         unsigned char contentLengthB1;
  61         unsigned char contentLengthB0;
  62         unsigned char paddingLength;
  63         unsigned char reserved;
  64 } fcgi_header;
  65 
  66 typedef struct _fcgi_begin_request {
  67         unsigned char roleB1;
  68         unsigned char roleB0;
  69         unsigned char flags;
  70         unsigned char reserved[5];
  71 } fcgi_begin_request;
  72 
  73 typedef struct _fcgi_begin_request_rec {
  74         fcgi_header hdr;
  75         fcgi_begin_request body;
  76 } fcgi_begin_request_rec;
  77 
  78 typedef struct _fcgi_end_request {
  79         unsigned char appStatusB3;
  80         unsigned char appStatusB2;
  81         unsigned char appStatusB1;
  82         unsigned char appStatusB0;
  83         unsigned char protocolStatus;
  84         unsigned char reserved[3];
  85 } fcgi_end_request;
  86 
  87 typedef struct _fcgi_end_request_rec {
  88         fcgi_header hdr;
  89         fcgi_end_request body;
  90 } fcgi_end_request_rec;
  91 
  92 /* FastCGI client API */
  93 
  94 typedef struct _fcgi_request {
  95         int            listen_socket;
  96 #ifdef _WIN32
  97         int            tcp;
  98 #endif
  99         int            fd;
 100         int            id;
 101         int            keep;
 102         int            closed;
 103 
 104         int            in_len;
 105         int            in_pad;
 106 
 107         fcgi_header   *out_hdr;
 108         unsigned char *out_pos;
 109         unsigned char  out_buf[1024*8];
 110         unsigned char  reserved[sizeof(fcgi_end_request_rec)];
 111 
 112         HashTable     *env;
 113 } fcgi_request;
 114 
 115 int fcgi_init(void);
 116 void fcgi_shutdown(void);
 117 void fcgi_init_request(fcgi_request *req, int listen_socket);
 118 int fcgi_accept_request(fcgi_request *req);
 119 int fcgi_finish_request(fcgi_request *req, int force_close);
 120 
 121 void fcgi_set_in_shutdown(int);
 122 void fcgi_set_allowed_clients(char *);
 123 void fcgi_close(fcgi_request *req, int force, int destroy);
 124 
 125 char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
 126 char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
 127 
 128 int fcgi_read(fcgi_request *req, char *str, int len);
 129 
 130 ssize_t fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
 131 int fcgi_flush(fcgi_request *req, int close);
 132 
 133 void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
 134 void fcgi_free_mgmt_var_cb(void * ptr);
 135 
 136 const char *fcgi_get_last_client_ip();
 137 
 138 /*
 139  * Local variables:
 140  * tab-width: 4
 141  * c-basic-offset: 4
 142  * End:
 143  * vim600: sw=4 ts=4 fdm=marker
 144  * vim<600: sw=4 ts=4
 145  */

/* [<][>][^][v][top][bottom][index][help] */