]> icculus.org git repositories - mikachu/openbox.git/blob - parser/parse.h
xml tags are case sensitive
[mikachu/openbox.git] / parser / parse.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    parse.h for the Openbox window manager
4    Copyright (c) 2003        Ben Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef __parse_h
20 #define __parse_h
21
22 #include "version.h"
23
24 #include <libxml/parser.h>
25 #include <glib.h>
26
27 G_BEGIN_DECLS
28
29 typedef struct _ObParseInst ObParseInst;
30
31 typedef void (*ParseCallback)(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
32                               gpointer data);
33
34 ObParseInst* parse_startup();
35 void parse_shutdown(ObParseInst *inst);
36
37 /* Loads Openbox's rc, from the normal paths */
38 gboolean parse_load_rc(xmlDocPtr *doc, xmlNodePtr *root);
39 /* Loads an Openbox menu, from the normal paths */
40 gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root);
41 /* Loads an Openbox menu, from the normal paths */
42 gboolean parse_load_theme(const gchar *name, xmlDocPtr *doc, xmlNodePtr *root,
43                           gchar **path);
44
45 void parse_register(ObParseInst *inst, const gchar *tag,
46                     ParseCallback func, gpointer data);
47 void parse_tree(ObParseInst *inst, xmlDocPtr doc, xmlNodePtr node);
48
49
50 /* open/close */
51
52 gboolean parse_load(const gchar *path, const gchar *rootname,
53                     xmlDocPtr *doc, xmlNodePtr *root);
54 gboolean parse_load_mem(gpointer data, guint len, const gchar *rootname,
55                         xmlDocPtr *doc, xmlNodePtr *root);
56 void parse_close(xmlDocPtr doc);
57
58
59 /* helpers */
60
61 xmlNodePtr parse_find_node(const gchar *tag, xmlNodePtr node);
62
63 gchar *parse_string(xmlDocPtr doc, xmlNodePtr node);
64 gint parse_int(xmlDocPtr doc, xmlNodePtr node);
65 gboolean parse_bool(xmlDocPtr doc, xmlNodePtr node);
66
67 gboolean parse_contains(const gchar *val, xmlDocPtr doc, xmlNodePtr node);
68 gboolean parse_attr_contains(const gchar *val, xmlNodePtr node,
69                              const gchar *name);
70
71 gboolean parse_attr_string(const gchar *name, xmlNodePtr node, gchar **value);
72 gboolean parse_attr_int(const gchar *name, xmlNodePtr node, gint *value);
73 gboolean parse_attr_bool(const gchar *name, xmlNodePtr node, gboolean *value);
74
75 /* paths */
76
77 void parse_paths_startup();
78 void parse_paths_shutdown();
79
80 const gchar* parse_xdg_config_home_path();
81 const gchar* parse_xdg_data_home_path();
82 GSList* parse_xdg_config_dir_paths();
83 GSList* parse_xdg_data_dir_paths();
84
85 /*! Expands the ~ character to the home directory throughout the given
86   string */
87 gchar *parse_expand_tilde(const gchar *f);
88 /*! Makes a directory */
89 gboolean parse_mkdir(const gchar *path, gint mode);
90 /*! Makes a directory and all its parents */
91 gboolean parse_mkdir_path(const gchar *path, gint mode);
92
93 G_END_DECLS
94
95 #endif