Mercurial > audlegacy
annotate src/audacious/configdb.c @ 3001:6d4b7b739232 trunk
fully implement UiSkinnedNumber, number.c no longer needed
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Sun, 08 Jul 2007 12:21:09 +0200 |
parents | d226b83fa329 |
children | 4c758281fe8f |
rev | line source |
---|---|
2865
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
1 /* |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
2 * audacious: Cross-platform multimedia player. |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
3 * configdb.c: Compatibility API for BMP's ConfigDB system. |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
4 * |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
5 * Copyright (c) 2005-2007 Audacious development team. |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
6 * Copyright (c) 2003-2005 BMP development team. |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
7 * |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
8 * Redistribution and use in source and binary forms, with or without |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
9 * modification, are permitted provided that the following conditions are |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
10 * met: |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
11 * |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
12 * 1. Redistributions of source code must retain the above copyright notice, |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
13 * this list of conditions and the following disclaimer. |
2313 | 14 * |
2865
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
15 * 2. Redistributions in binary form must reproduce the above copyright |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
16 * notice, this list of conditions and the following disclaimer in the |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
17 * documentation and/or other materials provided with the distribution. |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
18 * |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
19 * 3. The name of the author may not be used to endorse or promote products |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
20 * derived from this software without specific prior written permission. |
2313 | 21 * |
2865
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
25 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
30 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
31 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
d226b83fa329
BSD relicensing (pass 6).
William Pitcock <nenolod@atheme.org>
parents:
2712
diff
changeset
|
32 * POSSIBILITY OF SUCH DAMAGE. |
2313 | 33 */ |
34 | |
35 #ifdef HAVE_CONFIG_H | |
36 # include "config.h" | |
37 #endif | |
38 | |
39 #include "configdb.h" | |
40 | |
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
|
41 #include <stdlib.h> |
2313 | 42 #include <string.h> |
2358 | 43 |
44 #include <libmcs/mcs.h> | |
2313 | 45 |
46 | |
47 #define RCFILE_DEFAULT_SECTION_NAME "audacious" | |
48 | |
2358 | 49 static gboolean mcs_initted = FALSE; |
2313 | 50 |
51 struct _ConfigDb | |
52 { | |
2358 | 53 mcs_handle_t *handle; |
2313 | 54 }; |
55 | |
56 | |
57 ConfigDb * | |
58 bmp_cfg_db_open() | |
59 { | |
60 ConfigDb *db; | |
61 | |
62 db = g_new(ConfigDb, 1); | |
63 | |
2358 | 64 if (!mcs_initted) |
65 { | |
66 mcs_init(); | |
67 mcs_initted = TRUE; | |
2325
63c9a2724e73
[svn] - revert r3646 because it is not a user-friendly method of transitioning.
nenolod
parents:
2318
diff
changeset
|
68 } |
2313 | 69 |
2358 | 70 db->handle = mcs_new(RCFILE_DEFAULT_SECTION_NAME); |
2313 | 71 |
72 return db; | |
73 } | |
74 | |
75 void | |
76 bmp_cfg_db_close(ConfigDb * db) | |
77 { | |
2358 | 78 mcs_destroy(db->handle); |
79 g_free(db); | |
2313 | 80 } |
81 | |
82 gboolean | |
83 bmp_cfg_db_get_string(ConfigDb * db, | |
84 const gchar * section, | |
85 const gchar * key, | |
86 gchar ** value) | |
87 { | |
88 if (!section) | |
89 section = RCFILE_DEFAULT_SECTION_NAME; | |
90 | |
2358 | 91 return mcs_get_string(db->handle, section, key, value); |
2313 | 92 } |
93 | |
94 gboolean | |
95 bmp_cfg_db_get_int(ConfigDb * db, | |
96 const gchar * section, const gchar * key, gint * value) | |
97 { | |
98 if (!section) | |
99 section = RCFILE_DEFAULT_SECTION_NAME; | |
100 | |
2358 | 101 return mcs_get_int(db->handle, section, key, value); |
2313 | 102 } |
103 | |
104 gboolean | |
105 bmp_cfg_db_get_bool(ConfigDb * db, | |
106 const gchar * section, | |
107 const gchar * key, | |
108 gboolean * value) | |
109 { | |
110 if (!section) | |
111 section = RCFILE_DEFAULT_SECTION_NAME; | |
112 | |
2358 | 113 return mcs_get_bool(db->handle, section, key, value); |
2313 | 114 } |
115 | |
116 gboolean | |
117 bmp_cfg_db_get_float(ConfigDb * db, | |
118 const gchar * section, | |
119 const gchar * key, | |
120 gfloat * value) | |
121 { | |
122 if (!section) | |
123 section = RCFILE_DEFAULT_SECTION_NAME; | |
124 | |
2358 | 125 return mcs_get_float(db->handle, section, key, value); |
2313 | 126 } |
127 | |
128 gboolean | |
129 bmp_cfg_db_get_double(ConfigDb * db, | |
130 const gchar * section, | |
131 const gchar * key, | |
132 gdouble * value) | |
133 { | |
134 if (!section) | |
135 section = RCFILE_DEFAULT_SECTION_NAME; | |
136 | |
2358 | 137 return mcs_get_double(db->handle, section, key, value); |
2313 | 138 } |
139 | |
140 void | |
141 bmp_cfg_db_set_string(ConfigDb * db, | |
142 const gchar * section, | |
143 const gchar * key, | |
2346
0b98ad8c8b17
[svn] removed xmms_create_dirbrowser, small config db fixes
mf0102
parents:
2326
diff
changeset
|
144 const gchar * value) |
2313 | 145 { |
146 if (!section) | |
147 section = RCFILE_DEFAULT_SECTION_NAME; | |
148 | |
2358 | 149 mcs_set_string(db->handle, section, key, value); |
2313 | 150 } |
151 | |
152 void | |
153 bmp_cfg_db_set_int(ConfigDb * db, | |
154 const gchar * section, | |
155 const gchar * key, | |
156 gint value) | |
157 { | |
158 if (!section) | |
159 section = RCFILE_DEFAULT_SECTION_NAME; | |
160 | |
2358 | 161 mcs_set_int(db->handle, section, key, value); |
2313 | 162 } |
163 | |
164 void | |
165 bmp_cfg_db_set_bool(ConfigDb * db, | |
166 const gchar * section, | |
167 const gchar * key, | |
168 gboolean value) | |
169 { | |
170 if (!section) | |
171 section = RCFILE_DEFAULT_SECTION_NAME; | |
172 | |
2359
75598f596c92
[svn] - support for libmcs (pass --enable-mcs to configure)
nenolod
parents:
2358
diff
changeset
|
173 mcs_set_bool(db->handle, section, key, value); |
2313 | 174 } |
175 | |
176 void | |
177 bmp_cfg_db_set_float(ConfigDb * db, | |
178 const gchar * section, | |
179 const gchar * key, | |
180 gfloat value) | |
181 { | |
182 if (!section) | |
183 section = RCFILE_DEFAULT_SECTION_NAME; | |
184 | |
2358 | 185 mcs_set_float(db->handle, section, key, value); |
2313 | 186 } |
187 | |
188 void | |
189 bmp_cfg_db_set_double(ConfigDb * db, | |
190 const gchar * section, | |
191 const gchar * key, | |
192 gdouble value) | |
193 { | |
194 if (!section) | |
195 section = RCFILE_DEFAULT_SECTION_NAME; | |
196 | |
2358 | 197 mcs_set_double(db->handle, section, key, value); |
2313 | 198 } |
199 | |
200 void | |
201 bmp_cfg_db_unset_key(ConfigDb * db, | |
202 const gchar * section, | |
203 const gchar * key) | |
204 { | |
205 g_return_if_fail(db != NULL); | |
206 g_return_if_fail(key != NULL); | |
207 | |
208 if (!section) | |
209 section = RCFILE_DEFAULT_SECTION_NAME; | |
210 | |
2358 | 211 mcs_unset_key(db->handle, section, key); |
2313 | 212 } |