1/*
2 * fastcgi.h --
3 *
4 *	Defines for the FastCGI protocol.
5 *
6 *
7 * Copyright (c) 1995-1996 Open Market, Inc.
8 *
9 * See the file "LICENSE.TERMS" for information on usage and redistribution
10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 *
12 * $Id: fastcgi.h,v 1.1.1.1 2003/10/18 09:54:10 weigon Exp $
13 */
14
15#ifndef _FASTCGI_H
16#define _FASTCGI_H
17
18/*
19 * Listening socket file number
20 */
21#define FCGI_LISTENSOCK_FILENO 0
22
23typedef struct {
24    unsigned char version;
25    unsigned char type;
26    unsigned char requestIdB1;
27    unsigned char requestIdB0;
28    unsigned char contentLengthB1;
29    unsigned char contentLengthB0;
30    unsigned char paddingLength;
31    unsigned char reserved;
32} FCGI_Header;
33
34#define FCGI_MAX_LENGTH 0xffff
35
36/*
37 * Number of bytes in a FCGI_Header.  Future versions of the protocol
38 * will not reduce this number.
39 */
40#define FCGI_HEADER_LEN  8
41
42/*
43 * Value for version component of FCGI_Header
44 */
45#define FCGI_VERSION_1           1
46
47/*
48 * Values for type component of FCGI_Header
49 */
50#define FCGI_BEGIN_REQUEST       1
51#define FCGI_ABORT_REQUEST       2
52#define FCGI_END_REQUEST         3
53#define FCGI_PARAMS              4
54#define FCGI_STDIN               5
55#define FCGI_STDOUT              6
56#define FCGI_STDERR              7
57#define FCGI_DATA                8
58#define FCGI_GET_VALUES          9
59#define FCGI_GET_VALUES_RESULT  10
60#define FCGI_UNKNOWN_TYPE       11
61#define FCGI_MAXTYPE (FCGI_UNKNOWN_TYPE)
62
63/*
64 * Value for requestId component of FCGI_Header
65 */
66#define FCGI_NULL_REQUEST_ID     0
67
68
69typedef struct {
70    unsigned char roleB1;
71    unsigned char roleB0;
72    unsigned char flags;
73    unsigned char reserved[5];
74} FCGI_BeginRequestBody;
75
76typedef struct {
77    FCGI_Header header;
78    FCGI_BeginRequestBody body;
79} FCGI_BeginRequestRecord;
80
81/*
82 * Mask for flags component of FCGI_BeginRequestBody
83 */
84#define FCGI_KEEP_CONN  1
85
86/*
87 * Values for role component of FCGI_BeginRequestBody
88 */
89#define FCGI_RESPONDER  1
90#define FCGI_AUTHORIZER 2
91#define FCGI_FILTER     3
92
93
94typedef struct {
95    unsigned char appStatusB3;
96    unsigned char appStatusB2;
97    unsigned char appStatusB1;
98    unsigned char appStatusB0;
99    unsigned char protocolStatus;
100    unsigned char reserved[3];
101} FCGI_EndRequestBody;
102
103typedef struct {
104    FCGI_Header header;
105    FCGI_EndRequestBody body;
106} FCGI_EndRequestRecord;
107
108/*
109 * Values for protocolStatus component of FCGI_EndRequestBody
110 */
111#define FCGI_REQUEST_COMPLETE 0
112#define FCGI_CANT_MPX_CONN    1
113#define FCGI_OVERLOADED       2
114#define FCGI_UNKNOWN_ROLE     3
115
116
117/*
118 * Variable names for FCGI_GET_VALUES / FCGI_GET_VALUES_RESULT records
119 */
120#define FCGI_MAX_CONNS  "FCGI_MAX_CONNS"
121#define FCGI_MAX_REQS   "FCGI_MAX_REQS"
122#define FCGI_MPXS_CONNS "FCGI_MPXS_CONNS"
123
124
125typedef struct {
126    unsigned char type;
127    unsigned char reserved[7];
128} FCGI_UnknownTypeBody;
129
130typedef struct {
131    FCGI_Header header;
132    FCGI_UnknownTypeBody body;
133} FCGI_UnknownTypeRecord;
134
135#endif	/* _FASTCGI_H */
136
137