3 # Copyright 2021, João Valverde <j@v6e.pt>
5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 1998 Gerald Combs
9 # SPDX-License-Identifier: GPL-2.0-or-later
12 # Uses pyclibrary to parse C headers for enums and integer macro
13 # definitions. Exports that data to a C file for the introspection API.
15 # Requires: https://github.com/MatthieuDartiailh/pyclibrary
21 from pyclibrary
import CParser
23 def parse_files(infiles
, outfile
):
25 print("Input: {}".format(infiles
))
26 print("Output: '{}'".format(outfile
))
28 parser
= CParser(infiles
)
32 * Wireshark - Network traffic analyzer
33 * By Gerald Combs <gerald@wireshark.org>
34 * Copyright 1998 Gerald Combs
36 * SPDX-License-Identifier: GPL-2.0-or-later
38 * Generated automatically from %s. It can be re-created by running
39 * "tools/make-enums.py" from the top source directory.
41 * It is fine to edit this file by hand. Particularly if a symbol
42 * disappears from the API it can just be removed here. There is no
43 * requirement to re-run the generator script.
46 """ % (os
.path
.basename(sys
.argv
[0]))
49 source
+= '#include <{}>\n'.format(f
)
52 #define ENUM(arg) { #arg, arg }
54 static ws_enum_t const all_enums[] = {
57 definitions
= parser
.defs
['values']
58 symbols
= list(definitions
.keys())
62 if isinstance(definitions
[s
], int):
63 source
+= ' ENUM({}),\n'.format(s
)
71 fh
= open(outfile
, 'w')
73 sys
.exit('Unable to write ' + outfile
+ '.\n')
82 "epan/ftypes/ftypes.h",
85 parse_files(epan_files
, "epan/introspection-enums.c")
90 parse_files(wtap_files
, "wiretap/introspection-enums.c")
93 # Editor modelines - https://www.wireshark.org/tools/modelines.html
97 # indent-tabs-mode: nil
100 # vi: set shiftwidth=4 expandtab:
101 # :indentSize=4:noTabs=true: