On Windows, put Ethereal configuration files under the "Application

Data\Ethereal" directory under the user's profile, as that appears to be
the Windows 2000 standard.

svn path=/trunk/; revision=4071
This commit is contained in:
Guy Harris 2001-10-24 06:13:07 +00:00
parent 7e27e176c0
commit d453f6d992
7 changed files with 113 additions and 40 deletions

View File

@ -693,11 +693,15 @@ filter, and applies it to the current capture.
=item Save
Saves the current filter list in F<$HOME/.ethereal/cfilters> on
UNIX-compatible systems, and F<%USERPROFILE%\.ethereal\cfilters> on
Windows systems, if the list of filters being edited is the list of
UNIX-compatible systems, and F<%APPDATA%\Ethereal\cfilters> (or, if
%APPDATA% isn't defined,
F<%USERPROFILE%\Application Data\Ethereal\cfilters>)
on Windows systems, if the list of filters being edited is the list of
capture filters, or in F<$HOME/.ethereal/dfilters> on UNIX-compatible
systems, and F<%USERPROFILE%\.ethereal\dfilters> on Windows systems, if
the list of filters being edited is the list of display filters.
systems, and F<%APPDATA%\Ethereal\dfilters> (or, if %APPDATA% isn't
defined, F<%USERPROFILE%\Application Data\Ethereal\dfilters>) on Windows
systems, if the list of filters being edited is the list of display
filters.
=item Close
@ -758,7 +762,8 @@ F</usr/local/lib/ethereal/plugins/$VERSION>, and
F<$HOME/.ethereal/plugins> on UNIX-compatible systems, and in the
F<plugins\$VERSION> directory under the main installation directory (for
example, F<C:\Program Files\Ethereal\plugins\$VERSION>) and
F<%USERPROFILE%\.ethereal\plugins\$VERSION> on Windows
F<%APPDATA%\Ethereal\plugins\$VERSION> (or, if %APPDATA% isn't defined,
F<%USERPROFILE%\Application Data\Ethereal\plugins\$VERSION>) on Windows
systems; $VERSION is the version number of the plugin interface, which
is typically the version number of Ethereal. Note that a dissector
plugin module may support more than one protocol; there is not
@ -969,7 +974,9 @@ under the main installation directory (for example, F</usr/local/etc>)
on UNIX-compatible systems, and in the main installation directory (for
example, F<C:\Program Files\Ethereal>) on Windows systems, and the
personal preferences file, which is F<$HOME/.ethereal/preferences> on
UNIX-compatible systems and F<%USERPROFILE%\.ethereal\preferences> on
UNIX-compatible systems and F<%APPDATA%\Ethereal\preferences> (or, if
%APPDATA% isn't defined,
F<%USERPROFILE%\Application Data\Ethereal\preferences>) on
Windows systems, contain system-wide and personal preference settings,
respectively. The file contains preference settings of the form
I<prefname>B<:>I<value>, one per line, where I<prefname> is the name of
@ -995,8 +1002,10 @@ UNIX-compatible systems, and in the main installation directory (for
example, F<C:\Program Files\Ethereal>) on Windows systems, is consulted
to correlate 6-byte hardware addresses to names. If an address is not
found in the F<ethers> file, the F<$HOME/.ethereal/ethers> file on
UNIX-compatible systems, and the F<%USERPROFILE%\.ethereal\ethers> file
on Windows systems is consulted next. Each line contains one hardware
UNIX-compatible systems, and the F<%APPDATA%\Ethereal\ethers> file (or, if
%APPDATA% isn't defined, the
F<%USERPROFILE%\Application Data\Ethereal\ethers> file) on Windows
systems is consulted next. Each line contains one hardware
address and name, separated by whitespace. The digits of the hardware
address are separated by either a colon (:), a dash (-), or a period
(.). The following three lines are valid lines of an ethers file:
@ -1018,7 +1027,9 @@ UNIX-compatible systems, and in the main installation directory (for
example, F<C:\Program Files\Ethereal>) on Windows systems, correlates
4-byte IPX network numbers to names. If a network number is not found
in the F<ipxnets> file, the F<$HOME/.ethereal/ipxnets> file on
UNIX-compatible systems, and the F<%USERPROFILE%\.ethereal\ipxnets> file
UNIX-compatible systems, and the F<%APPDATA%\Ethereal\ipxnets> file (or,
if %APPDATA% isn't defined, the
F<%USERPROFILE%\Application Data\Ethereal\ipxnets> file)
on Windows systems, is consulted next. The format is the same as the
F<ethers> file, except that each address if four bytes instead of six.
Additionally, the address can be represented a single hexadecimal

