rage-iodine 1.7.58

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +40 -0
  3. data/.github/workflows/ruby.yml +42 -0
  4. data/.gitignore +20 -0
  5. data/.rspec +2 -0
  6. data/.yardopts +8 -0
  7. data/CHANGELOG.md +1098 -0
  8. data/Gemfile +11 -0
  9. data/LICENSE.txt +21 -0
  10. data/LIMITS.md +41 -0
  11. data/README.md +782 -0
  12. data/Rakefile +23 -0
  13. data/SPEC-PubSub-Draft.md +159 -0
  14. data/SPEC-WebSocket-Draft.md +239 -0
  15. data/bin/console +22 -0
  16. data/bin/info.md +353 -0
  17. data/bin/mustache_bench.rb +100 -0
  18. data/bin/poc/Gemfile.lock +23 -0
  19. data/bin/poc/README.md +37 -0
  20. data/bin/poc/config.ru +66 -0
  21. data/bin/poc/gemfile +1 -0
  22. data/bin/poc/www/index.html +57 -0
  23. data/examples/async_task.ru +92 -0
  24. data/examples/bates/README.md +3 -0
  25. data/examples/bates/config.ru +342 -0
  26. data/examples/bates/david+bold.pdf +0 -0
  27. data/examples/bates/public/drop-pdf.png +0 -0
  28. data/examples/bates/public/index.html +600 -0
  29. data/examples/config.ru +59 -0
  30. data/examples/echo.ru +59 -0
  31. data/examples/etag.ru +16 -0
  32. data/examples/hello.ru +29 -0
  33. data/examples/pubsub_engine.ru +81 -0
  34. data/examples/rack3.ru +12 -0
  35. data/examples/redis.ru +70 -0
  36. data/examples/shootout.ru +73 -0
  37. data/examples/sub-protocols.ru +90 -0
  38. data/examples/tcp_client.rb +66 -0
  39. data/examples/x-sendfile.ru +14 -0
  40. data/exe/iodine +280 -0
  41. data/ext/iodine/extconf.rb +110 -0
  42. data/ext/iodine/fio.c +12096 -0
  43. data/ext/iodine/fio.h +6390 -0
  44. data/ext/iodine/fio_cli.c +431 -0
  45. data/ext/iodine/fio_cli.h +189 -0
  46. data/ext/iodine/fio_json_parser.h +687 -0
  47. data/ext/iodine/fio_siphash.c +157 -0
  48. data/ext/iodine/fio_siphash.h +37 -0
  49. data/ext/iodine/fio_tls.h +129 -0
  50. data/ext/iodine/fio_tls_missing.c +649 -0
  51. data/ext/iodine/fio_tls_openssl.c +1056 -0
  52. data/ext/iodine/fio_tmpfile.h +50 -0
  53. data/ext/iodine/fiobj.h +44 -0
  54. data/ext/iodine/fiobj4fio.h +21 -0
  55. data/ext/iodine/fiobj_ary.c +333 -0
  56. data/ext/iodine/fiobj_ary.h +139 -0
  57. data/ext/iodine/fiobj_data.c +1185 -0
  58. data/ext/iodine/fiobj_data.h +167 -0
  59. data/ext/iodine/fiobj_hash.c +409 -0
  60. data/ext/iodine/fiobj_hash.h +176 -0
  61. data/ext/iodine/fiobj_json.c +622 -0
  62. data/ext/iodine/fiobj_json.h +68 -0
  63. data/ext/iodine/fiobj_mem.h +71 -0
  64. data/ext/iodine/fiobj_mustache.c +317 -0
  65. data/ext/iodine/fiobj_mustache.h +62 -0
  66. data/ext/iodine/fiobj_numbers.c +344 -0
  67. data/ext/iodine/fiobj_numbers.h +127 -0
  68. data/ext/iodine/fiobj_str.c +433 -0
  69. data/ext/iodine/fiobj_str.h +172 -0
  70. data/ext/iodine/fiobject.c +620 -0
  71. data/ext/iodine/fiobject.h +654 -0
  72. data/ext/iodine/hpack.h +1923 -0
  73. data/ext/iodine/http.c +2736 -0
  74. data/ext/iodine/http.h +1019 -0
  75. data/ext/iodine/http1.c +825 -0
  76. data/ext/iodine/http1.h +29 -0
  77. data/ext/iodine/http1_parser.h +1835 -0
  78. data/ext/iodine/http_internal.c +1279 -0
  79. data/ext/iodine/http_internal.h +248 -0
  80. data/ext/iodine/http_mime_parser.h +350 -0
  81. data/ext/iodine/iodine.c +1433 -0
  82. data/ext/iodine/iodine.h +64 -0
  83. data/ext/iodine/iodine_caller.c +218 -0
  84. data/ext/iodine/iodine_caller.h +27 -0
  85. data/ext/iodine/iodine_connection.c +941 -0
  86. data/ext/iodine/iodine_connection.h +55 -0
  87. data/ext/iodine/iodine_defer.c +420 -0
  88. data/ext/iodine/iodine_defer.h +6 -0
  89. data/ext/iodine/iodine_fiobj2rb.h +120 -0
  90. data/ext/iodine/iodine_helpers.c +282 -0
  91. data/ext/iodine/iodine_helpers.h +12 -0
  92. data/ext/iodine/iodine_http.c +1280 -0
  93. data/ext/iodine/iodine_http.h +23 -0
  94. data/ext/iodine/iodine_json.c +302 -0
  95. data/ext/iodine/iodine_json.h +6 -0
  96. data/ext/iodine/iodine_mustache.c +567 -0
  97. data/ext/iodine/iodine_mustache.h +6 -0
  98. data/ext/iodine/iodine_pubsub.c +580 -0
  99. data/ext/iodine/iodine_pubsub.h +26 -0
  100. data/ext/iodine/iodine_rack_io.c +273 -0
  101. data/ext/iodine/iodine_rack_io.h +20 -0
  102. data/ext/iodine/iodine_store.c +142 -0
  103. data/ext/iodine/iodine_store.h +20 -0
  104. data/ext/iodine/iodine_tcp.c +346 -0
  105. data/ext/iodine/iodine_tcp.h +13 -0
  106. data/ext/iodine/iodine_tls.c +261 -0
  107. data/ext/iodine/iodine_tls.h +13 -0
  108. data/ext/iodine/mustache_parser.h +1546 -0
  109. data/ext/iodine/redis_engine.c +957 -0
  110. data/ext/iodine/redis_engine.h +79 -0
  111. data/ext/iodine/resp_parser.h +317 -0
  112. data/ext/iodine/scheduler.c +173 -0
  113. data/ext/iodine/scheduler.h +6 -0
  114. data/ext/iodine/websocket_parser.h +506 -0
  115. data/ext/iodine/websockets.c +752 -0
  116. data/ext/iodine/websockets.h +185 -0
  117. data/iodine.gemspec +50 -0
  118. data/lib/iodine/connection.rb +61 -0
  119. data/lib/iodine/json.rb +42 -0
  120. data/lib/iodine/mustache.rb +113 -0
  121. data/lib/iodine/pubsub.rb +55 -0
  122. data/lib/iodine/rack_utils.rb +43 -0
  123. data/lib/iodine/tls.rb +16 -0
  124. data/lib/iodine/version.rb +3 -0
  125. data/lib/iodine.rb +274 -0
  126. data/lib/rack/handler/iodine.rb +33 -0
  127. data/logo.png +0 -0
  128. metadata +284 -0
