Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
79a4f789
Unverified
Commit
79a4f789
authored
Dec 29, 2020
by
Tatsuhiro Tsujikawa
Committed by
GitHub
Dec 29, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1546 from nghttp2/py3-scripts
Python3 development scripts
parents
46536729
28ba0b37
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
115 additions
and
121 deletions
+115
-121
author.py
author.py
+2
-2
genauthoritychartbl.py
genauthoritychartbl.py
+1
-1
gendowncasetbl.py
gendowncasetbl.py
+1
-1
genheaderfunc.py
genheaderfunc.py
+1
-1
genlibtokenlookup.py
genlibtokenlookup.py
+22
-22
genmethodfunc.py
genmethodfunc.py
+1
-2
gennghttpxfun.py
gennghttpxfun.py
+1
-1
gennmchartbl.py
gennmchartbl.py
+1
-1
gentokenlookup.py
gentokenlookup.py
+24
-24
genvchartbl.py
genvchartbl.py
+1
-1
help2rst.py
help2rst.py
+1
-3
mkcipherlist.py
mkcipherlist.py
+11
-12
mkhufftbl.py
mkhufftbl.py
+42
-43
mkstatichdtbl.py
mkstatichdtbl.py
+6
-7
No files found.
author.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
# script to extract commit author's name from standard input. The
# input should be <AUTHOR>:<EMAIL>, one per line.
...
...
@@ -49,4 +49,4 @@ for name in names:
ndict
[
lowname
]
=
name
for
name
in
sorted
(
ndict
.
values
()):
print
name
print
(
name
)
genauthoritychartbl.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
import
sys
def
name
(
i
):
...
...
gendowncasetbl.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
import
sys
def
name
(
i
):
...
...
genheaderfunc.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
from
gentokenlookup
import
gentokenlookup
...
...
genlibtokenlookup.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
HEADERS
=
[
(
':authority'
,
0
),
...
...
@@ -96,47 +96,47 @@ def build_header(headers):
def
gen_enum
():
name
=
''
print
'typedef enum {'
print
(
'typedef enum {'
)
for
k
,
token
in
HEADERS
:
if
token
is
None
:
print
' {},'
.
format
(
to_enum_hd
(
k
))
print
(
' {},'
.
format
(
to_enum_hd
(
k
)
))
else
:
if
name
!=
k
:
name
=
k
print
' {} = {},'
.
format
(
to_enum_hd
(
k
),
token
)
print
'} nghttp2_token;'
print
(
' {} = {},'
.
format
(
to_enum_hd
(
k
),
token
)
)
print
(
'} nghttp2_token;'
)
def
gen_index_header
():
print
'''
\
print
(
'''
\
static int32_t lookup_token(const uint8_t *name, size_t namelen) {
switch (namelen) {'''
switch (namelen) {'''
)
b
=
build_header
(
HEADERS
)
for
size
in
sorted
(
b
.
keys
()):
ents
=
b
[
size
]
print
'''
\
case {}:'''
.
format
(
size
)
print
'''
\
switch (name[{}]) {{'''
.
format
(
size
-
1
)
print
(
'''
\
case {}:'''
.
format
(
size
)
)
print
(
'''
\
switch (name[{}]) {{'''
.
format
(
size
-
1
)
)
for
c
in
sorted
(
ents
.
keys
()):
headers
=
sorted
(
ents
[
c
])
print
'''
\
case '{}':'''
.
format
(
c
)
print
(
'''
\
case '{}':'''
.
format
(
c
)
)
for
k
in
headers
:
print
'''
\
print
(
'''
\
if (memeq("{}", name, {})) {{
return {};
}}'''
.
format
(
k
[:
-
1
],
size
-
1
,
to_enum_hd
(
k
))
print
'''
\
break;'''
print
'''
\
}}'''
.
format
(
k
[:
-
1
],
size
-
1
,
to_enum_hd
(
k
))
)
print
(
'''
\
break;'''
)
print
(
'''
\
}
break;'''
print
'''
\
break;'''
)
print
(
'''
\
}
return -1;
}'''
}'''
)
if
__name__
==
'__main__'
:
gen_enum
()
print
''
print
()
gen_index_header
()
genmethodfunc.py
View file @
79a4f789
#!/usr/bin/env python
from
__future__
import
unicode_literals
#!/usr/bin/env python3
from
io
import
StringIO
from
gentokenlookup
import
gentokenlookup
...
...
gennghttpxfun.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
from
gentokenlookup
import
gentokenlookup
...
...
gennmchartbl.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
import
sys
def
name
(
i
):
...
...
gentokenlookup.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
def
to_enum_hd
(
k
,
prefix
):
res
=
prefix
...
...
@@ -24,46 +24,46 @@ def build_header(headers):
return
res
def
gen_enum
(
tokens
,
prefix
):
print
'''
\
enum {'''
print
(
'''
\
enum {'''
)
for
k
in
sorted
(
tokens
):
print
'''
\
{},'''
.
format
(
to_enum_hd
(
k
,
prefix
))
print
'''
\
print
(
'''
\
{},'''
.
format
(
to_enum_hd
(
k
,
prefix
))
)
print
(
'''
\
{}MAXIDX,
}};'''
.
format
(
prefix
)
}};'''
.
format
(
prefix
)
)
def
gen_index_header
(
tokens
,
prefix
,
value_type
,
comp_fun
,
return_type
,
fail_value
):
print
'''
\
print
(
'''
\
{} lookup_token(const {} *name, size_t namelen) {{
switch (namelen) {{'''
.
format
(
return_type
,
value_type
)
switch (namelen) {{'''
.
format
(
return_type
,
value_type
)
)
b
=
build_header
(
tokens
)
for
size
in
sorted
(
b
.
keys
()):
ents
=
b
[
size
]
print
'''
\
case {}:'''
.
format
(
size
)
print
'''
\
switch (name[{}]) {{'''
.
format
(
size
-
1
)
print
(
'''
\
case {}:'''
.
format
(
size
)
)
print
(
'''
\
switch (name[{}]) {{'''
.
format
(
size
-
1
)
)
for
c
in
sorted
(
ents
.
keys
()):
headers
=
sorted
(
ents
[
c
])
print
'''
\
case '{}':'''
.
format
(
c
)
print
(
'''
\
case '{}':'''
.
format
(
c
)
)
for
k
in
headers
:
print
'''
\
print
(
'''
\
if ({}("{}", name, {})) {{
return {};
}}'''
.
format
(
comp_fun
,
k
[:
-
1
],
size
-
1
,
to_enum_hd
(
k
,
prefix
))
print
'''
\
break;'''
print
'''
\
}}'''
.
format
(
comp_fun
,
k
[:
-
1
],
size
-
1
,
to_enum_hd
(
k
,
prefix
))
)
print
(
'''
\
break;'''
)
print
(
'''
\
}
break;'''
print
'''
\
break;'''
)
print
(
'''
\
}}
return {};
}}'''
.
format
(
fail_value
)
}}'''
.
format
(
fail_value
)
)
def
gentokenlookup
(
tokens
,
prefix
,
value_type
=
'uint8_t'
,
comp_fun
=
'util::streq_l'
,
return_type
=
'int'
,
fail_value
=
'-1'
):
gen_enum
(
tokens
,
prefix
)
print
''
print
()
gen_index_header
(
tokens
,
prefix
,
value_type
,
comp_fun
,
return_type
,
fail_value
)
genvchartbl.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
import
sys
def
name
(
i
):
...
...
help2rst.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
# -*- coding: utf-8 -*-
# script to produce rst file from program's help output.
from
__future__
import
unicode_literals
from
__future__
import
print_function
import
sys
import
re
import
argparse
...
...
mkcipherlist.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
# -*- coding: utf-8 -*-
# This script read cipher suite list csv file [1] and prints out id
...
...
@@ -8,7 +8,6 @@
# [1] http://www.iana.org/assignments/tls-parameters/tls-parameters-4.csv
# [2] http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml
from
__future__
import
unicode_literals
import
re
import
sys
import
csv
...
...
@@ -295,7 +294,7 @@ blacklist = [
ciphers
=
[]
found
=
set
()
for
hl
,
name
,
_
,
_
in
csv
.
reader
(
sys
.
stdin
):
for
hl
,
name
,
_
,
_
,
_
in
csv
.
reader
(
sys
.
stdin
):
if
name
not
in
blacklist
:
continue
...
...
@@ -306,21 +305,21 @@ for hl, name, _, _ in csv.reader(sys.stdin):
id
=
high
+
low
[
2
:]
+
'u'
ciphers
.
append
((
id
,
name
))
print
'''
\
enum {'''
print
(
'''
\
enum {'''
)
for
id
,
name
in
ciphers
:
print
'{} = {},'
.
format
(
name
,
id
)
print
(
'{} = {},'
.
format
(
name
,
id
)
)
print
'''
\
print
(
'''
\
};
'''
'''
)
for
id
,
name
in
ciphers
:
print
'''
\
case {}:'''
.
format
(
name
)
print
(
'''
\
case {}:'''
.
format
(
name
)
)
if
len
(
found
)
!=
len
(
blacklist
):
print
'{} found out of {}; not all cipher was found: {}'
.
format
(
print
(
'{} found out of {}; not all cipher was found: {}'
.
format
(
len
(
found
),
len
(
blacklist
),
found
.
symmetric_difference
(
blacklist
))
found
.
symmetric_difference
(
blacklist
))
)
mkhufftbl.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
# -*- coding: utf-8 -*-
# This script reads Huffman Code table [1] and generates symbol table
# and decoding tables in C language. The resulting code is used in
# lib/nghttp2_hd_huffman.h and lib/nghttp2_hd_huffman_data.c
#
# [1] http
://http2.github.io/http2-spec/compression
.html
# [1] http
s://httpwg.org/specs/rfc7541
.html
from
__future__
import
unicode_literals
import
re
import
sys
import
StringIO
from
io
import
StringIO
# From [1]
HUFFMAN_CODE_TABLE
=
"""
\
...
...
@@ -363,8 +362,8 @@ NGHTTP2_HUFF_SYM = 1 << 15
def
_print_transition_table
(
node
):
if
node
.
term
is
not
None
:
return
print
'/* {} */'
.
format
(
node
.
id
)
print
'{'
print
(
'/* {} */'
.
format
(
node
.
id
)
)
print
(
'{'
)
for
nd
,
sym
in
node
.
trans
:
flags
=
0
if
sym
is
None
:
...
...
@@ -382,38 +381,38 @@ def _print_transition_table(node):
flags
|=
NGHTTP2_HUFF_ACCEPTED
elif
nd
.
accept
:
flags
|=
NGHTTP2_HUFF_ACCEPTED
print
' {{0x{:02x}, {}}},'
.
format
(
id
|
flags
,
out
)
print
'},'
print
(
' {{0x{:02x}, {}}},'
.
format
(
id
|
flags
,
out
)
)
print
(
'},'
)
_print_transition_table
(
node
.
left
)
_print_transition_table
(
node
.
right
)
def
huffman_tree_print_transition_table
(
ctx
):
_print_transition_table
(
ctx
.
root
)
print
'/* 256 */'
print
'{'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
' {0x100, 0},'
print
'},'
print
(
'/* 256 */'
)
print
(
'{'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
' {0x100, 0},'
)
print
(
'},'
)
if
__name__
==
'__main__'
:
ctx
=
Context
()
symbol_tbl
=
[(
None
,
0
)
for
i
in
range
(
257
)]
for
line
in
StringIO
.
StringIO
(
HUFFMAN_CODE_TABLE
):
for
line
in
StringIO
(
HUFFMAN_CODE_TABLE
):
m
=
re
.
match
(
r'.*\(\s*(\d+)\)\s+([|01]+)\s+(\S+)\s+\[\s*(\d+)\].*'
,
line
)
if
m
:
...
...
@@ -430,40 +429,40 @@ if __name__ == '__main__':
huffman_tree_set_node_id
(
ctx
)
huffman_tree_build_transition_table
(
ctx
)
print
'''
\
print
(
'''
\
typedef struct {
uint32_t nbits;
uint32_t code;
} nghttp2_huff_sym;
'''
'''
)
print
'''
\
const nghttp2_huff_sym huff_sym_table[] = {'''
print
(
'''
\
const nghttp2_huff_sym huff_sym_table[] = {'''
)
for
i
in
range
(
257
):
nbits
=
symbol_tbl
[
i
][
0
]
k
=
int
(
symbol_tbl
[
i
][
1
],
16
)
k
=
k
<<
(
32
-
nbits
)
print
'''
\
print
(
'''
\
{{ {}, 0x{}u }}{}
\
'''
.
format
(
symbol_tbl
[
i
][
0
],
hex
(
k
)[
2
:],
','
if
i
<
256
else
''
)
print
'};'
print
''
'''
.
format
(
symbol_tbl
[
i
][
0
],
hex
(
k
)[
2
:],
','
if
i
<
256
else
''
)
)
print
(
'};'
)
print
()
print
'''
\
print
(
'''
\
enum {{
NGHTTP2_HUFF_ACCEPTED = {},
NGHTTP2_HUFF_SYM = {},
}} nghttp2_huff_decode_flag;
'''
.
format
(
NGHTTP2_HUFF_ACCEPTED
,
NGHTTP2_HUFF_SYM
)
'''
.
format
(
NGHTTP2_HUFF_ACCEPTED
,
NGHTTP2_HUFF_SYM
)
)
print
'''
\
print
(
'''
\
typedef struct {
uint16_t fstate;
uint8_t sym;
} nghttp2_huff_decode;
'''
'''
)
print
'''
\
const nghttp2_huff_decode huff_decode_table[][16] = {'''
print
(
'''
\
const nghttp2_huff_decode huff_decode_table[][16] = {'''
)
huffman_tree_print_transition_table
(
ctx
)
print
'};'
print
(
'};'
)
mkstatichdtbl.py
View file @
79a4f789
#!/usr/bin/env python
#!/usr/bin/env python
3
# -*- 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
# [1] http
s://httpwg.org/specs/rfc7541
.html
from
__future__
import
unicode_literals
import
re
,
sys
def
hd_map_hash
(
name
):
...
...
@@ -27,11 +26,11 @@ for line in sys.stdin:
val
=
m
.
group
(
3
).
strip
()
if
m
.
group
(
3
)
else
''
entries
.
append
((
int
(
m
.
group
(
1
)),
m
.
group
(
2
),
val
))
print
'static nghttp2_hd_entry static_table[] = {'
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("{}", "{}", {}, {}u),'
\
.
format
(
ent
[
1
],
ent
[
2
],
entries
[
idx
][
0
]
-
1
,
hd_map_hash
(
ent
[
1
]))
print
'};'
print
(
'MAKE_STATIC_ENT("{}", "{}", {}, {}u),'
\
.
format
(
ent
[
1
],
ent
[
2
],
entries
[
idx
][
0
]
-
1
,
hd_map_hash
(
ent
[
1
]))
)
print
(
'};'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment