comparison src/audlegacy/configdb.c @ 4811:7bf7f83a217e

rename src/audacious src/audlegacy so that both audlegacy and audacious can coexist.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 26 Nov 2008 00:44:56 +0900
parents src/audacious/configdb.c@0ea6dd6bfb5a
children
comparison
equal deleted inserted replaced
4810:c10e53092037 4811:7bf7f83a217e
1 /* This program is free software; you can redistribute it and/or modify
2 * it under the terms of the GNU General Public License as published by
3 * the Free Software Foundation; under version 3 of the License.
4 *
5 * This program is distributed in the hope that it will be useful,
6 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 * GNU General Public License for more details.
9 *
10 * You should have received a copy of the GNU General Public License
11 * along with this program. If not, see <http://www.gnu.org/licenses>.
12 *
13 * The Audacious team does not consider modular code linking to
14 * Audacious or using our public API to be a derived work.
15 */
16
17 #ifdef HAVE_CONFIG_H
18 # include "config.h"
19 #endif
20
21 #include "configdb.h"
22 #include <libmcs/mcs.h>
23 #include <stdlib.h>
24 #include <string.h>
25
26
27 #define RCFILE_DEFAULT_SECTION_NAME "audlegacy"
28
29 static gboolean mcs_initted = FALSE;
30
31
32 mcs_handle_t *
33 cfg_db_open()
34 {
35 if (!mcs_initted)
36 {
37 mcs_init();
38 mcs_initted = TRUE;
39 }
40
41 return mcs_new(RCFILE_DEFAULT_SECTION_NAME);
42 }
43
44 void
45 cfg_db_close(mcs_handle_t * db)
46 {
47 mcs_destroy(db);
48 }
49
50 gboolean
51 cfg_db_get_string(mcs_handle_t * db,
52 const gchar * section,
53 const gchar * key,
54 gchar ** value)
55 {
56 if (!section)
57 section = RCFILE_DEFAULT_SECTION_NAME;
58
59 return mcs_get_string(db, section, key, value);
60 }
61
62 gboolean
63 cfg_db_get_int(mcs_handle_t * db,
64 const gchar * section, const gchar * key, gint * value)
65 {
66 if (!section)
67 section = RCFILE_DEFAULT_SECTION_NAME;
68
69 return mcs_get_int(db, section, key, value);
70 }
71
72 gboolean
73 cfg_db_get_bool(mcs_handle_t * db,
74 const gchar * section,
75 const gchar * key,
76 gboolean * value)
77 {
78 if (!section)
79 section = RCFILE_DEFAULT_SECTION_NAME;
80
81 return mcs_get_bool(db, section, key, value);
82 }
83
84 gboolean
85 cfg_db_get_float(mcs_handle_t * db,
86 const gchar * section,
87 const gchar * key,
88 gfloat * value)
89 {
90 if (!section)
91 section = RCFILE_DEFAULT_SECTION_NAME;
92
93 return mcs_get_float(db, section, key, value);
94 }
95
96 gboolean
97 cfg_db_get_double(mcs_handle_t * db,
98 const gchar * section,
99 const gchar * key,
100 gdouble * value)
101 {
102 if (!section)
103 section = RCFILE_DEFAULT_SECTION_NAME;
104
105 return mcs_get_double(db, section, key, value);
106 }
107
108 void
109 cfg_db_set_string(mcs_handle_t * db,
110 const gchar * section,
111 const gchar * key,
112 const gchar * value)
113 {
114 if (!section)
115 section = RCFILE_DEFAULT_SECTION_NAME;
116
117 mcs_set_string(db, section, key, value);
118 }
119
120 void
121 cfg_db_set_int(mcs_handle_t * db,
122 const gchar * section,
123 const gchar * key,
124 gint value)
125 {
126 if (!section)
127 section = RCFILE_DEFAULT_SECTION_NAME;
128
129 mcs_set_int(db, section, key, value);
130 }
131
132 void
133 cfg_db_set_bool(mcs_handle_t * db,
134 const gchar * section,
135 const gchar * key,
136 gboolean value)
137 {
138 if (!section)
139 section = RCFILE_DEFAULT_SECTION_NAME;
140
141 mcs_set_bool(db, section, key, value);
142 }
143
144 void
145 cfg_db_set_float(mcs_handle_t * db,
146 const gchar * section,
147 const gchar * key,
148 gfloat value)
149 {
150 if (!section)
151 section = RCFILE_DEFAULT_SECTION_NAME;
152
153 mcs_set_float(db, section, key, value);
154 }
155
156 void
157 cfg_db_set_double(mcs_handle_t * db,
158 const gchar * section,
159 const gchar * key,
160 gdouble value)
161 {
162 if (!section)
163 section = RCFILE_DEFAULT_SECTION_NAME;
164
165 mcs_set_double(db, section, key, value);
166 }
167
168 void
169 cfg_db_unset_key(mcs_handle_t * db,
170 const gchar * section,
171 const gchar * key)
172 {
173 g_return_if_fail(db != NULL);
174 g_return_if_fail(key != NULL);
175
176 if (!section)
177 section = RCFILE_DEFAULT_SECTION_NAME;
178
179 mcs_unset_key(db, section, key);
180 }