@@ -0,0 +1,1923 @@
1
+ #ifndef H_HPACK_H
2
+
3
+ #ifndef _GNU_SOURCE
4
+ #define _GNU_SOURCE
5
+ #endif
6
+
7
+ #include <stdint.h>
8
+ #include <stdlib.h>
9
+ #include <string.h>
10
+
11
+ #include <fio.h>
12
+
13
+ #ifndef MAYBE_UNUSED
14
+ #define MAYBE_UNUSED __attribute__((unused))
15
+ #endif
16
+
17
+ /**
18
+ * Sets the limit for both a single header value and a packed header group.
19
+ * Must be less than 2^16 -1
20
+ */
21
+ #define HPACK_BUFFER_SIZE 16384
22
+
23
+ /**
24
+ * Sets the limit for the amount of data an HPACK dynamic table can reference.
25
+ * Should be less then 65,535 (2^16 -1 is the type size limit).
26
+ */
27
+ #define HPACK_MAX_TABLE_SIZE 65535
28
+
29
+ /* *****************************************************************************
30
+ Required Callbacks
31
+ ***************************************************************************** */
32
+
33
+ /* *****************************************************************************
34
+ Types
35
+ ***************************************************************************** */
36
+
37
+ /** The HPACK context. */
38
+ typedef struct hpack_context_s hpack_context_s;
39
+
40
+ /* *****************************************************************************
41
+ Context API
42
+ ***************************************************************************** */
43
+
44
+ /* *****************************************************************************
45
+ Primitive Types API
46
+ ***************************************************************************** */
47
+
48
+ /**
49
+ * Encodes an integer.
50
+ *
51
+ * Returns the number of bytes written to the destination buffer. If the buffer
52
+ * was too small, returns the number of bytes that would have been written.
53
+ */
54
+ static inline int hpack_int_pack(void *dest, size_t limit, uint64_t i,
55
+ uint8_t prefix);
56
+
57
+ /**
58
+ * Decodes an integer, updating the `pos` marker to the next unprocessed byte.
59
+ *
60
+ * The position marker may start as non-zero, meaning that `len - (*pos)` is the
61
+ * actual length.
62
+ *
63
+ * An encoding / decoding error results in a return value of -1.
64
+ */
65
+ static inline int64_t hpack_int_unpack(void *data, size_t len, uint8_t prefix,
66
+ size_t *pos);
67
+
68
+ /**
69
+ * Encodes a String.
70
+ *
71
+ * Returns the number of bytes written to the destination buffer. If the buffer
72
+ * was too small, returns the number of bytes that would have been written.
73
+ */
74
+ static inline int hpack_string_pack(void *dest, size_t limit, void *data,
75
+ size_t len, uint8_t compress);
76
+
77
+ /**
78
+ * Decodes a String.
79
+ *
80
+ * Returns the number of bytes written to the destination buffer. If the buffer
81
+ * was too small, returns the number of bytes that would have been written.
82
+ *
83
+ * An encoding / decoding error results in a return value of -1.
84
+ *
85
+ * The position marker may start as non-zero, meaning that `len - (*pos)` is the
86
+ * actual length.
87
+ */
88
+ static inline int hpack_string_unpack(void *dest, size_t limit, void *encoded,
89
+ size_t len, size_t *pos);
90
+
91
+ /* *****************************************************************************
92
+ Static table API
93
+ ***************************************************************************** */
94
+
95
+ /**
96
+ * Sets the provided pointers with the information in the static header table.
97
+ *
98
+ * The `index` is 1..61 (not zero based).
99
+ *
100
+ * Set `get_value` to 1 to collect the value data rather then the header name.
101
+ *
102
+ * Returns -1 if request is out of bounds.
103
+ */
104
+ static int hpack_header_static_find(uint8_t index, uint8_t get_value,
105
+ const char **name, size_t *len);
106
+
107
+ /* *****************************************************************************
108
+ Huffman API (internal)
109
+ ***************************************************************************** */
110
+
111
+ /* the huffman encoding map */
112
+ typedef const struct {
113
+ const uint32_t code;
114
+ const uint8_t bits;
115
+ } huffman_encode_s;
116
+ static const huffman_encode_s huffman_encode_table[257];
117
+
118
+ /* the huffman decoding binary tree type */
119
+ typedef struct {
120
+ const int16_t value; // value, -1 == none.
121
+ const uint8_t offset[2]; // offset for 0 and one. 0 == leaf node.
122
+ } huffman_decode_s;
123
+ static const huffman_decode_s huffman_decode_tree[513];
124
+
125
+ /**
126
+ * Unpack (de-compress) using HPACK huffman - returns the number of bytes
127
+ * written and advances the position marker.
128
+ */
129
+ static MAYBE_UNUSED int hpack_huffman_unpack(void *dest, size_t limit,
130
+ void *encoded, size_t len,
131
+ size_t *pos);
132
+
133
+ /**
134
+ * Pack (compress) using HPACK huffman - returns the number of bytes written or
135
+ * required.
136
+ */
137
+ static MAYBE_UNUSED int hpack_huffman_pack(void *dest, const int limit,
138
+ void *data, size_t len);
139
+
140
+ /* *****************************************************************************
141
+
142
+
143
+
144
+
145
+
146
+ Implementation
147
+
148
+
149
+
150
+
151
+
152
+
153
+ ***************************************************************************** */
154
+
155
+ /* *****************************************************************************
156
+ Integer encoding
157
+ ***************************************************************************** */
158
+
159
+ static inline int hpack_int_pack(void *dest_, size_t limit, uint64_t i,
160
+ uint8_t prefix) {
161
+ uint8_t mask = ((1 << (prefix)) - 1);
162
+ uint8_t *dest = (uint8_t *)dest_;
163
+ int len = 1;
164
+
165
+ if (!dest_ || !limit)
166
+ goto calc_final_length;
167
+
168
+ if (i < mask) {
169
+ // zero out prefix bits
170
+ dest[0] &= ~mask;
171
+ // fill in i;
172
+ dest[0] |= i;
173
+ return 1;
174
+ }
175
+
176
+ dest[0] |= mask;
177
+
178
+ if ((size_t)len >= limit)
179
+ goto calc_final_length;
180
+
181
+ i -= mask;
182
+
183
+ while (i > 127) {
184
+ dest[len] = 128 | (i & 127);
185
+ ++len;
186
+ if ((size_t)len >= limit)
187
+ goto calc_final_length;
188
+ i >>= 7;
189
+ }
190
+
191
+ dest[len] = i & 0x7fU;
192
+ ++len;
193
+
194
+ return len;
195
+
196
+ calc_final_length:
197
+ len = 1;
198
+ if (i < mask)
199
+ return len;
200
+ i -= mask;
201
+ while (i) {
202
+ ++len;
203
+ i >>= 7;
204
+ }
205
+ return len;
206
+ }
207
+
208
+ static inline int64_t hpack_int_unpack(void *data_, size_t len, uint8_t prefix,
209
+ size_t *pos) {
210
+ uint8_t *data = (uint8_t *)data_;
211
+ len -= *pos;
212
+ if (len > 8)
213
+ len = 8;
214
+ uint64_t result = 0;
215
+ uint64_t bit = 0;
216
+ uint8_t mask = ((1 << (prefix)) - 1);
217
+
218
+ if ((mask & (data[*pos])) != mask) {
219
+ result = (mask & (data[(*pos)++]));
220
+ return (int64_t)result;
221
+ }
222
+
223
+ ++(*pos);
224
+ --len;
225
+
226
+ while (len && (data[*pos] & 128)) {
227
+ result |= ((data[*pos] & 0x7fU) << (bit));
228
+ bit += 7;
229
+ ++(*pos);
230
+ --len;
231
+ }
232
+ if (!len) {
233
+ return -1;
234
+ }
235
+ result |= ((data[*pos] & 0x7fU) << bit);
236
+ result += mask;
237
+
238
+ ++(*pos);
239
+ return (int64_t)result;
240
+ }
241
+
242
+ /* *****************************************************************************
243
+ String encoding
244
+ ***************************************************************************** */
245
+
246
+ static MAYBE_UNUSED int hpack_string_pack(void *dest_, size_t limit,
247
+ void *data_, size_t len,
248
+ uint8_t compress) {
249
+ uint8_t *dest = (uint8_t *)dest_;
250
+ uint8_t *buf = (uint8_t *)data_;
251
+ int encoded_int_len = 0;
252
+ int pos = 0;
253
+ if (compress) {
254
+ dest[pos] = 128;
255
+ int comp_len = hpack_huffman_pack(NULL, 0, buf, len);
256
+ encoded_int_len = hpack_int_pack(dest, limit, comp_len, 7);
257
+ if (encoded_int_len + comp_len > (int)limit)
258
+ return comp_len + encoded_int_len;
259
+ comp_len = hpack_huffman_pack(dest + encoded_int_len,
260
+ limit - encoded_int_len, buf, len);
261
+ return encoded_int_len + comp_len;
262
+ }
263
+ dest[pos] = 0;
264
+ encoded_int_len = hpack_int_pack(dest, limit, len, 7);
265
+ if (encoded_int_len + (int)len > (int)limit)
266
+ return len + encoded_int_len;
267
+ memcpy(dest + encoded_int_len, buf, len);
268
+ return len + encoded_int_len;
269
+ }
270
+
271
+ static MAYBE_UNUSED int hpack_string_unpack(void *dest_, size_t limit,
272
+ void *encoded_, size_t len,
273
+ size_t *pos) {
274
+ uint8_t *dest = (uint8_t *)dest_;
275
+ uint8_t *buf = (uint8_t *)encoded_;
276
+ const size_t org_pos = *pos;
277
+ uint8_t compressed = buf[*pos] & 128;
278
+ int64_t l = hpack_int_unpack(buf, len, 7, pos);
279
+ if (!l) {
280
+ return 0;
281
+ }
282
+ if (l == -1 || l > (int64_t)len - (int64_t)*pos) {
283
+ return -1;
284
+ }
285
+ len = l;
286
+ if (compressed) {
287
+ len = hpack_huffman_unpack(dest, limit, buf, len + (*pos), pos);
288
+ if (len > limit)
289
+ goto overflow;
290
+ } else {
291
+ if (len > limit)
292
+ goto overflow;
293
+ memcpy(dest, buf + (*pos), len);
294
+ *pos += len;
295
+ }
296
+ return len;
297
+
298
+ overflow:
299
+ *pos = org_pos;
300
+ return len;
301
+ }
302
+
303
+ /* *****************************************************************************
304
+ Huffman encoding
305
+ ***************************************************************************** */
306
+
307
+ static MAYBE_UNUSED int hpack_huffman_unpack(void *dest_, size_t limit,
308
+ void *encoded_, size_t len,
309
+ size_t *r_pos) {
310
+ uint8_t *dest = (uint8_t *)dest_;
311
+ uint8_t *encoded = (uint8_t *)encoded_;
312
+ size_t pos = 0;
313
+ uint8_t expect = 0;
314
+ len -= *r_pos;
315
+ register const huffman_decode_s *node = huffman_decode_tree;
316
+ while (len) {
317
+ register const uint8_t byte = encoded[(*r_pos)++];
318
+ --len;
319
+ expect = 1;
320
+ for (uint8_t bit = 0; bit < 8; ++bit) {
321
+ node += node->offset[(byte >> (7 - bit)) & 1];
322
+ if (node->offset[0])
323
+ continue;
324
+ switch (node->value) {
325
+ case 256U:
326
+ goto done;
327
+ case -1:
328
+ goto error;
329
+ }
330
+ if (pos < limit)
331
+ dest[pos] = (uint8_t)node->value;
332
+ ++pos;
333
+ /* test if all remaining bits are set (possible padding) */
334
+ expect = ((uint8_t)(byte | (0xFF << (7 - bit))) & 0xFF) ^ 0xFF;
335
+ node = huffman_decode_tree;
336
+ }
337
+ }
338
+ done:
339
+ if (expect) {
340
+ /* padding error */
341
+ return -1;
342
+ }
343
+ return pos;
344
+ error:
345
+ return -1;
346
+ }
347
+
348
+ static MAYBE_UNUSED int hpack_huffman_pack(void *dest_, const int limit,
349
+ void *data_, size_t len) {
350
+ uint8_t *dest = (uint8_t *)dest_;
351
+ uint8_t *data = (uint8_t *)data_;
352
+ int comp_len = 0;
353
+ uint8_t *pos = data;
354
+ const uint8_t *end = pos + len;
355
+ uint8_t offset = 0;
356
+ if (!len)
357
+ return 0;
358
+ if (!limit)
359
+ goto calc_final_length;
360
+
361
+ dest[comp_len] = 0;
362
+ do {
363
+ uint32_t code = huffman_encode_table[*pos].code;
364
+ uint8_t bits = huffman_encode_table[*pos].bits;
365
+ ++pos;
366
+
367
+ if (offset) {
368
+ /* does the code fit in the existing byte */
369
+ if (bits + offset <= 8) {
370
+ dest[comp_len] |= code >> (24 + offset);
371
+ offset = offset + bits;
372
+ continue;
373
+ }
374
+ /* fill in current byte */
375
+ dest[comp_len] |= (code >> (24 + offset)) & 0xFF;
376
+ code <<= 8 - offset;
377
+ bits -= 8 - offset;
378
+ offset = 0;
379
+ ++comp_len;
380
+ dest[comp_len] = 0;
381
+ }
382
+
383
+ /* make sure we have enough space */
384
+ if (((bits + (comp_len << 3) + 7) >> 3) >= limit)
385
+ goto calc_final_length;
386
+
387
+ /* copy full bytes */
388
+ switch (bits >> 3) {
389
+ case 3:
390
+ dest[comp_len + 2] = (uint8_t)(code >> 8) & 0xFF;
391
+ /* fallthrough */
392
+ case 2:
393
+ dest[comp_len + 1] = (uint8_t)(code >> 16) & 0xFF;
394
+ /* fallthrough */
395
+ case 1:
396
+ dest[comp_len + 0] = (uint8_t)(code >> 24) & 0xFF;
397
+ comp_len += (bits >> 3);
398
+ code <<= (bits & (~7));
399
+ dest[comp_len] = 0;
400
+ }
401
+
402
+ /* copy partial bits */
403
+ dest[comp_len] |= (uint8_t)(code >> 24) & ((uint8_t)0xFF);
404
+ offset = bits & 7;
405
+ } while (pos < end);
406
+
407
+ if (offset & 7) {
408
+ /* pad last bits as 1 */
409
+ dest[comp_len] |= (uint8_t)(0xFFUL >> (offset & 7));
410
+ ++comp_len;
411
+ }
412
+ return comp_len;
413
+
414
+ calc_final_length:
415
+
416
+ comp_len = 0;
417
+ for (size_t i = 0; i < len; i++) {
418
+ comp_len += huffman_encode_table[data[i]].bits;
419
+ }
420
+ comp_len += 7;
421
+ comp_len >>= 3;
422
+ return comp_len;
423
+ }
424
+
425
+ /* *****************************************************************************
426
+ Header static table lookup
427
+ ***************************************************************************** */
428
+
429
+ static const struct {
430
+ struct hpack_static_data_s {
431
+ const char *val;
432
+ const size_t len;
433
+ } data[2];
434
+ } MAYBE_UNUSED hpack_static_table[] = {
435
+ /* [0] */ {.data = {{.len = 0}, {.len = 0}}},
436
+ {.data = {{.val = ":authority", .len = 10}, {.len = 0}}},
437
+ {.data = {{.val = ":method", .len = 7}, {.val = "GET", .len = 3}}},
438
+ {.data = {{.val = ":method", .len = 7}, {.val = "POST", .len = 4}}},
439
+ {.data = {{.val = ":path", .len = 5}, {.val = "/", .len = 1}}},
440
+ {.data = {{.val = ":path", .len = 5}, {.val = "/index.html", .len = 11}}},
441
+ {.data = {{.val = ":scheme", .len = 7}, {.val = "http", .len = 0}}},
442
+ {.data = {{.val = ":scheme", .len = 7}, {.val = "https", .len = 0}}},
443
+ {.data = {{.val = ":status", .len = 7}, {.val = "200", .len = 0}}},
444
+ {.data = {{.val = ":status", .len = 7}, {.val = "204", .len = 0}}},
445
+ {.data = {{.val = ":status", .len = 7}, {.val = "206", .len = 0}}},
446
+ {.data = {{.val = ":status", .len = 7}, {.val = "304", .len = 0}}},
447
+ {.data = {{.val = ":status", .len = 7}, {.val = "400", .len = 0}}},
448
+ {.data = {{.val = ":status", .len = 7}, {.val = "404", .len = 0}}},
449
+ {.data = {{.val = ":status", .len = 7}, {.val = "500", .len = 0}}},
450
+ {.data = {{.val = "accept-charset", .len = 14}, {.len = 0}}},
451
+ {.data = {{.val = "accept-encoding", .len = 15},
452
+ {.val = "gzip, deflate", .len = 13}}},
453
+ {.data = {{.val = "accept-language", .len = 15}, {.len = 0}}},
454
+ {.data = {{.val = "accept-ranges", .len = 13}, {.len = 0}}},
455
+ {.data = {{.val = "accept", .len = 6}, {.len = 0}}},
456
+ {.data = {{.val = "access-control-allow-origin", .len = 27}, {.len = 0}}},
457
+ {.data = {{.val = "age", .len = 3}, {.len = 0}}},
458
+ {.data = {{.val = "allow", .len = 5}, {.len = 0}}},
459
+ {.data = {{.val = "authorization", .len = 13}, {.len = 0}}},
460
+ {.data = {{.val = "cache-control", .len = 13}, {.len = 0}}},
461
+ {.data = {{.val = "content-disposition", .len = 0}, {.len = 0}}},
462
+ {.data = {{.val = "content-encoding", .len = 16}, {.len = 0}}},
463
+ {.data = {{.val = "content-language", .len = 16}, {.len = 0}}},
464
+ {.data = {{.val = "content-length", .len = 14}, {.len = 0}}},
465
+ {.data = {{.val = "content-location", .len = 16}, {.len = 0}}},
466
+ {.data = {{.val = "content-range", .len = 13}, {.len = 0}}},
467
+ {.data = {{.val = "content-type", .len = 12}, {.len = 0}}},
468
+ {.data = {{.val = "cookie", .len = 6}, {.len = 0}}},
469
+ {.data = {{.val = "date", .len = 4}, {.len = 0}}},
470
+ {.data = {{.val = "etag", .len = 4}, {.len = 0}}},
471
+ {.data = {{.val = "expect", .len = 6}, {.len = 0}}},
472
+ {.data = {{.val = "expires", .len = 7}, {.len = 0}}},
473
+ {.data = {{.val = "from", .len = 4}, {.len = 0}}},
474
+ {.data = {{.val = "host", .len = 4}, {.len = 0}}},
475
+ {.data = {{.val = "if-match", .len = 8}, {.len = 0}}},
476
+ {.data = {{.val = "if-modified-since", .len = 17}, {.len = 0}}},
477
+ {.data = {{.val = "if-none-match", .len = 13}, {.len = 0}}},
478
+ {.data = {{.val = "if-range", .len = 8}, {.len = 0}}},
479
+ {.data = {{.val = "if-unmodified-since", .len = 19}, {.len = 0}}},
480
+ {.data = {{.val = "last-modified", .len = 13}, {.len = 0}}},
481
+ {.data = {{.val = "link", .len = 4}, {.len = 0}}},
482
+ {.data = {{.val = "location", .len = 8}, {.len = 0}}},
483
+ {.data = {{.val = "max-forwards", .len = 12}, {.len = 0}}},
484
+ {.data = {{.val = "proxy-authenticate", .len = 18}, {.len = 0}}},
485
+ {.data = {{.val = "proxy-authorization", .len = 19}, {.len = 0}}},
486
+ {.data = {{.val = "range", .len = 5}, {.len = 0}}},
487
+ {.data = {{.val = "referer", .len = 7}, {.len = 0}}},
488
+ {.data = {{.val = "refresh", .len = 7}, {.len = 0}}},
489
+ {.data = {{.val = "retry-after", .len = 11}, {.len = 0}}},
490
+ {.data = {{.val = "server", .len = 6}, {.len = 0}}},
491
+ {.data = {{.val = "set-cookie", .len = 10}, {.len = 0}}},
492
+ {.data = {{.val = "strict-transport-security", .len = 25}, {.len = 0}}},
493
+ {.data = {{.val = "transfer-encoding", .len = 17}, {.len = 0}}},
494
+ {.data = {{.val = "user-agent", .len = 10}, {.len = 0}}},
495
+ {.data = {{.val = "vary", .len = 4}, {.len = 0}}},
496
+ {.data = {{.val = "via", .len = 3}, {.len = 0}}},
497
+ {.data = {{.val = "www-authenticate", .len = 16}, {.len = 0}}},
498
+ };
499
+
500
+ static MAYBE_UNUSED int hpack_header_static_find(uint8_t index,
501
+ uint8_t requested_type,
502
+ const char **name,
503
+ size_t *len) {
504
+ if (requested_type > 1 ||
505
+ index >= (sizeof(hpack_static_table) / sizeof(hpack_static_table[0])))
506
+ goto err;
507
+ struct hpack_static_data_s d = hpack_static_table[index].data[requested_type];
508
+ *name = d.val;
509
+ *len = d.len;
510
+ return 0;
511
+ err:
512
+
513
+ *name = NULL;
514
+ *len = 0;
515
+ return -1;
516
+ }
517
+
518
+ /* *****************************************************************************
519
+
520
+
521
+
522
+
523
+
524
+
525
+ Testing
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+ ***************************************************************************** */
534
+
535
+ #if DEBUG
536
+
537
+ #include <inttypes.h>
538
+ #include <stdio.h>
539
+
540
+ void hpack_test(void) {
541
+ uint8_t buffer[1 << 15];
542
+ const size_t limit = (1 << 15);
543
+ size_t buf_pos = 0;
544
+ {
545
+ /* test integer packing */
546
+ int64_t result;
547
+ size_t pos = 0;
548
+ fprintf(stderr, "* HPACK testing integer primitive packing.\n");
549
+ if ((result = hpack_int_unpack((uint8_t *)"\x0c", 1, 4, &pos)) != 12) {
550
+ fprintf(stderr,
551
+ "* HPACK INTEGER DECODER ERROR ex. 0c 12 != %" PRId64 "\n",
552
+ result);
553
+ exit(-1);
554
+ }
555
+
556
+ pos = 0;
557
+ if ((result = hpack_int_unpack((uint8_t *)"\x1f\x9a\x0a", 3, 5, &pos)) !=
558
+ 1337) {
559
+ fprintf(
560
+ stderr,
561
+ "* HPACK INTEGER DECODER ERROR ex. \\x1f\\x9a\\x0a 1337 != %" PRId64
562
+ "\n",
563
+ result);
564
+ exit(-1);
565
+ }
566
+
567
+ for (size_t i = 0; i < (1 << 21); ++i) {
568
+ buf_pos = 0;
569
+ int pack_bytes =
570
+ hpack_int_pack(buffer + buf_pos, limit - buf_pos, i, i & 7);
571
+ if (pack_bytes == -1) {
572
+ fprintf(stderr,
573
+ "* HPACK INTEGER ENCODE ERROR 1 ( %zu) (prefix == %zu)\n", i,
574
+ i & 7);
575
+ exit(-1);
576
+ }
577
+ buf_pos += pack_bytes;
578
+ pack_bytes =
579
+ hpack_int_pack(buffer + buf_pos, limit - buf_pos, (i << 4), i & 7);
580
+ if (pack_bytes == -1) {
581
+ fprintf(stderr,
582
+ "* HPACK INTEGER ENCODE ERROR 1 ( %zu) (prefix == %zu)\n", i,
583
+ i & 7);
584
+ exit(-1);
585
+ }
586
+ buf_pos = 0;
587
+ result = hpack_int_unpack(buffer, limit, (i & 7), &buf_pos);
588
+ if ((size_t)result != i) {
589
+ fprintf(stderr,
590
+ "* HPACK INTEGER DECODE ERROR 2 expected %zu got %" PRId64
591
+ " (prefix == %zu)\n",
592
+ i, result, (i & 7));
593
+ exit(-1);
594
+ }
595
+ result = hpack_int_unpack(buffer, limit, (i & 7), &buf_pos);
596
+ if ((size_t)result != (i << 4)) {
597
+ fprintf(stderr,
598
+ "* HPACK INTEGER DECODE ERROR 2 expected %zu got %" PRId64
599
+ " (prefix == %zu)\n",
600
+ (i << 4), result, (i & 7));
601
+ exit(-1);
602
+ }
603
+ }
604
+ fprintf(stderr, "* HPACK integer primitive test complete.\n");
605
+ }
606
+ buf_pos = 0;
607
+ {
608
+ /* validate huffman tree */
609
+ for (int i = 0; i < 257; ++i) {
610
+ const huffman_decode_s *node = huffman_decode_tree;
611
+ uint32_t code = huffman_encode_table[i].code;
612
+ uint8_t consumed = 32 - huffman_encode_table[i].bits;
613
+ while (consumed < 32) {
614
+ node += node->offset[(code >> 31) & 1];
615
+ code <<= 1;
616
+ ++consumed;
617
+ }
618
+ if (i != node->value) {
619
+ fprintf(stderr,
620
+ "ERROR validating huffman tree - validation error for %d "
621
+ "(value: %d != "
622
+ "%d)\n",
623
+ i, node->value, i);
624
+ exit(-1);
625
+ }
626
+ }
627
+ fprintf(stderr, "* HPACK Huffman tree validated.\n");
628
+ /* test huffman encoding / decoding packing */
629
+ const size_t results_limit = 1024;
630
+ uint8_t results[1024];
631
+ size_t pos = 0;
632
+ memset(results, 0, results_limit);
633
+ int tmp = hpack_huffman_unpack(
634
+ results, results_limit,
635
+ "\x9d\x29\xad\x17\x18\x63\xc7\x8f\x0b\x97\xc8\xe9\xae\x82"
636
+ "\xae\x43\xd3",
637
+ 17, &pos);
638
+ if (tmp == -1) {
639
+ fprintf(stderr, "* HPACK HUFFMAN TEST FAILED unpacking error (1).\n");
640
+ exit(-1);
641
+ } else if ((size_t)tmp > (limit - buf_pos)) {
642
+ fprintf(stderr, "* HPACK HUFFMAN TEST buffer full error (1).\n");
643
+ } else if (memcmp(results, "https://www.example.com", 23) || tmp != 23) {
644
+ fprintf(stderr,
645
+ "* HPACK HUFFMAN TEST FAILED result error (1).\n(%d) %.*s\n", tmp,
646
+ tmp, results);
647
+ exit(-1);
648
+ }
649
+ memset(results, 0, results_limit);
650
+ pos = 0;
651
+ tmp = hpack_huffman_unpack(
652
+ results, results_limit,
653
+ "\xf1\xe3\xc2\xe5\xf2\x3a\x6b\xa0\xab\x90\xf4\xff", 12, &pos);
654
+ if (tmp == -1) {
655
+ fprintf(stderr, "* HPACK HUFFMAN TEST FAILED unpacking error (2).\n");
656
+ exit(-1);
657
+ } else if ((size_t)tmp > results_limit) {
658
+ fprintf(stderr, "* HPACK HUFFMAN TEST buffer full error (2).\n");
659
+ } else if (memcmp(results, "www.example.com", 15) || tmp != 15) {
660
+ fprintf(stderr, "* HPACK HUFFMAN TEST FAILED result error (2).\n");
661
+ exit(-1);
662
+ }
663
+
664
+ memset(results, 0, results_limit);
665
+ tmp = hpack_huffman_pack(results, results_limit, "https://www.example.com",
666
+ 23);
667
+ if (tmp == -1) {
668
+ fprintf(stderr, "* HPACK HUFFMAN TEST FAILED packing error!.\n");
669
+ exit(-1);
670
+ } else if ((size_t)tmp > limit - buf_pos) {
671
+ fprintf(stderr, "* HPACK HUFFMAN TEST packing buffer full!\n");
672
+ } else if (tmp != 17 || memcmp("\x9d\x29\xad\x17\x18\x63\xc7\x8f\x0b\x97"
673
+ "\xc8\xe9\xae\x82\xae\x43\xd3",
674
+ results, 17)) {
675
+ fprintf(stderr,
676
+ "* HPACK HUFFMAN TEST FAILED packing result error!\n(%d) ", tmp);
677
+ for (int i = 0; i < tmp; ++i) {
678
+ fprintf(stderr, "\\x%.2X", results[i]);
679
+ }
680
+ fprintf(stderr, "\n");
681
+ exit(-1);
682
+ }
683
+ memset(results, 0, results_limit);
684
+ memset(buffer, 0, 128);
685
+ tmp = hpack_huffman_pack(
686
+ buffer, limit,
687
+ "I want to go home... but I have to write tests... woohoo!", 57);
688
+ if (tmp == -1) {
689
+ fprintf(stderr, "* HPACK HUFFMAN TEST FAILED packing error (3).\n");
690
+ exit(-1);
691
+ } else if ((size_t)tmp > limit) {
692
+ fprintf(stderr, "* HPACK HUFFMAN TEST buffer full (3).\n");
693
+ } else {
694
+ int old_tmp = tmp;
695
+ pos = 0;
696
+ tmp = hpack_huffman_unpack(results, results_limit, buffer, tmp, &pos);
697
+ if (tmp == -1) {
698
+ fprintf(
699
+ stderr,
700
+ "* HPACK HUFFMAN TEST FAILED unpacking error (3) for %d bytes.\n"
701
+ "* Got (%d): %.*s\n",
702
+ old_tmp, tmp, (int)tmp, results);
703
+ exit(-1);
704
+ } else if (memcmp(results,
705
+ "I want to go home... but I have to write tests... "
706
+ "woohoo!",
707
+ 57) ||
708
+ tmp != 57) {
709
+ fprintf(stderr,
710
+ "* HPACK HUFFMAN TEST FAILED result error (3).\n* Got "
711
+ "(%u): %.*s\n",
712
+ tmp, (int)tmp, results);
713
+ exit(-1);
714
+ }
715
+ }
716
+ fprintf(stderr, "* HPACK Huffman compression test finished.\n");
717
+ }
718
+ buf_pos = 0;
719
+ memset(buffer, 0, 128);
720
+ if (1) {
721
+ /* test string packing */
722
+ size_t pos = 0;
723
+ int tmp = hpack_string_unpack(
724
+ buffer, limit, "\x0a\x63\x75\x73\x74\x6f\x6d\x2d\x6b\x65\x79", 11,
725
+ &pos);
726
+ if (pos != 11) {
727
+ fprintf(stderr,
728
+ "* HPACK STRING UNPACKING FAILED(!) wrong reading position %zu "
729
+ "!= 11\n",
730
+ pos);
731
+ exit(-1);
732
+ }
733
+ if (tmp == -1) {
734
+ fprintf(stderr, "* HPACK STRING UNPACKING FAILED(!) for example.\n");
735
+ exit(-1);
736
+ } else {
737
+ if (tmp != 10)
738
+ fprintf(stderr,
739
+ "* HPACK STRING UNPACKING ERROR example len %d != 10.\n", tmp);
740
+ if (memcmp(buffer, "\x63\x75\x73\x74\x6f\x6d\x2d\x6b\x65\x79", 10))
741
+ fprintf(stderr,
742
+ "* HPACK STRING UNPACKING ERROR example returned: %.*s\n",
743
+ (int)tmp, buffer);
744
+ }
745
+
746
+ pos = 0;
747
+ memset(buffer, 0, 128);
748
+ tmp = hpack_string_unpack(
749
+ buffer, limit, "\x8c\xf1\xe3\xc2\xe5\xf2\x3a\x6b\xa0\xab\x90\xf4\xff",
750
+ 13, &pos);
751
+ if (tmp == -1) {
752
+ fprintf(stderr,
753
+ "* HPACK STRING UNPACKING FAILED(!) for compressed example. %s\n",
754
+ buffer);
755
+ exit(-1);
756
+ } else {
757
+ if (tmp != 15) {
758
+ fprintf(
759
+ stderr,
760
+ "* HPACK STRING UNPACKING ERROR compressed example len %d != 15.\n",
761
+ tmp);
762
+ exit(-1);
763
+ }
764
+ if (memcmp(buffer, "www.example.com", 10)) {
765
+ fprintf(stderr,
766
+ "* HPACK STRING UNPACKING ERROR compressed example returned: "
767
+ "%.*s\n",
768
+ tmp, buffer);
769
+ exit(-1);
770
+ }
771
+ if (pos != 13) {
772
+ fprintf(stderr,
773
+ "* HPACK STRING UNPACKING FAILED(!) wrong reading position %zu "
774
+ "!= 13\n",
775
+ pos);
776
+ exit(-1);
777
+ }
778
+ }
779
+
780
+ if (1) {
781
+ char *str1 = "This is a string to be packed, either compressed or not.";
782
+ buf_pos = 0;
783
+ size_t i = 0;
784
+ const size_t repeats = 1024;
785
+ for (i = 0; i < repeats; i++) {
786
+ tmp = hpack_string_pack(buffer + buf_pos, limit - buf_pos, str1, 56,
787
+ (i & 1) == 1);
788
+ if (tmp == -1)
789
+ fprintf(stderr, "* HPACK STRING PACKING FAIL AT %zu\n", i);
790
+ else if ((size_t)tmp > limit - buf_pos)
791
+ break;
792
+ buf_pos += tmp;
793
+ }
794
+ int count = i;
795
+ buf_pos = 0;
796
+ while (i) {
797
+ char result[56];
798
+ memset(result, 0, 56);
799
+ --i;
800
+ tmp = hpack_string_unpack(result, 56, buffer, limit, &buf_pos);
801
+ if (tmp == -1) {
802
+ fprintf(stderr, "* HPACK STRING UNPACKING FAIL AT %zu\n",
803
+ (repeats - 1) - i);
804
+ exit(-1);
805
+ } else if (tmp != 56) {
806
+ fprintf(stderr,
807
+ "* HPACK STRING UNPACKING ERROR AT %zu - got string "
808
+ "length %u instead of 56: %.*s\n",
809
+ (repeats - 1) - i, tmp, 56, result);
810
+ exit(-1);
811
+ }
812
+ if (memcmp(str1, result, 56)) {
813
+ fprintf(stderr,
814
+ "* HPACK STRING UNPACKING ERROR AT %zu. Got (%u) %.*s\n",
815
+ (repeats - 1) - i, tmp, tmp, result);
816
+ exit(-1);
817
+ }
818
+ }
819
+ fprintf(stderr,
820
+ "* HPACK string primitive test complete (buffer used %d/%zu "
821
+ "strings)\n",
822
+ count, repeats);
823
+ }
824
+ }
825
+ }
826
+ #else
827
+
828
+ #define hpack_test()
829
+
830
+ #endif /* DEBUG */
831
+
832
+ /* *****************************************************************************
833
+
834
+
835
+
836
+
837
+
838
+
839
+ Auto-generate binary tree from table data
840
+
841
+
842
+
843
+
844
+
845
+
846
+ ***************************************************************************** */
847
+
848
+ #if HPACK_BUILD_HPACK_STRUCT
849
+
850
+ /*
851
+ This section prints out the C code required to create a static, Array based,
852
+ binary tree with the following type / fields:
853
+ */
854
+
855
+ #include <stdio.h>
856
+
857
+ typedef struct {
858
+ uint32_t code;
859
+ uint8_t bits;
860
+ int16_t value;
861
+ } huffman_code_s;
862
+
863
+ /* the huffman decoding binary tree type */
864
+ typedef struct {
865
+ int16_t value; // value, -1 == none.
866
+ uint8_t offset[2]; // offset for 0 and one. 0 == leaf node.
867
+ } huffman_decode_nc_s;
868
+
869
+ /** used to print the binary reverse testing */
870
+ static MAYBE_UNUSED void huffman__print_bin_num(uint32_t num, uint8_t bits) {
871
+ fprintf(stderr, "0b");
872
+ if (((32 - bits) & 31))
873
+ num <<= ((32 - bits) & 31);
874
+ for (size_t i = 0; i < bits; i++) {
875
+ if (num & (1 << (31 - i)))
876
+ fprintf(stderr, "1");
877
+ else
878
+ fprintf(stderr, "0");
879
+ }
880
+ }
881
+
882
+ static void huffman__print_unit(huffman_decode_nc_s d, size_t index,
883
+ size_t code, size_t bits) {
884
+ if (d.value != -1) {
885
+ fprintf(stderr,
886
+ " {.value = %d, .offset = {%zu, %zu}}, // [%zu]:", (int)d.value,
887
+ (size_t)d.offset[0], (size_t)d.offset[1], index);
888
+ huffman__print_bin_num(code, bits);
889
+ fprintf(stderr, "\n");
890
+ } else {
891
+ fprintf(stderr, " {.value = %d, .offset = {%zu, %zu}}, // [%zu]\n",
892
+ (int)d.value, (size_t)d.offset[0], (size_t)d.offset[1], index);
893
+ }
894
+ }
895
+
896
+ #define HUFFMAN_TREE_BUFFER (1 << 12)
897
+
898
+ void huffman__print_tree(void) {
899
+ /* The Huffman Encoding table was copied from
900
+ * http://httpwg.org/specs/rfc7541.html#huffman.code
901
+ */
902
+ const huffman_encode_s encode_table[] = {
903
+ /* 257 elements, 0..256 all sym + EOS */
904
+ {0x1ff8U, 13}, {0x7fffd8U, 23}, {0xfffffe2U, 28}, {0xfffffe3U, 28},
905
+ {0xfffffe4U, 28}, {0xfffffe5U, 28}, {0xfffffe6U, 28}, {0xfffffe7U, 28},
906
+ {0xfffffe8U, 28}, {0xffffeaU, 24}, {0x3ffffffcU, 30}, {0xfffffe9U, 28},
907
+ {0xfffffeaU, 28}, {0x3ffffffdU, 30}, {0xfffffebU, 28}, {0xfffffecU, 28},
908
+ {0xfffffedU, 28}, {0xfffffeeU, 28}, {0xfffffefU, 28}, {0xffffff0U, 28},
909
+ {0xffffff1U, 28}, {0xffffff2U, 28}, {0x3ffffffeU, 30}, {0xffffff3U, 28},
910
+ {0xffffff4U, 28}, {0xffffff5U, 28}, {0xffffff6U, 28}, {0xffffff7U, 28},
911
+ {0xffffff8U, 28}, {0xffffff9U, 28}, {0xffffffaU, 28}, {0xffffffbU, 28},
912
+ {0x14U, 6}, {0x3f8U, 10}, {0x3f9U, 10}, {0xffaU, 12},
913
+ {0x1ff9U, 13}, {0x15U, 6}, {0xf8U, 8}, {0x7faU, 11},
914
+ {0x3faU, 10}, {0x3fbU, 10}, {0xf9U, 8}, {0x7fbU, 11},
915
+ {0xfaU, 8}, {0x16U, 6}, {0x17U, 6}, {0x18U, 6},
916
+ {0x0U, 5}, {0x1U, 5}, {0x2U, 5}, {0x19U, 6},
917
+ {0x1aU, 6}, {0x1bU, 6}, {0x1cU, 6}, {0x1dU, 6},
918
+ {0x1eU, 6}, {0x1fU, 6}, {0x5cU, 7}, {0xfbU, 8},
919
+ {0x7ffcU, 15}, {0x20U, 6}, {0xffbU, 12}, {0x3fcU, 10},
920
+ {0x1ffaU, 13}, {0x21U, 6}, {0x5dU, 7}, {0x5eU, 7},
921
+ {0x5fU, 7}, {0x60U, 7}, {0x61U, 7}, {0x62U, 7},
922
+ {0x63U, 7}, {0x64U, 7}, {0x65U, 7}, {0x66U, 7},
923
+ {0x67U, 7}, {0x68U, 7}, {0x69U, 7}, {0x6aU, 7},
924
+ {0x6bU, 7}, {0x6cU, 7}, {0x6dU, 7}, {0x6eU, 7},
925
+ {0x6fU, 7}, {0x70U, 7}, {0x71U, 7}, {0x72U, 7},
926
+ {0xfcU, 8}, {0x73U, 7}, {0xfdU, 8}, {0x1ffbU, 13},
927
+ {0x7fff0U, 19}, {0x1ffcU, 13}, {0x3ffcU, 14}, {0x22U, 6},
928
+ {0x7ffdU, 15}, {0x3U, 5}, {0x23U, 6}, {0x4U, 5},
929
+ {0x24U, 6}, {0x5U, 5}, {0x25U, 6}, {0x26U, 6},
930
+ {0x27U, 6}, {0x6U, 5}, {0x74U, 7}, {0x75U, 7},
931
+ {0x28U, 6}, {0x29U, 6}, {0x2aU, 6}, {0x7U, 5},
932
+ {0x2bU, 6}, {0x76U, 7}, {0x2cU, 6}, {0x8U, 5},
933
+ {0x9U, 5}, {0x2dU, 6}, {0x77U, 7}, {0x78U, 7},
934
+ {0x79U, 7}, {0x7aU, 7}, {0x7bU, 7}, {0x7ffeU, 15},
935
+ {0x7fcU, 11}, {0x3ffdU, 14}, {0x1ffdU, 13}, {0xffffffcU, 28},
936
+ {0xfffe6U, 20}, {0x3fffd2U, 22}, {0xfffe7U, 20}, {0xfffe8U, 20},
937
+ {0x3fffd3U, 22}, {0x3fffd4U, 22}, {0x3fffd5U, 22}, {0x7fffd9U, 23},
938
+ {0x3fffd6U, 22}, {0x7fffdaU, 23}, {0x7fffdbU, 23}, {0x7fffdcU, 23},
939
+ {0x7fffddU, 23}, {0x7fffdeU, 23}, {0xffffebU, 24}, {0x7fffdfU, 23},
940
+ {0xffffecU, 24}, {0xffffedU, 24}, {0x3fffd7U, 22}, {0x7fffe0U, 23},
941
+ {0xffffeeU, 24}, {0x7fffe1U, 23}, {0x7fffe2U, 23}, {0x7fffe3U, 23},
942
+ {0x7fffe4U, 23}, {0x1fffdcU, 21}, {0x3fffd8U, 22}, {0x7fffe5U, 23},
943
+ {0x3fffd9U, 22}, {0x7fffe6U, 23}, {0x7fffe7U, 23}, {0xffffefU, 24},
944
+ {0x3fffdaU, 22}, {0x1fffddU, 21}, {0xfffe9U, 20}, {0x3fffdbU, 22},
945
+ {0x3fffdcU, 22}, {0x7fffe8U, 23}, {0x7fffe9U, 23}, {0x1fffdeU, 21},
946
+ {0x7fffeaU, 23}, {0x3fffddU, 22}, {0x3fffdeU, 22}, {0xfffff0U, 24},
947
+ {0x1fffdfU, 21}, {0x3fffdfU, 22}, {0x7fffebU, 23}, {0x7fffecU, 23},
948
+ {0x1fffe0U, 21}, {0x1fffe1U, 21}, {0x3fffe0U, 22}, {0x1fffe2U, 21},
949
+ {0x7fffedU, 23}, {0x3fffe1U, 22}, {0x7fffeeU, 23}, {0x7fffefU, 23},
950
+ {0xfffeaU, 20}, {0x3fffe2U, 22}, {0x3fffe3U, 22}, {0x3fffe4U, 22},
951
+ {0x7ffff0U, 23}, {0x3fffe5U, 22}, {0x3fffe6U, 22}, {0x7ffff1U, 23},
952
+ {0x3ffffe0U, 26}, {0x3ffffe1U, 26}, {0xfffebU, 20}, {0x7fff1U, 19},
953
+ {0x3fffe7U, 22}, {0x7ffff2U, 23}, {0x3fffe8U, 22}, {0x1ffffecU, 25},
954
+ {0x3ffffe2U, 26}, {0x3ffffe3U, 26}, {0x3ffffe4U, 26}, {0x7ffffdeU, 27},
955
+ {0x7ffffdfU, 27}, {0x3ffffe5U, 26}, {0xfffff1U, 24}, {0x1ffffedU, 25},
956
+ {0x7fff2U, 19}, {0x1fffe3U, 21}, {0x3ffffe6U, 26}, {0x7ffffe0U, 27},
957
+ {0x7ffffe1U, 27}, {0x3ffffe7U, 26}, {0x7ffffe2U, 27}, {0xfffff2U, 24},
958
+ {0x1fffe4U, 21}, {0x1fffe5U, 21}, {0x3ffffe8U, 26}, {0x3ffffe9U, 26},
959
+ {0xffffffdU, 28}, {0x7ffffe3U, 27}, {0x7ffffe4U, 27}, {0x7ffffe5U, 27},
960
+ {0xfffecU, 20}, {0xfffff3U, 24}, {0xfffedU, 20}, {0x1fffe6U, 21},
961
+ {0x3fffe9U, 22}, {0x1fffe7U, 21}, {0x1fffe8U, 21}, {0x7ffff3U, 23},
962
+ {0x3fffeaU, 22}, {0x3fffebU, 22}, {0x1ffffeeU, 25}, {0x1ffffefU, 25},
963
+ {0xfffff4U, 24}, {0xfffff5U, 24}, {0x3ffffeaU, 26}, {0x7ffff4U, 23},
964
+ {0x3ffffebU, 26}, {0x7ffffe6U, 27}, {0x3ffffecU, 26}, {0x3ffffedU, 26},
965
+ {0x7ffffe7U, 27}, {0x7ffffe8U, 27}, {0x7ffffe9U, 27}, {0x7ffffeaU, 27},
966
+ {0x7ffffebU, 27}, {0xffffffeU, 28}, {0x7ffffecU, 27}, {0x7ffffedU, 27},
967
+ {0x7ffffeeU, 27}, {0x7ffffefU, 27}, {0x7fffff0U, 27}, {0x3ffffeeU, 26},
968
+ {0x3fffffffU, 30},
969
+ };
970
+ /* copy code list */
971
+ huffman_code_s ordered[257];
972
+ for (uint16_t i = 0; i < 257; ++i) {
973
+ ordered[i] = (huffman_code_s){
974
+ .value = i,
975
+ .bits = encode_table[i].bits,
976
+ .code = encode_table[i].code,
977
+ };
978
+ }
979
+ /* order list by code's bit order (0100 > 0011), use a bunch of CPU... */
980
+ {
981
+ uint16_t i = 0;
982
+ while (i < 256) {
983
+ if (ordered[i].code > ordered[i + 1].code) {
984
+ huffman_code_s tmp = ordered[i + 1];
985
+ ++i;
986
+ do {
987
+ ordered[i] = ordered[i - 1];
988
+ } while (--i && ordered[i - 1].code > tmp.code);
989
+ ordered[i] = tmp;
990
+ }
991
+ ++i;
992
+ }
993
+ }
994
+ /* build tree */
995
+ huffman_decode_nc_s tree[HUFFMAN_TREE_BUFFER];
996
+ size_t tree_len = 0;
997
+ for (int i = 0; i < HUFFMAN_TREE_BUFFER; ++i) {
998
+ tree[i] = (huffman_decode_nc_s){.value = -1,
999
+ .offset = {(uint8_t)-1, (uint8_t)-1}};
1000
+ }
1001
+ {
1002
+ size_t max_offset = 0;
1003
+ size_t next = 1;
1004
+ for (int i = 0; i < 257; ++i) {
1005
+ /* for each code point, map a tree path */
1006
+ size_t pos = 0;
1007
+ uint32_t code = ordered[i].code;
1008
+ for (int b = 0; b < ordered[i].bits; ++b) {
1009
+ if (code & (1ULL << (ordered[i].bits - 1))) {
1010
+ /* map 1 branch */
1011
+ if (tree[pos].offset[1] != (uint8_t)-1)
1012
+ pos += tree[pos].offset[1];
1013
+ else {
1014
+ if (next - pos > max_offset)
1015
+ max_offset = next - pos;
1016
+ tree[pos].offset[1] = next - pos;
1017
+ pos = next;
1018
+ ++next;
1019
+ }
1020
+ } else {
1021
+ /* map 0 branch */
1022
+ if (tree[pos].offset[0] != (uint8_t)-1)
1023
+ pos += tree[pos].offset[0];
1024
+ else {
1025
+ if (next - pos > max_offset)
1026
+ max_offset = next - pos;
1027
+ tree[pos].offset[0] = next - pos;
1028
+ pos = next;
1029
+ ++next;
1030
+ }
1031
+ }
1032
+ code <<= 1;
1033
+ }
1034
+ tree[pos] = (huffman_decode_nc_s){.value = ordered[i].value};
1035
+ }
1036
+ fprintf(stderr, "Total tree length = %zu, max offset = %zu\n", next,
1037
+ max_offset);
1038
+ tree_len = next;
1039
+ }
1040
+ {
1041
+ /* Validate tree */
1042
+ for (int i = 0; i < 257; ++i) {
1043
+ huffman_decode_nc_s *node = tree;
1044
+ uint32_t code = ordered[i].code;
1045
+ uint8_t consumed = 32 - ordered[i].bits;
1046
+ code <<= consumed;
1047
+ while (consumed < 32) {
1048
+ node += node->offset[(code >> 31) & 1];
1049
+ code <<= 1;
1050
+ ++consumed;
1051
+ }
1052
+ if (ordered[i].value != node->value) {
1053
+ fprintf(stderr,
1054
+ "ERROR building tree - validation error for %d (value: %d != "
1055
+ "%d)\n",
1056
+ i, node->value, ordered[i].value);
1057
+ exit(-1);
1058
+ }
1059
+ }
1060
+ }
1061
+ fprintf(stderr,
1062
+ "***** Copy after this line ****\n\n"
1063
+ "/** Static Huffman encoding map, left aligned */\n"
1064
+
1065
+ "static const huffman_encode_s huffman_encode_table[257] = {\n");
1066
+ for (size_t i = 0; i < 257; ++i) {
1067
+ /* print huffman code left align */
1068
+ fprintf(stderr, " {.code = 0x%.08X, .bits = %u}, // [%zu] \n",
1069
+ (encode_table[i].code << (32 - encode_table[i].bits)),
1070
+ encode_table[i].bits, i);
1071
+ }
1072
+ fprintf(stderr,
1073
+ "};\n\n/** Static Huffman decoding tree, flattened as an array */\n"
1074
+
1075
+ "static const huffman_decode_s huffman_decode_tree[%zu] = {\n",
1076
+ tree_len);
1077
+ for (size_t i = 0; i < tree_len; ++i) {
1078
+ huffman__print_unit(
1079
+ tree[i], i,
1080
+ (tree[i].value == -1) ? 0 : encode_table[tree[i].value].code,
1081
+ (tree[i].value == -1) ? 0 : encode_table[tree[i].value].bits);
1082
+ }
1083
+ fprintf(stderr, "};\n\n\n**************( stop copying )**************\n\n");
1084
+ for (int i = 0; i < 256; ++i) {
1085
+ uint8_t data[4] = {0};
1086
+ uint8_t result = 0;
1087
+ size_t r_pos = 0;
1088
+ uint32_t code = ordered[i].code;
1089
+ code <<= 32 - ordered[i].bits;
1090
+ code |= (1UL << (32 - ordered[i].bits)) - 1;
1091
+ data[0] = (code >> 24) & 0xFF;
1092
+ data[1] = (code >> 16) & 0xFF;
1093
+ data[2] = (code >> 8) & 0xFF;
1094
+ data[3] = (code >> 0) & 0xFF;
1095
+ hpack_huffman_unpack(&result, 1, &data, 4, &r_pos);
1096
+ r_pos = 0;
1097
+ if (result != ordered[i].value) {
1098
+ fprintf(stderr, "ERR: (%u) %u != %u (%d, %d)\n", data[0], result,
1099
+ ordered[i].value,
1100
+ hpack_huffman_unpack(&result, 1, &data, 1, &r_pos), i);
1101
+ exit(-1);
1102
+ }
1103
+ }
1104
+ hpack_test();
1105
+ }
1106
+
1107
+ int main(void) {
1108
+ huffman__print_tree();
1109
+ return 0;
1110
+ }
1111
+
1112
+ #endif
1113
+
1114
+ /* *****************************************************************************
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+ Paste auto-generated data here
1122
+
1123
+
1124
+
1125
+
1126
+
1127
+
1128
+
1129
+ ***************************************************************************** */
1130
+
1131
+ /** Static Huffman encoding map, left aligned */
1132
+ static const huffman_encode_s huffman_encode_table[257] = {
1133
+ {.code = 0xFFC00000, .bits = 13}, // [0]
1134
+ {.code = 0xFFFFB000, .bits = 23}, // [1]
1135
+ {.code = 0xFFFFFE20, .bits = 28}, // [2]
1136
+ {.code = 0xFFFFFE30, .bits = 28}, // [3]
1137
+ {.code = 0xFFFFFE40, .bits = 28}, // [4]
1138
+ {.code = 0xFFFFFE50, .bits = 28}, // [5]
1139
+ {.code = 0xFFFFFE60, .bits = 28}, // [6]
1140
+ {.code = 0xFFFFFE70, .bits = 28}, // [7]
1141
+ {.code = 0xFFFFFE80, .bits = 28}, // [8]
1142
+ {.code = 0xFFFFEA00, .bits = 24}, // [9]
1143
+ {.code = 0xFFFFFFF0, .bits = 30}, // [10]
1144
+ {.code = 0xFFFFFE90, .bits = 28}, // [11]
1145
+ {.code = 0xFFFFFEA0, .bits = 28}, // [12]
1146
+ {.code = 0xFFFFFFF4, .bits = 30}, // [13]
1147
+ {.code = 0xFFFFFEB0, .bits = 28}, // [14]
1148
+ {.code = 0xFFFFFEC0, .bits = 28}, // [15]
1149
+ {.code = 0xFFFFFED0, .bits = 28}, // [16]
1150
+ {.code = 0xFFFFFEE0, .bits = 28}, // [17]
1151
+ {.code = 0xFFFFFEF0, .bits = 28}, // [18]
1152
+ {.code = 0xFFFFFF00, .bits = 28}, // [19]
1153
+ {.code = 0xFFFFFF10, .bits = 28}, // [20]
1154
+ {.code = 0xFFFFFF20, .bits = 28}, // [21]
1155
+ {.code = 0xFFFFFFF8, .bits = 30}, // [22]
1156
+ {.code = 0xFFFFFF30, .bits = 28}, // [23]
1157
+ {.code = 0xFFFFFF40, .bits = 28}, // [24]
1158
+ {.code = 0xFFFFFF50, .bits = 28}, // [25]
1159
+ {.code = 0xFFFFFF60, .bits = 28}, // [26]
1160
+ {.code = 0xFFFFFF70, .bits = 28}, // [27]
1161
+ {.code = 0xFFFFFF80, .bits = 28}, // [28]
1162
+ {.code = 0xFFFFFF90, .bits = 28}, // [29]
1163
+ {.code = 0xFFFFFFA0, .bits = 28}, // [30]
1164
+ {.code = 0xFFFFFFB0, .bits = 28}, // [31]
1165
+ {.code = 0x50000000, .bits = 6}, // [32]
1166
+ {.code = 0xFE000000, .bits = 10}, // [33]
1167
+ {.code = 0xFE400000, .bits = 10}, // [34]
1168
+ {.code = 0xFFA00000, .bits = 12}, // [35]
1169
+ {.code = 0xFFC80000, .bits = 13}, // [36]
1170
+ {.code = 0x54000000, .bits = 6}, // [37]
1171
+ {.code = 0xF8000000, .bits = 8}, // [38]
1172
+ {.code = 0xFF400000, .bits = 11}, // [39]
1173
+ {.code = 0xFE800000, .bits = 10}, // [40]
1174
+ {.code = 0xFEC00000, .bits = 10}, // [41]
1175
+ {.code = 0xF9000000, .bits = 8}, // [42]
1176
+ {.code = 0xFF600000, .bits = 11}, // [43]
1177
+ {.code = 0xFA000000, .bits = 8}, // [44]
1178
+ {.code = 0x58000000, .bits = 6}, // [45]
1179
+ {.code = 0x5C000000, .bits = 6}, // [46]
1180
+ {.code = 0x60000000, .bits = 6}, // [47]
1181
+ {.code = 0x00000000, .bits = 5}, // [48]
1182
+ {.code = 0x08000000, .bits = 5}, // [49]
1183
+ {.code = 0x10000000, .bits = 5}, // [50]
1184
+ {.code = 0x64000000, .bits = 6}, // [51]
1185
+ {.code = 0x68000000, .bits = 6}, // [52]
1186
+ {.code = 0x6C000000, .bits = 6}, // [53]
1187
+ {.code = 0x70000000, .bits = 6}, // [54]
1188
+ {.code = 0x74000000, .bits = 6}, // [55]
1189
+ {.code = 0x78000000, .bits = 6}, // [56]
1190
+ {.code = 0x7C000000, .bits = 6}, // [57]
1191
+ {.code = 0xB8000000, .bits = 7}, // [58]
1192
+ {.code = 0xFB000000, .bits = 8}, // [59]
1193
+ {.code = 0xFFF80000, .bits = 15}, // [60]
1194
+ {.code = 0x80000000, .bits = 6}, // [61]
1195
+ {.code = 0xFFB00000, .bits = 12}, // [62]
1196
+ {.code = 0xFF000000, .bits = 10}, // [63]
1197
+ {.code = 0xFFD00000, .bits = 13}, // [64]
1198
+ {.code = 0x84000000, .bits = 6}, // [65]
1199
+ {.code = 0xBA000000, .bits = 7}, // [66]
1200
+ {.code = 0xBC000000, .bits = 7}, // [67]
1201
+ {.code = 0xBE000000, .bits = 7}, // [68]
1202
+ {.code = 0xC0000000, .bits = 7}, // [69]
1203
+ {.code = 0xC2000000, .bits = 7}, // [70]
1204
+ {.code = 0xC4000000, .bits = 7}, // [71]
1205
+ {.code = 0xC6000000, .bits = 7}, // [72]
1206
+ {.code = 0xC8000000, .bits = 7}, // [73]
1207
+ {.code = 0xCA000000, .bits = 7}, // [74]
1208
+ {.code = 0xCC000000, .bits = 7}, // [75]
1209
+ {.code = 0xCE000000, .bits = 7}, // [76]
1210
+ {.code = 0xD0000000, .bits = 7}, // [77]
1211
+ {.code = 0xD2000000, .bits = 7}, // [78]
1212
+ {.code = 0xD4000000, .bits = 7}, // [79]
1213
+ {.code = 0xD6000000, .bits = 7}, // [80]
1214
+ {.code = 0xD8000000, .bits = 7}, // [81]
1215
+ {.code = 0xDA000000, .bits = 7}, // [82]
1216
+ {.code = 0xDC000000, .bits = 7}, // [83]
1217
+ {.code = 0xDE000000, .bits = 7}, // [84]
1218
+ {.code = 0xE0000000, .bits = 7}, // [85]
1219
+ {.code = 0xE2000000, .bits = 7}, // [86]
1220
+ {.code = 0xE4000000, .bits = 7}, // [87]
1221
+ {.code = 0xFC000000, .bits = 8}, // [88]
1222
+ {.code = 0xE6000000, .bits = 7}, // [89]
1223
+ {.code = 0xFD000000, .bits = 8}, // [90]
1224
+ {.code = 0xFFD80000, .bits = 13}, // [91]
1225
+ {.code = 0xFFFE0000, .bits = 19}, // [92]
1226
+ {.code = 0xFFE00000, .bits = 13}, // [93]
1227
+ {.code = 0xFFF00000, .bits = 14}, // [94]
1228
+ {.code = 0x88000000, .bits = 6}, // [95]
1229
+ {.code = 0xFFFA0000, .bits = 15}, // [96]
1230
+ {.code = 0x18000000, .bits = 5}, // [97]
1231
+ {.code = 0x8C000000, .bits = 6}, // [98]
1232
+ {.code = 0x20000000, .bits = 5}, // [99]
1233
+ {.code = 0x90000000, .bits = 6}, // [100]
1234
+ {.code = 0x28000000, .bits = 5}, // [101]
1235
+ {.code = 0x94000000, .bits = 6}, // [102]
1236
+ {.code = 0x98000000, .bits = 6}, // [103]
1237
+ {.code = 0x9C000000, .bits = 6}, // [104]
1238
+ {.code = 0x30000000, .bits = 5}, // [105]
1239
+ {.code = 0xE8000000, .bits = 7}, // [106]
1240
+ {.code = 0xEA000000, .bits = 7}, // [107]
1241
+ {.code = 0xA0000000, .bits = 6}, // [108]
1242
+ {.code = 0xA4000000, .bits = 6}, // [109]
1243
+ {.code = 0xA8000000, .bits = 6}, // [110]
1244
+ {.code = 0x38000000, .bits = 5}, // [111]
1245
+ {.code = 0xAC000000, .bits = 6}, // [112]
1246
+ {.code = 0xEC000000, .bits = 7}, // [113]
1247
+ {.code = 0xB0000000, .bits = 6}, // [114]
1248
+ {.code = 0x40000000, .bits = 5}, // [115]
1249
+ {.code = 0x48000000, .bits = 5}, // [116]
1250
+ {.code = 0xB4000000, .bits = 6}, // [117]
1251
+ {.code = 0xEE000000, .bits = 7}, // [118]
1252
+ {.code = 0xF0000000, .bits = 7}, // [119]
1253
+ {.code = 0xF2000000, .bits = 7}, // [120]
1254
+ {.code = 0xF4000000, .bits = 7}, // [121]
1255
+ {.code = 0xF6000000, .bits = 7}, // [122]
1256
+ {.code = 0xFFFC0000, .bits = 15}, // [123]
1257
+ {.code = 0xFF800000, .bits = 11}, // [124]
1258
+ {.code = 0xFFF40000, .bits = 14}, // [125]
1259
+ {.code = 0xFFE80000, .bits = 13}, // [126]
1260
+ {.code = 0xFFFFFFC0, .bits = 28}, // [127]
1261
+ {.code = 0xFFFE6000, .bits = 20}, // [128]
1262
+ {.code = 0xFFFF4800, .bits = 22}, // [129]
1263
+ {.code = 0xFFFE7000, .bits = 20}, // [130]
1264
+ {.code = 0xFFFE8000, .bits = 20}, // [131]
1265
+ {.code = 0xFFFF4C00, .bits = 22}, // [132]
1266
+ {.code = 0xFFFF5000, .bits = 22}, // [133]
1267
+ {.code = 0xFFFF5400, .bits = 22}, // [134]
1268
+ {.code = 0xFFFFB200, .bits = 23}, // [135]
1269
+ {.code = 0xFFFF5800, .bits = 22}, // [136]
1270
+ {.code = 0xFFFFB400, .bits = 23}, // [137]
1271
+ {.code = 0xFFFFB600, .bits = 23}, // [138]
1272
+ {.code = 0xFFFFB800, .bits = 23}, // [139]
1273
+ {.code = 0xFFFFBA00, .bits = 23}, // [140]
1274
+ {.code = 0xFFFFBC00, .bits = 23}, // [141]
1275
+ {.code = 0xFFFFEB00, .bits = 24}, // [142]
1276
+ {.code = 0xFFFFBE00, .bits = 23}, // [143]
1277
+ {.code = 0xFFFFEC00, .bits = 24}, // [144]
1278
+ {.code = 0xFFFFED00, .bits = 24}, // [145]
1279
+ {.code = 0xFFFF5C00, .bits = 22}, // [146]
1280
+ {.code = 0xFFFFC000, .bits = 23}, // [147]
1281
+ {.code = 0xFFFFEE00, .bits = 24}, // [148]
1282
+ {.code = 0xFFFFC200, .bits = 23}, // [149]
1283
+ {.code = 0xFFFFC400, .bits = 23}, // [150]
1284
+ {.code = 0xFFFFC600, .bits = 23}, // [151]
1285
+ {.code = 0xFFFFC800, .bits = 23}, // [152]
1286
+ {.code = 0xFFFEE000, .bits = 21}, // [153]
1287
+ {.code = 0xFFFF6000, .bits = 22}, // [154]
1288
+ {.code = 0xFFFFCA00, .bits = 23}, // [155]
1289
+ {.code = 0xFFFF6400, .bits = 22}, // [156]
1290
+ {.code = 0xFFFFCC00, .bits = 23}, // [157]
1291
+ {.code = 0xFFFFCE00, .bits = 23}, // [158]
1292
+ {.code = 0xFFFFEF00, .bits = 24}, // [159]
1293
+ {.code = 0xFFFF6800, .bits = 22}, // [160]
1294
+ {.code = 0xFFFEE800, .bits = 21}, // [161]
1295
+ {.code = 0xFFFE9000, .bits = 20}, // [162]
1296
+ {.code = 0xFFFF6C00, .bits = 22}, // [163]
1297
+ {.code = 0xFFFF7000, .bits = 22}, // [164]
1298
+ {.code = 0xFFFFD000, .bits = 23}, // [165]
1299
+ {.code = 0xFFFFD200, .bits = 23}, // [166]
1300
+ {.code = 0xFFFEF000, .bits = 21}, // [167]
1301
+ {.code = 0xFFFFD400, .bits = 23}, // [168]
1302
+ {.code = 0xFFFF7400, .bits = 22}, // [169]
1303
+ {.code = 0xFFFF7800, .bits = 22}, // [170]
1304
+ {.code = 0xFFFFF000, .bits = 24}, // [171]
1305
+ {.code = 0xFFFEF800, .bits = 21}, // [172]
1306
+ {.code = 0xFFFF7C00, .bits = 22}, // [173]
1307
+ {.code = 0xFFFFD600, .bits = 23}, // [174]
1308
+ {.code = 0xFFFFD800, .bits = 23}, // [175]
1309
+ {.code = 0xFFFF0000, .bits = 21}, // [176]
1310
+ {.code = 0xFFFF0800, .bits = 21}, // [177]
1311
+ {.code = 0xFFFF8000, .bits = 22}, // [178]
1312
+ {.code = 0xFFFF1000, .bits = 21}, // [179]
1313
+ {.code = 0xFFFFDA00, .bits = 23}, // [180]
1314
+ {.code = 0xFFFF8400, .bits = 22}, // [181]
1315
+ {.code = 0xFFFFDC00, .bits = 23}, // [182]
1316
+ {.code = 0xFFFFDE00, .bits = 23}, // [183]
1317
+ {.code = 0xFFFEA000, .bits = 20}, // [184]
1318
+ {.code = 0xFFFF8800, .bits = 22}, // [185]
1319
+ {.code = 0xFFFF8C00, .bits = 22}, // [186]
1320
+ {.code = 0xFFFF9000, .bits = 22}, // [187]
1321
+ {.code = 0xFFFFE000, .bits = 23}, // [188]
1322
+ {.code = 0xFFFF9400, .bits = 22}, // [189]
1323
+ {.code = 0xFFFF9800, .bits = 22}, // [190]
1324
+ {.code = 0xFFFFE200, .bits = 23}, // [191]
1325
+ {.code = 0xFFFFF800, .bits = 26}, // [192]
1326
+ {.code = 0xFFFFF840, .bits = 26}, // [193]
1327
+ {.code = 0xFFFEB000, .bits = 20}, // [194]
1328
+ {.code = 0xFFFE2000, .bits = 19}, // [195]
1329
+ {.code = 0xFFFF9C00, .bits = 22}, // [196]
1330
+ {.code = 0xFFFFE400, .bits = 23}, // [197]
1331
+ {.code = 0xFFFFA000, .bits = 22}, // [198]
1332
+ {.code = 0xFFFFF600, .bits = 25}, // [199]
1333
+ {.code = 0xFFFFF880, .bits = 26}, // [200]
1334
+ {.code = 0xFFFFF8C0, .bits = 26}, // [201]
1335
+ {.code = 0xFFFFF900, .bits = 26}, // [202]
1336
+ {.code = 0xFFFFFBC0, .bits = 27}, // [203]
1337
+ {.code = 0xFFFFFBE0, .bits = 27}, // [204]
1338
+ {.code = 0xFFFFF940, .bits = 26}, // [205]
1339
+ {.code = 0xFFFFF100, .bits = 24}, // [206]
1340
+ {.code = 0xFFFFF680, .bits = 25}, // [207]
1341
+ {.code = 0xFFFE4000, .bits = 19}, // [208]
1342
+ {.code = 0xFFFF1800, .bits = 21}, // [209]
1343
+ {.code = 0xFFFFF980, .bits = 26}, // [210]
1344
+ {.code = 0xFFFFFC00, .bits = 27}, // [211]
1345
+ {.code = 0xFFFFFC20, .bits = 27}, // [212]
1346
+ {.code = 0xFFFFF9C0, .bits = 26}, // [213]
1347
+ {.code = 0xFFFFFC40, .bits = 27}, // [214]
1348
+ {.code = 0xFFFFF200, .bits = 24}, // [215]
1349
+ {.code = 0xFFFF2000, .bits = 21}, // [216]
1350
+ {.code = 0xFFFF2800, .bits = 21}, // [217]
1351
+ {.code = 0xFFFFFA00, .bits = 26}, // [218]
1352
+ {.code = 0xFFFFFA40, .bits = 26}, // [219]
1353
+ {.code = 0xFFFFFFD0, .bits = 28}, // [220]
1354
+ {.code = 0xFFFFFC60, .bits = 27}, // [221]
1355
+ {.code = 0xFFFFFC80, .bits = 27}, // [222]
1356
+ {.code = 0xFFFFFCA0, .bits = 27}, // [223]
1357
+ {.code = 0xFFFEC000, .bits = 20}, // [224]
1358
+ {.code = 0xFFFFF300, .bits = 24}, // [225]
1359
+ {.code = 0xFFFED000, .bits = 20}, // [226]
1360
+ {.code = 0xFFFF3000, .bits = 21}, // [227]
1361
+ {.code = 0xFFFFA400, .bits = 22}, // [228]
1362
+ {.code = 0xFFFF3800, .bits = 21}, // [229]
1363
+ {.code = 0xFFFF4000, .bits = 21}, // [230]
1364
+ {.code = 0xFFFFE600, .bits = 23}, // [231]
1365
+ {.code = 0xFFFFA800, .bits = 22}, // [232]
1366
+ {.code = 0xFFFFAC00, .bits = 22}, // [233]
1367
+ {.code = 0xFFFFF700, .bits = 25}, // [234]
1368
+ {.code = 0xFFFFF780, .bits = 25}, // [235]
1369
+ {.code = 0xFFFFF400, .bits = 24}, // [236]
1370
+ {.code = 0xFFFFF500, .bits = 24}, // [237]
1371
+ {.code = 0xFFFFFA80, .bits = 26}, // [238]
1372
+ {.code = 0xFFFFE800, .bits = 23}, // [239]
1373
+ {.code = 0xFFFFFAC0, .bits = 26}, // [240]
1374
+ {.code = 0xFFFFFCC0, .bits = 27}, // [241]
1375
+ {.code = 0xFFFFFB00, .bits = 26}, // [242]
1376
+ {.code = 0xFFFFFB40, .bits = 26}, // [243]
1377
+ {.code = 0xFFFFFCE0, .bits = 27}, // [244]
1378
+ {.code = 0xFFFFFD00, .bits = 27}, // [245]
1379
+ {.code = 0xFFFFFD20, .bits = 27}, // [246]
1380
+ {.code = 0xFFFFFD40, .bits = 27}, // [247]
1381
+ {.code = 0xFFFFFD60, .bits = 27}, // [248]
1382
+ {.code = 0xFFFFFFE0, .bits = 28}, // [249]
1383
+ {.code = 0xFFFFFD80, .bits = 27}, // [250]
1384
+ {.code = 0xFFFFFDA0, .bits = 27}, // [251]
1385
+ {.code = 0xFFFFFDC0, .bits = 27}, // [252]
1386
+ {.code = 0xFFFFFDE0, .bits = 27}, // [253]
1387
+ {.code = 0xFFFFFE00, .bits = 27}, // [254]
1388
+ {.code = 0xFFFFFB80, .bits = 26}, // [255]
1389
+ {.code = 0xFFFFFFFC, .bits = 30}, // [256]
1390
+ };
1391
+
1392
+ /** Static Huffman decoding tree, flattened as an array */
1393
+ static const huffman_decode_s huffman_decode_tree[513] = {
1394
+ {.value = -1, .offset = {1, 44}}, // [0]
1395
+ {.value = -1, .offset = {1, 16}}, // [1]
1396
+ {.value = -1, .offset = {1, 8}}, // [2]
1397
+ {.value = -1, .offset = {1, 4}}, // [3]
1398
+ {.value = -1, .offset = {1, 2}}, // [4]
1399
+ {.value = 48, .offset = {0, 0}}, // [5]:0b00000
1400
+ {.value = 49, .offset = {0, 0}}, // [6]:0b00001
1401
+ {.value = -1, .offset = {1, 2}}, // [7]
1402
+ {.value = 50, .offset = {0, 0}}, // [8]:0b00010
1403
+ {.value = 97, .offset = {0, 0}}, // [9]:0b00011
1404
+ {.value = -1, .offset = {1, 4}}, // [10]
1405
+ {.value = -1, .offset = {1, 2}}, // [11]
1406
+ {.value = 99, .offset = {0, 0}}, // [12]:0b00100
1407
+ {.value = 101, .offset = {0, 0}}, // [13]:0b00101
1408
+ {.value = -1, .offset = {1, 2}}, // [14]
1409
+ {.value = 105, .offset = {0, 0}}, // [15]:0b00110
1410
+ {.value = 111, .offset = {0, 0}}, // [16]:0b00111
1411
+ {.value = -1, .offset = {1, 12}}, // [17]
1412
+ {.value = -1, .offset = {1, 4}}, // [18]
1413
+ {.value = -1, .offset = {1, 2}}, // [19]
1414
+ {.value = 115, .offset = {0, 0}}, // [20]:0b01000
1415
+ {.value = 116, .offset = {0, 0}}, // [21]:0b01001
1416
+ {.value = -1, .offset = {1, 4}}, // [22]
1417
+ {.value = -1, .offset = {1, 2}}, // [23]
1418
+ {.value = 32, .offset = {0, 0}}, // [24]:0b010100
1419
+ {.value = 37, .offset = {0, 0}}, // [25]:0b010101
1420
+ {.value = -1, .offset = {1, 2}}, // [26]
1421
+ {.value = 45, .offset = {0, 0}}, // [27]:0b010110
1422
+ {.value = 46, .offset = {0, 0}}, // [28]:0b010111
1423
+ {.value = -1, .offset = {1, 8}}, // [29]
1424
+ {.value = -1, .offset = {1, 4}}, // [30]
1425
+ {.value = -1, .offset = {1, 2}}, // [31]
1426
+ {.value = 47, .offset = {0, 0}}, // [32]:0b011000
1427
+ {.value = 51, .offset = {0, 0}}, // [33]:0b011001
1428
+ {.value = -1, .offset = {1, 2}}, // [34]
1429
+ {.value = 52, .offset = {0, 0}}, // [35]:0b011010
1430
+ {.value = 53, .offset = {0, 0}}, // [36]:0b011011
1431
+ {.value = -1, .offset = {1, 4}}, // [37]
1432
+ {.value = -1, .offset = {1, 2}}, // [38]
1433
+ {.value = 54, .offset = {0, 0}}, // [39]:0b011100
1434
+ {.value = 55, .offset = {0, 0}}, // [40]:0b011101
1435
+ {.value = -1, .offset = {1, 2}}, // [41]
1436
+ {.value = 56, .offset = {0, 0}}, // [42]:0b011110
1437
+ {.value = 57, .offset = {0, 0}}, // [43]:0b011111
1438
+ {.value = -1, .offset = {1, 36}}, // [44]
1439
+ {.value = -1, .offset = {1, 16}}, // [45]
1440
+ {.value = -1, .offset = {1, 8}}, // [46]
1441
+ {.value = -1, .offset = {1, 4}}, // [47]
1442
+ {.value = -1, .offset = {1, 2}}, // [48]
1443
+ {.value = 61, .offset = {0, 0}}, // [49]:0b100000
1444
+ {.value = 65, .offset = {0, 0}}, // [50]:0b100001
1445
+ {.value = -1, .offset = {1, 2}}, // [51]
1446
+ {.value = 95, .offset = {0, 0}}, // [52]:0b100010
1447
+ {.value = 98, .offset = {0, 0}}, // [53]:0b100011
1448
+ {.value = -1, .offset = {1, 4}}, // [54]
1449
+ {.value = -1, .offset = {1, 2}}, // [55]
1450
+ {.value = 100, .offset = {0, 0}}, // [56]:0b100100
1451
+ {.value = 102, .offset = {0, 0}}, // [57]:0b100101
1452
+ {.value = -1, .offset = {1, 2}}, // [58]
1453
+ {.value = 103, .offset = {0, 0}}, // [59]:0b100110
1454
+ {.value = 104, .offset = {0, 0}}, // [60]:0b100111
1455
+ {.value = -1, .offset = {1, 8}}, // [61]
1456
+ {.value = -1, .offset = {1, 4}}, // [62]
1457
+ {.value = -1, .offset = {1, 2}}, // [63]
1458
+ {.value = 108, .offset = {0, 0}}, // [64]:0b101000
1459
+ {.value = 109, .offset = {0, 0}}, // [65]:0b101001
1460
+ {.value = -1, .offset = {1, 2}}, // [66]
1461
+ {.value = 110, .offset = {0, 0}}, // [67]:0b101010
1462
+ {.value = 112, .offset = {0, 0}}, // [68]:0b101011
1463
+ {.value = -1, .offset = {1, 4}}, // [69]
1464
+ {.value = -1, .offset = {1, 2}}, // [70]
1465
+ {.value = 114, .offset = {0, 0}}, // [71]:0b101100
1466
+ {.value = 117, .offset = {0, 0}}, // [72]:0b101101
1467
+ {.value = -1, .offset = {1, 4}}, // [73]
1468
+ {.value = -1, .offset = {1, 2}}, // [74]
1469
+ {.value = 58, .offset = {0, 0}}, // [75]:0b1011100
1470
+ {.value = 66, .offset = {0, 0}}, // [76]:0b1011101
1471
+ {.value = -1, .offset = {1, 2}}, // [77]
1472
+ {.value = 67, .offset = {0, 0}}, // [78]:0b1011110
1473
+ {.value = 68, .offset = {0, 0}}, // [79]:0b1011111
1474
+ {.value = -1, .offset = {1, 32}}, // [80]
1475
+ {.value = -1, .offset = {1, 16}}, // [81]
1476
+ {.value = -1, .offset = {1, 8}}, // [82]
1477
+ {.value = -1, .offset = {1, 4}}, // [83]
1478
+ {.value = -1, .offset = {1, 2}}, // [84]
1479
+ {.value = 69, .offset = {0, 0}}, // [85]:0b1100000
1480
+ {.value = 70, .offset = {0, 0}}, // [86]:0b1100001
1481
+ {.value = -1, .offset = {1, 2}}, // [87]
1482
+ {.value = 71, .offset = {0, 0}}, // [88]:0b1100010
1483
+ {.value = 72, .offset = {0, 0}}, // [89]:0b1100011
1484
+ {.value = -1, .offset = {1, 4}}, // [90]
1485
+ {.value = -1, .offset = {1, 2}}, // [91]
1486
+ {.value = 73, .offset = {0, 0}}, // [92]:0b1100100
1487
+ {.value = 74, .offset = {0, 0}}, // [93]:0b1100101
1488
+ {.value = -1, .offset = {1, 2}}, // [94]
1489
+ {.value = 75, .offset = {0, 0}}, // [95]:0b1100110
1490
+ {.value = 76, .offset = {0, 0}}, // [96]:0b1100111
1491
+ {.value = -1, .offset = {1, 8}}, // [97]
1492
+ {.value = -1, .offset = {1, 4}}, // [98]
1493
+ {.value = -1, .offset = {1, 2}}, // [99]
1494
+ {.value = 77, .offset = {0, 0}}, // [100]:0b1101000
1495
+ {.value = 78, .offset = {0, 0}}, // [101]:0b1101001
1496
+ {.value = -1, .offset = {1, 2}}, // [102]
1497
+ {.value = 79, .offset = {0, 0}}, // [103]:0b1101010
1498
+ {.value = 80, .offset = {0, 0}}, // [104]:0b1101011
1499
+ {.value = -1, .offset = {1, 4}}, // [105]
1500
+ {.value = -1, .offset = {1, 2}}, // [106]
1501
+ {.value = 81, .offset = {0, 0}}, // [107]:0b1101100
1502
+ {.value = 82, .offset = {0, 0}}, // [108]:0b1101101
1503
+ {.value = -1, .offset = {1, 2}}, // [109]
1504
+ {.value = 83, .offset = {0, 0}}, // [110]:0b1101110
1505
+ {.value = 84, .offset = {0, 0}}, // [111]:0b1101111
1506
+ {.value = -1, .offset = {1, 16}}, // [112]
1507
+ {.value = -1, .offset = {1, 8}}, // [113]
1508
+ {.value = -1, .offset = {1, 4}}, // [114]
1509
+ {.value = -1, .offset = {1, 2}}, // [115]
1510
+ {.value = 85, .offset = {0, 0}}, // [116]:0b1110000
1511
+ {.value = 86, .offset = {0, 0}}, // [117]:0b1110001
1512
+ {.value = -1, .offset = {1, 2}}, // [118]
1513
+ {.value = 87, .offset = {0, 0}}, // [119]:0b1110010
1514
+ {.value = 89, .offset = {0, 0}}, // [120]:0b1110011
1515
+ {.value = -1, .offset = {1, 4}}, // [121]
1516
+ {.value = -1, .offset = {1, 2}}, // [122]
1517
+ {.value = 106, .offset = {0, 0}}, // [123]:0b1110100
1518
+ {.value = 107, .offset = {0, 0}}, // [124]:0b1110101
1519
+ {.value = -1, .offset = {1, 2}}, // [125]
1520
+ {.value = 113, .offset = {0, 0}}, // [126]:0b1110110
1521
+ {.value = 118, .offset = {0, 0}}, // [127]:0b1110111
1522
+ {.value = -1, .offset = {1, 8}}, // [128]
1523
+ {.value = -1, .offset = {1, 4}}, // [129]
1524
+ {.value = -1, .offset = {1, 2}}, // [130]
1525
+ {.value = 119, .offset = {0, 0}}, // [131]:0b1111000
1526
+ {.value = 120, .offset = {0, 0}}, // [132]:0b1111001
1527
+ {.value = -1, .offset = {1, 2}}, // [133]
1528
+ {.value = 121, .offset = {0, 0}}, // [134]:0b1111010
1529
+ {.value = 122, .offset = {0, 0}}, // [135]:0b1111011
1530
+ {.value = -1, .offset = {1, 8}}, // [136]
1531
+ {.value = -1, .offset = {1, 4}}, // [137]
1532
+ {.value = -1, .offset = {1, 2}}, // [138]
1533
+ {.value = 38, .offset = {0, 0}}, // [139]:0b11111000
1534
+ {.value = 42, .offset = {0, 0}}, // [140]:0b11111001
1535
+ {.value = -1, .offset = {1, 2}}, // [141]
1536
+ {.value = 44, .offset = {0, 0}}, // [142]:0b11111010
1537
+ {.value = 59, .offset = {0, 0}}, // [143]:0b11111011
1538
+ {.value = -1, .offset = {1, 4}}, // [144]
1539
+ {.value = -1, .offset = {1, 2}}, // [145]
1540
+ {.value = 88, .offset = {0, 0}}, // [146]:0b11111100
1541
+ {.value = 90, .offset = {0, 0}}, // [147]:0b11111101
1542
+ {.value = -1, .offset = {1, 8}}, // [148]
1543
+ {.value = -1, .offset = {1, 4}}, // [149]
1544
+ {.value = -1, .offset = {1, 2}}, // [150]
1545
+ {.value = 33, .offset = {0, 0}}, // [151]:0b1111111000
1546
+ {.value = 34, .offset = {0, 0}}, // [152]:0b1111111001
1547
+ {.value = -1, .offset = {1, 2}}, // [153]
1548
+ {.value = 40, .offset = {0, 0}}, // [154]:0b1111111010
1549
+ {.value = 41, .offset = {0, 0}}, // [155]:0b1111111011
1550
+ {.value = -1, .offset = {1, 6}}, // [156]
1551
+ {.value = -1, .offset = {1, 2}}, // [157]
1552
+ {.value = 63, .offset = {0, 0}}, // [158]:0b1111111100
1553
+ {.value = -1, .offset = {1, 2}}, // [159]
1554
+ {.value = 39, .offset = {0, 0}}, // [160]:0b11111111010
1555
+ {.value = 43, .offset = {0, 0}}, // [161]:0b11111111011
1556
+ {.value = -1, .offset = {1, 6}}, // [162]
1557
+ {.value = -1, .offset = {1, 2}}, // [163]
1558
+ {.value = 124, .offset = {0, 0}}, // [164]:0b11111111100
1559
+ {.value = -1, .offset = {1, 2}}, // [165]
1560
+ {.value = 35, .offset = {0, 0}}, // [166]:0b111111111010
1561
+ {.value = 62, .offset = {0, 0}}, // [167]:0b111111111011
1562
+ {.value = -1, .offset = {1, 8}}, // [168]
1563
+ {.value = -1, .offset = {1, 4}}, // [169]
1564
+ {.value = -1, .offset = {1, 2}}, // [170]
1565
+ {.value = 0, .offset = {0, 0}}, // [171]:0b1111111111000
1566
+ {.value = 36, .offset = {0, 0}}, // [172]:0b1111111111001
1567
+ {.value = -1, .offset = {1, 2}}, // [173]
1568
+ {.value = 64, .offset = {0, 0}}, // [174]:0b1111111111010
1569
+ {.value = 91, .offset = {0, 0}}, // [175]:0b1111111111011
1570
+ {.value = -1, .offset = {1, 4}}, // [176]
1571
+ {.value = -1, .offset = {1, 2}}, // [177]
1572
+ {.value = 93, .offset = {0, 0}}, // [178]:0b1111111111100
1573
+ {.value = 126, .offset = {0, 0}}, // [179]:0b1111111111101
1574
+ {.value = -1, .offset = {1, 4}}, // [180]
1575
+ {.value = -1, .offset = {1, 2}}, // [181]
1576
+ {.value = 94, .offset = {0, 0}}, // [182]:0b11111111111100
1577
+ {.value = 125, .offset = {0, 0}}, // [183]:0b11111111111101
1578
+ {.value = -1, .offset = {1, 4}}, // [184]
1579
+ {.value = -1, .offset = {1, 2}}, // [185]
1580
+ {.value = 60, .offset = {0, 0}}, // [186]:0b111111111111100
1581
+ {.value = 96, .offset = {0, 0}}, // [187]:0b111111111111101
1582
+ {.value = -1, .offset = {1, 2}}, // [188]
1583
+ {.value = 123, .offset = {0, 0}}, // [189]:0b111111111111110
1584
+ {.value = -1, .offset = {1, 30}}, // [190]
1585
+ {.value = -1, .offset = {1, 10}}, // [191]
1586
+ {.value = -1, .offset = {1, 4}}, // [192]
1587
+ {.value = -1, .offset = {1, 2}}, // [193]
1588
+ {.value = 92, .offset = {0, 0}}, // [194]:0b1111111111111110000
1589
+ {.value = 195, .offset = {0, 0}}, // [195]:0b1111111111111110001
1590
+ {.value = -1, .offset = {1, 2}}, // [196]
1591
+ {.value = 208, .offset = {0, 0}}, // [197]:0b1111111111111110010
1592
+ {.value = -1, .offset = {1, 2}}, // [198]
1593
+ {.value = 128, .offset = {0, 0}}, // [199]:0b11111111111111100110
1594
+ {.value = 130, .offset = {0, 0}}, // [200]:0b11111111111111100111
1595
+ {.value = -1, .offset = {1, 8}}, // [201]
1596
+ {.value = -1, .offset = {1, 4}}, // [202]
1597
+ {.value = -1, .offset = {1, 2}}, // [203]
1598
+ {.value = 131, .offset = {0, 0}}, // [204]:0b11111111111111101000
1599
+ {.value = 162, .offset = {0, 0}}, // [205]:0b11111111111111101001
1600
+ {.value = -1, .offset = {1, 2}}, // [206]
1601
+ {.value = 184, .offset = {0, 0}}, // [207]:0b11111111111111101010
1602
+ {.value = 194, .offset = {0, 0}}, // [208]:0b11111111111111101011
1603
+ {.value = -1, .offset = {1, 4}}, // [209]
1604
+ {.value = -1, .offset = {1, 2}}, // [210]
1605
+ {.value = 224, .offset = {0, 0}}, // [211]:0b11111111111111101100
1606
+ {.value = 226, .offset = {0, 0}}, // [212]:0b11111111111111101101
1607
+ {.value = -1, .offset = {1, 4}}, // [213]
1608
+ {.value = -1, .offset = {1, 2}}, // [214]
1609
+ {.value = 153, .offset = {0, 0}}, // [215]:0b111111111111111011100
1610
+ {.value = 161, .offset = {0, 0}}, // [216]:0b111111111111111011101
1611
+ {.value = -1, .offset = {1, 2}}, // [217]
1612
+ {.value = 167, .offset = {0, 0}}, // [218]:0b111111111111111011110
1613
+ {.value = 172, .offset = {0, 0}}, // [219]:0b111111111111111011111
1614
+ {.value = -1, .offset = {1, 46}}, // [220]
1615
+ {.value = -1, .offset = {1, 16}}, // [221]
1616
+ {.value = -1, .offset = {1, 8}}, // [222]
1617
+ {.value = -1, .offset = {1, 4}}, // [223]
1618
+ {.value = -1, .offset = {1, 2}}, // [224]
1619
+ {.value = 176, .offset = {0, 0}}, // [225]:0b111111111111111100000
1620
+ {.value = 177, .offset = {0, 0}}, // [226]:0b111111111111111100001
1621
+ {.value = -1, .offset = {1, 2}}, // [227]
1622
+ {.value = 179, .offset = {0, 0}}, // [228]:0b111111111111111100010
1623
+ {.value = 209, .offset = {0, 0}}, // [229]:0b111111111111111100011
1624
+ {.value = -1, .offset = {1, 4}}, // [230]
1625
+ {.value = -1, .offset = {1, 2}}, // [231]
1626
+ {.value = 216, .offset = {0, 0}}, // [232]:0b111111111111111100100
1627
+ {.value = 217, .offset = {0, 0}}, // [233]:0b111111111111111100101
1628
+ {.value = -1, .offset = {1, 2}}, // [234]
1629
+ {.value = 227, .offset = {0, 0}}, // [235]:0b111111111111111100110
1630
+ {.value = 229, .offset = {0, 0}}, // [236]:0b111111111111111100111
1631
+ {.value = -1, .offset = {1, 14}}, // [237]
1632
+ {.value = -1, .offset = {1, 6}}, // [238]
1633
+ {.value = -1, .offset = {1, 2}}, // [239]
1634
+ {.value = 230, .offset = {0, 0}}, // [240]:0b111111111111111101000
1635
+ {.value = -1, .offset = {1, 2}}, // [241]
1636
+ {.value = 129, .offset = {0, 0}}, // [242]:0b1111111111111111010010
1637
+ {.value = 132, .offset = {0, 0}}, // [243]:0b1111111111111111010011
1638
+ {.value = -1, .offset = {1, 4}}, // [244]
1639
+ {.value = -1, .offset = {1, 2}}, // [245]
1640
+ {.value = 133, .offset = {0, 0}}, // [246]:0b1111111111111111010100
1641
+ {.value = 134, .offset = {0, 0}}, // [247]:0b1111111111111111010101
1642
+ {.value = -1, .offset = {1, 2}}, // [248]
1643
+ {.value = 136, .offset = {0, 0}}, // [249]:0b1111111111111111010110
1644
+ {.value = 146, .offset = {0, 0}}, // [250]:0b1111111111111111010111
1645
+ {.value = -1, .offset = {1, 8}}, // [251]
1646
+ {.value = -1, .offset = {1, 4}}, // [252]
1647
+ {.value = -1, .offset = {1, 2}}, // [253]
1648
+ {.value = 154, .offset = {0, 0}}, // [254]:0b1111111111111111011000
1649
+ {.value = 156, .offset = {0, 0}}, // [255]:0b1111111111111111011001
1650
+ {.value = -1, .offset = {1, 2}}, // [256]
1651
+ {.value = 160, .offset = {0, 0}}, // [257]:0b1111111111111111011010
1652
+ {.value = 163, .offset = {0, 0}}, // [258]:0b1111111111111111011011
1653
+ {.value = -1, .offset = {1, 4}}, // [259]
1654
+ {.value = -1, .offset = {1, 2}}, // [260]
1655
+ {.value = 164, .offset = {0, 0}}, // [261]:0b1111111111111111011100
1656
+ {.value = 169, .offset = {0, 0}}, // [262]:0b1111111111111111011101
1657
+ {.value = -1, .offset = {1, 2}}, // [263]
1658
+ {.value = 170, .offset = {0, 0}}, // [264]:0b1111111111111111011110
1659
+ {.value = 173, .offset = {0, 0}}, // [265]:0b1111111111111111011111
1660
+ {.value = -1, .offset = {1, 40}}, // [266]
1661
+ {.value = -1, .offset = {1, 16}}, // [267]
1662
+ {.value = -1, .offset = {1, 8}}, // [268]
1663
+ {.value = -1, .offset = {1, 4}}, // [269]
1664
+ {.value = -1, .offset = {1, 2}}, // [270]
1665
+ {.value = 178, .offset = {0, 0}}, // [271]:0b1111111111111111100000
1666
+ {.value = 181, .offset = {0, 0}}, // [272]:0b1111111111111111100001
1667
+ {.value = -1, .offset = {1, 2}}, // [273]
1668
+ {.value = 185, .offset = {0, 0}}, // [274]:0b1111111111111111100010
1669
+ {.value = 186, .offset = {0, 0}}, // [275]:0b1111111111111111100011
1670
+ {.value = -1, .offset = {1, 4}}, // [276]
1671
+ {.value = -1, .offset = {1, 2}}, // [277]
1672
+ {.value = 187, .offset = {0, 0}}, // [278]:0b1111111111111111100100
1673
+ {.value = 189, .offset = {0, 0}}, // [279]:0b1111111111111111100101
1674
+ {.value = -1, .offset = {1, 2}}, // [280]
1675
+ {.value = 190, .offset = {0, 0}}, // [281]:0b1111111111111111100110
1676
+ {.value = 196, .offset = {0, 0}}, // [282]:0b1111111111111111100111
1677
+ {.value = -1, .offset = {1, 8}}, // [283]
1678
+ {.value = -1, .offset = {1, 4}}, // [284]
1679
+ {.value = -1, .offset = {1, 2}}, // [285]
1680
+ {.value = 198, .offset = {0, 0}}, // [286]:0b1111111111111111101000
1681
+ {.value = 228, .offset = {0, 0}}, // [287]:0b1111111111111111101001
1682
+ {.value = -1, .offset = {1, 2}}, // [288]
1683
+ {.value = 232, .offset = {0, 0}}, // [289]:0b1111111111111111101010
1684
+ {.value = 233, .offset = {0, 0}}, // [290]:0b1111111111111111101011
1685
+ {.value = -1, .offset = {1, 8}}, // [291]
1686
+ {.value = -1, .offset = {1, 4}}, // [292]
1687
+ {.value = -1, .offset = {1, 2}}, // [293]
1688
+ {.value = 1, .offset = {0, 0}}, // [294]:0b11111111111111111011000
1689
+ {.value = 135, .offset = {0, 0}}, // [295]:0b11111111111111111011001
1690
+ {.value = -1, .offset = {1, 2}}, // [296]
1691
+ {.value = 137, .offset = {0, 0}}, // [297]:0b11111111111111111011010
1692
+ {.value = 138, .offset = {0, 0}}, // [298]:0b11111111111111111011011
1693
+ {.value = -1, .offset = {1, 4}}, // [299]
1694
+ {.value = -1, .offset = {1, 2}}, // [300]
1695
+ {.value = 139, .offset = {0, 0}}, // [301]:0b11111111111111111011100
1696
+ {.value = 140, .offset = {0, 0}}, // [302]:0b11111111111111111011101
1697
+ {.value = -1, .offset = {1, 2}}, // [303]
1698
+ {.value = 141, .offset = {0, 0}}, // [304]:0b11111111111111111011110
1699
+ {.value = 143, .offset = {0, 0}}, // [305]:0b11111111111111111011111
1700
+ {.value = -1, .offset = {1, 32}}, // [306]
1701
+ {.value = -1, .offset = {1, 16}}, // [307]
1702
+ {.value = -1, .offset = {1, 8}}, // [308]
1703
+ {.value = -1, .offset = {1, 4}}, // [309]
1704
+ {.value = -1, .offset = {1, 2}}, // [310]
1705
+ {.value = 147, .offset = {0, 0}}, // [311]:0b11111111111111111100000
1706
+ {.value = 149, .offset = {0, 0}}, // [312]:0b11111111111111111100001
1707
+ {.value = -1, .offset = {1, 2}}, // [313]
1708
+ {.value = 150, .offset = {0, 0}}, // [314]:0b11111111111111111100010
1709
+ {.value = 151, .offset = {0, 0}}, // [315]:0b11111111111111111100011
1710
+ {.value = -1, .offset = {1, 4}}, // [316]
1711
+ {.value = -1, .offset = {1, 2}}, // [317]
1712
+ {.value = 152, .offset = {0, 0}}, // [318]:0b11111111111111111100100
1713
+ {.value = 155, .offset = {0, 0}}, // [319]:0b11111111111111111100101
1714
+ {.value = -1, .offset = {1, 2}}, // [320]
1715
+ {.value = 157, .offset = {0, 0}}, // [321]:0b11111111111111111100110
1716
+ {.value = 158, .offset = {0, 0}}, // [322]:0b11111111111111111100111
1717
+ {.value = -1, .offset = {1, 8}}, // [323]
1718
+ {.value = -1, .offset = {1, 4}}, // [324]
1719
+ {.value = -1, .offset = {1, 2}}, // [325]
1720
+ {.value = 165, .offset = {0, 0}}, // [326]:0b11111111111111111101000
1721
+ {.value = 166, .offset = {0, 0}}, // [327]:0b11111111111111111101001
1722
+ {.value = -1, .offset = {1, 2}}, // [328]
1723
+ {.value = 168, .offset = {0, 0}}, // [329]:0b11111111111111111101010
1724
+ {.value = 174, .offset = {0, 0}}, // [330]:0b11111111111111111101011
1725
+ {.value = -1, .offset = {1, 4}}, // [331]
1726
+ {.value = -1, .offset = {1, 2}}, // [332]
1727
+ {.value = 175, .offset = {0, 0}}, // [333]:0b11111111111111111101100
1728
+ {.value = 180, .offset = {0, 0}}, // [334]:0b11111111111111111101101
1729
+ {.value = -1, .offset = {1, 2}}, // [335]
1730
+ {.value = 182, .offset = {0, 0}}, // [336]:0b11111111111111111101110
1731
+ {.value = 183, .offset = {0, 0}}, // [337]:0b11111111111111111101111
1732
+ {.value = -1, .offset = {1, 22}}, // [338]
1733
+ {.value = -1, .offset = {1, 8}}, // [339]
1734
+ {.value = -1, .offset = {1, 4}}, // [340]
1735
+ {.value = -1, .offset = {1, 2}}, // [341]
1736
+ {.value = 188, .offset = {0, 0}}, // [342]:0b11111111111111111110000
1737
+ {.value = 191, .offset = {0, 0}}, // [343]:0b11111111111111111110001
1738
+ {.value = -1, .offset = {1, 2}}, // [344]
1739
+ {.value = 197, .offset = {0, 0}}, // [345]:0b11111111111111111110010
1740
+ {.value = 231, .offset = {0, 0}}, // [346]:0b11111111111111111110011
1741
+ {.value = -1, .offset = {1, 6}}, // [347]
1742
+ {.value = -1, .offset = {1, 2}}, // [348]
1743
+ {.value = 239, .offset = {0, 0}}, // [349]:0b11111111111111111110100
1744
+ {.value = -1, .offset = {1, 2}}, // [350]
1745
+ {.value = 9, .offset = {0, 0}}, // [351]:0b111111111111111111101010
1746
+ {.value = 142, .offset = {0, 0}}, // [352]:0b111111111111111111101011
1747
+ {.value = -1, .offset = {1, 4}}, // [353]
1748
+ {.value = -1, .offset = {1, 2}}, // [354]
1749
+ {.value = 144, .offset = {0, 0}}, // [355]:0b111111111111111111101100
1750
+ {.value = 145, .offset = {0, 0}}, // [356]:0b111111111111111111101101
1751
+ {.value = -1, .offset = {1, 2}}, // [357]
1752
+ {.value = 148, .offset = {0, 0}}, // [358]:0b111111111111111111101110
1753
+ {.value = 159, .offset = {0, 0}}, // [359]:0b111111111111111111101111
1754
+ {.value = -1, .offset = {1, 20}}, // [360]
1755
+ {.value = -1, .offset = {1, 8}}, // [361]
1756
+ {.value = -1, .offset = {1, 4}}, // [362]
1757
+ {.value = -1, .offset = {1, 2}}, // [363]
1758
+ {.value = 171, .offset = {0, 0}}, // [364]:0b111111111111111111110000
1759
+ {.value = 206, .offset = {0, 0}}, // [365]:0b111111111111111111110001
1760
+ {.value = -1, .offset = {1, 2}}, // [366]
1761
+ {.value = 215, .offset = {0, 0}}, // [367]:0b111111111111111111110010
1762
+ {.value = 225, .offset = {0, 0}}, // [368]:0b111111111111111111110011
1763
+ {.value = -1, .offset = {1, 4}}, // [369]
1764
+ {.value = -1, .offset = {1, 2}}, // [370]
1765
+ {.value = 236, .offset = {0, 0}}, // [371]:0b111111111111111111110100
1766
+ {.value = 237, .offset = {0, 0}}, // [372]:0b111111111111111111110101
1767
+ {.value = -1, .offset = {1, 4}}, // [373]
1768
+ {.value = -1, .offset = {1, 2}}, // [374]
1769
+ {.value = 199, .offset = {0, 0}}, // [375]:0b1111111111111111111101100
1770
+ {.value = 207, .offset = {0, 0}}, // [376]:0b1111111111111111111101101
1771
+ {.value = -1, .offset = {1, 2}}, // [377]
1772
+ {.value = 234, .offset = {0, 0}}, // [378]:0b1111111111111111111101110
1773
+ {.value = 235, .offset = {0, 0}}, // [379]:0b1111111111111111111101111
1774
+ {.value = -1, .offset = {1, 34}}, // [380]
1775
+ {.value = -1, .offset = {1, 16}}, // [381]
1776
+ {.value = -1, .offset = {1, 8}}, // [382]
1777
+ {.value = -1, .offset = {1, 4}}, // [383]
1778
+ {.value = -1, .offset = {1, 2}}, // [384]
1779
+ {.value = 192, .offset = {0, 0}}, // [385]:0b11111111111111111111100000
1780
+ {.value = 193, .offset = {0, 0}}, // [386]:0b11111111111111111111100001
1781
+ {.value = -1, .offset = {1, 2}}, // [387]
1782
+ {.value = 200, .offset = {0, 0}}, // [388]:0b11111111111111111111100010
1783
+ {.value = 201, .offset = {0, 0}}, // [389]:0b11111111111111111111100011
1784
+ {.value = -1, .offset = {1, 4}}, // [390]
1785
+ {.value = -1, .offset = {1, 2}}, // [391]
1786
+ {.value = 202, .offset = {0, 0}}, // [392]:0b11111111111111111111100100
1787
+ {.value = 205, .offset = {0, 0}}, // [393]:0b11111111111111111111100101
1788
+ {.value = -1, .offset = {1, 2}}, // [394]
1789
+ {.value = 210, .offset = {0, 0}}, // [395]:0b11111111111111111111100110
1790
+ {.value = 213, .offset = {0, 0}}, // [396]:0b11111111111111111111100111
1791
+ {.value = -1, .offset = {1, 8}}, // [397]
1792
+ {.value = -1, .offset = {1, 4}}, // [398]
1793
+ {.value = -1, .offset = {1, 2}}, // [399]
1794
+ {.value = 218, .offset = {0, 0}}, // [400]:0b11111111111111111111101000
1795
+ {.value = 219, .offset = {0, 0}}, // [401]:0b11111111111111111111101001
1796
+ {.value = -1, .offset = {1, 2}}, // [402]
1797
+ {.value = 238, .offset = {0, 0}}, // [403]:0b11111111111111111111101010
1798
+ {.value = 240, .offset = {0, 0}}, // [404]:0b11111111111111111111101011
1799
+ {.value = -1, .offset = {1, 4}}, // [405]
1800
+ {.value = -1, .offset = {1, 2}}, // [406]
1801
+ {.value = 242, .offset = {0, 0}}, // [407]:0b11111111111111111111101100
1802
+ {.value = 243, .offset = {0, 0}}, // [408]:0b11111111111111111111101101
1803
+ {.value = -1, .offset = {1, 2}}, // [409]
1804
+ {.value = 255, .offset = {0, 0}}, // [410]:0b11111111111111111111101110
1805
+ {.value = -1, .offset = {1, 2}}, // [411]
1806
+ {.value = 203, .offset = {0, 0}}, // [412]:0b111111111111111111111011110
1807
+ {.value = 204, .offset = {0, 0}}, // [413]:0b111111111111111111111011111
1808
+ {.value = -1, .offset = {1, 32}}, // [414]
1809
+ {.value = -1, .offset = {1, 16}}, // [415]
1810
+ {.value = -1, .offset = {1, 8}}, // [416]
1811
+ {.value = -1, .offset = {1, 4}}, // [417]
1812
+ {.value = -1, .offset = {1, 2}}, // [418]
1813
+ {.value = 211, .offset = {0, 0}}, // [419]:0b111111111111111111111100000
1814
+ {.value = 212, .offset = {0, 0}}, // [420]:0b111111111111111111111100001
1815
+ {.value = -1, .offset = {1, 2}}, // [421]
1816
+ {.value = 214, .offset = {0, 0}}, // [422]:0b111111111111111111111100010
1817
+ {.value = 221, .offset = {0, 0}}, // [423]:0b111111111111111111111100011
1818
+ {.value = -1, .offset = {1, 4}}, // [424]
1819
+ {.value = -1, .offset = {1, 2}}, // [425]
1820
+ {.value = 222, .offset = {0, 0}}, // [426]:0b111111111111111111111100100
1821
+ {.value = 223, .offset = {0, 0}}, // [427]:0b111111111111111111111100101
1822
+ {.value = -1, .offset = {1, 2}}, // [428]
1823
+ {.value = 241, .offset = {0, 0}}, // [429]:0b111111111111111111111100110
1824
+ {.value = 244, .offset = {0, 0}}, // [430]:0b111111111111111111111100111
1825
+ {.value = -1, .offset = {1, 8}}, // [431]
1826
+ {.value = -1, .offset = {1, 4}}, // [432]
1827
+ {.value = -1, .offset = {1, 2}}, // [433]
1828
+ {.value = 245, .offset = {0, 0}}, // [434]:0b111111111111111111111101000
1829
+ {.value = 246, .offset = {0, 0}}, // [435]:0b111111111111111111111101001
1830
+ {.value = -1, .offset = {1, 2}}, // [436]
1831
+ {.value = 247, .offset = {0, 0}}, // [437]:0b111111111111111111111101010
1832
+ {.value = 248, .offset = {0, 0}}, // [438]:0b111111111111111111111101011
1833
+ {.value = -1, .offset = {1, 4}}, // [439]
1834
+ {.value = -1, .offset = {1, 2}}, // [440]
1835
+ {.value = 250, .offset = {0, 0}}, // [441]:0b111111111111111111111101100
1836
+ {.value = 251, .offset = {0, 0}}, // [442]:0b111111111111111111111101101
1837
+ {.value = -1, .offset = {1, 2}}, // [443]
1838
+ {.value = 252, .offset = {0, 0}}, // [444]:0b111111111111111111111101110
1839
+ {.value = 253, .offset = {0, 0}}, // [445]:0b111111111111111111111101111
1840
+ {.value = -1, .offset = {1, 30}}, // [446]
1841
+ {.value = -1, .offset = {1, 14}}, // [447]
1842
+ {.value = -1, .offset = {1, 6}}, // [448]
1843
+ {.value = -1, .offset = {1, 2}}, // [449]
1844
+ {.value = 254, .offset = {0, 0}}, // [450]:0b111111111111111111111110000
1845
+ {.value = -1, .offset = {1, 2}}, // [451]
1846
+ {.value = 2, .offset = {0, 0}}, // [452]:0b1111111111111111111111100010
1847
+ {.value = 3, .offset = {0, 0}}, // [453]:0b1111111111111111111111100011
1848
+ {.value = -1, .offset = {1, 4}}, // [454]
1849
+ {.value = -1, .offset = {1, 2}}, // [455]
1850
+ {.value = 4, .offset = {0, 0}}, // [456]:0b1111111111111111111111100100
1851
+ {.value = 5, .offset = {0, 0}}, // [457]:0b1111111111111111111111100101
1852
+ {.value = -1, .offset = {1, 2}}, // [458]
1853
+ {.value = 6, .offset = {0, 0}}, // [459]:0b1111111111111111111111100110
1854
+ {.value = 7, .offset = {0, 0}}, // [460]:0b1111111111111111111111100111
1855
+ {.value = -1, .offset = {1, 8}}, // [461]
1856
+ {.value = -1, .offset = {1, 4}}, // [462]
1857
+ {.value = -1, .offset = {1, 2}}, // [463]
1858
+ {.value = 8, .offset = {0, 0}}, // [464]:0b1111111111111111111111101000
1859
+ {.value = 11, .offset = {0, 0}}, // [465]:0b1111111111111111111111101001
1860
+ {.value = -1, .offset = {1, 2}}, // [466]
1861
+ {.value = 12, .offset = {0, 0}}, // [467]:0b1111111111111111111111101010
1862
+ {.value = 14, .offset = {0, 0}}, // [468]:0b1111111111111111111111101011
1863
+ {.value = -1, .offset = {1, 4}}, // [469]
1864
+ {.value = -1, .offset = {1, 2}}, // [470]
1865
+ {.value = 15, .offset = {0, 0}}, // [471]:0b1111111111111111111111101100
1866
+ {.value = 16, .offset = {0, 0}}, // [472]:0b1111111111111111111111101101
1867
+ {.value = -1, .offset = {1, 2}}, // [473]
1868
+ {.value = 17, .offset = {0, 0}}, // [474]:0b1111111111111111111111101110
1869
+ {.value = 18, .offset = {0, 0}}, // [475]:0b1111111111111111111111101111
1870
+ {.value = -1, .offset = {1, 16}}, // [476]
1871
+ {.value = -1, .offset = {1, 8}}, // [477]
1872
+ {.value = -1, .offset = {1, 4}}, // [478]
1873
+ {.value = -1, .offset = {1, 2}}, // [479]
1874
+ {.value = 19, .offset = {0, 0}}, // [480]:0b1111111111111111111111110000
1875
+ {.value = 20, .offset = {0, 0}}, // [481]:0b1111111111111111111111110001
1876
+ {.value = -1, .offset = {1, 2}}, // [482]
1877
+ {.value = 21, .offset = {0, 0}}, // [483]:0b1111111111111111111111110010
1878
+ {.value = 23, .offset = {0, 0}}, // [484]:0b1111111111111111111111110011
1879
+ {.value = -1, .offset = {1, 4}}, // [485]
1880
+ {.value = -1, .offset = {1, 2}}, // [486]
1881
+ {.value = 24, .offset = {0, 0}}, // [487]:0b1111111111111111111111110100
1882
+ {.value = 25, .offset = {0, 0}}, // [488]:0b1111111111111111111111110101
1883
+ {.value = -1, .offset = {1, 2}}, // [489]
1884
+ {.value = 26, .offset = {0, 0}}, // [490]:0b1111111111111111111111110110
1885
+ {.value = 27, .offset = {0, 0}}, // [491]:0b1111111111111111111111110111
1886
+ {.value = -1, .offset = {1, 8}}, // [492]
1887
+ {.value = -1, .offset = {1, 4}}, // [493]
1888
+ {.value = -1, .offset = {1, 2}}, // [494]
1889
+ {.value = 28, .offset = {0, 0}}, // [495]:0b1111111111111111111111111000
1890
+ {.value = 29, .offset = {0, 0}}, // [496]:0b1111111111111111111111111001
1891
+ {.value = -1, .offset = {1, 2}}, // [497]
1892
+ {.value = 30, .offset = {0, 0}}, // [498]:0b1111111111111111111111111010
1893
+ {.value = 31, .offset = {0, 0}}, // [499]:0b1111111111111111111111111011
1894
+ {.value = -1, .offset = {1, 4}}, // [500]
1895
+ {.value = -1, .offset = {1, 2}}, // [501]
1896
+ {.value = 127, .offset = {0, 0}}, // [502]:0b1111111111111111111111111100
1897
+ {.value = 220, .offset = {0, 0}}, // [503]:0b1111111111111111111111111101
1898
+ {.value = -1, .offset = {1, 2}}, // [504]
1899
+ {.value = 249, .offset = {0, 0}}, // [505]:0b1111111111111111111111111110
1900
+ {.value = -1, .offset = {1, 4}}, // [506]
1901
+ {.value = -1, .offset = {1, 2}}, // [507]
1902
+ {.value = 10, .offset = {0, 0}}, // [508]:0b111111111111111111111111111100
1903
+ {.value = 13, .offset = {0, 0}}, // [509]:0b111111111111111111111111111101
1904
+ {.value = -1, .offset = {1, 2}}, // [510]
1905
+ {.value = 22, .offset = {0, 0}}, // [511]:0b111111111111111111111111111110
1906
+ {.value = 256, .offset = {0, 0}}, // [512]:0b111111111111111111111111111111
1907
+ };
1908
+
1909
+ /* *****************************************************************************
1910
+
1911
+
1912
+
1913
+
1914
+
1915
+ Don't overwrite this
1916
+
1917
+
1918
+
1919
+
1920
+
1921
+ ***************************************************************************** */
1922
+
1923
+ #endif /* H_HPACK_H */