PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/cgi/fastcgi.h

http://github.com/dreamcat4/php-fpm
C Header | 150 lines | 96 code | 26 blank | 28 comment | 0 complexity | 0d41a3a54c0bf13d679aae79e7d64460 MD5 | raw file
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2008 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: fastcgi.h,v 1.2.2.4.2.7 2008/10/21 16:43:59 lbarnaud Exp $ */
  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. #ifdef _WIN32
  82. int tcp;
  83. #endif
  84. int fd;
  85. int id;
  86. int keep;
  87. int in_len;
  88. int in_pad;
  89. fcgi_header *out_hdr;
  90. unsigned char *out_pos;
  91. unsigned char out_buf[1024*8];
  92. unsigned char reserved[sizeof(fcgi_end_request_rec)];
  93. HashTable env;
  94. } fcgi_request;
  95. int fcgi_init(void);
  96. void fcgi_shutdown(void);
  97. int fcgi_is_fastcgi(void);
  98. void fcgi_set_is_fastcgi(int);
  99. void fcgi_set_in_shutdown(int);
  100. void fcgi_set_allowed_clients(char *);
  101. int fcgi_in_shutdown(void);
  102. int fcgi_listen(const char *path, int backlog);
  103. void fcgi_init_request(fcgi_request *req, int listen_socket);
  104. int fcgi_accept_request(fcgi_request *req);
  105. int fcgi_finish_request(fcgi_request *req);
  106. char* fcgi_getenv(fcgi_request *req, const char* var, int var_len);
  107. char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val);
  108. int fcgi_read(fcgi_request *req, char *str, int len);
  109. int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
  110. int fcgi_flush(fcgi_request *req, int close);
  111. void fcgi_close(fcgi_request *req, int force, int destroy);
  112. #ifdef PHP_WIN32
  113. void fcgi_impersonate(void);
  114. #endif
  115. void fcgi_set_mgmt_var(char * name, size_t name_len, const char * value, size_t value_len);
  116. void fcgi_free_mgmt_var_cb(void * ptr);
  117. /*
  118. * Local variables:
  119. * tab-width: 4
  120. * c-basic-offset: 4
  121. * End:
  122. * vim600: sw=4 ts=4 fdm=marker
  123. * vim<600: sw=4 ts=4
  124. */