Pathnames detection generalized, no longer 'configuration' specific.
[udpgate.git] / src / configuration.c
index 9543064..8be581b 100644 (file)
 #include <glib/ghash.h>
 #include <glib/gstring.h>
 #include <glib/gmem.h>
+#include <glib/gstrfuncs.h>
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
-#include <glib/gstrfuncs.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include "configuration.h"     /* self */
-#include "configuration-pathname.h"
+#include "pathname.h"
 #include "network.h"
 #include "main.h"
 
 #define LOCATION_LINK "/proc/self/exe" /* for Linux kernel */
 
 
+static G_CONST_RETURN gchar *configuration_pathname(void)
+{
+static const gchar *static_pathname;
+
+       return pathname_find(&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",
+                       NULL);
+}
+
 static GHashTable *configuration_hash_new(void)
 {
        return g_hash_table_new_full(g_str_hash,g_str_equal,