You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
4.1 KiB

  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2006 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. /* $Id$ */
  19. /* FastCGI protocol */
  20. #define FCGI_VERSION_1 1
  21. #define FCGI_MAX_LENGTH 0xffff
  22. #define FCGI_KEEP_CONN 1
  23. typedef enum _fcgi_role {
  24. FCGI_RESPONDER = 1,
  25. FCGI_AUTHORIZER = 2,
  26. FCGI_FILTER = 3
  27. } fcgi_role;
  28. typedef enum _fcgi_request_type {
  29. FCGI_BEGIN_REQUEST = 1, /* [in] */
  30. FCGI_ABORT_REQUEST = 2, /* [in] (not supported) */
  31. FCGI_END_REQUEST = 3, /* [out] */
  32. FCGI_PARAMS = 4, /* [in] environment variables */
  33. FCGI_STDIN = 5, /* [in] post data */
  34. FCGI_STDOUT = 6, /* [out] response */
  35. FCGI_STDERR = 7, /* [out] errors */
  36. FCGI_DATA = 8, /* [in] filter data (not supported) */
  37. FCGI_GET_VALUES = 9, /* [in] */
  38. FCGI_GET_VALUES_RESULT = 10 /* [out] */
  39. } fcgi_request_type;
  40. typedef enum _fcgi_protocol_status {
  41. FCGI_REQUEST_COMPLETE = 0,
  42. FCGI_CANT_MPX_CONN = 1,
  43. FCGI_OVERLOADED = 2,
  44. FCGI_UNKNOWN_ROLE = 3
  45. } dcgi_protocol_status;
  46. typedef struct _fcgi_header {
  47. unsigned char version;
  48. unsigned char type;
  49. unsigned char requestIdB1;
  50. unsigned char requestIdB0;
  51. unsigned char contentLengthB1;
  52. unsigned char contentLengthB0;
  53. unsigned char paddingLength;
  54. unsigned char reserved;
  55. } fcgi_header;
  56. typedef struct _fcgi_begin_request {
  57. unsigned char roleB1;
  58. unsigned char roleB0;
  59. unsigned char flags;
  60. unsigned char reserved[5];
  61. } fcgi_begin_request;
  62. typedef struct _fcgi_begin_request_rec {
  63. fcgi_header hdr;
  64. fcgi_begin_request body;
  65. } fcgi_begin_request_rec;
  66. typedef struct _fcgi_end_request {
  67. unsigned char appStatusB3;
  68. unsigned char appStatusB2;
  69. unsigned char appStatusB1;
  70. unsigned char appStatusB0;
  71. unsigned char protocolStatus;
  72. unsigned char reserved[3];
  73. } fcgi_end_request;
  74. typedef struct _fcgi_end_request_rec {
  75. fcgi_header hdr;
  76. fcgi_end_request body;
  77. } fcgi_end_request_rec;
  78. /* FastCGI client API */
  79. typedef struct _fcgi_request {
  80. int listen_socket;
  81. int fd;
  82. int id;
  83. int keep;
  84. int in_len;
  85. int in_pad;
  86. fcgi_header *out_hdr;
  87. unsigned char *out_pos;
  88. unsigned char out_buf[1024*8];
  89. unsigned char reserved[sizeof(fcgi_end_request_rec)];
  90. HashTable env;
  91. } fcgi_request;
  92. int fcgi_init(void);
  93. int fcgi_is_fastcgi(void);
  94. int fcgi_listen(const char *path, int backlog);
  95. void fcgi_init_request(fcgi_request *req, int listen_socket);
  96. int fcgi_accept_request(fcgi_request *req);
  97. int fcgi_finish_request(fcgi_request *req);
  98. char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
  99. char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
  100. int fcgi_read(fcgi_request *req, char *str, int len);
  101. int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
  102. int fcgi_flush(fcgi_request *req, int close);
  103. #ifdef PHP_WIN32
  104. void fcgi_impersonate(void);
  105. #endif
  106. /*
  107. * Local variables:
  108. * tab-width: 4
  109. * c-basic-offset: 4
  110. * End:
  111. * vim600: sw=4 ts=4 fdm=marker
  112. * vim<600: sw=4 ts=4
  113. */