X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=parser%2Fparse.c;h=552221caf9e5128043253336faecc6442f3f59d1;hb=78d725009812d3aed87024264f0112ca9968519a;hp=b288d016bfd744adee034370eea9ee07fa6d9e25;hpb=efedb4df9c18ff68630ecb6fa9c012b459207e7d;p=chaz%2Fopenbox diff --git a/parser/parse.c b/parser/parse.c index b288d016..552221ca 100644 --- a/parser/parse.c +++ b/parser/parse.c @@ -79,16 +79,27 @@ void parse_register(ObParseInst *i, const gchar *tag, g_hash_table_insert(i->callbacks, c->tag, c); } -gboolean parse_load_rc(xmlDocPtr *doc, xmlNodePtr *root) +gboolean parse_load_rc(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root, + gchar **fileused) { GSList *it; - gchar *path; gboolean r = FALSE; + *fileused = NULL; + for (it = xdg_config_dir_paths; !r && it; it = g_slist_next(it)) { - path = g_build_filename(it->data, "openbox", "rc.xml", NULL); - r = parse_load(path, "openbox_config", doc, root); - g_free(path); + if (file) { + if ((r = parse_load(file, "openbox_config", doc, root))) + *fileused = g_strdup(file); + } else { + gchar *path; + + path = g_build_filename(it->data, "openbox", "rc.xml", NULL); + if ((r = parse_load(path, "openbox_config", doc, root))) + *fileused = path; + else + g_free(path); + } } if (!r) g_warning("Unable to find a valid config file, using defaults"); @@ -160,7 +171,7 @@ gboolean parse_load(const gchar *path, const gchar *rootname, *doc = NULL; g_warning("%s is an empty document", path); } else { - if (xmlStrcasecmp((*root)->name, (const xmlChar*)rootname)) { + if (xmlStrcmp((*root)->name, (const xmlChar*)rootname)) { xmlFreeDoc(*doc); *doc = NULL; g_warning("Document %s is of wrong type. root node is " @@ -183,7 +194,7 @@ gboolean parse_load_mem(gpointer data, guint len, const gchar *rootname, *doc = NULL; g_warning("Given memory is an empty document"); } else { - if (xmlStrcasecmp((*root)->name, (const xmlChar*)rootname)) { + if (xmlStrcmp((*root)->name, (const xmlChar*)rootname)) { xmlFreeDoc(*doc); *doc = NULL; g_warning("Document in given memory is of wrong type. root " @@ -255,7 +266,7 @@ gboolean parse_contains(const gchar *val, xmlDocPtr doc, xmlNodePtr node) xmlNodePtr parse_find_node(const gchar *tag, xmlNodePtr node) { while (node) { - if (!xmlStrcasecmp(node->name, (const xmlChar*) tag)) + if (!xmlStrcmp(node->name, (const xmlChar*) tag)) return node; node = node->next; } @@ -335,6 +346,8 @@ static GSList* slist_path_add(GSList *list, gpointer data, GSListFunc func) if (!g_slist_find_custom(list, data, (GCompareFunc) slist_path_cmp)) list = func(list, data); + else + g_free(data); return list; } @@ -389,7 +402,7 @@ void parse_paths_startup() (GSListFunc) g_slist_append); } xdg_config_dir_paths = slist_path_add(xdg_config_dir_paths, - xdg_config_home_path, + g_strdup(xdg_config_home_path), (GSListFunc) g_slist_prepend); path = g_getenv("XDG_DATA_DIRS"); @@ -411,7 +424,7 @@ void parse_paths_startup() (GSListFunc) g_slist_append); } xdg_data_dir_paths = slist_path_add(xdg_data_dir_paths, - xdg_data_home_path, + g_strdup(xdg_data_home_path), (GSListFunc) g_slist_prepend); }