diff options
| author | Dana Jansens <danakj@orodu.net> | 2009-12-21 14:04:39 -0500 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2009-12-21 14:08:38 -0500 |
| commit | b06b684589a618a2481ccc2745d5e03abb6bd5e0 (patch) | |
| tree | f0a48ae7e8dd6fef771dcb1de8f7f49b9a8e0863 /obt | |
| parent | 04dc598a1fb195065403055fbb95589dd3511daa (diff) | |
rename the obt_parse library to obt_xml (since it is very xml specific)
Diffstat (limited to 'obt')
| -rw-r--r-- | obt/parse.h | 89 | ||||
| -rw-r--r-- | obt/xml.c (renamed from obt/parse.c) | 98 | ||||
| -rw-r--r-- | obt/xml.h | 89 |
3 files changed, 138 insertions, 138 deletions
diff --git a/obt/parse.h b/obt/parse.h deleted file mode 100644 index 400acf94..00000000 --- a/obt/parse.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- - - obt/parse.h for the Openbox window manager - Copyright (c) 2003-2007 Dana Jansens - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - See the COPYING file for a copy of the GNU General Public License. -*/ - -#ifndef __obt_parse_h -#define __obt_parse_h - -#include <libxml/parser.h> -#include <glib.h> - -G_BEGIN_DECLS - -typedef struct _ObtParseInst ObtParseInst; - -typedef void (*ObtParseCallback)(xmlNodePtr node, gpointer data); - -ObtParseInst* obt_parse_instance_new(void); -void obt_parse_instance_ref(ObtParseInst *inst); -void obt_parse_instance_unref(ObtParseInst *inst); - -gboolean obt_parse_load_file(ObtParseInst *inst, - const gchar *path, - const gchar *root_node); -gboolean obt_parse_load_config_file(ObtParseInst *inst, - const gchar *domain, - const gchar *filename, - const gchar *root_node); -gboolean obt_parse_load_data_file(ObtParseInst *inst, - const gchar *domain, - const gchar *filename, - const gchar *root_node); -gboolean obt_parse_load_theme_file(ObtParseInst *inst, - const gchar *theme, - const gchar *domain, - const gchar *filename, - const gchar *root_node); -gboolean obt_parse_load_mem(ObtParseInst *inst, - gpointer data, guint len, const gchar *root_node); - -gboolean obt_parse_save_file(ObtParseInst *inst, - const gchar *path, - gboolean pretty); - -xmlDocPtr obt_parse_doc(ObtParseInst *inst); -xmlNodePtr obt_parse_root(ObtParseInst *inst); - -void obt_parse_close(ObtParseInst *inst); - -void obt_parse_register(ObtParseInst *inst, const gchar *tag, - ObtParseCallback func, gpointer data); -void obt_parse_tree(ObtParseInst *i, xmlNodePtr node); -void obt_parse_tree_from_root(ObtParseInst *i); - - -/* helpers */ - -xmlNodePtr obt_parse_find_node(xmlNodePtr node, const gchar *name); - -gboolean obt_parse_node_contains (xmlNodePtr node, const gchar *val); -gchar *obt_parse_node_string (xmlNodePtr node); -gint obt_parse_node_int (xmlNodePtr node); -gboolean obt_parse_node_bool (xmlNodePtr node); - -gboolean obt_parse_attr_contains (xmlNodePtr node, const gchar *name, - const gchar *val); -gboolean obt_parse_attr_string (xmlNodePtr node, const gchar *name, - gchar **value); -gboolean obt_parse_attr_int (xmlNodePtr node, const gchar *name, - gint *value); -gboolean obt_parse_attr_bool (xmlNodePtr node, const gchar *name, - gboolean *value); - -G_END_DECLS - -#endif @@ -16,7 +16,7 @@ See the COPYING file for a copy of the GNU General Public License. */ -#include "obt/parse.h" +#include "obt/xml.h" #include "obt/paths.h" #include <glib.h> @@ -36,11 +36,11 @@ struct Callback { gchar *tag; - ObtParseCallback func; + ObtXmlCallback func; gpointer data; }; -struct _ObtParseInst { +struct _ObtXmlInst { gint ref; ObtPaths *xdg_paths; GHashTable *callbacks; @@ -55,9 +55,9 @@ static void destfunc(struct Callback *c) g_free(c); } -ObtParseInst* obt_parse_instance_new(void) +ObtXmlInst* obt_xml_instance_new(void) { - ObtParseInst *i = g_new(ObtParseInst, 1); + ObtXmlInst *i = g_new(ObtXmlInst, 1); i->ref = 1; i->xdg_paths = obt_paths_new(); i->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, @@ -68,12 +68,12 @@ ObtParseInst* obt_parse_instance_new(void) return i; } -void obt_parse_instance_ref(ObtParseInst *i) +void obt_xml_instance_ref(ObtXmlInst *i) { ++i->ref; } -void obt_parse_instance_unref(ObtParseInst *i) +void obt_xml_instance_unref(ObtXmlInst *i) { if (i && --i->ref == 0) { obt_paths_unref(i->xdg_paths); @@ -82,20 +82,20 @@ void obt_parse_instance_unref(ObtParseInst *i) } } -xmlDocPtr obt_parse_doc(ObtParseInst *i) +xmlDocPtr obt_xml_doc(ObtXmlInst *i) { g_assert(i->doc); /* a doc is open? */ return i->doc; } -xmlNodePtr obt_parse_root(ObtParseInst *i) +xmlNodePtr obt_xml_root(ObtXmlInst *i) { g_assert(i->doc); /* a doc is open? */ return i->root; } -void obt_parse_register(ObtParseInst *i, const gchar *tag, - ObtParseCallback func, gpointer data) +void obt_xml_register(ObtXmlInst *i, const gchar *tag, + ObtXmlCallback func, gpointer data) { struct Callback *c; @@ -111,7 +111,7 @@ void obt_parse_register(ObtParseInst *i, const gchar *tag, g_hash_table_insert(i->callbacks, c->tag, c); } -static gboolean load_file(ObtParseInst *i, +static gboolean load_file(ObtXmlInst *i, const gchar *domain, const gchar *filename, const gchar *root_node, @@ -164,9 +164,9 @@ static gboolean load_file(ObtParseInst *i, return r; } -gboolean obt_parse_load_file(ObtParseInst *i, - const gchar *path, - const gchar *root_node) +gboolean obt_xml_load_file(ObtXmlInst *i, + const gchar *path, + const gchar *root_node) { GSList *paths; gboolean r; @@ -182,10 +182,10 @@ gboolean obt_parse_load_file(ObtParseInst *i, return r; } -gboolean obt_parse_load_config_file(ObtParseInst *i, - const gchar *domain, - const gchar *filename, - const gchar *root_node) +gboolean obt_xml_load_config_file(ObtXmlInst *i, + const gchar *domain, + const gchar *filename, + const gchar *root_node) { GSList *it, *paths = NULL; gboolean r; @@ -202,10 +202,10 @@ gboolean obt_parse_load_config_file(ObtParseInst *i, return r; } -gboolean obt_parse_load_data_file(ObtParseInst *i, - const gchar *domain, - const gchar *filename, - const gchar *root_node) +gboolean obt_xml_load_data_file(ObtXmlInst *i, + const gchar *domain, + const gchar *filename, + const gchar *root_node) { GSList *it, *paths = NULL; gboolean r; @@ -222,11 +222,11 @@ gboolean obt_parse_load_data_file(ObtParseInst *i, return r; } -gboolean obt_parse_load_theme_file(ObtParseInst *i, - const gchar *theme, - const gchar *domain, - const gchar *filename, - const gchar *root_node) +gboolean obt_xml_load_theme_file(ObtXmlInst *i, + const gchar *theme, + const gchar *domain, + const gchar *filename, + const gchar *root_node) { GSList *it, *paths = NULL; gboolean r; @@ -249,8 +249,8 @@ gboolean obt_parse_load_theme_file(ObtParseInst *i, } -gboolean obt_parse_load_mem(ObtParseInst *i, - gpointer data, guint len, const gchar *root_node) +gboolean obt_xml_load_mem(ObtXmlInst *i, + gpointer data, guint len, const gchar *root_node) { gboolean r = FALSE; @@ -277,14 +277,14 @@ gboolean obt_parse_load_mem(ObtParseInst *i, return r; } -gboolean obt_parse_save_file(ObtParseInst *inst, - const gchar *path, - gboolean pretty) +gboolean obt_xml_save_file(ObtXmlInst *inst, + const gchar *path, + gboolean pretty) { return xmlSaveFormatFile(path, inst->doc, pretty) != -1; } -void obt_parse_close(ObtParseInst *i) +void obt_xml_close(ObtXmlInst *i) { if (i && i->doc) { xmlFreeDoc(i->doc); @@ -295,7 +295,7 @@ void obt_parse_close(ObtParseInst *i) } } -void obt_parse_tree(ObtParseInst *i, xmlNodePtr node) +void obt_xml_tree(ObtXmlInst *i, xmlNodePtr node) { g_assert(i->doc); /* a doc is open? */ @@ -306,12 +306,12 @@ void obt_parse_tree(ObtParseInst *i, xmlNodePtr node) } } -void obt_parse_tree_from_root(ObtParseInst *i) +void obt_xml_tree_from_root(ObtXmlInst *i) { - obt_parse_tree(i, i->root->children); + obt_xml_tree(i, i->root->children); } -gchar *obt_parse_node_string(xmlNodePtr node) +gchar *obt_xml_node_string(xmlNodePtr node) { xmlChar *c = xmlNodeGetContent(node); gchar *s; @@ -321,7 +321,7 @@ gchar *obt_parse_node_string(xmlNodePtr node) return s; } -gint obt_parse_node_int(xmlNodePtr node) +gint obt_xml_node_int(xmlNodePtr node) { xmlChar *c = xmlNodeGetContent(node); gint i; @@ -331,7 +331,7 @@ gint obt_parse_node_int(xmlNodePtr node) return i; } -gboolean obt_parse_node_bool(xmlNodePtr node) +gboolean obt_xml_node_bool(xmlNodePtr node) { xmlChar *c = xmlNodeGetContent(node); gboolean b = FALSE; @@ -346,7 +346,7 @@ gboolean obt_parse_node_bool(xmlNodePtr node) return b; } -gboolean obt_parse_node_contains(xmlNodePtr node, const gchar *val) +gboolean obt_xml_node_contains(xmlNodePtr node, const gchar *val) { xmlChar *c = xmlNodeGetContent(node); gboolean r; @@ -356,7 +356,7 @@ gboolean obt_parse_node_contains(xmlNodePtr node, const gchar *val) return r; } -xmlNodePtr obt_parse_find_node(xmlNodePtr node, const gchar *tag) +xmlNodePtr obt_xml_find_node(xmlNodePtr node, const gchar *tag) { while (node) { if (!xmlStrcmp(node->name, (const xmlChar*) tag)) @@ -366,8 +366,8 @@ xmlNodePtr obt_parse_find_node(xmlNodePtr node, const gchar *tag) return NULL; } -gboolean obt_parse_attr_bool(xmlNodePtr node, const gchar *name, - gboolean *value) +gboolean obt_xml_attr_bool(xmlNodePtr node, const gchar *name, + gboolean *value) { xmlChar *c = xmlGetProp(node, (const xmlChar*) name); gboolean r = FALSE; @@ -390,7 +390,7 @@ gboolean obt_parse_attr_bool(xmlNodePtr node, const gchar *name, return r; } -gboolean obt_parse_attr_int(xmlNodePtr node, const gchar *name, gint *value) +gboolean obt_xml_attr_int(xmlNodePtr node, const gchar *name, gint *value) { xmlChar *c = xmlGetProp(node, (const xmlChar*) name); gboolean r = FALSE; @@ -403,8 +403,8 @@ gboolean obt_parse_attr_int(xmlNodePtr node, const gchar *name, gint *value) return r; } -gboolean obt_parse_attr_string(xmlNodePtr node, const gchar *name, - gchar **value) +gboolean obt_xml_attr_string(xmlNodePtr node, const gchar *name, + gchar **value) { xmlChar *c = xmlGetProp(node, (const xmlChar*) name); gboolean r = FALSE; @@ -417,8 +417,8 @@ gboolean obt_parse_attr_string(xmlNodePtr node, const gchar *name, return r; } -gboolean obt_parse_attr_contains(xmlNodePtr node, const gchar *name, - const gchar *val) +gboolean obt_xml_attr_contains(xmlNodePtr node, const gchar *name, + const gchar *val) { xmlChar *c = xmlGetProp(node, (const xmlChar*) name); gboolean r = FALSE; diff --git a/obt/xml.h b/obt/xml.h new file mode 100644 index 00000000..006ab503 --- /dev/null +++ b/obt/xml.h @@ -0,0 +1,89 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + obt/parse.h for the Openbox window manager + Copyright (c) 2003-2007 Dana Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + +#ifndef __obt_xml_h +#define __obt_xml_h + +#include <libxml/parser.h> +#include <glib.h> + +G_BEGIN_DECLS + +typedef struct _ObtXmlInst ObtXmlInst; + +typedef void (*ObtXmlCallback)(xmlNodePtr node, gpointer data); + +ObtXmlInst* obt_xml_instance_new(void); +void obt_xml_instance_ref(ObtXmlInst *inst); +void obt_xml_instance_unref(ObtXmlInst *inst); + +gboolean obt_xml_load_file(ObtXmlInst *inst, + const gchar *path, + const gchar *root_node); +gboolean obt_xml_load_config_file(ObtXmlInst *inst, + const gchar *domain, + const gchar *filename, + const gchar *root_node); +gboolean obt_xml_load_data_file(ObtXmlInst *inst, + const gchar *domain, + const gchar *filename, + const gchar *root_node); +gboolean obt_xml_load_theme_file(ObtXmlInst *inst, + const gchar *theme, + const gchar *domain, + const gchar *filename, + const gchar *root_node); +gboolean obt_xml_load_mem(ObtXmlInst *inst, + gpointer data, guint len, const gchar *root_node); + +gboolean obt_xml_save_file(ObtXmlInst *inst, + const gchar *path, + gboolean pretty); + +xmlDocPtr obt_xml_doc(ObtXmlInst *inst); +xmlNodePtr obt_xml_root(ObtXmlInst *inst); + +void obt_xml_close(ObtXmlInst *inst); + +void obt_xml_register(ObtXmlInst *inst, const gchar *tag, + ObtXmlCallback func, gpointer data); +void obt_xml_tree(ObtXmlInst *i, xmlNodePtr node); +void obt_xml_tree_from_root(ObtXmlInst *i); + + +/* helpers */ + +xmlNodePtr obt_xml_find_node (xmlNodePtr node, const gchar *name); + +gboolean obt_xml_node_contains (xmlNodePtr node, const gchar *val); +gchar *obt_xml_node_string (xmlNodePtr node); +gint obt_xml_node_int (xmlNodePtr node); +gboolean obt_xml_node_bool (xmlNodePtr node); + +gboolean obt_xml_attr_contains (xmlNodePtr node, const gchar *name, + const gchar *val); +gboolean obt_xml_attr_string (xmlNodePtr node, const gchar *name, + gchar **value); +gboolean obt_xml_attr_int (xmlNodePtr node, const gchar *name, + gint *value); +gboolean obt_xml_attr_bool (xmlNodePtr node, const gchar *name, + gboolean *value); + +G_END_DECLS + +#endif |