View File

@ -442,7 +442,9 @@ under the main installation directory (for example, F</usr/local/etc>)
on UNIX-compatible systems, and in the main installation directory (for
example, F<C:\Program Files\Ethereal>) on Windows systems, and the
personal preferences file, which is F<$HOME/.ethereal/preferences> on
UNIX-compatible systems and F<%USERPROFILE%\.ethereal\preferences> on
UNIX-compatible systems and F<%APPDATA%\Ethereal\preferences> (or, if
%APPDATA% isn't defined,
F<%USERPROFILE%\Application Data\Ethereal\preferences>) on
Windows systems, contain system-wide and personal preference settings,
respectively. The file contains preference settings of the form
I<prefname>B<:>I<value>, one per line, where I<prefname> is the name of
@ -463,8 +465,10 @@ UNIX-compatible systems, and in the main installation directory (for
example, F<C:\Program Files\Ethereal>) on Windows systems, is consulted
to correlate 6-byte hardware addresses to names. If an address is not
found in the F<ethers> file, the F<$HOME/.ethereal/ethers> file on
UNIX-compatible systems, and the F<%USERPROFILE%\.ethereal\ethers> file
on Windows systems is consulted next. Each line contains one hardware
UNIX-compatible systems, and the F<%APPDATA%\Ethereal\ethers> file (or, if
%APPDATA% isn't defined, the
F<%USERPROFILE%\Application Data\Ethereal\ethers> file) on Windows
systems is consulted next. Each line contains one hardware
address and name, separated by whitespace. The digits of the hardware
address are separated by either a colon (:), a dash (-), or a period
(.). The following three lines are valid lines of an ethers file:
@ -486,7 +490,9 @@ UNIX-compatible systems, and in the main installation directory (for
example, F<C:\Program Files\Ethereal>) on Windows systems, correlates
4-byte IPX network numbers to names. If a network number is not found
in the F<ipxnets> file, the F<$HOME/.ethereal/ipxnets> file on
UNIX-compatible systems, and the F<%USERPROFILE%\.ethereal\ipxnets> file
UNIX-compatible systems, and the F<%APPDATA%\Ethereal\ipxnets> file (or,
if %APPDATA% isn't defined, the
F<%USERPROFILE%\Application Data\Ethereal\ipxnets> file)
on Windows systems, is consulted next. The format is the same as the
F<ethers> file, except that each address if four bytes instead of six.
Additionally, the address can be represented a single hexadecimal

View File

