diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-10-21 21:48:00 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-10-21 21:48:00 +0000 |
commit | e980dd9d3bfe00047bc454a2a68d590c2deb37ea (patch) | |
tree | 63b6b1f2a27db0a1dcf8e986ed3441c7c3a0a274 /epan | |
parent | fa928f62c3b9bf3bd69c6e83747f954d7ba1c7ea (diff) | |
download | wireshark-e980dd9d3bfe00047bc454a2a68d590c2deb37ea.tar.gz wireshark-e980dd9d3bfe00047bc454a2a68d590c2deb37ea.tar.bz2 wireshark-e980dd9d3bfe00047bc454a2a68d590c2deb37ea.zip |
Use G_DIR_SEPARATOR_S rather than "/" as a pathname separator in format
strings used to generate pathnames.
Move the definition of PF_DIR from <epan/epan.h> to <epan/filesystem.h>,
so that files requiring only the definition of PF_DIR don't have to
include <epan/epan.h>, and get rid of no-longer-necessary includes of
<epan/epan.h>.
Add a routine to get the directory for "system files" such as
"/etc/ethers" - it's "/etc" on UNIX, and the datafile directory on
Windows (as there's no "/etc" on Windows). Use that to construct the
pathname of the ethers and ipxnet files.
svn path=/trunk/; revision=4056
Diffstat (limited to 'epan')
-rw-r--r-- | epan/epan.h | 13 | ||||
-rw-r--r-- | epan/filesystem.c | 22 | ||||
-rw-r--r-- | epan/filesystem.h | 19 | ||||
-rw-r--r-- | epan/plugins.c | 3 | ||||
-rw-r--r-- | epan/resolv.c | 67 |
5 files changed, 65 insertions, 59 deletions
diff --git a/epan/epan.h b/epan/epan.h index a2d97585f8..a45387ffc5 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -1,6 +1,6 @@ /* epan.h * - * $Id: epan.h,v 1.6 2001/04/02 00:38:34 hagbard Exp $ + * $Id: epan.h,v 1.7 2001/10/21 21:47:58 guy Exp $ * * Ethereal Protocol Analyzer Library * @@ -56,15 +56,4 @@ epan_dissect_new(void* pseudo_header, const guint8* data, frame_data *fd, proto_ void epan_dissect_free(epan_dissect_t* edt); - - - - -/* Should this be ".libepan"? For backwards-compatibility, I'll keep - * it ".ethereal" for now. - */ -#define PF_DIR ".ethereal" - - - #endif /* EPAN_H */ diff --git a/epan/filesystem.c b/epan/filesystem.c index 273cf8f164..ead507c535 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -1,7 +1,7 @@ /* filesystem.c * Filesystem utility routines * - * $Id: filesystem.c,v 1.6 2001/08/21 08:16:54 guy Exp $ + * $Id: filesystem.c,v 1.7 2001/10/21 21:47:58 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -191,8 +191,8 @@ test_for_directory(const char *path) } /* - * Get the directory in which global configuration and data files are - * stored. + * Get the directory in which Ethereal's global configuration and data + * files are stored. */ const char * get_datafile_dir(void) @@ -269,6 +269,22 @@ get_datafile_dir(void) #endif } +/* + * Get the directory in which files that, at least on UNIX, are + * system files (such as "/etc/ethers") are stored; on Windows, + * there's no "/etc" directory, so we get them from the Ethereal + * global configuration and data file directory. + */ +const char * +get_systemfile_dir(void) +{ +#ifdef WIN32 + return get_datafile_dir(); +#else + return "/etc"; +#endif +} + /* Returns the user's home directory, via the HOME environment * variable, or a default directory if HOME is not set */ const char* diff --git a/epan/filesystem.h b/epan/filesystem.h index d26fc929cf..37f4d432a8 100644 --- a/epan/filesystem.h +++ b/epan/filesystem.h @@ -1,7 +1,7 @@ /* filesystem.h * Filesystem utility definitions * - * $Id: filesystem.h,v 1.4 2001/08/21 06:39:16 guy Exp $ + * $Id: filesystem.h,v 1.5 2001/10/21 21:47:58 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -26,6 +26,15 @@ #define FILESYSTEM_H /* + * Name of directory, under the user's home directory, in which + * personal configuration files are stored. + * + * XXX - should this be ".libepan"? For backwards-compatibility, I'll keep + * it ".ethereal" for now. + */ +#define PF_DIR ".ethereal" + +/* * Given a pathname, return a pointer to the last pathname separator * character in the pathname, or NULL if the pathname contains no * separators. @@ -63,6 +72,14 @@ int test_for_directory(const char *); */ const char *get_datafile_dir(void); +/* + * Get the directory in which files that, at least on UNIX, are + * system files (such as "/etc/ethers") are stored; on Windows, + * there's no "/etc" directory, so we get them from the Ethereal + * global configuration and data file directory. + */ +const char *get_systemfile_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 9594fdcf01..8ad868514c 100644 --- a/epan/plugins.c +++ b/epan/plugins.c @@ -1,7 +1,7 @@ /* plugins.c * plugin routines * - * $Id: plugins.c,v 1.34 2001/09/14 09:27:35 guy Exp $ + * $Id: plugins.c,v 1.35 2001/10/21 21:47:58 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -26,7 +26,6 @@ # include "config.h" #endif -#include <epan.h> #include "plugins.h" #ifdef HAVE_PLUGINS diff --git a/epan/resolv.c b/epan/resolv.c index b3d5f54bea..aa7457e077 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.13 2001/10/21 19:54:49 guy Exp $ + * $Id: resolv.c,v 1.14 2001/10/21 21:47:58 guy Exp $ * * Laurent Deniel <deniel@worldnet.fr> * @@ -86,8 +86,6 @@ #define ENAME_ETHERS "ethers" #define ENAME_IPXNETS "ipxnets" #define ENAME_MANUF "manuf" -#define EPATH_PERSONAL_ETHERS ".ethereal/ethers" /* with "$HOME/" prefix */ -#define EPATH_PERSONAL_IPXNETS ".ethereal/ipxnets" /* with "$HOME/" prefix */ #define MAXMANUFLEN 9 /* max vendor name length with ending '\0' */ #define HASHETHSIZE 1024 @@ -171,11 +169,11 @@ static int ipxnet_resolution_initialized = 0; * GUI code to change them. */ -gchar *g_ethers_path = NULL; /* {directory}/ENAME_ETHERS */ -gchar *g_pethers_path = NULL; /* "$HOME"/EPATH_PERSONAL_ETHERS */ -gchar *g_ipxnets_path = NULL; /* {directory}/ENAME_IPXNETS */ -gchar *g_pipxnets_path = NULL; /* "$HOME"/EPATH_PERSONAL_IPXNETS */ - /* first resolving call */ +gchar *g_ethers_path = NULL; /* global ethers file */ +gchar *g_pethers_path = NULL; /* personal ethers file */ +gchar *g_ipxnets_path = NULL; /* global ipxnets file */ +gchar *g_pipxnets_path = NULL; /* personal ipxnets file */ + /* first resolving call */ /* * Local function definitions @@ -410,7 +408,7 @@ static int fgetline(char **buf, int *size, FILE *fp) * The following functions implement ethernet address resolution and * ethers files parsing (see ethers(4)). * - * /etc/manuf has the same format as ethers(4) except that names are + * The manuf file has the same format as ethers(4) except that names are * truncated to MAXMANUFLEN-1 characters and that an address contains * only 3 bytes (instead of 6). * @@ -432,7 +430,7 @@ static int fgetline(char **buf, int *size, FILE *fp) static int parse_ether_line(char *line, ether_t *eth, int six_bytes) { /* - * See man ethers(4) for /etc/ethers file format + * See man ethers(4) for ethers file format * (not available on all systems). * We allow both ethernet address separators (':' and '-'), * as well as Ethereal's '.' separator. @@ -628,29 +626,22 @@ static void initialize_ethers(void) ether_t *eth; char *manuf_path; - /* Compute the pathname of the ethers file. - * On UNIX, it's "/etc/ethers"; on Windows, it's "ethers" under the - * datafile directory (there's no notion of an "ethers file" on - * Windows, so it's an Ethereal-specific file). - */ + /* Compute the pathname of the ethers file. */ if (g_ethers_path == NULL) { -#ifdef WIN32 - dir = get_datafile_dir(); -#else - dir = "/etc"; -#endif - g_ethers_path = g_malloc(strlen(dir) + strlen(ENAME_ETHERS) + 2); - sprintf(g_ethers_path, "%s/%s", dir, ENAME_ETHERS); + g_ethers_path = g_malloc(strlen(get_systemfile_dir()) + + strlen(ENAME_ETHERS) + 2); + sprintf(g_ethers_path, "%s" G_DIR_SEPARATOR_S "%s", + get_systemfile_dir(), ENAME_ETHERS); } /* Set g_pethers_path here, but don't actually do anything * with it. It's used in get_ethbyname() and get_ethbyaddr() */ if (g_pethers_path == NULL) { - g_pethers_path = g_malloc(strlen(get_home_dir()) + - strlen(EPATH_PERSONAL_ETHERS) + 2); - sprintf(g_pethers_path, "%s/%s", - get_home_dir(), EPATH_PERSONAL_ETHERS); + g_pethers_path = g_malloc(strlen(get_home_dir()) + + strlen(PF_DIR) + strlen(ENAME_ETHERS) + 3); + sprintf(g_pethers_path, "%s" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s", + get_home_dir(), PF_DIR, ENAME_ETHERS); } /* manuf hash table initialization */ @@ -658,7 +649,7 @@ static void initialize_ethers(void) /* 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, + sprintf(manuf_path, "%s" G_DIR_SEPARATOR_S "%s", get_datafile_dir(), ENAME_MANUF); /* Read it and initialize the hash table */ @@ -942,9 +933,6 @@ static void initialize_ipxnets(void) char *dir; /* Compute the pathname of the ipxnets file. - * On UNIX, it's "/etc/ipxnets"; on Windows, it's "ipxnets" under the - * datafile directory (there's no notion of an "ipxnets file" on - * Windows, so it's an Ethereal-specific file). * * XXX - is there a notion of an "ipxnets file" in any flavor of * UNIX, or with any add-on Netware package for UNIX? If not, @@ -952,23 +940,20 @@ static void initialize_ipxnets(void) * directory as well? */ if (g_ipxnets_path == NULL) { -#ifdef WIN32 - dir = get_datafile_dir(); -#else - dir = "/etc"; -#endif - g_ipxnets_path = g_malloc(strlen(dir) + strlen(ENAME_IPXNETS) + 2); - sprintf(g_ipxnets_path, "%s/%s", dir, ENAME_IPXNETS); + g_ipxnets_path = g_malloc(strlen(get_systemfile_dir()) + + strlen(ENAME_IPXNETS) + 2); + sprintf(g_ipxnets_path, "%s" G_DIR_SEPARATOR_S "%s", + get_systemfile_dir(), ENAME_IPXNETS); } /* Set g_pipxnets_path here, but don't actually do anything * with it. It's used in get_ipxnetbyname() and get_ipxnetbyaddr() */ if (g_pipxnets_path == NULL) { - g_pipxnets_path = g_malloc(strlen(get_home_dir()) + - strlen(EPATH_PERSONAL_IPXNETS) + 2); - sprintf(g_pipxnets_path, "%s/%s", - get_home_dir(), EPATH_PERSONAL_IPXNETS); + g_pipxnets_path = g_malloc(strlen(get_home_dir()) + + strlen(PF_DIR) + strlen(ENAME_IPXNETS) + 3); + sprintf(g_pipxnets_path, "%s" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s", + get_home_dir(), PF_DIR, ENAME_IPXNETS); } } /* initialize_ipxnets */ |