summaryrefslogtreecommitdiff
path: root/epan/plugins.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-11-06 22:43:25 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-11-06 22:43:25 +0000
commitc3187174bfe39f05c8aa8c6b411952e4b502477d (patch)
tree0eb95991cb932d74ca534ed0df29a3f2f256b1b8 /epan/plugins.c
parent4e954caec384454ebf4eb61140c466e8787daabe (diff)
downloadwireshark-c3187174bfe39f05c8aa8c6b411952e4b502477d.tar.gz
replace *a lot* of file related calls by their GLib counterparts. This is necessary for the switch to GTK 2.6 (at least on WIN32).
to do this, I've added file_util.h to wiretap (would file_compat.h be a better name?), and provide compat_macros like eth_open() instead of open(). While at it, move other file related things there, like #include <io.h>, definition of O_BINARY and alike, so it's all in one place. deleted related things from config.h.win32 As of these massive changes, I'm almost certain that this will break the Unix build. I'll keep an eye on the buildbot so hopefully everything is working again soon. svn path=/trunk/; revision=16403
Diffstat (limited to 'epan/plugins.c')
-rw-r--r--epan/plugins.c48
1 files changed, 15 insertions, 33 deletions
diff --git a/epan/plugins.c b/epan/plugins.c
index 9d606376b8..806488fd7d 100644
--- a/epan/plugins.c
+++ b/epan/plugins.c
@@ -44,15 +44,12 @@
#include <stdlib.h>
#include <errno.h>
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "filesystem.h"
+#include "file_util.h"
#include "report_err.h"
/* linked list of all plugins */
@@ -129,16 +126,12 @@ static void
plugins_scan_dir(const char *dirname)
{
#define FILENAME_LEN 1024
+ ETH_DIR *dir; /* scanned directory */
+ ETH_DIRENT *file; /* current file */
+ const char *name;
#if GLIB_MAJOR_VERSION < 2
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 *name;
-#else /* GLIB 2 */
- GDir *dir; /* scanned directory */
- GError **dummy;
- const gchar *name;
#endif
gchar filename[FILENAME_LEN]; /* current file name */
GModule *handle; /* handle returned by dlopen */
@@ -170,40 +163,34 @@ plugins_scan_dir(const char *dirname)
*/
lt_lib_ext = "";
}
+#endif
- if ((dir = opendir(dirname)) != NULL)
+ if ((dir = g_dir_open(dirname, 0, NULL)) != NULL)
{
- while ((file = readdir(dir)) != NULL)
+ while ((file = eth_dir_read_name(dir)) != NULL)
{
+ name = eth_dir_get_name(file);
+#if GLIB_MAJOR_VERSION < 2
/* don't try to open "." and ".." */
- if (!(strcmp(file->d_name, "..") &&
- strcmp(file->d_name, "."))) continue;
+ if (!(strcmp(name, "..") &&
+ strcmp(name, "."))) continue;
/* skip anything but files with lt_lib_ext */
- dot = strrchr(file->d_name, '.');
+ dot = strrchr(name, '.');
if (dot == NULL || strcmp(dot, lt_lib_ext) != 0) continue;
- g_snprintf(filename, FILENAME_LEN, "%s" G_DIR_SEPARATOR_S "%s",
- dirname, file->d_name);
- name = (gchar *)file->d_name;
#else /* GLIB 2 */
/*
* GLib 2.x defines G_MODULE_SUFFIX as the extension used on this
* platform for loadable modules.
*/
- dummy = g_malloc(sizeof(GError *));
- *dummy = NULL;
- if ((dir = g_dir_open(dirname, 0, dummy)) != NULL)
- {
- while ((name = g_dir_read_name(dir)) != NULL)
- {
/* skip anything but files with G_MODULE_SUFFIX */
dot = strrchr(name, '.');
if (dot == NULL || strcmp(dot+1, G_MODULE_SUFFIX) != 0) continue;
+#endif
g_snprintf(filename, FILENAME_LEN, "%s" G_DIR_SEPARATOR_S "%s",
dirname, name);
-#endif
if ((handle = g_module_open(filename, 0)) == NULL)
{
report_failure("Couldn't load module %s: %s", filename,
@@ -343,15 +330,10 @@ plugins_scan_dir(const char *dirname)
register_protoinfo();
}
+ eth_dir_close(dir);
+ }
#if GLIB_MAJOR_VERSION < 2
- closedir(dir);
- }
g_free(hack_path);
-#else /* GLIB 2 */
- g_dir_close(dir);
- }
- g_clear_error(dummy);
- g_free(dummy);
#endif
}