diff options
Diffstat (limited to '')
-rw-r--r-- | src/sledjchisl/fcgi_SC.h | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/src/sledjchisl/fcgi_SC.h b/src/sledjchisl/fcgi_SC.h new file mode 100644 index 0000000..2b3fa65 --- /dev/null +++ b/src/sledjchisl/fcgi_SC.h | |||
@@ -0,0 +1,136 @@ | |||
1 | /* fcgi_SC.h - Generic fcgi handler, coz the oters all suck. | ||
2 | * | ||
3 | * Copyright 2020 David Seikel <onefang@sledjhamr.org> | ||
4 | */ | ||
5 | |||
6 | enum fcgiEventType{ | ||
7 | FSC_CSI, | ||
8 | FSC_KEYS, | ||
9 | FSC_MOUSE, | ||
10 | FSC_RAW | ||
11 | }; | ||
12 | |||
13 | struct fcgiEvent { | ||
14 | enum fcgiEventType type; // The type of this event. | ||
15 | char *sequence; // Either a translated sequence, or raw bytes. | ||
16 | int isTranslated; // Whether or not sequence is translated. | ||
17 | int count; // Number of entries in params. | ||
18 | int *params; // For CSI events, the decoded parameters. | ||
19 | }; | ||
20 | |||
21 | |||
22 | |||
23 | |||
24 | // From the spec. | ||
25 | |||
26 | /* | ||
27 | * Listening socket file number | ||
28 | */ | ||
29 | #define FCGI_LISTENSOCK_FILENO 0 | ||
30 | |||
31 | typedef struct { | ||
32 | unsigned char version; | ||
33 | unsigned char type; | ||
34 | unsigned char requestIdB1; | ||
35 | unsigned char requestIdB0; | ||
36 | unsigned char contentLengthB1; | ||
37 | unsigned char contentLengthB0; | ||
38 | unsigned char paddingLength; | ||
39 | unsigned char reserved; | ||
40 | } FCGI_Header; | ||
41 | |||
42 | /* | ||
43 | * Number of bytes in a FCGI_Header. Future versions of the protocol | ||
44 | * will not reduce this number. | ||
45 | */ | ||
46 | #define FCGI_HEADER_LEN 8 | ||
47 | |||
48 | /* | ||
49 | * Value for version component of FCGI_Header | ||
50 | */ | ||
51 | #define FCGI_VERSION_1 1 | ||
52 | |||
53 | /* | ||
54 | * Values for type component of FCGI_Header | ||
55 | */ | ||
56 | #define FCGI_BEGIN_REQUEST 1 | ||
57 | #define FCGI_ABORT_REQUEST 2 | ||
58 | #define FCGI_END_REQUEST 3 | ||
59 | #define FCGI_PARAMS 4 | ||
60 | #define FCGI_STDIN 5 | ||
61 | #define FCGI_STDOUT 6 | ||
62 | #define FCGI_STDERR 7 | ||
63 | #define FCGI_DATA 8 | ||
64 | #define FCGI_GET_VALUES 9 | ||
65 | #define FCGI_GET_VALUES_RESULT 10 | ||
66 | #define FCGI_UNKNOWN_TYPE 11 | ||
67 | #define FCGI_MAXTYPE (FCGI_UNKNOWN_TYPE) | ||
68 | |||
69 | /* | ||
70 | * Value for requestId component of FCGI_Header | ||
71 | */ | ||
72 | #define FCGI_NULL_REQUEST_ID 0 | ||
73 | |||
74 | typedef struct { | ||
75 | unsigned char roleB1; | ||
76 | unsigned char roleB0; | ||
77 | unsigned char flags; | ||
78 | unsigned char reserved[5]; | ||
79 | } FCGI_BeginRequestBody; | ||
80 | |||
81 | typedef struct { | ||
82 | FCGI_Header header; | ||
83 | FCGI_BeginRequestBody body; | ||
84 | } FCGI_BeginRequestRecord; | ||
85 | |||
86 | /* | ||
87 | * Mask for flags component of FCGI_BeginRequestBody | ||
88 | */ | ||
89 | #define FCGI_KEEP_CONN 1 | ||
90 | |||
91 | /* | ||
92 | * Values for role component of FCGI_BeginRequestBody | ||
93 | */ | ||
94 | #define FCGI_RESPONDER 1 | ||
95 | #define FCGI_AUTHORIZER 2 | ||
96 | #define FCGI_FILTER 3 | ||
97 | |||
98 | typedef struct { | ||
99 | unsigned char appStatusB3; | ||
100 | unsigned char appStatusB2; | ||
101 | unsigned char appStatusB1; | ||
102 | unsigned char appStatusB0; | ||
103 | unsigned char protocolStatus; | ||
104 | unsigned char reserved[3]; | ||
105 | } FCGI_EndRequestBody; | ||
106 | |||
107 | typedef struct { | ||
108 | FCGI_Header header; | ||
109 | FCGI_EndRequestBody body; | ||
110 | } FCGI_EndRequestRecord; | ||
111 | |||
112 | /* | ||
113 | * Values for protocolStatus component of FCGI_EndRequestBody | ||
114 | */ | ||
115 | #define FCGI_REQUEST_COMPLETE 0 | ||
116 | #define FCGI_CANT_MPX_CONN 1 | ||
117 | #define FCGI_OVERLOADED 2 | ||
118 | #define FCGI_UNKNOWN_ROLE 3 | ||
119 | |||
120 | /* | ||
121 | * Variable names for FCGI_GET_VALUES / FCGI_GET_VALUES_RESULT records | ||
122 | */ | ||
123 | #define FCGI_MAX_CONNS "FCGI_MAX_CONNS" | ||
124 | #define FCGI_MAX_REQS "FCGI_MAX_REQS" | ||
125 | #define FCGI_MPXS_CONNS "FCGI_MPXS_CONNS" | ||
126 | |||
127 | typedef struct { | ||
128 | unsigned char type; | ||
129 | unsigned char reserved[7]; | ||
130 | } FCGI_UnknownTypeBody; | ||
131 | |||
132 | typedef struct { | ||
133 | FCGI_Header header; | ||
134 | FCGI_UnknownTypeBody body; | ||
135 | } FCGI_UnknownTypeRecord; | ||
136 | |||