comparison src/audacious/rcfile.c @ 4405:15c491f342eb

Rename bmp_rcfile* -> aud_rcfile*
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 31 Mar 2008 06:23:31 +0300
parents f1c756f39e6c
children
comparison
equal deleted inserted replaced
4404:7513318719a7 4405:15c491f342eb
29 29
30 #include <unistd.h> 30 #include <unistd.h>
31 #include <sys/stat.h> 31 #include <sys/stat.h>
32 32
33 33
34 static RcSection *bmp_rcfile_create_section(RcFile * file, 34 static RcSection *aud_rcfile_create_section(RcFile * file,
35 const gchar * name); 35 const gchar * name);
36 static RcLine *bmp_rcfile_create_string(RcSection * section, 36 static RcLine *aud_rcfile_create_string(RcSection * section,
37 const gchar * key, 37 const gchar * key,
38 const gchar * value); 38 const gchar * value);
39 static RcSection *bmp_rcfile_find_section(RcFile * file, const gchar * name); 39 static RcSection *aud_rcfile_find_section(RcFile * file, const gchar * name);
40 static RcLine *bmp_rcfile_find_string(RcSection * section, const gchar * key); 40 static RcLine *aud_rcfile_find_string(RcSection * section, const gchar * key);
41 41
42 /** 42 /**
43 * bmp_rcfile_new: 43 * aud_rcfile_new:
44 * 44 *
45 * #RcFile object factory. 45 * #RcFile object factory.
46 * 46 *
47 * Return value: A #RcFile object. 47 * Return value: A #RcFile object.
48 **/ 48 **/
49 RcFile * 49 RcFile *
50 bmp_rcfile_new(void) 50 aud_rcfile_new(void)
51 { 51 {
52 return g_new0(RcFile, 1); 52 return g_new0(RcFile, 1);
53 } 53 }
54 54
55 /** 55 /**
56 * bmp_rcfile_free: 56 * aud_rcfile_free:
57 * @file: A #RcFile object to destroy. 57 * @file: A #RcFile object to destroy.
58 * 58 *
59 * #RcFile object destructor. 59 * #RcFile object destructor.
60 **/ 60 **/
61 void 61 void
62 bmp_rcfile_free(RcFile * file) 62 aud_rcfile_free(RcFile * file)
63 { 63 {
64 RcSection *section; 64 RcSection *section;
65 RcLine *line; 65 RcLine *line;
66 GList *section_list, *line_list; 66 GList *section_list, *line_list;
67 67
89 g_list_free(file->sections); 89 g_list_free(file->sections);
90 g_free(file); 90 g_free(file);
91 } 91 }
92 92
93 /** 93 /**
94 * bmp_rcfile_open: 94 * aud_rcfile_open:
95 * @filename: Path to rcfile to open. 95 * @filename: Path to rcfile to open.
96 * 96 *
97 * Opens an rcfile and returns an #RcFile object representing it. 97 * Opens an rcfile and returns an #RcFile object representing it.
98 * 98 *
99 * Return value: An #RcFile object representing the rcfile given. 99 * Return value: An #RcFile object representing the rcfile given.
100 **/ 100 **/
101 RcFile * 101 RcFile *
102 bmp_rcfile_open(const gchar * filename) 102 aud_rcfile_open(const gchar * filename)
103 { 103 {
104 RcFile *file; 104 RcFile *file;
105 105
106 gchar *buffer, **lines, *tmp; 106 gchar *buffer, **lines, *tmp;
107 gint i; 107 gint i;
111 g_return_val_if_fail(strlen(filename) > 0, FALSE); 111 g_return_val_if_fail(strlen(filename) > 0, FALSE);
112 112
113 if (!g_file_get_contents(filename, &buffer, NULL, NULL)) 113 if (!g_file_get_contents(filename, &buffer, NULL, NULL))
114 return NULL; 114 return NULL;
115 115
116 file = bmp_rcfile_new(); 116 file = aud_rcfile_new();
117 lines = g_strsplit(buffer, "\n", 0); 117 lines = g_strsplit(buffer, "\n", 0);
118 g_free(buffer); 118 g_free(buffer);
119 i = 0; 119 i = 0;
120 while (lines[i]) { 120 while (lines[i]) {
121 if (lines[i][0] == '[') { 121 if (lines[i][0] == '[') {
122 if ((tmp = strchr(lines[i], ']'))) { 122 if ((tmp = strchr(lines[i], ']'))) {
123 *tmp = '\0'; 123 *tmp = '\0';
124 section = bmp_rcfile_create_section(file, &lines[i][1]); 124 section = aud_rcfile_create_section(file, &lines[i][1]);
125 } 125 }
126 } 126 }
127 else if (lines[i][0] != '#' && section) { 127 else if (lines[i][0] != '#' && section) {
128 if ((tmp = strchr(lines[i], '='))) { 128 if ((tmp = strchr(lines[i], '='))) {
129 gchar **frags; 129 gchar **frags;
130 frags = g_strsplit(lines[i], "=", 2); 130 frags = g_strsplit(lines[i], "=", 2);
131 if (strlen(frags[1]) > 0) { 131 if (strlen(frags[1]) > 0) {
132 bmp_rcfile_create_string(section, frags[0], frags[1]); 132 aud_rcfile_create_string(section, frags[0], frags[1]);
133 }; 133 };
134 g_strfreev(frags); 134 g_strfreev(frags);
135 } 135 }
136 } 136 }
137 i++; 137 i++;
139 g_strfreev(lines); 139 g_strfreev(lines);
140 return file; 140 return file;
141 } 141 }
142 142
143 /** 143 /**
144 * bmp_rcfile_write: 144 * aud_rcfile_write:
145 * @file: A #RcFile object to write to disk. 145 * @file: A #RcFile object to write to disk.
146 * @filename: A path to write the #RcFile object's data to. 146 * @filename: A path to write the #RcFile object's data to.
147 * 147 *
148 * Writes the contents of a #RcFile object to disk. 148 * Writes the contents of a #RcFile object to disk.
149 * 149 *
150 * Return value: TRUE on success, FALSE otherwise. 150 * Return value: TRUE on success, FALSE otherwise.
151 **/ 151 **/
152 gboolean 152 gboolean
153 bmp_rcfile_write(RcFile * file, const gchar * filename) 153 aud_rcfile_write(RcFile * file, const gchar * filename)
154 { 154 {
155 FILE *fp; 155 FILE *fp;
156 GList *section_list, *line_list; 156 GList *section_list, *line_list;
157 RcSection *section; 157 RcSection *section;
158 RcLine *line; 158 RcLine *line;
181 fclose(fp); 181 fclose(fp);
182 return TRUE; 182 return TRUE;
183 } 183 }
184 184
185 /** 185 /**
186 * bmp_rcfile_read_string: 186 * aud_rcfile_read_string:
187 * @file: A #RcFile object to write to disk. 187 * @file: A #RcFile object to write to disk.
188 * @section: The section of the RcFile to look in. 188 * @section: The section of the RcFile to look in.
189 * @key: The name of the identifier to look up. 189 * @key: The name of the identifier to look up.
190 * @value: A pointer to a memory location to place the data. 190 * @value: A pointer to a memory location to place the data.
191 * 191 *
192 * Looks up a value in an RcFile and places it in %value. 192 * Looks up a value in an RcFile and places it in %value.
193 * 193 *
194 * Return value: TRUE on success, FALSE otherwise. 194 * Return value: TRUE on success, FALSE otherwise.
195 **/ 195 **/
196 gboolean 196 gboolean
197 bmp_rcfile_read_string(RcFile * file, const gchar * section, 197 aud_rcfile_read_string(RcFile * file, const gchar * section,
198 const gchar * key, gchar ** value) 198 const gchar * key, gchar ** value)
199 { 199 {
200 RcSection *sect; 200 RcSection *sect;
201 RcLine *line; 201 RcLine *line;
202 202
203 g_return_val_if_fail(file != NULL, FALSE); 203 g_return_val_if_fail(file != NULL, FALSE);
204 g_return_val_if_fail(section != NULL, FALSE); 204 g_return_val_if_fail(section != NULL, FALSE);
205 g_return_val_if_fail(key != NULL, FALSE); 205 g_return_val_if_fail(key != NULL, FALSE);
206 g_return_val_if_fail(value != NULL, FALSE); 206 g_return_val_if_fail(value != NULL, FALSE);
207 207
208 if (!(sect = bmp_rcfile_find_section(file, section))) 208 if (!(sect = aud_rcfile_find_section(file, section)))
209 return FALSE; 209 return FALSE;
210 if (!(line = bmp_rcfile_find_string(sect, key))) 210 if (!(line = aud_rcfile_find_string(sect, key)))
211 return FALSE; 211 return FALSE;
212 *value = g_strdup(line->value); 212 *value = g_strdup(line->value);
213 return TRUE; 213 return TRUE;
214 } 214 }
215 215
216 /** 216 /**
217 * bmp_rcfile_read_int: 217 * aud_rcfile_read_int:
218 * @file: A #RcFile object to write to disk. 218 * @file: A #RcFile object to write to disk.
219 * @section: The section of the RcFile to look in. 219 * @section: The section of the RcFile to look in.
220 * @key: The name of the identifier to look up. 220 * @key: The name of the identifier to look up.
221 * @value: A pointer to a memory location to place the data. 221 * @value: A pointer to a memory location to place the data.
222 * 222 *
223 * Looks up a value in an RcFile and places it in %value. 223 * Looks up a value in an RcFile and places it in %value.
224 * 224 *
225 * Return value: TRUE on success, FALSE otherwise. 225 * Return value: TRUE on success, FALSE otherwise.
226 **/ 226 **/
227 gboolean 227 gboolean
228 bmp_rcfile_read_int(RcFile * file, const gchar * section, 228 aud_rcfile_read_int(RcFile * file, const gchar * section,
229 const gchar * key, gint * value) 229 const gchar * key, gint * value)
230 { 230 {
231 gchar *str; 231 gchar *str;
232 232
233 g_return_val_if_fail(file != NULL, FALSE); 233 g_return_val_if_fail(file != NULL, FALSE);
234 g_return_val_if_fail(section != NULL, FALSE); 234 g_return_val_if_fail(section != NULL, FALSE);
235 g_return_val_if_fail(key != NULL, FALSE); 235 g_return_val_if_fail(key != NULL, FALSE);
236 g_return_val_if_fail(value != NULL, FALSE); 236 g_return_val_if_fail(value != NULL, FALSE);
237 237
238 if (!bmp_rcfile_read_string(file, section, key, &str)) 238 if (!aud_rcfile_read_string(file, section, key, &str))
239 return FALSE; 239 return FALSE;
240 *value = atoi(str); 240 *value = atoi(str);
241 g_free(str); 241 g_free(str);
242 242
243 return TRUE; 243 return TRUE;
244 } 244 }
245 245
246 /** 246 /**
247 * bmp_rcfile_read_bool: 247 * aud_rcfile_read_bool:
248 * @file: A #RcFile object to write to disk. 248 * @file: A #RcFile object to write to disk.
249 * @section: The section of the RcFile to look in. 249 * @section: The section of the RcFile to look in.
250 * @key: The name of the identifier to look up. 250 * @key: The name of the identifier to look up.
251 * @value: A pointer to a memory location to place the data. 251 * @value: A pointer to a memory location to place the data.
252 * 252 *
253 * Looks up a value in an RcFile and places it in %value. 253 * Looks up a value in an RcFile and places it in %value.
254 * 254 *
255 * Return value: TRUE on success, FALSE otherwise. 255 * Return value: TRUE on success, FALSE otherwise.
256 **/ 256 **/
257 gboolean 257 gboolean
258 bmp_rcfile_read_bool(RcFile * file, const gchar * section, 258 aud_rcfile_read_bool(RcFile * file, const gchar * section,
259 const gchar * key, gboolean * value) 259 const gchar * key, gboolean * value)
260 { 260 {
261 gchar *str; 261 gchar *str;
262 262
263 g_return_val_if_fail(file != NULL, FALSE); 263 g_return_val_if_fail(file != NULL, FALSE);
264 g_return_val_if_fail(section != NULL, FALSE); 264 g_return_val_if_fail(section != NULL, FALSE);
265 g_return_val_if_fail(key != NULL, FALSE); 265 g_return_val_if_fail(key != NULL, FALSE);
266 g_return_val_if_fail(value != NULL, FALSE); 266 g_return_val_if_fail(value != NULL, FALSE);
267 267
268 if (!bmp_rcfile_read_string(file, section, key, &str)) 268 if (!aud_rcfile_read_string(file, section, key, &str))
269 return FALSE; 269 return FALSE;
270 if (!strcasecmp(str, "TRUE")) 270 if (!strcasecmp(str, "TRUE"))
271 *value = TRUE; 271 *value = TRUE;
272 else 272 else
273 *value = FALSE; 273 *value = FALSE;
274 g_free(str); 274 g_free(str);
275 return TRUE; 275 return TRUE;
276 } 276 }
277 277
278 /** 278 /**
279 * bmp_rcfile_read_float: 279 * aud_rcfile_read_float:
280 * @file: A #RcFile object to write to disk. 280 * @file: A #RcFile object to write to disk.
281 * @section: The section of the RcFile to look in. 281 * @section: The section of the RcFile to look in.
282 * @key: The name of the identifier to look up. 282 * @key: The name of the identifier to look up.
283 * @value: A pointer to a memory location to place the data. 283 * @value: A pointer to a memory location to place the data.
284 * 284 *
285 * Looks up a value in an RcFile and places it in %value. 285 * Looks up a value in an RcFile and places it in %value.
286 * 286 *
287 * Return value: TRUE on success, FALSE otherwise. 287 * Return value: TRUE on success, FALSE otherwise.
288 **/ 288 **/
289 gboolean 289 gboolean
290 bmp_rcfile_read_float(RcFile * file, const gchar * section, 290 aud_rcfile_read_float(RcFile * file, const gchar * section,
291 const gchar * key, gfloat * value) 291 const gchar * key, gfloat * value)
292 { 292 {
293 gchar *str, *locale; 293 gchar *str, *locale;
294 294
295 g_return_val_if_fail(file != NULL, FALSE); 295 g_return_val_if_fail(file != NULL, FALSE);
296 g_return_val_if_fail(section != NULL, FALSE); 296 g_return_val_if_fail(section != NULL, FALSE);
297 g_return_val_if_fail(key != NULL, FALSE); 297 g_return_val_if_fail(key != NULL, FALSE);
298 g_return_val_if_fail(value != NULL, FALSE); 298 g_return_val_if_fail(value != NULL, FALSE);
299 299
300 if (!bmp_rcfile_read_string(file, section, key, &str)) 300 if (!aud_rcfile_read_string(file, section, key, &str))
301 return FALSE; 301 return FALSE;
302 302
303 locale = g_strdup(setlocale(LC_NUMERIC, NULL)); 303 locale = g_strdup(setlocale(LC_NUMERIC, NULL));
304 setlocale(LC_NUMERIC, "C"); 304 setlocale(LC_NUMERIC, "C");
305 *value = strtod(str, NULL); 305 *value = strtod(str, NULL);
309 309
310 return TRUE; 310 return TRUE;
311 } 311 }
312 312
313 /** 313 /**
314 * bmp_rcfile_read_double: 314 * aud_rcfile_read_double:
315 * @file: A #RcFile object to write to disk. 315 * @file: A #RcFile object to write to disk.
316 * @section: The section of the RcFile to look in. 316 * @section: The section of the RcFile to look in.
317 * @key: The name of the identifier to look up. 317 * @key: The name of the identifier to look up.
318 * @value: A pointer to a memory location to place the data. 318 * @value: A pointer to a memory location to place the data.
319 * 319 *
320 * Looks up a value in an RcFile and places it in %value. 320 * Looks up a value in an RcFile and places it in %value.
321 * 321 *
322 * Return value: TRUE on success, FALSE otherwise. 322 * Return value: TRUE on success, FALSE otherwise.
323 **/ 323 **/
324 gboolean 324 gboolean
325 bmp_rcfile_read_double(RcFile * file, const gchar * section, 325 aud_rcfile_read_double(RcFile * file, const gchar * section,
326 const gchar * key, gdouble * value) 326 const gchar * key, gdouble * value)
327 { 327 {
328 gchar *str, *locale; 328 gchar *str, *locale;
329 329
330 g_return_val_if_fail(file != NULL, FALSE); 330 g_return_val_if_fail(file != NULL, FALSE);
331 g_return_val_if_fail(section != NULL, FALSE); 331 g_return_val_if_fail(section != NULL, FALSE);
332 g_return_val_if_fail(key != NULL, FALSE); 332 g_return_val_if_fail(key != NULL, FALSE);
333 g_return_val_if_fail(value != NULL, FALSE); 333 g_return_val_if_fail(value != NULL, FALSE);
334 334
335 if (!bmp_rcfile_read_string(file, section, key, &str)) 335 if (!aud_rcfile_read_string(file, section, key, &str))
336 return FALSE; 336 return FALSE;
337 337
338 locale = g_strdup(setlocale(LC_NUMERIC, NULL)); 338 locale = g_strdup(setlocale(LC_NUMERIC, NULL));
339 setlocale(LC_NUMERIC, "C"); 339 setlocale(LC_NUMERIC, "C");
340 *value = strtod(str, NULL); 340 *value = strtod(str, NULL);
344 344
345 return TRUE; 345 return TRUE;
346 } 346 }
347 347
348 /** 348 /**
349 * bmp_rcfile_write_string: 349 * aud_rcfile_write_string:
350 * @file: A #RcFile object to write to disk. 350 * @file: A #RcFile object to write to disk.
351 * @section: The section of the RcFile to set the key in. 351 * @section: The section of the RcFile to set the key in.
352 * @key: The name of the identifier to set. 352 * @key: The name of the identifier to set.
353 * @value: The value to set for that identifier. 353 * @value: The value to set for that identifier.
354 * 354 *
355 * Sets a value in an RcFile for %key. 355 * Sets a value in an RcFile for %key.
356 **/ 356 **/
357 void 357 void
358 bmp_rcfile_write_string(RcFile * file, const gchar * section, 358 aud_rcfile_write_string(RcFile * file, const gchar * section,
359 const gchar * key, const gchar * value) 359 const gchar * key, const gchar * value)
360 { 360 {
361 RcSection *sect; 361 RcSection *sect;
362 RcLine *line; 362 RcLine *line;
363 363
364 g_return_if_fail(file != NULL); 364 g_return_if_fail(file != NULL);
365 g_return_if_fail(section != NULL); 365 g_return_if_fail(section != NULL);
366 g_return_if_fail(key != NULL); 366 g_return_if_fail(key != NULL);
367 g_return_if_fail(value != NULL); 367 g_return_if_fail(value != NULL);
368 368
369 sect = bmp_rcfile_find_section(file, section); 369 sect = aud_rcfile_find_section(file, section);
370 if (!sect) 370 if (!sect)
371 sect = bmp_rcfile_create_section(file, section); 371 sect = aud_rcfile_create_section(file, section);
372 if ((line = bmp_rcfile_find_string(sect, key))) { 372 if ((line = aud_rcfile_find_string(sect, key))) {
373 g_free(line->value); 373 g_free(line->value);
374 line->value = g_strstrip(g_strdup(value)); 374 line->value = g_strstrip(g_strdup(value));
375 } 375 }
376 else 376 else
377 bmp_rcfile_create_string(sect, key, value); 377 aud_rcfile_create_string(sect, key, value);
378 } 378 }
379 379
380 /** 380 /**
381 * bmp_rcfile_write_int: 381 * aud_rcfile_write_int:
382 * @file: A #RcFile object to write to disk. 382 * @file: A #RcFile object to write to disk.
383 * @section: The section of the RcFile to set the key in. 383 * @section: The section of the RcFile to set the key in.
384 * @key: The name of the identifier to set. 384 * @key: The name of the identifier to set.
385 * @value: The value to set for that identifier. 385 * @value: The value to set for that identifier.
386 * 386 *
387 * Sets a value in an RcFile for %key. 387 * Sets a value in an RcFile for %key.
388 **/ 388 **/
389 void 389 void
390 bmp_rcfile_write_int(RcFile * file, const gchar * section, 390 aud_rcfile_write_int(RcFile * file, const gchar * section,
391 const gchar * key, gint value) 391 const gchar * key, gint value)
392 { 392 {
393 gchar *strvalue; 393 gchar *strvalue;
394 394
395 g_return_if_fail(file != NULL); 395 g_return_if_fail(file != NULL);
396 g_return_if_fail(section != NULL); 396 g_return_if_fail(section != NULL);
397 g_return_if_fail(key != NULL); 397 g_return_if_fail(key != NULL);
398 398
399 strvalue = g_strdup_printf("%d", value); 399 strvalue = g_strdup_printf("%d", value);
400 bmp_rcfile_write_string(file, section, key, strvalue); 400 aud_rcfile_write_string(file, section, key, strvalue);
401 g_free(strvalue); 401 g_free(strvalue);
402 } 402 }
403 403
404 /** 404 /**
405 * bmp_rcfile_write_boolean: 405 * aud_rcfile_write_boolean:
406 * @file: A #RcFile object to write to disk. 406 * @file: A #RcFile object to write to disk.
407 * @section: The section of the RcFile to set the key in. 407 * @section: The section of the RcFile to set the key in.
408 * @key: The name of the identifier to set. 408 * @key: The name of the identifier to set.
409 * @value: The value to set for that identifier. 409 * @value: The value to set for that identifier.
410 * 410 *
411 * Sets a value in an RcFile for %key. 411 * Sets a value in an RcFile for %key.
412 **/ 412 **/
413 void 413 void
414 bmp_rcfile_write_boolean(RcFile * file, const gchar * section, 414 aud_rcfile_write_boolean(RcFile * file, const gchar * section,
415 const gchar * key, gboolean value) 415 const gchar * key, gboolean value)
416 { 416 {
417 g_return_if_fail(file != NULL); 417 g_return_if_fail(file != NULL);
418 g_return_if_fail(section != NULL); 418 g_return_if_fail(section != NULL);
419 g_return_if_fail(key != NULL); 419 g_return_if_fail(key != NULL);
420 420
421 if (value) 421 if (value)
422 bmp_rcfile_write_string(file, section, key, "TRUE"); 422 aud_rcfile_write_string(file, section, key, "TRUE");
423 else 423 else
424 bmp_rcfile_write_string(file, section, key, "FALSE"); 424 aud_rcfile_write_string(file, section, key, "FALSE");
425 } 425 }
426 426
427 /** 427 /**
428 * bmp_rcfile_write_float: 428 * aud_rcfile_write_float:
429 * @file: A #RcFile object to write to disk. 429 * @file: A #RcFile object to write to disk.
430 * @section: The section of the RcFile to set the key in. 430 * @section: The section of the RcFile to set the key in.
431 * @key: The name of the identifier to set. 431 * @key: The name of the identifier to set.
432 * @value: The value to set for that identifier. 432 * @value: The value to set for that identifier.
433 * 433 *
434 * Sets a value in an RcFile for %key. 434 * Sets a value in an RcFile for %key.
435 **/ 435 **/
436 void 436 void
437 bmp_rcfile_write_float(RcFile * file, const gchar * section, 437 aud_rcfile_write_float(RcFile * file, const gchar * section,
438 const gchar * key, gfloat value) 438 const gchar * key, gfloat value)
439 { 439 {
440 gchar *strvalue, *locale; 440 gchar *strvalue, *locale;
441 441
442 g_return_if_fail(file != NULL); 442 g_return_if_fail(file != NULL);
445 445
446 locale = g_strdup(setlocale(LC_NUMERIC, NULL)); 446 locale = g_strdup(setlocale(LC_NUMERIC, NULL));
447 setlocale(LC_NUMERIC, "C"); 447 setlocale(LC_NUMERIC, "C");
448 strvalue = g_strdup_printf("%g", value); 448 strvalue = g_strdup_printf("%g", value);
449 setlocale(LC_NUMERIC, locale); 449 setlocale(LC_NUMERIC, locale);
450 bmp_rcfile_write_string(file, section, key, strvalue); 450 aud_rcfile_write_string(file, section, key, strvalue);
451 g_free(locale); 451 g_free(locale);
452 g_free(strvalue); 452 g_free(strvalue);
453 } 453 }
454 454
455 /** 455 /**
456 * bmp_rcfile_write_double: 456 * aud_rcfile_write_double:
457 * @file: A #RcFile object to write to disk. 457 * @file: A #RcFile object to write to disk.
458 * @section: The section of the RcFile to set the key in. 458 * @section: The section of the RcFile to set the key in.
459 * @key: The name of the identifier to set. 459 * @key: The name of the identifier to set.
460 * @value: The value to set for that identifier. 460 * @value: The value to set for that identifier.
461 * 461 *
462 * Sets a value in an RcFile for %key. 462 * Sets a value in an RcFile for %key.
463 **/ 463 **/
464 void 464 void
465 bmp_rcfile_write_double(RcFile * file, const gchar * section, 465 aud_rcfile_write_double(RcFile * file, const gchar * section,
466 const gchar * key, gdouble value) 466 const gchar * key, gdouble value)
467 { 467 {
468 gchar *strvalue, *locale; 468 gchar *strvalue, *locale;
469 469
470 g_return_if_fail(file != NULL); 470 g_return_if_fail(file != NULL);
473 473
474 locale = g_strdup(setlocale(LC_NUMERIC, NULL)); 474 locale = g_strdup(setlocale(LC_NUMERIC, NULL));
475 setlocale(LC_NUMERIC, "C"); 475 setlocale(LC_NUMERIC, "C");
476 strvalue = g_strdup_printf("%g", value); 476 strvalue = g_strdup_printf("%g", value);
477 setlocale(LC_NUMERIC, locale); 477 setlocale(LC_NUMERIC, locale);
478 bmp_rcfile_write_string(file, section, key, strvalue); 478 aud_rcfile_write_string(file, section, key, strvalue);
479 g_free(locale); 479 g_free(locale);
480 g_free(strvalue); 480 g_free(strvalue);
481 } 481 }
482 482
483 /** 483 /**
484 * bmp_rcfile_remove_key: 484 * aud_rcfile_remove_key:
485 * @file: A #RcFile object to write to disk. 485 * @file: A #RcFile object to write to disk.
486 * @section: The section of the RcFile to set the key in. 486 * @section: The section of the RcFile to set the key in.
487 * @key: The name of the identifier to remove. 487 * @key: The name of the identifier to remove.
488 * 488 *
489 * Removes %key from an #RcFile object. 489 * Removes %key from an #RcFile object.
490 **/ 490 **/
491 void 491 void
492 bmp_rcfile_remove_key(RcFile * file, const gchar * section, const gchar * key) 492 aud_rcfile_remove_key(RcFile * file, const gchar * section, const gchar * key)
493 { 493 {
494 RcSection *sect; 494 RcSection *sect;
495 RcLine *line; 495 RcLine *line;
496 496
497 g_return_if_fail(file != NULL); 497 g_return_if_fail(file != NULL);
498 g_return_if_fail(section != NULL); 498 g_return_if_fail(section != NULL);
499 g_return_if_fail(key != NULL); 499 g_return_if_fail(key != NULL);
500 500
501 if ((sect = bmp_rcfile_find_section(file, section)) != NULL) { 501 if ((sect = aud_rcfile_find_section(file, section)) != NULL) {
502 if ((line = bmp_rcfile_find_string(sect, key)) != NULL) { 502 if ((line = aud_rcfile_find_string(sect, key)) != NULL) {
503 g_free(line->key); 503 g_free(line->key);
504 g_free(line->value); 504 g_free(line->value);
505 g_free(line); 505 g_free(line);
506 sect->lines = g_list_remove(sect->lines, line); 506 sect->lines = g_list_remove(sect->lines, line);
507 } 507 }
508 } 508 }
509 } 509 }
510 510
511 static RcSection * 511 static RcSection *
512 bmp_rcfile_create_section(RcFile * file, const gchar * name) 512 aud_rcfile_create_section(RcFile * file, const gchar * name)
513 { 513 {
514 RcSection *section; 514 RcSection *section;
515 515
516 section = g_new0(RcSection, 1); 516 section = g_new0(RcSection, 1);
517 section->name = g_strdup(name); 517 section->name = g_strdup(name);
519 519
520 return section; 520 return section;
521 } 521 }
522 522
523 static RcLine * 523 static RcLine *
524 bmp_rcfile_create_string(RcSection * section, 524 aud_rcfile_create_string(RcSection * section,
525 const gchar * key, const gchar * value) 525 const gchar * key, const gchar * value)
526 { 526 {
527 RcLine *line; 527 RcLine *line;
528 528
529 line = g_new0(RcLine, 1); 529 line = g_new0(RcLine, 1);
533 533
534 return line; 534 return line;
535 } 535 }
536 536
537 static RcSection * 537 static RcSection *
538 bmp_rcfile_find_section(RcFile * file, const gchar * name) 538 aud_rcfile_find_section(RcFile * file, const gchar * name)
539 { 539 {
540 RcSection *section; 540 RcSection *section;
541 GList *list; 541 GList *list;
542 542
543 list = file->sections; 543 list = file->sections;
549 } 549 }
550 return NULL; 550 return NULL;
551 } 551 }
552 552
553 static RcLine * 553 static RcLine *
554 bmp_rcfile_find_string(RcSection * section, const gchar * key) 554 aud_rcfile_find_string(RcSection * section, const gchar * key)
555 { 555 {
556 RcLine *line; 556 RcLine *line;
557 GList *list; 557 GList *list;
558 558
559 list = section->lines; 559 list = section->lines;