Ethereal-dev: [Ethereal-dev] ethereal plugin interface
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Matthijs Melchior <mmelchior@xxxxxxxxx>
Date: Mon, 30 Jun 2003 22:14:22 +0200
Hi, Here is a way to ease the mainenance for the WIN32 plugin interface contents. It is reduced from 5 files to 1 file with simple C declarations. Appended is a Python script that takes the list of declarations and generates the 5 lists used in building the plugin interface files for WIN32. Before I send a complete patch [large] lets discuss what I have done. Take "plugins/plugin_table.h" and create "plugins/plugin_api_list.c" from it, by doing the following: - keep only the typedefs. - remove the typedef keyword, leaving only declarations. - remove the "addr_" prefix and indirection - Add some includes: <glib.h>, <sys/time.h>, "file.h", "asn1.h", "epan/conversation.h", "prefs.h", "packet-giop.h", "reassemble.h" Use cygwin "gcc -aux-info xyzzy ... -c plugin_api_list.c" to create a file with conststent formatted declarations. This makes it possible to extract the symbol names with a regular expression... Use "plugin_gen.py xyzzy" to generate 5 new files formatted as the 5 tables where the interface symbols are currently stored. Change the tables to '#include "new_file"' in the fillowing files: epan/plugins.c plugins/plugin_api.c plugins/plugin_api.h plugins/plugin_api_decls.h plugins/plugin_table.h Modify plugins/Makefile.nmake to generate new files when the plugin_api_list.c file has changed. When this transformation has been made, we can go one step further and remove the code to initialize "patable". That can be done through structure initialization, and still be confident there is no incorrect order in the symbols. What do you think -- Regards, ---------------------------------------------------------------- -o) Matthijs Melchior Maarssen /\\ mmelchior@xxxxxxxxx Netherlands _\_v ---------------------------------------------------------------- ----
#! /usr/bin/python # -*- python -*- # # mmelchior@xxxxxxxxx # # gererate files for the windows plugin interface from a file with declarations # # The input for this script is genereted by gcc using the following command: # # gcc -aux-info xyzzy $(pkg-config --cflags glib-2.0) -I ethereal-0.9.13 -c plugin_api_list.c # # this gives one declaration per line, with consistent spacing. # this makes it possible to extract the symbol name with a regular expression. # # with a much more elaborate parser than the one RE we have now, we could do without gcc. # """Ethereal Windows interface generator.""" import sys, string, os, re from string import strip, replace pattFile = re.compile('.*plugin_api_list.* extern (.*)') # match filename and select declaration pattName = re.compile('\w* .*?(\w*) \(.*') # select symbol name names = [] count = 0 if len(sys.argv) > 1: file = open(sys.argv[1], 'r') # input name on command line else: file = sys.stdin # read from a stream f1 = open("Xepan_plugins.c", 'w') f2 = open("Xplugin_api.h", 'w') f3 = open("Xplugin_api.c", 'w') f4 = open("Xplugin_api_decls.h", 'w') f5 = open("Xplugin_table.h", 'w') while 1: line = file.readline() if not line: break count += 1 matchobj = pattFile.match(line) if matchobj: # print "+", count, " ", strip(line) decl = matchobj.group(1) # print "= ", decl matchobj = pattName.match(decl) if matchobj: name = matchobj.group(1) # print " ", name f1.write("patable.p_%s = %s;\n" % (name, name)) f2.write("#define %s (*p_%s)\n" % (name, name)) f3.write("p_%s = pat->p_%s;\n" % (name, name)) f4.write("addr_%s p_%s;\n" % (name, name)) f5.write(replace("typedef %s\n" % decl, name, "(*addr_%s)" % name)) names.append(name) else: print '**** function name not fount in "%s"' % decl f6 = open("Xass-list", 'w'); pos = 0 for i in names: f6.write(i) pos += len(i) if pos > 60: pos = 0 f6.write(",\n") else: f6.write(", ") f6.write('\n') f6.close() file.close() f1.close() f2.close() f3.close() f4.close() f5.close()
- Prev by Date: [Ethereal-dev] Problem with MAPI decodes
- Next by Date: Re: [Ethereal-dev] Problem with MAPI decodes
- Previous by thread: Re: [Ethereal-dev] Problem with MAPI decodes
- Index(es):