This repository has been archived by the owner on Mar 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfcgi_header.c
77 lines (63 loc) · 1.99 KB
/
fcgi_header.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "fcgi_header.h"
#define fcgi_header_twobyte_set(header, field, value) do { \
(header)->field ## B0 = value & 0xff; \
(header)->field ## B1 = (value >> 8) & 0xff; \
} while (0)
#define fcgi_header_twobyte_get(header, field) \
(((header)->field ## B0 & 0xff) | \
(((header)->field ## B1 & 0xff) << 8))
void fcgi_header_version_set(fcgi_header_t header, uint8_t version)
{
header->version = version;
}
uint8_t fcgi_header_version_get(fcgi_header_t header)
{
return header->version;
}
void fcgi_header_type_set(fcgi_header_t header, uint8_t type)
{
header->type = type;
}
uint8_t fcgi_header_type_get(fcgi_header_t header)
{
return header->type;
}
void fcgi_header_request_id_set(fcgi_header_t header, uint16_t request_id)
{
fcgi_header_twobyte_set(header, request_id, request_id);
}
uint16_t fcgi_header_request_id_get(fcgi_header_t header)
{
return fcgi_header_twobyte_get(header, request_id);
}
void fcgi_header_content_length_set(fcgi_header_t header, uint16_t content_length)
{
fcgi_header_twobyte_set(header, content_length, content_length);
}
uint16_t fcgi_header_content_length_get(fcgi_header_t header)
{
return fcgi_header_twobyte_get(header, content_length);
}
void fcgi_header_padding_length_set(fcgi_header_t header, uint8_t padding_length)
{
header->padding_length = padding_length;
}
uint8_t fcgi_header_padding_length_get(fcgi_header_t header)
{
return header->padding_length;
}
void fcgi_header_reserved_set(fcgi_header_t header)
{
header->reserved = 0;
}
/* set all FastCGI record header field */
void fcgi_header_set(fcgi_header_t header, uint8_t version, uint8_t type,
uint16_t request_id, uint16_t content_length, uint8_t padding_length)
{
fcgi_header_version_set(header, version); /* set by default to v1 */
fcgi_header_type_set(header, type);
fcgi_header_request_id_set(header, request_id);
fcgi_header_content_length_set(header, content_length);
fcgi_header_padding_length_set(header, padding_length);
fcgi_header_reserved_set(header); /* alway set to zero in v1 */
}