aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2000-01-29 16:41:28 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2000-01-29 16:41:28 +0000
commitea8136cd8e70da00e46ae281f14e089bd920919c (patch)
tree53deec5da8ef15a67bc81a2c251fb0657eec9d2e /util.c
parent18d8686647ba6b7ddc5c2cad51b7379148f274f9 (diff)
downloadwireshark-ea8136cd8e70da00e46ae281f14e089bd920919c.tar.gz
wireshark-ea8136cd8e70da00e46ae281f14e089bd920919c.tar.bz2
wireshark-ea8136cd8e70da00e46ae281f14e089bd920919c.zip
Remove instances of getenv("HOME") and provide a get_home_dir() function
which provides a default value if "HOME" is not set. svn path=/trunk/; revision=1579
Diffstat (limited to 'util.c')
-rw-r--r--util.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/util.c b/util.c
index 0082f523d2..429741db2f 100644
--- a/util.c
+++ b/util.c
@@ -1,7 +1,7 @@
/* util.c
* Utility routines
*
- * $Id: util.c,v 1.30 2000/01/26 04:56:14 guy Exp $
+ * $Id: util.c,v 1.31 2000/01/29 16:41:15 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -574,4 +574,33 @@ free_interface_list(GList *if_list)
}
}
+const char*
+get_home_dir(void)
+{
+ char *env_value;
+ static const char *home = NULL;
+#ifdef WIN32
+ static const char *default_home = "C:";
+#else
+ static const char *default_home = "/tmp";
+#endif
+
+ /* Return the cached value, if available */
+ if (home)
+ return home;
+
+ env_value = getenv("HOME");
+
+ if (env_value) {
+ home = env_value;
+ }
+ else {
+ home = default_home;
+ }
+
+ return home;
+}
+
+
+
#endif /* HAVE_LIBPCAP */