diff options
-rw-r--r-- | cmake/modules/WiresharkPlugin.cmake | 17 | ||||
-rw-r--r-- | codecs/codecs.c | 16 | ||||
-rw-r--r-- | epan/epan.c | 16 | ||||
-rwxr-xr-x | packaging/macosx/osx-app.sh.in | 2 | ||||
-rw-r--r-- | wiretap/wtap.c | 16 | ||||
-rw-r--r-- | wsutil/plugins.c | 79 | ||||
-rw-r--r-- | wsutil/plugins.h | 8 |
7 files changed, 88 insertions, 66 deletions
diff --git a/cmake/modules/WiresharkPlugin.cmake b/cmake/modules/WiresharkPlugin.cmake index 6c0e6d37b8..52a1b566b1 100644 --- a/cmake/modules/WiresharkPlugin.cmake +++ b/cmake/modules/WiresharkPlugin.cmake @@ -41,15 +41,20 @@ macro(ADD_PLUGIN_LIBRARY _plugin _subfolder) FOLDER "Plugins" ) - # LIBRARY_OUTPUT_DIRECTORY alone appears to be sufficient. - set_target_properties(${_plugin} PROPERTIES - #ARCHIVE_OUTPUT_DIRECTORY ${PLUGIN_DIR} - LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_DIR} - #RUNTIME_OUTPUT_DIRECTORY ${PLUGIN_DIR} + if(ENABLE_APPLICATION_BUNDLE) + set_target_properties(${_plugin} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_DIR}/${_subfolder} + ) + else() + # Why don't we just write to ${PLUGIN_DIR}/${_subfolder} + # everywhere? + set_target_properties(${_plugin} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_DIR} ) +endif() # Try to force output to ${PLUGIN_DIR} without the configuration - # type appended. Needed for CPack on Windows. + # type appended. Needed on Windows. foreach(_config_type ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${_config_type} _config_upper) set_target_properties(${_plugin} PROPERTIES diff --git a/codecs/codecs.c b/codecs/codecs.c index b109a6af2b..fd8d7355c1 100644 --- a/codecs/codecs.c +++ b/codecs/codecs.c @@ -5,19 +5,7 @@ * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * SPDX-License-Identifier: GPL-2.0+ */ #include "config.h" @@ -109,7 +97,7 @@ codecs_init(void) #endif #ifdef HAVE_PLUGINS - libwscodecs_plugins = plugins_init("codecs"); + libwscodecs_plugins = plugins_init(WS_PLUGIN_CODEC); g_slist_foreach(codecs_plugins, call_plugin_register_codec_module, NULL); #endif /* HAVE_PLUGINS */ } diff --git a/epan/epan.c b/epan/epan.c index 7708c46e84..0806a23141 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -4,19 +4,7 @@ * * Copyright (c) 2001 by Gerald Combs <gerald@wireshark.org> * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * SPDX-License-Identifier: GPL-2.0+ */ #include "config.h" @@ -218,7 +206,7 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da except_init(); #ifdef HAVE_PLUGINS - libwireshark_plugins = plugins_init("epan"); + libwireshark_plugins = plugins_init(WS_PLUGIN_EPAN); #endif /* initialize libgcrypt (beware, it won't be thread-safe) */ diff --git a/packaging/macosx/osx-app.sh.in b/packaging/macosx/osx-app.sh.in index 78a05f6861..76487f27b3 100755 --- a/packaging/macosx/osx-app.sh.in +++ b/packaging/macosx/osx-app.sh.in @@ -232,7 +232,7 @@ pkgexec="$bundle/Contents/MacOS" pkgres="$bundle/Contents/Resources" pkgbin="$pkgres/bin" pkglib="$bundle/Contents/Frameworks" -pkgplugin="$bundle/Contents/PlugIns/wireshark/@VERSION_MAJOR@.@VERSION_MINOR@" +pkgplugin="$bundle/Contents/PlugIns/wireshark/@VERSION_MAJOR@.@VERSION_MINOR@/epan" # Set the 'macosx' directory, usually the current directory. resdir=`pwd` diff --git a/wiretap/wtap.c b/wiretap/wtap.c index bfff86786c..9ee5ed8bf1 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -3,19 +3,7 @@ * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * SPDX-License-Identifier: GPL-2.0+ */ #include <config.h> @@ -1434,7 +1422,7 @@ wtap_init(gboolean load_wiretap_plugins) wtap_init_encap_types(); #ifdef HAVE_PLUGINS if (load_wiretap_plugins) { - libwiretap_plugins = plugins_init("wiretap"); + libwiretap_plugins = plugins_init(WS_PLUGIN_WIRETAP); g_slist_foreach(wtap_plugins, call_plugin_register_wtap_module, NULL); } #endif diff --git a/wsutil/plugins.c b/wsutil/plugins.c index c4ef3f26ce..86c02e0c0d 100644 --- a/wsutil/plugins.c +++ b/wsutil/plugins.c @@ -34,9 +34,18 @@ typedef struct _plugin { GModule *handle; /* handle returned by g_module_open */ gchar *name; /* plugin name */ const gchar *version; /* plugin version */ - const gchar *type; /* type of plugin */ + const gchar *type_dir; /* filesystem name (where it resides). */ + const gchar *type_name; /* user-facing name (what it does). Should these be capitalized? */ } plugin; +#define TYPE_DIR_EPAN "epan" +#define TYPE_DIR_WIRETAP "wiretap" +#define TYPE_DIR_CODECS "codecs" + +#define TYPE_NAME_DISSECTOR "dissector" +#define TYPE_NAME_FILE_TYPE "file type" +#define TYPE_NAME_CODEC "codec" + /* array of plugins */ static GPtrArray *plugins_array = NULL; /* map of names to plugin */ @@ -58,7 +67,7 @@ compare_plugins(gconstpointer a, gconstpointer b) } static void -plugins_scan_dir(GPtrArray **plugins_ptr, const char *dirpath, const char *type_name, gboolean build_dir) +plugins_scan_dir(GPtrArray **plugins_ptr, const char *dirpath, plugin_type_e type, gboolean build_dir) { GDir *dir; const char *name; /* current file name */ @@ -148,10 +157,31 @@ DIAG_ON(pedantic) new_plug->handle = handle; new_plug->name = g_strdup(name); new_plug->version = plug_version; - if (build_dir) - new_plug->type = "[build]"; - else - new_plug->type = type_name; + new_plug->type_dir = "[build]"; + switch (type) { + case WS_PLUGIN_EPAN: + if (!build_dir) { + new_plug->type_dir = TYPE_DIR_EPAN; + } + // XXX This isn't true for stats_tree and TRANSUM. + new_plug->type_name = TYPE_NAME_DISSECTOR; + break; + case WS_PLUGIN_WIRETAP: + if (!build_dir) { + new_plug->type_dir = TYPE_DIR_WIRETAP; + } + new_plug->type_name = TYPE_NAME_FILE_TYPE; + break; + case WS_PLUGIN_CODEC: + if (!build_dir) { + new_plug->type_dir = TYPE_DIR_CODECS; + } + new_plug->type_name = TYPE_NAME_CODEC; + break; + default: + g_error("Unknown plugin type: %u. Aborting.", (unsigned) type); + break; + } /* Add it to the list of plugins. */ if (*plugins_ptr == NULL) @@ -167,7 +197,7 @@ DIAG_ON(pedantic) * Scan the buildir for plugins. */ static void -scan_plugins_build_dir(GPtrArray **plugins_ptr, const char *type_name) +scan_plugins_build_dir(GPtrArray **plugins_ptr, plugin_type_e type) { const char *plugin_dir; const char *name; @@ -179,7 +209,7 @@ scan_plugins_build_dir(GPtrArray **plugins_ptr, const char *type_name) if ((dir = ws_dir_open(plugin_dir, 0, NULL)) == NULL) return; - plugins_scan_dir(plugins_ptr, plugin_dir, type_name, TRUE); + plugins_scan_dir(plugins_ptr, plugin_dir, type, TRUE); while ((file = ws_dir_read_name(dir)) != NULL) { name = ws_dir_get_name(file); @@ -202,7 +232,7 @@ scan_plugins_build_dir(GPtrArray **plugins_ptr, const char *type_name) g_free(plugin_dir_path); plugin_dir_path = g_build_filename(plugin_dir, name, (gchar *)NULL); } - plugins_scan_dir(plugins_ptr, plugin_dir_path, type_name, TRUE); + plugins_scan_dir(plugins_ptr, plugin_dir_path, type, TRUE); g_free(plugin_dir_path); } ws_dir_close(dir); @@ -212,11 +242,28 @@ scan_plugins_build_dir(GPtrArray **plugins_ptr, const char *type_name) * Scan for plugins. */ plugins_t * -plugins_init(const char *type_name) +plugins_init(plugin_type_e type) { if (!g_module_supported()) return NULL; /* nothing to do */ + const char *type_dir; + + switch (type) { + case WS_PLUGIN_EPAN: + type_dir = TYPE_DIR_EPAN; + break; + case WS_PLUGIN_WIRETAP: + type_dir = TYPE_DIR_WIRETAP; + break; + case WS_PLUGIN_CODEC: + type_dir = TYPE_DIR_CODECS; + break; + default: + g_error("Unknown plugin type: %u. Aborting.", (unsigned) type); + break; + } + gchar *dirpath; GPtrArray *plugins = NULL; @@ -234,12 +281,12 @@ plugins_init(const char *type_name) */ if (running_in_build_directory()) { - scan_plugins_build_dir(&plugins, type_name); + scan_plugins_build_dir(&plugins, type); } else { - dirpath = g_build_filename(get_plugins_dir_with_version(), type_name, (gchar *)NULL); - plugins_scan_dir(&plugins, dirpath, type_name, FALSE); + dirpath = g_build_filename(get_plugins_dir_with_version(), type_dir, (gchar *)NULL); + plugins_scan_dir(&plugins, dirpath, type, FALSE); g_free(dirpath); } @@ -253,8 +300,8 @@ plugins_init(const char *type_name) */ if (!started_with_special_privs()) { - dirpath = g_build_filename(get_plugins_pers_dir_with_version(), type_name, (gchar *)NULL); - plugins_scan_dir(&plugins, dirpath, type_name, FALSE); + dirpath = g_build_filename(get_plugins_pers_dir_with_version(), type_dir, (gchar *)NULL); + plugins_scan_dir(&plugins, dirpath, type, FALSE); g_free(dirpath); } @@ -271,7 +318,7 @@ plugins_get_descriptions(plugin_description_callback callback, void *callback_da for (guint i = 0; i < plugins_array->len; i++) { plugin *plug = (plugin *)plugins_array->pdata[i]; - callback(plug->name, plug->version, plug->type, g_module_name(plug->handle), callback_data); + callback(plug->name, plug->version, plug->type_name, g_module_name(plug->handle), callback_data); } } diff --git a/wsutil/plugins.h b/wsutil/plugins.h index c476211d92..7987a42e16 100644 --- a/wsutil/plugins.h +++ b/wsutil/plugins.h @@ -24,7 +24,13 @@ typedef void (*plugin_register_func)(void); typedef void plugins_t; -WS_DLL_PUBLIC plugins_t *plugins_init(const char *type_name); +typedef enum { + WS_PLUGIN_EPAN, + WS_PLUGIN_WIRETAP, + WS_PLUGIN_CODEC +} plugin_type_e; + +WS_DLL_PUBLIC plugins_t *plugins_init(plugin_type_e type); typedef void (*plugin_description_callback)(const char *name, const char *version, const char *types, const char *filename, |