wsutil: Switch away from G_MODULE_SUFFIX and g_module_build_path
GLib 2.76 deprecated G_MODULE_SUFFIX, so just use ".dll" on Windows and ".so" elsewhere. It also deprecated g_module_build_path, so just use g_strconcat. ws_module_open was only used to open wpcap.dll, so rename it to load_wpcap_module.
This commit is contained in:
parent
764982a7d9
commit
1ffff913de
|
@ -189,7 +189,7 @@ load_wpcap(void)
|
|||
GModule *wh; /* wpcap handle */
|
||||
const symbol_table_t *sym;
|
||||
|
||||
wh = ws_module_open("wpcap.dll", 0);
|
||||
wh = load_wpcap_module();
|
||||
|
||||
if (!wh) {
|
||||
return;
|
||||
|
|
|
@ -33,7 +33,7 @@ Capture driver
|
|||
Wireshark doesn't have direct access to the capture hardware. Instead of this,
|
||||
it uses the Libpcap/Winpcap library to capture data from network cards.
|
||||
|
||||
On Win32, in capture-wpcap.c the function ws_module_open("wpcap.dll") is called
|
||||
On Win32, in capture-wpcap.c the function load_wpcap_module() is called
|
||||
to load the wpcap.dll. This dll includes all functions needed for
|
||||
packet capturing.
|
||||
|
||||
|
|
|
@ -527,7 +527,7 @@ ws_load_library(const gchar *library_name)
|
|||
return NULL;
|
||||
|
||||
/* First try the program directory */
|
||||
full_path = g_module_build_path(program_path, library_name);
|
||||
full_path = g_strconcat(program_path, G_DIR_SEPARATOR_S, library_name, NULL);
|
||||
full_path_w = g_utf8_to_utf16(full_path, -1, NULL, NULL, NULL);
|
||||
|
||||
if (full_path && full_path_w) {
|
||||
|
@ -540,7 +540,7 @@ ws_load_library(const gchar *library_name)
|
|||
}
|
||||
|
||||
/* Next try the system directory */
|
||||
full_path = g_module_build_path(system_path, library_name);
|
||||
full_path = g_strconcat(system_path, G_DIR_SEPARATOR_S, library_name, NULL);
|
||||
full_path_w = g_utf8_to_utf16(full_path, -1, NULL, NULL, NULL);
|
||||
|
||||
if (full_path && full_path_w) {
|
||||
|
@ -580,16 +580,18 @@ load_npcap_module(const gchar *full_path, GModuleFlags flags)
|
|||
}
|
||||
|
||||
GModule *
|
||||
ws_module_open(gchar *module_name, GModuleFlags flags)
|
||||
load_wpcap_module(void)
|
||||
{
|
||||
gchar *module_name = "wpcap.dll";
|
||||
gchar *full_path;
|
||||
GModule *mod;
|
||||
GModuleFlags flags = 0;
|
||||
|
||||
if (!init_dll_load_paths() || !module_name)
|
||||
if (!init_dll_load_paths())
|
||||
return NULL;
|
||||
|
||||
/* First try the program directory */
|
||||
full_path = g_module_build_path(program_path, module_name);
|
||||
full_path = g_strconcat(program_path, G_DIR_SEPARATOR_S, module_name, NULL);
|
||||
|
||||
if (full_path) {
|
||||
mod = g_module_open(full_path, flags);
|
||||
|
@ -600,7 +602,7 @@ ws_module_open(gchar *module_name, GModuleFlags flags)
|
|||
}
|
||||
|
||||
/* Next try the Npcap directory */
|
||||
full_path = g_module_build_path(npcap_path, module_name);
|
||||
full_path = g_strconcat(npcap_path, G_DIR_SEPARATOR_S, module_name, NULL);
|
||||
|
||||
if (full_path) {
|
||||
mod = load_npcap_module(full_path, flags);
|
||||
|
@ -611,7 +613,7 @@ ws_module_open(gchar *module_name, GModuleFlags flags)
|
|||
}
|
||||
|
||||
/* At last try the system directory */
|
||||
full_path = g_module_build_path(system_path, module_name);
|
||||
full_path = g_strconcat(system_path, G_DIR_SEPARATOR_S, module_name, NULL);
|
||||
|
||||
if (full_path) {
|
||||
mod = g_module_open(full_path, flags);
|
||||
|
|
|
@ -145,15 +145,13 @@ gboolean ws_init_dll_search_path(void);
|
|||
WS_DLL_PUBLIC
|
||||
void *ws_load_library(const gchar *library_name);
|
||||
|
||||
/** Load a DLL using g_module_open.
|
||||
/** Load wpcap.dll using g_module_open.
|
||||
* Only the system and program directories are searched.
|
||||
*
|
||||
* @param module_name The name of the DLL.
|
||||
* @param flags Flags to be passed to g_module_open.
|
||||
* @return A handle to the DLL if found, NULL on failure.
|
||||
*/
|
||||
WS_DLL_PUBLIC
|
||||
GModule *ws_module_open(gchar *module_name, GModuleFlags flags);
|
||||
GModule *load_wpcap_module(void);
|
||||
|
||||
/** Create or open a "Wireshark is running" mutex.
|
||||
* Create or open a mutex which signals that Wireshark or its associated
|
||||
|
|
|
@ -122,6 +122,13 @@ pass_plugin_version_compatibility(GModule *handle, const char *name)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
// GLib and Qt allow ".dylib" and ".so" on macOS. Should we do the same?
|
||||
#ifdef _WIN32
|
||||
#define MODULE_SUFFIX ".dll"
|
||||
#else
|
||||
#define MODULE_SUFFIX ".so"
|
||||
#endif
|
||||
|
||||
static void
|
||||
scan_plugins_dir(GHashTable *plugins_module, const char *dirpath, plugin_type_e type, gboolean append_type)
|
||||
{
|
||||
|
@ -146,8 +153,8 @@ scan_plugins_dir(GHashTable *plugins_module, const char *dirpath, plugin_type_e
|
|||
}
|
||||
|
||||
while ((name = g_dir_read_name(dir)) != NULL) {
|
||||
/* Skip anything but files with G_MODULE_SUFFIX. */
|
||||
if (!g_str_has_suffix(name, "." G_MODULE_SUFFIX))
|
||||
/* Skip anything but files with .dll or .so. */
|
||||
if (!g_str_has_suffix(name, MODULE_SUFFIX))
|
||||
continue;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue