2013-10-15 18:23:10 +02:00
|
|
|
#!/usr/bin/env python
|
2014-10-25 11:12:49 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# This scripts reads static table entries [1] and generates
|
|
|
|
# nghttp2_hd_static_entry table. This table is used in
|
|
|
|
# lib/nghttp2_hd.c.
|
|
|
|
#
|
|
|
|
# [1] http://http2.github.io/http2-spec/compression.html
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
2013-10-15 18:23:10 +02:00
|
|
|
import re, sys
|
|
|
|
|
2014-01-07 15:41:09 +01:00
|
|
|
entries = []
|
2013-10-15 18:23:10 +02:00
|
|
|
for line in sys.stdin:
|
2014-06-14 15:24:47 +02:00
|
|
|
m = re.match(r'(\d+)\s+(\S+)\s+(\S.*)?', line)
|
|
|
|
val = m.group(3).strip() if m.group(3) else ''
|
2015-04-15 15:32:11 +02:00
|
|
|
entries.append((int(m.group(1)), m.group(2), val))
|
|
|
|
|
|
|
|
print 'static nghttp2_hd_entry static_table[] = {'
|
|
|
|
idx = 0
|
|
|
|
for i, ent in enumerate(entries):
|
|
|
|
if entries[idx][1] != ent[1]:
|
|
|
|
idx = i
|
|
|
|
print 'MAKE_STATIC_ENT("{}", "{}", {}),'\
|
|
|
|
.format(ent[1], ent[2], entries[idx][0] - 1)
|
2014-01-07 15:41:09 +01:00
|
|
|
print '};'
|