Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 # This script exists to auto-generate Http2HuffmanOutgoing.h from the table
2 # contained in the HPACK spec. It's pretty simple to run:
3 # python make_outgoing_tables.py < http2_huffman_table.txt > Http2HuffmanOutgoing.h
4 # where huff_outgoing.txt is copy/pasted text from the latest version of the
5 # HPACK spec, with all non-relevant lines removed (the most recent version
6 # of huff_outgoing.txt also lives in this directory as an example).
7 import sys
9 sys.stdout.write('''/*
10 * THIS FILE IS AUTO-GENERATED. DO NOT EDIT!
11 */
12 #ifndef mozilla__net__Http2HuffmanOutgoing_h
13 #define mozilla__net__Http2HuffmanOutgoing_h
15 namespace mozilla {
16 namespace net {
18 struct HuffmanOutgoingEntry {
19 uint32_t mValue;
20 uint8_t mLength;
21 };
23 static HuffmanOutgoingEntry HuffmanOutgoing[] = {
24 ''')
26 entries = []
27 for line in sys.stdin:
28 line = line.strip()
29 obracket = line.rfind('[')
30 nbits = int(line[obracket + 1:-1])
32 encend = obracket - 1
33 hexits = nbits / 4
34 if hexits * 4 != nbits:
35 hexits += 1
37 enc = line[encend - hexits:encend]
38 val = int(enc, 16)
40 entries.append({'length': nbits, 'value': val})
42 line = []
43 for i, e in enumerate(entries):
44 sys.stdout.write(' { 0x%08x, %s }' %
45 (e['value'], e['length']))
46 if i < (len(entries) - 1):
47 sys.stdout.write(',')
48 sys.stdout.write('\n')
50 sys.stdout.write('''};
52 } // namespace net
53 } // namespace mozilla
55 #endif // mozilla__net__Http2HuffmanOutgoing_h
56 ''')