Sidebar style for treevie win sidebar.
[gmpc.git] / src / config1.h
blobe3809dbe2bae91600bee0c7d47994fc152c20c55
1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2012 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.org/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <glib.h>
21 #ifndef __CONFIG_1_H__
22 #define __CONFIG_1_H__
24 /**
25 * \defgroup Config1 Config
26 * \brief GMPC config system.
28 /* @{@ */
29 #define CFG_INT_NOT_DEFINED -65536
32 typedef struct _config_obj config_obj;
35 typedef struct conf_mult_obj
37 char *key;
38 char *value;
39 struct conf_mult_obj *next;
40 struct conf_mult_obj *prev;
41 } conf_mult_obj;
43 /**
44 * @param url The path to the config file to open.
46 * Open the config file.
48 * @returns A #config_obj if opened succesful #NULL on failure.
50 config_obj *cfg_open(const gchar * url);
52 /**
53 * @param cfgo The #config_obj to close
55 * Free's the #config_obj and if needed saves it.
57 void cfg_close(config_obj * cfgo);
60 /**
61 * @param cfg The #config_obj.
62 * @param class The config subclass.
63 * @param key The key to get.
65 * Get a single config value as a string.
67 * F.e. #cfg_get_single_value_as_string(cfg, "aap", "mies");
68 * Will get the value of key mies in class aap.
71 * @returns NULL when the value is not availible, an allocated string if
72 * found. (needs to be free'ed)
74 char *cfg_get_single_value_as_string(config_obj * cfg, const char *class,
75 const char *key);
76 /**
77 * @param cfg The #config_obj.
78 * @param class The config subclass.
79 * @param key The key to get.
80 * @param value The new value for class:key.
82 * Set single value.
84 void cfg_set_single_value_as_string(config_obj * cfg, const char *class,
85 const char *key, const char *value);
86 /**
87 * @param cfg The #config_obj.
88 * @param class The config subclass.
89 * @param key The key to get.
90 * @param def The value to return if class:key is not found.
92 * Get single string value.
94 * @returns The value off class:key converted to a string or def is not found.
96 char *cfg_get_single_value_as_string_with_default(config_obj * cfg,
97 const char *class,
98 const char *key,
99 const char *def);
101 * @param cfg The #config_obj.
102 * @param class The config subclass.
103 * @param key The key to get.
105 * Get a single config value as a int.
108 * @returns CFG_INT_NOT_DEFINED when the value is not availible.
110 int cfg_get_single_value_as_int(config_obj * cfg, const char *class,
111 const char *key);
113 * @param cfg The #config_obj.
114 * @param class The config subclass.
115 * @param key The key to get.
116 * @param value The new value for class:key.
118 * Set single value.
120 void cfg_set_single_value_as_int(config_obj * cfg, const char *class,
121 const char *key, int value);
123 * @param cfg The #config_obj.
124 * @param class The config subclass.
125 * @param key The key to get.
126 * @param def The value to return if class:key is not found.
128 * Get single int value.
129 * @returns The value off class:key converted to a int or def is not found.
131 int cfg_get_single_value_as_int_with_default(config_obj * cfg,
132 const char *class, const char *key,
133 int def);
136 * @param cfg The #config_obj.
137 * @param class The config subclass.
138 * @param key The key to get.
140 * Get a single config value as a float.
143 * @returns CFG_INT_NOT_DEFINED when the value is not availible.
145 float cfg_get_single_value_as_float(config_obj * cfg, const char *class,
146 const char *key);
148 * @param cfg The #config_obj.
149 * @param class The config subclass.
150 * @param key The key to get.
151 * @param value The new value for class:key.
153 * Set single value.
155 void cfg_set_single_value_as_float(config_obj * cfg, const char *class,
156 const char *key, float value);
158 * @param cfg The #config_obj.
159 * @param class The config subclass.
160 * @param key The key to get.
161 * @param def The value to return if class:key is not found.
163 * Get single float value.
164 * @returns The value off class:key converted to a float or def is not found.
166 float cfg_get_single_value_as_float_with_default(config_obj * cfg,
167 const char *class,
168 const char *key, float def);
171 * @param cfg The #config_obj.
172 * @param class The config subclass.
173 * @param key The key to remove.
175 * Removes a single value.
177 void cfg_del_single_value(config_obj * cfg, const char *class, const char *key);
180 * @param cfg The #config_obj
182 * Get a list of all the classes.
184 * @returns a linked list (type #conf_mult_obj) of all the classes.
186 conf_mult_obj *cfg_get_class_list(config_obj * data);
189 * @param cfg The #config_obj
190 * @param class The class to get the keys from.
192 * Get a list of all the keys in class class.
194 * @returns a linked list (type #conf_mult_obj) of all the keys.
196 conf_mult_obj *cfg_get_key_list(config_obj * data, const char *class);
199 * @param data The #conf_mult_obj to free
201 * Free's the #conf_mult_obj.
203 void cfg_free_multiple(conf_mult_obj * data);
206 * @param cfg the #config_obj.
208 * Remove class from the config file, including all sub-items.
210 void cfg_remove_class(config_obj * cfg, const char *class);
212 #define cfg_free_string(a) g_free(a);a=NULL;
213 /* @{@ */
214 #endif