/[graveman]/graveman/current/src/config.c
ViewVC logotype

Diff of /graveman/current/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.29 by scresto, Mon Apr 4 01:37:42 2005 UTC revision 1.30 by scresto, Tue Apr 12 23:12:52 2005 UTC
# Line 218  void config_init() Line 218  void config_init()
218  }  }
219    
220  /* on regarde si un fichier de configuration existe  /* on regarde si un fichier de configuration existe
221   * dans /usr/share/graveman/graveman.rc ou ~/.graveman/graveman.rc */   * tel que definie par http://standards.freedesktop.org/basedir-spec/latest/ */
222    
223  /* construction de la liste des PATH dans lequel on va chercher la configuration */  /* construction de la liste des PATH dans lequel on va chercher la configuration */
224  GSList *get_config_path()  GSList *get_config_path()
225  {  {
226    GSList *Lnewlist = NULL;    GSList *Lnewlist = NULL;
227    const gchar *Lenv;    const gchar *Lenv;
228    gchar *Lpath;    gchar Lpath[MAXPATHLEN];
229    gchar **Llistpath;    gchar **Llistpath;
230    gint i;    gint i;
231    
232    if ((Lenv=g_getenv("XDG_CONFIG_HOME"))) {    if ((Lenv=g_getenv("XDG_CONFIG_HOME"))) {
233      Lpath = g_strdup_printf("%s/%s/%s.conf", Lenv, PACKAGE, PACKAGE);      g_snprintf(Lpath, sizeof(Lpath)-1, "%s/%s/%s.conf", Lenv, PACKAGE, PACKAGE);
234      Lnewlist = g_slist_append(Lnewlist, Lpath);      Lnewlist = g_slist_append(Lnewlist, Lpath);
235    }    } else if ((Lenv=g_getenv("HOME"))) {
236        g_snprintf(Lpath, sizeof(Lpath)-1, "%s/.config/%s/%s.conf", Lenv, PACKAGE, PACKAGE);
   if ((Lenv=g_getenv("HOME"))) {  
     Lpath = g_strdup_printf("%s/.config/%s/%s.conf", Lenv, PACKAGE, PACKAGE);  
237      Lnewlist = g_slist_append(Lnewlist, Lpath);      Lnewlist = g_slist_append(Lnewlist, Lpath);
238    }    }
239    
# Line 243  GSList *get_config_path() Line 241  GSList *get_config_path()
241      Llistpath = g_strsplit(Lenv, ":", 0);      Llistpath = g_strsplit(Lenv, ":", 0);
242    
243      for (i=0; Llistpath[i]; i++) {      for (i=0; Llistpath[i]; i++) {
244        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);
245        Lnewlist = g_slist_append(Lnewlist, Lpath);        Lnewlist = g_slist_append(Lnewlist, Lpath);
246        }
247    
248        g_strfreev(Llistpath);
249    
250      } else {
251        g_snprintf(Lpath, sizeof(Lpath)-1, "/etc/xdg/%s", PACKAGE);
252      }
253    
254      return Lnewlist;
255    }
256    
257    /* on regarde si un repertoire de donnée existe
258     * tel que definie par http://standards.freedesktop.org/basedir-spec/latest/
259     * on regarde de + en dernier dans le DATADIR definie a la compilation
260     */
261    
262    /* construction de la liste des PATH dans lequel on va chercher la configuration */
263    GSList *get_data_path()
264    {
265      GSList *Lnewlist = NULL;
266      const gchar *Lenv;
267      gchar Lpath[MAXPATHLEN];
268      gchar **Llistpath;
269      gint i;
270    
271      if ((Lenv=g_getenv("XDG_DATA_HOME"))) {
272        g_strdup_printf(Lpath, sizeof(Lpath)-1, "%s/%s/%s.conf", Lenv, PACKAGE, PACKAGE);
273        Lnewlist = g_slist_append(Lnewlist, Lpath);
274      } else if ((Lenv=g_getenv("HOME"))) {
275        g_strdup_printf(Lpath, sizeof(Lpath)-1, "%s/.local/share/%s/%s.conf", Lenv, PACKAGE, PACKAGE);
276        Lnewlist = g_slist_append(Lnewlist, Lpath);
277      }
278    
279      if ((Lenv = g_getenv("XDG_DATA_DIRS"))) {
280        Llistpath = g_strsplit(Lenv, ":", 0);
281    
282        g_free(Lpath);      for (i=0; Llistpath[i]; i++) {
283          g_strdup_printf(Lpath, sizeof(Lpath)-1, "%s/%s/%s.conf", Llistpath[i], PACKAGE, PACKAGE);
284          Lnewlist = g_slist_append(Lnewlist, Lpath);
285      }      }
286    
287      g_strfreev(Llistpath);      g_strfreev(Llistpath);
288      } else {
289        g_snprintf(Lpath, sizeof(Lpath)-1, "/usr/local/share/%s", PACKAGE);
290        Lnewlist = g_slist_append(Lnewlist, Lpath);
291        g_snprintf(Lpath, sizeof(Lpath)-1, "/usr/share/%s", PACKAGE);
292        Lnewlist = g_slist_append(Lnewlist, Lpath);
293    }    }
294    
295    return Lnewlist;    return Lnewlist;

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26