Mercurial > audlegacy
annotate src/audacious/configdb.c @ 3112:4c758281fe8f trunk
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Thu, 19 Jul 2007 19:59:04 -0500 |
parents | d226b83fa329 |
children | 3b6d316f8b09 |
rev | line source |
---|---|
3112
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
1 /* This program is free software; you can redistribute it and/or modify |
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
2 * it under the terms of the GNU General Public License as published by |
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
3 * the Free Software Foundation; either version 2 of the License, or |
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
4 * (at your option) any later version. |
2313 | 5 * |
3112
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
6 * This program is distributed in the hope that it will be useful, |
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
9 * GNU General Public License for more details. |
2313 | 10 * |
3112
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
11 * You should have received a copy of the GNU General Public License |
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
12 * along with this program; if not, write to the Free Software |
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
13 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
2313 | 14 */ |
15 | |
16 #ifdef HAVE_CONFIG_H | |
17 # include "config.h" | |
18 #endif | |
19 | |
20 #include "configdb.h" | |
21 | |
2314
d5d95a459a19
[svn] - fix: E:configdb_rcfile.c(45) [bmp_cfg_db_open]:Autoconversion of integer to pointer is not allowed in C99
nenolod
parents:
2313
diff
changeset
|
22 #include <stdlib.h> |
2313 | 23 #include <string.h> |
2358 | 24 |
25 #include <libmcs/mcs.h> | |
2313 | 26 |
27 | |
28 #define RCFILE_DEFAULT_SECTION_NAME "audacious" | |
29 | |
2358 | 30 static gboolean mcs_initted = FALSE; |
2313 | 31 |
32 struct _ConfigDb | |
33 { | |
2358 | 34 mcs_handle_t *handle; |
2313 | 35 }; |
36 | |
37 | |
38 ConfigDb * | |
39 bmp_cfg_db_open() | |
40 { | |
41 ConfigDb *db; | |
42 | |
43 db = g_new(ConfigDb, 1); | |
44 | |
2358 | 45 if (!mcs_initted) |
46 { | |
47 mcs_init(); | |
48 mcs_initted = TRUE; | |
2325
63c9a2724e73
[svn] - revert r3646 because it is not a user-friendly method of transitioning.
nenolod
parents:
2318
diff
changeset
|
49 } |
2313 | 50 |
2358 | 51 db->handle = mcs_new(RCFILE_DEFAULT_SECTION_NAME); |
2313 | 52 |
53 return db; | |
54 } | |
55 | |
56 void | |
57 bmp_cfg_db_close(ConfigDb * db) | |
58 { | |
2358 | 59 mcs_destroy(db->handle); |
60 g_free(db); | |
2313 | 61 } |
62 | |
63 gboolean | |
64 bmp_cfg_db_get_string(ConfigDb * db, | |
65 const gchar * section, | |
66 const gchar * key, | |
67 gchar ** value) | |
68 { | |
69 if (!section) | |
70 section = RCFILE_DEFAULT_SECTION_NAME; | |
71 | |
2358 | 72 return mcs_get_string(db->handle, section, key, value); |
2313 | 73 } |
74 | |
75 gboolean | |
76 bmp_cfg_db_get_int(ConfigDb * db, | |
77 const gchar * section, const gchar * key, gint * value) | |
78 { | |
79 if (!section) | |
80 section = RCFILE_DEFAULT_SECTION_NAME; | |
81 | |
2358 | 82 return mcs_get_int(db->handle, section, key, value); |
2313 | 83 } |
84 | |
85 gboolean | |
86 bmp_cfg_db_get_bool(ConfigDb * db, | |
87 const gchar * section, | |
88 const gchar * key, | |
89 gboolean * value) | |
90 { | |
91 if (!section) | |
92 section = RCFILE_DEFAULT_SECTION_NAME; | |
93 | |
2358 | 94 return mcs_get_bool(db->handle, section, key, value); |
2313 | 95 } |
96 | |
97 gboolean | |
98 bmp_cfg_db_get_float(ConfigDb * db, | |
99 const gchar * section, | |
100 const gchar * key, | |
101 gfloat * value) | |
102 { | |
103 if (!section) | |
104 section = RCFILE_DEFAULT_SECTION_NAME; | |
105 | |
2358 | 106 return mcs_get_float(db->handle, section, key, value); |
2313 | 107 } |
108 | |
109 gboolean | |
110 bmp_cfg_db_get_double(ConfigDb * db, | |
111 const gchar * section, | |
112 const gchar * key, | |
113 gdouble * value) | |
114 { | |
115 if (!section) | |
116 section = RCFILE_DEFAULT_SECTION_NAME; | |
117 | |
2358 | 118 return mcs_get_double(db->handle, section, key, value); |
2313 | 119 } |
120 | |
121 void | |
122 bmp_cfg_db_set_string(ConfigDb * db, | |
123 const gchar * section, | |
124 const gchar * key, | |
2346
0b98ad8c8b17
[svn] removed xmms_create_dirbrowser, small config db fixes
mf0102
parents:
2326
diff
changeset
|
125 const gchar * value) |
2313 | 126 { |
127 if (!section) | |
128 section = RCFILE_DEFAULT_SECTION_NAME; | |
129 | |
2358 | 130 mcs_set_string(db->handle, section, key, value); |
2313 | 131 } |
132 | |
133 void | |
134 bmp_cfg_db_set_int(ConfigDb * db, | |
135 const gchar * section, | |
136 const gchar * key, | |
137 gint value) | |
138 { | |
139 if (!section) | |
140 section = RCFILE_DEFAULT_SECTION_NAME; | |
141 | |
2358 | 142 mcs_set_int(db->handle, section, key, value); |
2313 | 143 } |
144 | |
145 void | |
146 bmp_cfg_db_set_bool(ConfigDb * db, | |
147 const gchar * section, | |
148 const gchar * key, | |
149 gboolean value) | |
150 { | |
151 if (!section) | |
152 section = RCFILE_DEFAULT_SECTION_NAME; | |
153 | |
2359
75598f596c92
[svn] - support for libmcs (pass --enable-mcs to configure)
nenolod
parents:
2358
diff
changeset
|
154 mcs_set_bool(db->handle, section, key, value); |
2313 | 155 } |
156 | |
157 void | |
158 bmp_cfg_db_set_float(ConfigDb * db, | |
159 const gchar * section, | |
160 const gchar * key, | |
161 gfloat value) | |
162 { | |
163 if (!section) | |
164 section = RCFILE_DEFAULT_SECTION_NAME; | |
165 | |
2358 | 166 mcs_set_float(db->handle, section, key, value); |
2313 | 167 } |
168 | |
169 void | |
170 bmp_cfg_db_set_double(ConfigDb * db, | |
171 const gchar * section, | |
172 const gchar * key, | |
173 gdouble value) | |
174 { | |
175 if (!section) | |
176 section = RCFILE_DEFAULT_SECTION_NAME; | |
177 | |
2358 | 178 mcs_set_double(db->handle, section, key, value); |
2313 | 179 } |
180 | |
181 void | |
182 bmp_cfg_db_unset_key(ConfigDb * db, | |
183 const gchar * section, | |
184 const gchar * key) | |
185 { | |
186 g_return_if_fail(db != NULL); | |
187 g_return_if_fail(key != NULL); | |
188 | |
189 if (!section) | |
190 section = RCFILE_DEFAULT_SECTION_NAME; | |
191 | |
2358 | 192 mcs_unset_key(db->handle, section, key); |
2313 | 193 } |