aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/filesystem.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-03-31 04:38:51 +0100
committerMichael Mann <mmann78@netscape.net>2016-04-03 16:30:33 +0000
commit80a80edd5ec87b41d86faa03c9a9b7a773f32f74 (patch)
tree19077b05b0cb09a58bdec1e666a4e86c62e8a0b2 /wsutil/filesystem.c
parentee9858f347f54f22fbf88d2e78a53a5ada0e7018 (diff)
wsutil: Remove getenv_utf8(), replaced with g_getenv()
Replace getenv() calls in filesystem.c too for consistency. Change-Id: I31425179290e556e6696953531989d93777adf92 Reviewed-on: https://code.wireshark.org/review/14752 Petri-Dish: João Valverde <j@v6e.pt> Reviewed-by: João Valverde <j@v6e.pt> Tested-by: João Valverde <j@v6e.pt> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wsutil/filesystem.c')
-rw-r--r--wsutil/filesystem.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 8869cec10b..2a68a9949d 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -473,8 +473,7 @@ init_progfile_dir(const char *arg0
*/
if (GetModuleFileName(NULL, prog_pathname_w, G_N_ELEMENTS(prog_pathname_w)) != 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
/*
- * XXX - Should we use g_utf16_to_utf8(), as in
- * getenv_utf8()?
+ * XXX - Should we use g_utf16_to_utf8()?
*/
prog_pathname = utf_16to8(prog_pathname_w);
/*
@@ -527,8 +526,8 @@ init_progfile_dir(const char *arg0
char *prog_pathname;
char *curdir;
long path_max;
- char *pathstr;
- char *path_start, *path_end;
+ const char *pathstr;
+ const char *path_start, *path_end;
size_t path_component_len, path_len;
char *retstr;
char *path;
@@ -543,7 +542,7 @@ init_progfile_dir(const char *arg0
* set, causes us to look for plugins and the like in the build
* directory.)
*/
- if (getenv("WIRESHARK_RUN_FROM_BUILD_DIRECTORY") != NULL
+ if (g_getenv("WIRESHARK_RUN_FROM_BUILD_DIRECTORY") != NULL
&& !started_with_special_privs())
running_in_build_directory_flag = TRUE;
@@ -623,7 +622,7 @@ DIAG_ON(pedantic)
* that's executable.
*/
prog_pathname = NULL; /* haven't found it yet */
- pathstr = getenv("PATH");
+ pathstr = g_getenv("PATH");
path_start = pathstr;
if (path_start != NULL) {
while (*path_start != '\0') {
@@ -876,13 +875,13 @@ get_datafile_dir(void)
datafile_dir = g_strdup(TOP_SRCDIR);
return datafile_dir;
} else {
- if (getenv("WIRESHARK_DATA_DIR") && !started_with_special_privs()) {
+ if (g_getenv("WIRESHARK_DATA_DIR") && !started_with_special_privs()) {
/*
* The user specified a different directory for data files
* and we aren't running with special privileges.
* XXX - We might be able to dispense with the priv check
*/
- datafile_dir = g_strdup(getenv("WIRESHARK_DATA_DIR"));
+ datafile_dir = g_strdup(g_getenv("WIRESHARK_DATA_DIR"));
}
#ifdef __APPLE__
/*
@@ -975,12 +974,12 @@ init_plugin_dir(void)
*/
plugin_dir = g_strdup_printf("%s/plugins", get_progfile_dir());
} else {
- if (getenv("WIRESHARK_PLUGIN_DIR") && !started_with_special_privs()) {
+ if (g_getenv("WIRESHARK_PLUGIN_DIR") && !started_with_special_privs()) {
/*
* The user specified a different directory for plugins
* and we aren't running with special privileges.
*/
- plugin_dir = g_strdup(getenv("WIRESHARK_PLUGIN_DIR"));
+ plugin_dir = g_strdup(g_getenv("WIRESHARK_PLUGIN_DIR"));
}
#ifdef __APPLE__
/*
@@ -1042,7 +1041,7 @@ static const char *extcap_dir = NULL;
static void init_extcap_dir(void) {
#ifdef _WIN32
- char *alt_extcap_path;
+ const char *alt_extcap_path;
/*
* On Windows, the data file directory is the installation
@@ -1052,7 +1051,7 @@ static void init_extcap_dir(void) {
* on Windows, the data file directory is the directory
* in which the Wireshark binary resides.
*/
- alt_extcap_path = getenv_utf8("WIRESHARK_EXTCAP_DIR");
+ alt_extcap_path = g_getenv("WIRESHARK_EXTCAP_DIR");
if (alt_extcap_path) {
/*
* The user specified a different directory for extcap hooks.
@@ -1071,12 +1070,12 @@ static void init_extcap_dir(void) {
*/
extcap_dir = g_strdup_printf("%s/extcap", get_progfile_dir());
} else {
- if (getenv("WIRESHARK_EXTCAP_DIR") && !started_with_special_privs()) {
+ if (g_getenv("WIRESHARK_EXTCAP_DIR") && !started_with_special_privs()) {
/*
* The user specified a different directory for extcap hooks
* and we aren't running with special privileges.
*/
- extcap_dir = g_strdup(getenv("WIRESHARK_EXTCAP_DIR"));
+ extcap_dir = g_strdup(g_getenv("WIRESHARK_EXTCAP_DIR"));
}
#ifdef __APPLE__
/*
@@ -1248,7 +1247,7 @@ get_persconffile_dir_no_profile(void)
/*
* See if the user has selected an alternate environment.
*/
- env = getenv_utf8("WIRESHARK_APPDATA");
+ env = g_getenv("WIRESHARK_APPDATA");
if (env != NULL) {
persconffile_dir = g_strdup(env);
return persconffile_dir;
@@ -1262,7 +1261,7 @@ get_persconffile_dir_no_profile(void)
* so means you can use Wireshark even if the home directory
* is an inaccessible network drive.
*/
- env = getenv_utf8("APPDATA");
+ env = g_getenv("APPDATA");
if (env != NULL) {
/*
* Concatenate %APPDATA% with "\Wireshark".
@@ -1274,7 +1273,7 @@ get_persconffile_dir_no_profile(void)
/*
* OK, %APPDATA% wasn't set, so use %USERPROFILE%\Application Data.
*/
- env = getenv_utf8("USERPROFILE");
+ env = g_getenv("USERPROFILE");
if (env != NULL) {
persconffile_dir = g_build_filename(env, "Application Data", "Wireshark", NULL);
return persconffile_dir;
@@ -1304,7 +1303,7 @@ get_persconffile_dir_no_profile(void)
* (Note: before GLib 2.36, g_get_home_dir() didn't look at $HOME,
* but we always want to do so, so we don't use g_get_home_dir().)
*/
- homedir = getenv("HOME");
+ homedir = g_getenv("HOME");
if (homedir == NULL) {
/*
* It's not set.
@@ -1695,7 +1694,7 @@ static const char *
get_home_dir(void)
{
static const char *home = NULL;
- char *homedrive, *homepath;
+ const char *homedrive, *homepath;
char *homestring;
char *lastsep;
@@ -1708,9 +1707,9 @@ get_home_dir(void)
* Is there a chance that it might be set but one or more of
* HOMEDRIVE or HOMEPATH isn't set?
*/
- homedrive = getenv_utf8("HOMEDRIVE");
+ homedrive = g_getenv("HOMEDRIVE");
if (homedrive != NULL) {
- homepath = getenv_utf8("HOMEPATH");
+ homepath = g_getenv("HOMEPATH");
if (homepath != NULL) {
/*
* This is cached, so we don't need to worry about