Cleanup getenv(3) by GLib compatible functions.
authorshort <>
Sun, 26 Jun 2005 06:18:17 +0000 (06:18 +0000)
committershort <>
Sun, 26 Jun 2005 06:18:17 +0000 (06:18 +0000)
src/configuration.c
src/network.c

index 8be581b..4d80328 100644 (file)
@@ -24,6 +24,7 @@
 #include <glib/gstring.h>
 #include <glib/gmem.h>
 #include <glib/gstrfuncs.h>
+#include <glib/gutils.h>
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
@@ -54,8 +55,8 @@ static const gchar *static_pathname;
                        G_STRINGIFY(SYSCONFDIR) "/sysconfig",PACKAGE,
                        G_STRINGIFY(SYSCONFDIR) "/default",PACKAGE,
                        G_STRINGIFY(SYSCONFDIR) "",PACKAGE,
-                       /* 'getenv("HOME")' may return NULL and terminate the list prematurely. */
-                       getenv("HOME"),"." PACKAGE "rc",
+                       /* g_get_home_dir() may return NULL and terminate the list prematurely. */
+                       g_get_home_dir(),"." PACKAGE "rc",
                        NULL);
 }
 
index 838e80a..07a3061 100644 (file)
@@ -35,6 +35,7 @@
 #include <glib/galloca.h>
 #include <glib/gprintf.h>
 #include <glib/grand.h>
+#include <glib/gutils.h>
 
 #include "network.h"
 #include "packet.h"
@@ -63,10 +64,10 @@ static const gchar *static_pathname;
 static const char *user_val;
 
        if (!static_pathname)
-               user_val=getenv("USER");
+               user_val=g_get_user_name();
        return pathname_find(&static_pathname,
                        G_STRINGIFY(LOCALSTATEDIR) "/run",PACKAGE ".pid",
-                       (!user_val ? NULL : "/tmp"),
+                       (!user_val ? NULL : g_get_tmp_dir()),
                                        (!user_val ? NULL : udpgate_printf_alloca(".%s-%s.pid",user_val,PACKAGE)),
                        NULL);
 }