Debian Codegraph @

vendor/ls-qpack/tools/gen-enums.pl

raw
1 #!/usr/bin/perl
2 # Generate static table enums
3
4 use strict;
5 use warnings;
6
7 my @table = (
8 ":authority", "",
9 ":path", "/",
10 "age", "0",
11 "content-disposition", "",
12 "content-length", "0",
13 "cookie", "",
14 "date", "",
15 "etag", "",
16 "if-modified-since", "",
17 "if-none-match", "",
18 "last-modified", "",
19 "link", "",
20 "location", "",
21 "referer", "",
22 "set-cookie", "",
23 ":method", "CONNECT",
24 ":method", "DELETE",
25 ":method", "GET",
26 ":method", "HEAD",
27 ":method", "OPTIONS",
28 ":method", "POST",
29 ":method", "PUT",
30 ":scheme", "http",
31 ":scheme", "https",
32 ":status", "103",
33 ":status", "200",
34 ":status", "304",
35 ":status", "404",
36 ":status", "503",
37 "accept", "*/*",
38 "accept", "application/dns-message",
39 "accept-encoding", "gzip, deflate, br",
40 "accept-ranges", "bytes",
41 "access-control-allow-headers", "cache-control",
42 "access-control-allow-headers", "content-type",
43 "access-control-allow-origin", "*",
44 "cache-control", "max-age=0",
45 "cache-control", "max-age=2592000",
46 "cache-control", "max-age=604800",
47 "cache-control", "no-cache",
48 "cache-control", "no-store",
49 "cache-control", "public, max-age=31536000",
50 "content-encoding", "br",
51 "content-encoding", "gzip",
52 "content-type", "application/dns-message",
53 "content-type", "application/javascript",
54 "content-type", "application/json",
55 "content-type", "application/x-www-form-urlencoded",
56 "content-type", "image/gif",
57 "content-type", "image/jpeg",
58 "content-type", "image/png",
59 "content-type", "text/css",
60 "content-type", "text/html; charset=utf-8",
61 "content-type", "text/plain",
62 "content-type", "text/plain;charset=utf-8",
63 "range", "bytes=0-",
64 "strict-transport-security", "max-age=31536000",
65 "strict-transport-security", "max-age=31536000; includesubdomains",
66 "strict-transport-security", "max-age=31536000; includesubdomains; preload",
67 "vary", "accept-encoding",
68 "vary", "origin",
69 "x-content-type-options", "nosniff",
70 "x-xss-protection", "1; mode=block",
71 ":status", "100",
72 ":status", "204",
73 ":status", "206",
74 ":status", "302",
75 ":status", "400",
76 ":status", "403",
77 ":status", "421",
78 ":status", "425",
79 ":status", "500",
80 "accept-language", "",
81 "access-control-allow-credentials", "FALSE",
82 "access-control-allow-credentials", "TRUE",
83 "access-control-allow-headers", "*",
84 "access-control-allow-methods", "get",
85 "access-control-allow-methods", "get, post, options",
86 "access-control-allow-methods", "options",
87 "access-control-expose-headers", "content-length",
88 "access-control-request-headers", "content-type",
89 "access-control-request-method", "get",
90 "access-control-request-method", "post",
91 "alt-svc", "clear",
92 "authorization", "",
93 "content-security-policy", "script-src 'none'; object-src 'none'; base-uri 'none'",
94 "early-data", "1",
95 "expect-ct", "",
96 "forwarded", "",
97 "if-range", "",
98 "origin", "",
99 "purpose", "prefetch",
100 "server", "",
101 "timing-allow-origin", "*",
102 "upgrade-insecure-requests", "1",
103 "user-agent", "",
104 "x-forwarded-for", "",
105 "x-frame-options", "deny",
106 "x-frame-options", "sameorigin",
107 );
108
109
110 my $idx = 0;
111 print "enum lsqpack_tnam {\n";
112 while (my ($name, $value) = splice(@table, 0, 2)) {
113 my $enum = "$name-$value";
114 $enum =~ tr/a-z/A-Z/;
115 $enum =~ tr/-/_/;
116 $enum =~ s~[^A-Z0-9_]~_~g;
117 $enum =~ s/_+/_/g;
118 $enum =~ s/_+$//;
119 $enum =~ s/^_+//;
120 print " LSQPACK_TNV_$enum = $idx, /* \"$name\" \"$value\" */\n";
121 ++$idx;
122 }
123 print "};\n\n";