1 2 /* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7 #ifndef _NXT_FASTCGI_SOURCE_H_INCLUDED_ 8 #define _NXT_FASTCGI_SOURCE_H_INCLUDED_ 9 10 11 #define NXT_FASTCGI_BEGIN_REQUEST 1 12 #define NXT_FASTCGI_ABORT_REQUEST 2 13 #define NXT_FASTCGI_END_REQUEST 3 14 #define NXT_FASTCGI_PARAMS 4 15 #define NXT_FASTCGI_STDIN 5 16 #define NXT_FASTCGI_STDOUT 6 17 #define NXT_FASTCGI_STDERR 7 18 #define NXT_FASTCGI_DATA 8 19 20 21 typedef struct nxt_fastcgi_parse_s nxt_fastcgi_parse_t; 22 23 struct nxt_fastcgi_parse_s { 24 u_char *pos; 25 26 uint16_t length; /* 16 bits */ 27 uint8_t padding; 28 uint8_t type; 29 30 uint8_t state; 31 uint8_t fastcgi_error; /* 1 bit */ 32 uint8_t error; /* 1 bit */ 33 uint8_t done; /* 1 bit */ 34 35 /* FastCGI stdout and stderr buffer chains. */ 36 nxt_buf_t *out[2]; 37 38 nxt_buf_t *(*last_buf)(nxt_fastcgi_parse_t *fp); 39 void *data; 40 nxt_mp_t *mem_pool; 41 }; 42 43 44 typedef struct { 45 nxt_fastcgi_parse_t parse; 46 nxt_source_hook_t next; 47 } nxt_fastcgi_source_record_t; 48 49 50 typedef struct { 51 nxt_str_t name; 52 nxt_str_t value; 53 uintptr_t data[3]; 54 } nxt_fastcgi_source_request_t; 55 56 57 typedef struct nxt_fastcgi_source_s nxt_fastcgi_source_t; 58 typedef nxt_int_t (*nxt_fastcgi_source_request_create_t)( 59 nxt_fastcgi_source_t *fs); 60 61 62 struct nxt_fastcgi_source_s { 63 nxt_source_hook_t query; 64 nxt_source_hook_t *next; 65 66 nxt_upstream_source_t *upstream; 67 68 nxt_fastcgi_source_request_create_t request_create; 69 70 nxt_upstream_header_in_t header_in; 71 72 nxt_buf_t *rest; 73 74 uint32_t state; /* 2 bits */ 75 76 nxt_fastcgi_source_record_t record; 77 78 union { 79 nxt_fastcgi_source_request_t request; 80 } u; 81 }; 82 83 84 NXT_EXPORT void nxt_fastcgi_source_handler(nxt_task_t *task, 85 nxt_upstream_source_t *us, 86 nxt_fastcgi_source_request_create_t request_create); 87 NXT_EXPORT nxt_int_t nxt_fastcgi_source_hash_create(nxt_mp_t *mp, 88 nxt_lvlhsh_t *lh); 89 void nxt_fastcgi_record_parse(nxt_task_t *task, nxt_fastcgi_parse_t *fp, 90 nxt_buf_t *in); 91 92 93 #endif /* _NXT_FASTCGI_SOURCE_H_INCLUDED_ */ 94