@ -1,7 +1,7 @@
/* filesystem.c
* Filesystem utility routines
*
* $Id: filesystem.c,v 1.12 2001/10/23 08:15:11 guy Exp $
* $Id: filesystem.c,v 1.13 2001/10/24 06:13:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -293,23 +293,34 @@ get_systemfile_dir(void)
/*
* Name of directory, under the user's home directory, in which
* personal configuration files are stored.
*
*/
#ifdef WIN32
#define PF_DIR "Ethereal"
#else
/*
* XXX - should this be ".libepan"? For backwards-compatibility, I'll keep
* it ".ethereal" for now.
*/
#define PF_DIR ".ethereal"
#endif
/*
* Get the directory in which personal configuration files reside;
* it's PF_DIR, under the user's home directory.
* in UNIX-compatible systems, it's ".ethereal", under the user's home
* directory, and on Windows systems, it's "Ethereal", under %APPDATA%
* or, if %APPDATA% isn't set, it's "%USERPROFILE%\Application Data"
* (which is what %APPDATA% normally is on Windows 2000).
*/
const char *
get_persconffile_dir(void)
{
#ifndef WIN32
#ifdef WIN32
char *appdatadir;
char *userprofiledir;
#else
char *homedir;
struct passwd *pwd;
#endif
char *homedir;
static char *pf_dir = NULL;
/* Return the cached value, if available */
@ -318,19 +329,40 @@ get_persconffile_dir(void)
#ifdef WIN32
/*
* Use %USERPROFILE%, so that configuration files are stored
* in the user profile, rather than in the home directory.
* Use %APPDATA% or %USERPROFILE%, so that configuration files are
* stored in the user profile, rather than in the home directory.
* The Windows convention is to store configuration information
* in the user profile, and doing so means you can use
* Ethereal even if the home directory is an inaccessible
* network drive.
*/
homedir = getenv("USERPROFILE");
if (homedir == NULL) {
appdatadir = getenv("APPDATA");
if (appdatadir != NULL) {
/*
* Give up and use "C:".
* Concatenate %APPDATA% with "\Ethereal".
*/
homedir = "C:";
pf_dir = g_malloc(strlen(appdatadir) + strlen(PF_DIR) + 2);
sprintf(pf_dir, "%s" G_DIR_SEPARATOR_S "%s", appdatadir,
PF_DIR);
} else {
/*
* OK, %APPDATA% wasn't set, so use
* %USERPROFILE%\Application Data.
*/
userprofiledir = getenv("USERPROFILE");
if (userprofiledir != NULL) {
pf_dir = g_malloc(strlen(userprofiledir) +
strlen("Application Data" + strlen(PF_DIR) + 3);
sprintf(pf_dir,
"%s" G_DIR_SEPARATOR_S "Application Data" G_DIR_SEPARATOR_S "%s",
userprofiledir, PF_DIR);
} else {
/*
* Give up and use "C:".
*/
pf_dir = g_malloc(strlen("C:") + strlen(PF_DIR) + 2);
sprintf(pf_dir, "C:" G_DIR_SEPARATOR_S "%s", PF_DIR);
}
}
#else
/*
@ -353,29 +385,48 @@ get_persconffile_dir(void)
} else
homedir = "/tmp";
}
#endif
pf_dir = g_malloc(strlen(homedir) + strlen(PF_DIR) + 2);
sprintf(pf_dir, "%s" G_DIR_SEPARATOR_S "%s", homedir, PF_DIR);
#endif
return pf_dir;
}
/*
* Create the directory that holds personal configuration files, if
* necessary. If we attempted to create it, and failed, return -1 and
* set "*pf_dir_path_return" to the pathname of the directory; otherwise,
* set "*pf_dir_path_return" to the pathname of the directory we failed
* to create (it's g_mallocated, so our caller should free it); otherwise,
* return 0.
*/
int
create_persconffile_dir(const char **pf_dir_path_return)
create_persconffile_dir(char **pf_dir_path_return)
{
const char *pf_dir_path;
struct stat s_buf;
int ret;
pf_dir_path = get_persconffile_dir();
if (stat(pf_dir_path, &s_buf) != 0) {
if (stat(pf_dir_path, &s_buf) != 0 && errno == ENOENT) {
#ifdef WIN32
/*
* Does the parent directory of that directory
* exist? %APPDATA% may not exist even though
* %USERPROFILE% does.
*/
pf_dir_path_copy = g_strdup(pf_dir_path);
pf_dir_parent_path = get_dirname(pf_dir_path_copy);
if (stat(pf_dir_parent_path, &s_buf) != 0) {
/*
* No - make it first.
*/
ret = mkdir(pf_dir_parent_path);
if (ret == -1) {
*pf_dir_path_return = pf_dir_parent_path;
return -1;
}
}
g_free(pf_dir_path_copy);
ret = mkdir(pf_dir_path);
#else
ret = mkdir(pf_dir_path, 0755);
@ -390,6 +441,6 @@ create_persconffile_dir(const char **pf_dir_path_return)
ret = 0;
}
if (ret == -1)
*pf_dir_path_return = pf_dir_path;
*pf_dir_path_return = g_strdup(pf_dir_path);
return ret;
}

View File

@ -1,7 +1,7 @@
/* filesystem.h
* Filesystem utility definitions
*
* $Id: filesystem.h,v 1.8 2001/10/23 05:00:59 guy Exp $
* $Id: filesystem.h,v 1.9 2001/10/24 06:13:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -79,9 +79,10 @@ const char *get_persconffile_dir(void);
/*
* Create the directory that holds personal configuration files, if
* necessary. If we attempted to create it, and failed, return -1 and
* set "*pf_dir_path_return" to the pathname of the directory; otherwise,
* set "*pf_dir_path_return" to the pathname of the directory we failed
* to create (it's g_mallocated, so our caller should free it); otherwise,
* return 0.
*/
int create_persconffile_dir(const char **pf_dir_path_return);
int create_persconffile_dir(char **pf_dir_path_return);
#endif /* FILESYSTEM_H */

View File

@ -1,7 +1,7 @@
/* colors.c
* Definitions for color structures and routines
*
* $Id: colors.c,v 1.13 2001/10/23 05:01:02 guy Exp $
* $Id: colors.c,v 1.14 2001/10/24 06:13:06 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -288,7 +288,7 @@ write_filter(gpointer filter_arg, gpointer file_arg)
gboolean
write_filters(colfilter *filter)
{
const gchar *pf_dir_path;
gchar *pf_dir_path;
const gchar *path;
FILE *f;
@ -298,6 +298,7 @@ write_filters(colfilter *filter)
simple_dialog(ESD_TYPE_WARN, NULL,
"Can't create directory\n\"%s\"\nfor color files: %s.",
pf_dir_path, strerror(errno));
g_free(pf_dir_path);
return FALSE;
}

View File

@ -3,7 +3,7 @@
* (This used to be a notebook page under "Preferences", hence the
* "prefs" in the file name.)
*
* $Id: filter_prefs.c,v 1.31 2001/10/23 05:01:02 guy Exp $
* $Id: filter_prefs.c,v 1.32 2001/10/24 06:13:06 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -708,7 +708,7 @@ static void
filter_dlg_save_cb(GtkWidget *save_bt, gpointer data)
{
filter_list_type_t list = *(filter_list_type_t *)data;
const char *pf_dir_path;
char *pf_dir_path;
char *f_path;
int f_save_errno;
char *filter_type;
@ -719,6 +719,7 @@ filter_dlg_save_cb(GtkWidget *save_bt, gpointer data)
simple_dialog(ESD_TYPE_WARN, NULL,
"Can't create directory\n\"%s\"\nfor filter files: %s.",
pf_dir_path, strerror(errno));
g_free(pf_dir_path);
return;
}

View File

@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
* $Id: prefs_dlg.c,v 1.31 2001/10/23 05:01:02 guy Exp $
* $Id: prefs_dlg.c,v 1.32 2001/10/24 06:13:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -645,6 +645,7 @@ prefs_main_save_cb(GtkWidget *save_bt, gpointer parent_w)
{
gboolean must_redissect = FALSE;
int err;
char *pf_dir_path;
const char *pf_path;
/* Fetch the preferences (i.e., make sure all the values set in all of
@ -658,10 +659,11 @@ prefs_main_save_cb(GtkWidget *save_bt, gpointer parent_w)
/* Create the directory that holds personal configuration files, if
necessary. */
if (create_persconffile_dir(&pf_path) == -1) {
if (create_persconffile_dir(&pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_WARN, NULL,
"Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_path,
"Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_dir_path,
strerror(errno));
g_free(pf_dir_path);
} else {
/* Write the preferencs out. */
err = write_prefs(&pf_path);