1:255.13-alt1
[systemd_ALT.git] / src / resolve / generate-dns_type-gperf.py
blob0d818fb3d97c841095279e247011c3e126b378bc
1 #!/usr/bin/env python3
2 # SPDX-License-Identifier: LGPL-2.1-or-later
4 """Generate %-from-name.gperf from %-list.txt
5 """
7 import sys
9 name, prefix, input = sys.argv[1:]
11 print("""\
13 #if __GNUC__ >= 7
14 _Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
15 #endif
16 %}""")
17 print("""\
18 struct {}_name {{ const char* name; int id; }};
19 %null-strings
20 %%""".format(name))
22 for line in open(input):
23 line = line.rstrip()
24 s = line.replace('_', '-')
25 print("{}, {}{}".format(s, prefix, line))