aboutsummaryrefslogtreecommitdiffstats
path: root/tools/make-plugin-reg.py
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2017-10-01 00:56:03 +0100
committerJoão Valverde <j@v6e.pt>2017-12-14 08:43:57 +0000
commit995812c5f1add94df1c237596939130c1704b099 (patch)
tree42542c56b9a70c7d2d231c8bc36649be35af46b4 /tools/make-plugin-reg.py
parenta9821caab8a1f2c6e265bd5b63a060f1f241c704 (diff)
Refactor plugin registration and loading
Put different types of plugins (libwiretap, libwireshark) in different subdirectories, give libwiretap and libwireshark init routines that load the plugins, and have them scan the appropriate subdirectories so that we don't even *try* to, for example, load libwireshark plugins in programs that only use libwiretap. Compiled plugins are stored in subfolders of the plugin folders, with the subfolder name being the Wireshark minor version number (X.Y). There is another hierarchical level for each Wireshark library (libwireshark, libwscodecs and libwiretap). The folder names are respectively plugins/X.Y/{epan,codecs,wiretap}. Currently we only distribute "epan" (libwireshark) plugins. Change-Id: I3438787a6f45820d64ba4ca91cbe3c8864708acb Reviewed-on: https://code.wireshark.org/review/23983 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'tools/make-plugin-reg.py')
-rwxr-xr-xtools/make-plugin-reg.py66
1 files changed, 29 insertions, 37 deletions
diff --git a/tools/make-plugin-reg.py b/tools/make-plugin-reg.py
index 84053d3834..7a899d6d20 100755
--- a/tools/make-plugin-reg.py
+++ b/tools/make-plugin-reg.py
@@ -54,11 +54,11 @@ regs = {
# For those that don't know Python, r"" indicates a raw string,
# devoid of Python escapes.
-proto_regex = r"(?P<symbol>\bproto_register_[_A-Za-z0-9]+)\s*\(\s*void\s*\)[^;]*$"
+proto_regex = r"\bproto_register_(?P<symbol>[_A-Za-z0-9]+)\s*\(\s*void\s*\)[^;]*$"
-handoff_regex = r"(?P<symbol>\bproto_reg_handoff_[_A-Za-z0-9]+)\s*\(\s*void\s*\)[^;]*$"
+handoff_regex = r"\bproto_reg_handoff_(?P<symbol>[_A-Za-z0-9]+)\s*\(\s*void\s*\)[^;]*$"
-wtap_reg_regex = r"(?P<symbol>\bwtap_register_[_A-Za-z0-9]+)\s*\([^;]+$"
+wtap_reg_regex = r"\bwtap_register_(?P<symbol>[_A-Za-z0-9]+)\s*\([^;]+$"
# This table drives the pattern-matching and symbol-harvesting
patterns = [
@@ -107,52 +107,44 @@ reg_code += """
#define WS_BUILD_DLL
#include "ws_symbol_export.h"
-WS_DLL_PUBLIC_DEF void plugin_register (void);
-
-WS_DLL_PUBLIC_DEF const gchar plugin_version[] = VERSION;
-WS_DLL_PUBLIC_DEF const gchar plugin_release[] = VERSION_RELEASE;
-
"""
-for symbol in regs['proto_reg']:
- reg_code += "extern void %s(void);\n" % (symbol)
-
-reg_code += """
-WS_DLL_PUBLIC_DEF void
-plugin_register (void)
-{
-"""
+if registertype == "plugin":
+ reg_code += "#include <epan/proto.h>\n\n"
+if registertype == "plugin_wtap":
+ reg_code += "#include <wiretap/wtap.h>\n\n"
for symbol in regs['proto_reg']:
- reg_code += " %s();\n" % (symbol)
-
-reg_code += "}\n\n"
-
+ reg_code += "void proto_register_%s(void);\n" % (symbol)
for symbol in regs['handoff_reg']:
- reg_code += "extern void %s(void);\n" % (symbol)
+ reg_code += "void proto_reg_handoff_%s(void);\n" % (symbol)
+for symbol in regs['wtap_register']:
+ reg_code += "void wtap_register_%s(void);\n" % (symbol)
reg_code += """
-WS_DLL_PUBLIC_DEF void plugin_reg_handoff(void);
-
-WS_DLL_PUBLIC_DEF void
-plugin_reg_handoff(void)
-{
-"""
-
-for symbol in regs['handoff_reg']:
- reg_code += " %s();\n" % (symbol)
-reg_code += "}\n"
+WS_DLL_PUBLIC_DEF const gchar plugin_version[] = VERSION;
+WS_DLL_PUBLIC_DEF const gchar plugin_release[] = VERSION_RELEASE;
-if registertype == "plugin_wtap":
- reg_code += """
-WS_DLL_PUBLIC_DEF void
-register_wtap_module(void)
+WS_DLL_PUBLIC_DEF void plugin_register(void)
{
"""
+if registertype == "plugin":
+ for symbol in regs['proto_reg']:
+ reg_code +=" static proto_plugin plug_%s;\n\n" % (symbol)
+ reg_code +=" plug_%s.register_protoinfo = proto_register_%s;\n" % (symbol, symbol)
+ if symbol in regs['handoff_reg']:
+ reg_code +=" plug_%s.register_handoff = proto_reg_handoff_%s;\n" % (symbol, symbol)
+ else:
+ reg_code +=" plug_%s.register_handoff = NULL;\n" % (symbol)
+ reg_code += " proto_register_plugin(&plug_%s);\n" % (symbol)
+else:
for symbol in regs['wtap_register']:
- reg_code += " {extern void %s (void); %s ();}\n" % (symbol, symbol)
- reg_code += "}"
+ reg_code += " static wtap_plugin plug_%s;\n\n" % (symbol)
+ reg_code += " plug_%s.register_wtap_module = wtap_register_%s;\n" % (symbol, symbol)
+ reg_code += " wtap_register_plugin(&plug_%s);\n" % (symbol)
+
+reg_code += "};\n"
try:
print(('Updating ' + final_filename))