aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-11-29 09:10:03 +0000
committerGuy Harris <guy@alum.mit.edu>2000-11-29 09:10:03 +0000
commit458a1569131b434d4f6e51c9ee86d7fdf7126b3f (patch)
tree915211996bcbc6a519d7d74ad789a4b7666130bb /epan
parent5a8c21a217750833fc4d6dbff85c1f8cbfcf158e (diff)
Get the suffix for dynamically-loaded modules by means of a hack
involving "g_module_build_path()", rather than by checking the platform - this should let us handle non-Windows platforms that don't use ".so" (e.g., HP-UX). Use G_DIR_SEPARATOR_S as the pathname separator character when generating the pathname of the module. svn path=/trunk/; revision=2712
Diffstat (limited to 'epan')
-rw-r--r--epan/plugins.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/epan/plugins.c b/epan/plugins.c
index 042dec57ae..7dba4a661f 100644
--- a/epan/plugins.c
+++ b/epan/plugins.c
@@ -1,7 +1,7 @@
/* plugins.c
* plugin routines
*
- * $Id: plugins.c,v 1.13 2000/11/28 15:54:20 gram Exp $
+ * $Id: plugins.c,v 1.14 2000/11/29 09:10:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -445,6 +445,8 @@ static void
plugins_scan_dir(const char *dirname)
{
#define FILENAME_LEN 1024
+ gchar *hack_path; /* pathname used to construct lt_lib_ext */
+ gchar *lt_lib_ext; /* extension for loadable modules */
DIR *dir; /* scanned directory */
struct dirent *file; /* current file */
gchar filename[FILENAME_LEN]; /* current file name */
@@ -461,11 +463,29 @@ plugins_scan_dir(const char *dirname)
int cr;
FILE *statusfile;
-#ifdef WIN32
-#define LT_LIB_EXT ".dll"
-#else
-#define LT_LIB_EXT ".so"
-#endif
+ /*
+ * We find the extension used on this platform for loadable modules
+ * by the sneaky hack of calling "g_module_build_path" to build
+ * the pathname for a module with an empty directory name and
+ * empty module name, and then search for the last "." and use
+ * everything from the last "." on.
+ *
+ * GLib 2.0 will probably define G_MODULE_SUFFIX as the extension
+ * to use, but that's not checked into the GLib CVS tree yet,
+ * and we can't use it on systems that don't have GLib 2.0.
+ */
+ hack_path = g_module_build_path("", "");
+ lt_lib_ext = strrchr(hack_path, '.');
+ if (lt_lib_ext == NULL)
+ {
+ /*
+ * Does this mean there *is* no extension? Assume so.
+ *
+ * XXX - the code below assumes that all loadable modules have
+ * an extension....
+ */
+ lt_lib_ext = "";
+ }
if (!plugin_status_file)
{
@@ -485,11 +505,12 @@ plugins_scan_dir(const char *dirname)
if (!(strcmp(file->d_name, "..") &&
strcmp(file->d_name, "."))) continue;
- /* skip anything but files with LT_LIB_EXT */
+ /* skip anything but files with lt_lib_ext */
dot = strrchr(file->d_name, '.');
- if (dot == NULL || strcmp(dot, LT_LIB_EXT) != 0) continue;
+ if (dot == NULL || strcmp(dot, lt_lib_ext) != 0) continue;
- snprintf(filename, FILENAME_LEN, "%s/%s", dirname, file->d_name);
+ snprintf(filename, FILENAME_LEN, "%s" G_DIR_SEPARATOR_S "%s",
+ dirname, file->d_name);
if ((handle = g_module_open(filename, 0)) == NULL) continue;
name = (gchar *)file->d_name;
if (g_module_symbol(handle, "version", (gpointer*)&version) == FALSE)
@@ -599,6 +620,7 @@ plugins_scan_dir(const char *dirname)
}
closedir(dir);
}
+ g_free(hack_path);
if (statusfile) fclose(statusfile);
}