[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Graveman-cvs] Changes to graveman/current/src/config.c
From: |
sylvain cresto |
Subject: |
[Graveman-cvs] Changes to graveman/current/src/config.c |
Date: |
Tue, 12 Apr 2005 19:13:02 -0400 |
Index: graveman/current/src/config.c
diff -u graveman/current/src/config.c:1.29 graveman/current/src/config.c:1.30
--- graveman/current/src/config.c:1.29 Mon Apr 4 01:37:42 2005
+++ graveman/current/src/config.c Tue Apr 12 23:12:52 2005
@@ -218,24 +218,22 @@
}
/* on regarde si un fichier de configuration existe
- * dans /usr/share/graveman/graveman.rc ou ~/.graveman/graveman.rc */
+ * tel que definie par http://standards.freedesktop.org/basedir-spec/latest/ */
/* construction de la liste des PATH dans lequel on va chercher la
configuration */
GSList *get_config_path()
{
GSList *Lnewlist = NULL;
const gchar *Lenv;
- gchar *Lpath;
+ gchar Lpath[MAXPATHLEN];
gchar **Llistpath;
gint i;
if ((Lenv=g_getenv("XDG_CONFIG_HOME"))) {
- Lpath = g_strdup_printf("%s/%s/%s.conf", Lenv, PACKAGE, PACKAGE);
+ g_snprintf(Lpath, sizeof(Lpath)-1, "%s/%s/%s.conf", Lenv, PACKAGE,
PACKAGE);
Lnewlist = g_slist_append(Lnewlist, Lpath);
- }
-
- if ((Lenv=g_getenv("HOME"))) {
- Lpath = g_strdup_printf("%s/.config/%s/%s.conf", Lenv, PACKAGE, PACKAGE);
+ } else if ((Lenv=g_getenv("HOME"))) {
+ g_snprintf(Lpath, sizeof(Lpath)-1, "%s/.config/%s/%s.conf", Lenv, PACKAGE,
PACKAGE);
Lnewlist = g_slist_append(Lnewlist, Lpath);
}
@@ -243,13 +241,55 @@
Llistpath = g_strsplit(Lenv, ":", 0);
for (i=0; Llistpath[i]; i++) {
- Lpath = g_strdup_printf("%s/%s/%s.conf", Llistpath[i], PACKAGE, PACKAGE);
+ g_snprintf(Lpath, sizeof(Lpath)-1, "%s/%s/%s.conf", Llistpath[i],
PACKAGE, PACKAGE);
Lnewlist = g_slist_append(Lnewlist, Lpath);
+ }
+
+ g_strfreev(Llistpath);
+
+ } else {
+ g_snprintf(Lpath, sizeof(Lpath)-1, "/etc/xdg/%s", PACKAGE);
+ }
- g_free(Lpath);
+ return Lnewlist;
+}
+
+/* on regarde si un repertoire de donnée existe
+ * tel que definie par http://standards.freedesktop.org/basedir-spec/latest/
+ * on regarde de + en dernier dans le DATADIR definie a la compilation
+ */
+
+/* construction de la liste des PATH dans lequel on va chercher la
configuration */
+GSList *get_data_path()
+{
+ GSList *Lnewlist = NULL;
+ const gchar *Lenv;
+ gchar Lpath[MAXPATHLEN];
+ gchar **Llistpath;
+ gint i;
+
+ if ((Lenv=g_getenv("XDG_DATA_HOME"))) {
+ g_strdup_printf(Lpath, sizeof(Lpath)-1, "%s/%s/%s.conf", Lenv, PACKAGE,
PACKAGE);
+ Lnewlist = g_slist_append(Lnewlist, Lpath);
+ } else if ((Lenv=g_getenv("HOME"))) {
+ g_strdup_printf(Lpath, sizeof(Lpath)-1, "%s/.local/share/%s/%s.conf",
Lenv, PACKAGE, PACKAGE);
+ Lnewlist = g_slist_append(Lnewlist, Lpath);
+ }
+
+ if ((Lenv = g_getenv("XDG_DATA_DIRS"))) {
+ Llistpath = g_strsplit(Lenv, ":", 0);
+
+ for (i=0; Llistpath[i]; i++) {
+ g_strdup_printf(Lpath, sizeof(Lpath)-1, "%s/%s/%s.conf", Llistpath[i],
PACKAGE, PACKAGE);
+ Lnewlist = g_slist_append(Lnewlist, Lpath);
}
g_strfreev(Llistpath);
+ } else {
+ g_snprintf(Lpath, sizeof(Lpath)-1, "/usr/local/share/%s", PACKAGE);
+ Lnewlist = g_slist_append(Lnewlist, Lpath);
+ g_snprintf(Lpath, sizeof(Lpath)-1, "/usr/share/%s", PACKAGE);
+ Lnewlist = g_slist_append(Lnewlist, Lpath);
}
return Lnewlist;
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/04
- [Graveman-cvs] Changes to graveman/current/src/config.c,
sylvain cresto <=
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/14
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/14
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/14
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/17
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/17
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/19
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/20
- [Graveman-cvs] Changes to graveman/current/src/config.c, sylvain cresto, 2005/04/21