8 # generate files for the windows plugin interface from a file with declarations
10 # The input for this script is generated by gcc using the following command:
12 # gcc -aux-info xyzzy $(pkg-config --cflags glib-2.0) -I ethereal-0.9.13 -c plugin_api_list.c
14 # this gives one declaration per line, with consistent spacing.
16 # with a much more elaborate parser than the one RE we have now, we could do without gcc.
19 """Ethereal Windows interface generator."""
21 import sys, string, os, re
22 from string import strip, replace
24 pattFile = re.compile('.*plugin_api_list.* extern (.*)') # match filename and select declaration
25 pattName = re.compile('\w* .*?(\w*) \(.*') # select function name
28 file = open(sys.argv[1], 'r') # input name on command line
30 file = sys.stdin # read from a stream
32 f2 = open("Xplugin_api.h", 'w') # defines to hide indirection
33 f3 = open("Xplugin_api.c", 'w') # statements to copy addresses from structure
34 f4 = open("Xplugin_api_decls.h", 'w') # pointer definitions
35 f5 = open("Xplugin_table.h", 'w') # type definitions
36 f6 = open("Xass-list", 'w'); # exported structure initialization
38 comment = "/* This file is generated by %s, do not edit. */\n\n" % sys.argv[0]
48 line = file.readline()
50 matchobj = pattFile.match(line)
52 # print "+", count, " ", strip(line)
53 decl = matchobj.group(1)
55 matchobj = pattName.match(decl)
58 name = matchobj.group(1)
60 f2.write("#define %s (*p_%s)\n" % (name, name))
61 f3.write("p_%s = pat->p_%s;\n" % (name, name))
62 f4.write("addr_%s p_%s;\n" % (name, name))
63 f5.write(replace("typedef %s\n" % decl, name, "(*addr_%s)" % name))
65 pos = pos + len(name) + 2
72 print '**** function name not fount in "%s"' % decl
76 print "%d symbols exported" % count