aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.h.win324
-rw-r--r--epan/config.h.win324
-rw-r--r--epan/filesystem.c140
-rw-r--r--epan/filesystem.h24
-rw-r--r--epan/plugins.c108
-rw-r--r--epan/resolv.c22
-rw-r--r--epan/resolv.h3
-rw-r--r--file.c3
-rw-r--r--gtk/dfilter_expr_dlg.c6
-rw-r--r--gtk/file_dlg.c5
-rw-r--r--gtk/help_dlg.c6
-rw-r--r--gtk/packet_win.c6
-rw-r--r--gtk/prefs_dlg.c6
-rw-r--r--gtk/stream_prefs.c6
-rw-r--r--prefs.c21
-rw-r--r--util.c50
-rw-r--r--util.h37
17 files changed, 248 insertions, 203 deletions
diff --git a/config.h.win32 b/config.h.win32
index 3eb65be308..54631924b1 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -1,4 +1,4 @@
-/* $Id: config.h.win32,v 1.31 2001/08/18 23:21:30 guy Exp $ */
+/* $Id: config.h.win32,v 1.32 2001/08/21 06:39:14 guy Exp $ */
/* config.h.win32 Generated manually. :-) */
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
@@ -35,8 +35,6 @@
/* #undef HAVE_SA_LEN */
-#define DATAFILE_DIR "/usr/local/etc"
-
/* #undef NEED_SNPRINTF_H */
/* #undef NEED_STRERROR_H */
diff --git a/epan/config.h.win32 b/epan/config.h.win32
index 1a875eb82f..2caf7b2d46 100644
--- a/epan/config.h.win32
+++ b/epan/config.h.win32
@@ -1,4 +1,4 @@
-/* $Id: config.h.win32,v 1.7 2001/05/01 02:44:52 guy Exp $ */
+/* $Id: config.h.win32,v 1.8 2001/08/21 06:39:16 guy Exp $ */
/* config.h.win32 Generated manually. :-) */
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
@@ -28,8 +28,6 @@
#define HAVE_PLUGINS 1
-#define DATAFILE_DIR "/usr/local/etc"
-
#define NEED_INET_ATON_H 1
#define NEED_INET_V6DEFS_H 1
diff --git a/epan/filesystem.c b/epan/filesystem.c
index 0dfa42489e..c026c2d681 100644
--- a/epan/filesystem.c
+++ b/epan/filesystem.c
@@ -1,12 +1,11 @@
/* filesystem.c
* Filesystem utility routines
*
- * $Id: filesystem.c,v 1.4 2001/04/02 09:53:44 guy Exp $
+ * $Id: filesystem.c,v 1.5 2001/08/21 06:39:16 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* 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
@@ -29,12 +28,22 @@
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
+
#include <glib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
#ifndef WIN32
#include <pwd.h>
#endif
@@ -132,6 +141,131 @@ get_dirname(char *path)
return path;
}
+/*
+ * Given a pathname, return:
+ *
+ * the errno, if an attempt to "stat()" the file fails;
+ *
+ * EISDIR, if the attempt succeeded and the file turned out
+ * to be a directory;
+ *
+ * 0, if the attempt succeeded and the file turned out not
+ * to be a directory.
+ */
+
+/*
+ * Visual C++ on Win32 systems doesn't define these. (Old UNIX systems don't
+ * define them either.)
+ *
+ * Visual C++ on Win32 systems doesn't define S_IFIFO, it defines _S_IFIFO.
+ */
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+#ifndef S_IFIFO
+#define S_IFIFO _S_IFIFO
+#endif
+#ifndef S_ISFIFO
+#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#endif
+
+int
+test_for_directory(const char *path)
+{
+ struct stat statb;
+
+ if (stat(path, &statb) < 0)
+ return errno;
+
+ if (S_ISDIR(statb.st_mode))
+ return EISDIR;
+ else
+ return 0;
+}
+
+/*
+ * Get the directory in which global configuration and data files are
+ * stored.
+ */
+const char *
+get_datafile_dir(void)
+{
+#ifdef WIN32
+ char prog_pathname[_MAX_PATH+2];
+ char *dir_end;
+ size_t datafile_dir_len;
+ static char *datafile_dir;
+
+ /*
+ * Have we already gotten the pathname?
+ * If so, just return it.
+ */
+ if (datafile_dir != NULL)
+ return datafile_dir;
+
+ /*
+ * No, we haven't.
+ * Start out by assuming it's the default installation directory.
+ */
+ datafile_dir = "C:\\Program Files\\Ethereal\\";
+
+ /*
+ * Now we attempt to get the full pathname of the currently running
+ * program, under the assumption that we're running an installed
+ * version of the program. If we fail, we don't change "datafile_dir",
+ * and thus end up using DATAFILE_DIR.
+ *
+ * XXX - does NSIS put the installation directory into
+ * "\HKEY_LOCAL_MACHINE\SOFTWARE\Ethereal\InstallDir"?
+ * If so, perhaps we should read that from the registry,
+ * instead.
+ */
+ if (GetModuleFileName(NULL, prog_pathname, sizeof prog_pathname) != 0) {
+ /*
+ * If the program is an installed version, the full pathname
+ * includes the pathname of the directory in which it was
+ * installed; get that directory's pathname, and construct
+ * from it the pathname of the directory in which the
+ * plugins were installed.
+ *
+ * First, find the last "\\" in the directory, as that
+ * marks the end of the directory pathname.
+ *
+ * XXX - Can the pathname be something such as
+ * "C:ethereal.exe"? Or is it always a full pathname
+ * beginning with "\\" after the drive letter?
+ */
+ dir_end = strrchr(prog_pathname, '\\');
+ if (dir_end != NULL) {
+ /*
+ * Found it - now figure out how long the datafile
+ * directory pathname will be.
+ */
+ datafile_dir_len = (dir_end - prog_pathname);
+
+ /*
+ * Allocate a buffer for the plugin directory
+ * pathname, and construct it.
+ */
+ datafile_dir = g_malloc(datafile_dir_len + 1);
+ strncpy(datafile_dir, prog_pathname, datafile_dir_len);
+ datafile_dir[datafile_dir_len] = '\0';
+ }
+ }
+#else
+ /*
+ * Just use DATAFILE_DIR, as that's what the configure script
+ * set it to be.
+ */
+ return DATAFILE_DIR;
+#endif
+}
+
+/* Returns the user's home directory, via the HOME environment
+ * variable, or a default directory if HOME is not set */
const char*
get_home_dir(void)
{
diff --git a/epan/filesystem.h b/epan/filesystem.h
index 129bc02455..d26fc929cf 100644
--- a/epan/filesystem.h
+++ b/epan/filesystem.h
@@ -1,12 +1,11 @@
/* filesystem.h
* Filesystem utility definitions
*
- * $Id: filesystem.h,v 1.3 2001/04/02 09:53:44 guy Exp $
+ * $Id: filesystem.h,v 1.4 2001/08/21 06:39:16 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* 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
@@ -45,6 +44,25 @@ char *get_basename(char *);
*/
char *get_dirname(char *);
+/*
+ * Given a pathname, return:
+ *
+ * the errno, if an attempt to "stat()" the file fails;
+ *
+ * EISDIR, if the attempt succeeded and the file turned out
+ * to be a directory;
+ *
+ * 0, if the attempt succeeded and the file turned out not
+ * to be a directory.
+ */
+int test_for_directory(const char *);
+
+/*
+ * Get the directory in which global configuration and data files are
+ * stored.
+ */
+const char *get_datafile_dir(void);
+
/* Returns the user's home directory, via the HOME environment
* variable, or a default directory if HOME is not set */
const char* get_home_dir(void);
diff --git a/epan/plugins.c b/epan/plugins.c
index af38b88ad3..507707a352 100644
--- a/epan/plugins.c
+++ b/epan/plugins.c
@@ -1,7 +1,7 @@
/* plugins.c
* plugin routines
*
- * $Id: plugins.c,v 1.27 2001/08/19 00:42:36 guy Exp $
+ * $Id: plugins.c,v 1.28 2001/08/21 06:39:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -70,10 +70,7 @@ static plugin_address_table_t patable;
/* linked list of all plugins */
plugin *plugin_list;
-#ifdef WIN32
-#include <stdio.h>
-static gchar std_plug_dir[] = "C:\\Program Files\\Ethereal\\plugins\\" VERSION;
-#else
+#ifndef WIN32
static gchar std_plug_dir[] = "/usr/lib/ethereal/plugins/" VERSION;
static gchar local_plug_dir[] = "/usr/local/lib/ethereal/plugins/" VERSION;
#endif
@@ -277,13 +274,11 @@ void
init_plugins(const char *plugin_dir)
{
#ifdef WIN32
- char prog_pathname[_MAX_PATH+2];
- char *dir_end;
- size_t install_plugin_dir_len;
- char *install_plugin_dir;
+ const char *datafile_dir;
#else
- struct stat std_dir_stat, local_dir_stat, plugin_dir_stat;
+ struct stat std_dir_stat, local_dir_stat;
#endif
+ struct stat plugin_dir_stat;
if (plugin_list == NULL) /* ensure init_plugins is only run once */
{
@@ -423,77 +418,46 @@ init_plugins(const char *plugin_dir)
#ifdef WIN32
/*
- * Scan the default installation directory.
+ * On Windows, the data file directory is the installation
+ * directory; the plugins are stored under it.
*
- * This may not, in fact, be where Ethereal is installed;
- * we check that directory later, but we check this directory
- * as well, so that if you're running the program from a
- * source directory in which you've built it, you still get
- * to see the plugins installed on your system.
+ * Assume we're running the installed version of Ethereal;
+ * on Windows, the data file directory is the directory
+ * in which the Ethereal binary resides.
*/
- plugins_scan_dir(std_plug_dir);
+ datafile_dir = get_datafile_dir();
+ plugin_dir = g_malloc(strlen(datafile_dir) + strlen("plugins") +
+ strlen(VERSION) + 3);
+ sprintf(plugin_dir, "%s\\plugins\\%s", datafile_dir, VERSION);
/*
- * Now attempt to get the full pathname of the currently running
- * program, and assume that might contain the pathname of the
- * directory in which Ethereal was installed.
+ * Make sure that pathname refers to a directory.
*/
- if (GetModuleFileName(NULL, prog_pathname, sizeof prog_pathname) != 0) {
+ if (test_for_directory(plugin_dir) != 0) {
/*
- * If the program is an installed version, the full pathname
- * includes the pathname of the directory in which it was
- * installed; get that directory's pathname, and construct
- * from it the pathname of the directory in which the
- * plugins were installed.
+ * Either it doesn't refer to a directory or it
+ * refers to something that doesn't exist.
+ *
+ * Assume that means we're running, for example,
+ * a version of Ethereal we've built in a source
+ * directory, and fall back on the default
+ * installation directory, so you can put the plugins
+ * somewhere so they can be used with this version
+ * of Ethereal.
*
- * First, find the last "\\" in the directory, as that
- * marks the end of the directory pathname.
+ * XXX - should we, instead, have the Windows build
+ * procedure create a subdirectory of the "plugins"
+ * source directory, and copy the plugin DLLs there,
+ * so that you use the plugins from the build tree?
*/
- dir_end = strrchr(prog_pathname, '\\');
- if (dir_end != NULL) {
- /*
- * Include the "\\" in the directory's pathname,
- * as we'll be appending to that pathname.
- */
- dir_end++;
-
- /*
- * Found it - now figure out how long the plugin
- * directory pathname will be.
- * It's the length of the directory pathname
- * (dir_end - prog_pathname), plus the length of
- * the plugin directory's relative pathname.
- */
- install_plugin_dir_len = (dir_end - prog_pathname) +
- strlen("plugins\\"VERSION);
-
- /*
- * Allocate a buffer for the plugin directory
- * pathname, and construct it.
- */
- install_plugin_dir =
- g_malloc(install_plugin_dir_len + 1);
- strncpy(install_plugin_dir, prog_pathname,
- dir_end - prog_pathname);
- strcpy(install_plugin_dir + (dir_end - prog_pathname),
- "plugins\\"VERSION);
-
- /*
- * Is it the same as the standard plugin directory?
- * (Do a case-insensitive string comparison; this
- * *is* Windows, after all.)
- *
- * XXX - is there another way to determine whether
- * two pathnames refer to the same file?
- */
- if (g_strcasecmp(std_plug_dir, install_plugin_dir) != 0) {
- /*
- * It's a different directory - scan it.
- */
- plugins_scan_dir(install_plugin_dir);
- }
- }
+ plugin_dir =
+ "C:\\Program Files\\Ethereal\\plugins\\" VERSION;
}
+
+ /*
+ * Scan that directory.
+ */
+ plugins_scan_dir(plugin_dir);
#else
/*
* XXX - why not just scan "plugin_dir"? That's where we
diff --git a/epan/resolv.c b/epan/resolv.c
index 3f056f2ec5..aab6507658 100644
--- a/epan/resolv.c
+++ b/epan/resolv.c
@@ -1,7 +1,7 @@
/* resolv.c
* Routines for network object lookup
*
- * $Id: resolv.c,v 1.11 2001/06/07 22:07:02 guy Exp $
+ * $Id: resolv.c,v 1.12 2001/08/21 06:39:16 guy Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@@ -83,9 +83,14 @@
#include "prefs.h"
+/*
+ * XXX - on Windows, do "/etc/ethers" and "/etc/ipxnets" exist, perhaps in
+ * some other directory, or should we instead look for them in the Ethereal
+ * installation directory, treating them as Ethereal-specific files?
+ */
#define EPATH_ETHERS "/etc/ethers"
#define EPATH_IPXNETS "/etc/ipxnets"
-#define EPATH_MANUF DATAFILE_DIR "/manuf"
+#define ENAME_MANUF "manuf"
#define EPATH_PERSONAL_ETHERS ".ethereal/ethers" /* with "$HOME/" prefix */
#define EPATH_PERSONAL_IPXNETS ".ethereal/ipxnets" /* with "$HOME/" prefix */
@@ -173,7 +178,6 @@ gchar *g_ethers_path = EPATH_ETHERS;
gchar *g_pethers_path = NULL; /* "$HOME"/EPATH_PERSONAL_ETHERS */
gchar *g_ipxnets_path = EPATH_IPXNETS;
gchar *g_pipxnets_path = NULL; /* "$HOME"/EPATH_PERSONAL_IPXNETS */
-gchar *g_manuf_path = EPATH_MANUF; /* may only be changed before the */
/* first resolving call */
/*
@@ -624,6 +628,7 @@ static hashmanuf_t *manuf_name_lookup(const guint8 *addr)
static void initialize_ethers(void)
{
ether_t *eth;
+ char *manuf_path;
/* Set g_pethers_path here, but don't actually do anything
* with it. It's used in get_ethbyname() and get_ethbyaddr()
@@ -637,7 +642,14 @@ static void initialize_ethers(void)
/* manuf hash table initialization */
- set_ethent(g_manuf_path);
+ /* Compute the pathname of the manuf file */
+ manuf_path = (gchar *) g_malloc(strlen(get_datafile_dir()) +
+ strlen(ENAME_MANUF) + 2);
+ sprintf(manuf_path, "%s%c%s", get_datafile_dir(), G_DIR_SEPARATOR,
+ ENAME_MANUF);
+
+ /* Read it and initialize the hash table */
+ set_ethent(manuf_path);
while ((eth = get_ethent(0))) {
add_manuf_name(eth->addr, eth->name);
@@ -645,6 +657,8 @@ static void initialize_ethers(void)
end_ethent();
+ g_free(manuf_path);
+
} /* initialize_ethers */
static hashether_t *add_eth_name(const guint8 *addr, const guchar *name)
diff --git a/epan/resolv.h b/epan/resolv.h
index f48e513296..4be3abd5d3 100644
--- a/epan/resolv.h
+++ b/epan/resolv.h
@@ -1,7 +1,7 @@
/* resolv.h
* Definitions for network object lookup
*
- * $Id: resolv.h,v 1.6 2001/04/15 03:37:15 guy Exp $
+ * $Id: resolv.h,v 1.7 2001/08/21 06:39:17 guy Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@@ -36,7 +36,6 @@
extern gchar *g_ethers_path;
extern gchar *g_ipxnets_path;
-extern gchar *g_manuf_path;
extern gchar *g_pethers_path;
extern gchar *g_pipxnets_path;
diff --git a/file.c b/file.c
index 7bb4d48694..88389ea6fa 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.243 2001/07/17 05:32:42 hagbard Exp $
+ * $Id: file.c,v 1.244 2001/08/21 06:39:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -69,6 +69,7 @@
#endif
#include <epan.h>
+#include <filesystem.h>
#include "gtk/main.h"
#include "color.h"
diff --git a/gtk/dfilter_expr_dlg.c b/gtk/dfilter_expr_dlg.c
index 3105c7c5ab..cf38308883 100644
--- a/gtk/dfilter_expr_dlg.c
+++ b/gtk/dfilter_expr_dlg.c
@@ -7,10 +7,10 @@
* Copyright 2000, Jeffrey C. Foster<jfoste@woodward.com> and
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: dfilter_expr_dlg.c,v 1.22 2001/04/20 21:57:55 guy Exp $
+ * $Id: dfilter_expr_dlg.c,v 1.23 2001/08/21 06:39:18 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 2000 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@@ -26,7 +26,6 @@
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
/* Todo -
@@ -62,7 +61,6 @@
#include "globals.h"
#include "gtkglobals.h"
#include "main.h"
-#include "util.h"
#include "ui_util.h"
#include "simple_dialog.h"
#include "dlg_utils.h"
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 8f89941b0a..4c6067e427 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -1,7 +1,7 @@
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.40 2001/06/05 07:38:37 guy Exp $
+ * $Id: file_dlg.c,v 1.41 2001/08/21 06:39:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -36,6 +36,8 @@
#include <string.h>
+#include <epan/filesystem.h>
+
#include "globals.h"
#include "gtkglobals.h"
#include "prefs.h"
@@ -47,7 +49,6 @@
#include "menu.h"
#include "file_dlg.h"
#include "dlg_utils.h"
-#include "util.h"
#include "main.h"
static void file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs);
diff --git a/gtk/help_dlg.c b/gtk/help_dlg.c
index 969a3d5b18..0cbd11554f 100644
--- a/gtk/help_dlg.c
+++ b/gtk/help_dlg.c
@@ -1,11 +1,11 @@
/* help_dlg.c
*
- * $Id: help_dlg.c,v 1.17 2001/05/12 19:45:37 gerald Exp $
+ * $Id: help_dlg.c,v 1.18 2001/08/21 06:39:18 guy Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 2000 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@@ -21,7 +21,6 @@
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifdef HAVE_CONFIG_H
@@ -46,7 +45,6 @@
#include "globals.h"
#include "gtkglobals.h"
#include "main.h"
-#include "util.h"
#include "ui_util.h"
#include "proto.h"
diff --git a/gtk/packet_win.c b/gtk/packet_win.c
index 8354acef52..a396dee8b9 100644
--- a/gtk/packet_win.c
+++ b/gtk/packet_win.c
@@ -3,10 +3,10 @@
*
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet_win.c,v 1.21 2001/03/24 23:53:07 guy Exp $
+ * $Id: packet_win.c,v 1.22 2001/08/21 06:39:18 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@@ -28,7 +28,6 @@
* - improve the window Title and allow user to config it
* - Add print support ? ( could be a mess)
* - Add button to have main window jump to this packet ?
- *
*/
@@ -58,7 +57,6 @@
#include "column.h"
#include "print.h"
#include "resolv.h"
-#include "util.h"
#include "packet_win.h"
#include "simple_dialog.h"
#include "proto_draw.h"
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index d120110017..574d08416e 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1,12 +1,11 @@
/* prefs_dlg.c
* Routines for handling preferences
*
- * $Id: prefs_dlg.c,v 1.24 2001/01/11 04:40:26 gram Exp $
+ * $Id: prefs_dlg.c,v 1.25 2001/08/21 06:39:18 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* 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
@@ -56,7 +55,6 @@
#include "print_prefs.h"
#include "stream_prefs.h"
#include "gui_prefs.h"
-#include "util.h"
#include "ui_util.h"
#include "dlg_utils.h"
#include "simple_dialog.h"
diff --git a/gtk/stream_prefs.c b/gtk/stream_prefs.c
index 6ccb613aee..5db8dc5105 100644
--- a/gtk/stream_prefs.c
+++ b/gtk/stream_prefs.c
@@ -1,12 +1,11 @@
/* stream_prefs.c
* Dialog boxes for preferences for the stream window
*
- * $Id: stream_prefs.c,v 1.8 2001/03/01 20:49:50 gram Exp $
+ * $Id: stream_prefs.c,v 1.9 2001/08/21 06:39:18 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* 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
@@ -37,7 +36,6 @@
#include "keys.h"
#include "print.h"
#include "prefs_dlg.h"
-#include "util.h"
static void update_text_color(GtkWidget *, gpointer);
static void update_current_color(GtkWidget *, gpointer);
diff --git a/prefs.c b/prefs.c
index a6425b4822..50a15ed74a 100644
--- a/prefs.c
+++ b/prefs.c
@@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
- * $Id: prefs.c,v 1.60 2001/07/23 18:14:36 guy Exp $
+ * $Id: prefs.c,v 1.61 2001/08/21 06:39:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -66,11 +66,11 @@ static gchar *put_string_list(GList *);
static void clear_string_list(GList *);
static void free_col_info(e_prefs *);
-#define PF_NAME "preferences"
-
-#define GPF_PATH DATAFILE_DIR "/ethereal.conf"
+#define GPF_NAME "ethereal.conf"
+#define PF_NAME "preferences"
static gboolean init_prefs = TRUE;
+static gchar *gpf_path = NULL;
static gchar *pf_path = NULL;
/*
@@ -724,11 +724,18 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
prefs.name_resolve = PREFS_RESOLV_ALL;
}
+ /* Construct the pathname of the global preferences file. */
+ if (! gpf_path) {
+ gpf_path = (gchar *) g_malloc(strlen(get_datafile_dir()) +
+ strlen(GPF_NAME) + 2);
+ sprintf(gpf_path, "%s%c%s", get_datafile_dir(), G_DIR_SEPARATOR, GPF_NAME);
+ }
+
/* Read the global preferences file, if it exists. */
*gpf_path_return = NULL;
- if ((pf = fopen(GPF_PATH, "r")) != NULL) {
+ if ((pf = fopen(gpf_path, "r")) != NULL) {
/* We succeeded in opening it; read it. */
- read_prefs_file(GPF_PATH, pf);
+ read_prefs_file(gpf_path, pf);
fclose(pf);
} else {
/* We failed to open it. If we failed for some reason other than
@@ -736,7 +743,7 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
caller can report the error. */
if (errno != ENOENT) {
*gpf_errno_return = errno;
- *gpf_path_return = GPF_PATH;
+ *gpf_path_return = gpf_path;
}
}
diff --git a/util.c b/util.c
index e7f23accec..dc078b8793 100644
--- a/util.c
+++ b/util.c
@@ -1,12 +1,11 @@
/* util.c
* Utility routines
*
- * $Id: util.c,v 1.51 2001/04/02 09:53:43 guy Exp $
+ * $Id: util.c,v 1.52 2001/08/21 06:39:15 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* 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
@@ -90,51 +89,6 @@ typedef int mode_t; /* for win32 */
#endif
/*
- * Given a pathname, return:
- *
- * the errno, if an attempt to "stat()" the file fails;
- *
- * EISDIR, if the attempt succeeded and the file turned out
- * to be a directory;
- *
- * 0, if the attempt succeeded and the file turned out not
- * to be a directory.
- */
-
-/*
- * Visual C++ on Win32 systems doesn't define these. (Old UNIX systems don't
- * define them either.)
- *
- * Visual C++ on Win32 systems doesn't define S_IFIFO, it defines _S_IFIFO.
- */
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
-#endif
-#ifndef S_IFIFO
-#define S_IFIFO _S_IFIFO
-#endif
-#ifndef S_ISFIFO
-#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
-#endif
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
-#endif
-
-int
-test_for_directory(const char *path)
-{
- struct stat statb;
-
- if (stat(path, &statb) < 0)
- return errno;
-
- if (S_ISDIR(statb.st_mode))
- return EISDIR;
- else
- return 0;
-}
-
-/*
* Collect command-line arguments as a string consisting of the arguments,
* separated by spaces.
*/
diff --git a/util.h b/util.h
index 4d52866e15..0bacc3804e 100644
--- a/util.h
+++ b/util.h
@@ -1,12 +1,11 @@
/* util.h
* Utility definitions
*
- * $Id: util.h,v 1.23 2001/04/02 09:53:43 guy Exp $
+ * $Id: util.h,v 1.24 2001/08/21 06:39:15 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* 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
@@ -30,38 +29,6 @@
extern "C" {
#endif /* __cplusplus */
-/*
- * Given a pathname, return:
- *
- * the errno, if an attempt to "stat()" the file fails;
- *
- * EISDIR, if the attempt succeeded and the file turned out
- * to be a directory;
- *
- * 0, if the attempt succeeded and the file turned out not
- * to be a directory.
- */
-int test_for_directory(const char *);
-
-/*
- * Given a pathname, return a pointer to the last pathname separator
- * character in the pathname, or NULL if the pathname contains no
- * separators.
- */
-char *find_last_pathname_separator(char *);
-
-/*
- * Given a pathname, return the last component.
- */
-char *get_basename(char *);
-
-/*
- * Given a pathname, return a string containing everything but the
- * last component. NOTE: this overwrites the pathname handed into
- * it....
- */
-char *get_dirname(char *);
-
int create_tempfile(char *, int, const char *);
/*