annotate src/audacious/rcfile.c @ 4779:aa79a84627b9

g_basename is deprecated, replace with g_path_get_basename.
author Tony Vroon <chainsaw@gentoo.org>
date Fri, 26 Sep 2008 21:02:49 +0100
parents 15c491f342eb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3112
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
1 /* Audacious
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
2 * Copyright (c) 2005-2007 Audacious team
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
3 *
3112
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
4 * BMP
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
5 * Copyright (c) 2003-2005 BMP team
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
6 *
3112
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
7 * 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
8 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3112
diff changeset
9 * the Free Software Foundation; under version 3 of the License.
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
10 *
3112
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
11 * 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
12 * 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
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
14 * GNU General Public License for more details.
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
15 *
4c758281fe8f Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents: 2865
diff changeset
16 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3112
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
18 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
19 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
20 * Audacious or using our public API to be a derived work.
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
21 */
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
22
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
23 #include "rcfile.h"
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
24
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
25 #include <stdio.h>
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
26 #include <string.h>
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
27 #include <stdlib.h>
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
28 #include <locale.h>
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
29
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
30 #include <unistd.h>
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
31 #include <sys/stat.h>
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
32
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
33
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
34 static RcSection *aud_rcfile_create_section(RcFile * file,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
35 const gchar * name);
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
36 static RcLine *aud_rcfile_create_string(RcSection * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
37 const gchar * key,
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
38 const gchar * value);
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
39 static RcSection *aud_rcfile_find_section(RcFile * file, const gchar * name);
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
40 static RcLine *aud_rcfile_find_string(RcSection * section, const gchar * key);
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
41
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
42 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
43 * aud_rcfile_new:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
44 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
45 * #RcFile object factory.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
46 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
47 * Return value: A #RcFile object.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
48 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
49 RcFile *
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
50 aud_rcfile_new(void)
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
51 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
52 return g_new0(RcFile, 1);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
53 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
54
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
55 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
56 * aud_rcfile_free:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
57 * @file: A #RcFile object to destroy.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
58 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
59 * #RcFile object destructor.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
60 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
61 void
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
62 aud_rcfile_free(RcFile * file)
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
63 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
64 RcSection *section;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
65 RcLine *line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
66 GList *section_list, *line_list;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
67
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
68 if (file == NULL)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
69 return;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
70
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
71 section_list = file->sections;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
72 while (section_list) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
73 section = (RcSection *) section_list->data;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
74 g_free(section->name);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
75
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
76 line_list = section->lines;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
77 while (line_list) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
78 line = (RcLine *) line_list->data;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
79 g_free(line->key);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
80 g_free(line->value);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
81 g_free(line);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
82 line_list = g_list_next(line_list);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
83 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
84 g_list_free(section->lines);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
85 g_free(section);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
86
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
87 section_list = g_list_next(section_list);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
88 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
89 g_list_free(file->sections);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
90 g_free(file);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
91 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
92
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
93 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
94 * aud_rcfile_open:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
95 * @filename: Path to rcfile to open.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
96 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
97 * Opens an rcfile and returns an #RcFile object representing it.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
98 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
99 * Return value: An #RcFile object representing the rcfile given.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
100 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
101 RcFile *
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
102 aud_rcfile_open(const gchar * filename)
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
103 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
104 RcFile *file;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
105
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
106 gchar *buffer, **lines, *tmp;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
107 gint i;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
108 RcSection *section = NULL;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
109
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
110 g_return_val_if_fail(filename != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
111 g_return_val_if_fail(strlen(filename) > 0, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
112
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
113 if (!g_file_get_contents(filename, &buffer, NULL, NULL))
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
114 return NULL;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
115
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
116 file = aud_rcfile_new();
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
117 lines = g_strsplit(buffer, "\n", 0);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
118 g_free(buffer);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
119 i = 0;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
120 while (lines[i]) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
121 if (lines[i][0] == '[') {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
122 if ((tmp = strchr(lines[i], ']'))) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
123 *tmp = '\0';
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
124 section = aud_rcfile_create_section(file, &lines[i][1]);
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
125 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
126 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
127 else if (lines[i][0] != '#' && section) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
128 if ((tmp = strchr(lines[i], '='))) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
129 gchar **frags;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
130 frags = g_strsplit(lines[i], "=", 2);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
131 if (strlen(frags[1]) > 0) {
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
132 aud_rcfile_create_string(section, frags[0], frags[1]);
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
133 };
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
134 g_strfreev(frags);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
135 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
136 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
137 i++;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
138 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
139 g_strfreev(lines);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
140 return file;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
141 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
142
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
143 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
144 * aud_rcfile_write:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
145 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
146 * @filename: A path to write the #RcFile object's data to.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
147 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
148 * Writes the contents of a #RcFile object to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
149 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
150 * Return value: TRUE on success, FALSE otherwise.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
151 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
152 gboolean
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
153 aud_rcfile_write(RcFile * file, const gchar * filename)
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
154 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
155 FILE *fp;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
156 GList *section_list, *line_list;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
157 RcSection *section;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
158 RcLine *line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
159
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
160 g_return_val_if_fail(file != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
161 g_return_val_if_fail(filename != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
162
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
163 if (!(fp = fopen(filename, "w")))
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
164 return FALSE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
165
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
166 section_list = file->sections;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
167 while (section_list) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
168 section = (RcSection *) section_list->data;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
169 if (section->lines) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
170 fprintf(fp, "[%s]\n", section->name);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
171 line_list = section->lines;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
172 while (line_list) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
173 line = (RcLine *) line_list->data;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
174 fprintf(fp, "%s=%s\n", line->key, line->value);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
175 line_list = g_list_next(line_list);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
176 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
177 fprintf(fp, "\n");
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
178 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
179 section_list = g_list_next(section_list);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
180 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
181 fclose(fp);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
182 return TRUE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
183 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
184
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
185 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
186 * aud_rcfile_read_string:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
187 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
188 * @section: The section of the RcFile to look in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
189 * @key: The name of the identifier to look up.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
190 * @value: A pointer to a memory location to place the data.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
191 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
192 * Looks up a value in an RcFile and places it in %value.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
193 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
194 * Return value: TRUE on success, FALSE otherwise.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
195 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
196 gboolean
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
197 aud_rcfile_read_string(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
198 const gchar * key, gchar ** value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
199 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
200 RcSection *sect;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
201 RcLine *line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
202
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
203 g_return_val_if_fail(file != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
204 g_return_val_if_fail(section != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
205 g_return_val_if_fail(key != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
206 g_return_val_if_fail(value != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
207
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
208 if (!(sect = aud_rcfile_find_section(file, section)))
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
209 return FALSE;
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
210 if (!(line = aud_rcfile_find_string(sect, key)))
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
211 return FALSE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
212 *value = g_strdup(line->value);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
213 return TRUE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
214 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
215
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
216 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
217 * aud_rcfile_read_int:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
218 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
219 * @section: The section of the RcFile to look in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
220 * @key: The name of the identifier to look up.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
221 * @value: A pointer to a memory location to place the data.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
222 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
223 * Looks up a value in an RcFile and places it in %value.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
224 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
225 * Return value: TRUE on success, FALSE otherwise.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
226 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
227 gboolean
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
228 aud_rcfile_read_int(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
229 const gchar * key, gint * value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
230 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
231 gchar *str;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
232
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
233 g_return_val_if_fail(file != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
234 g_return_val_if_fail(section != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
235 g_return_val_if_fail(key != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
236 g_return_val_if_fail(value != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
237
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
238 if (!aud_rcfile_read_string(file, section, key, &str))
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
239 return FALSE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
240 *value = atoi(str);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
241 g_free(str);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
242
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
243 return TRUE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
244 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
245
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
246 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
247 * aud_rcfile_read_bool:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
248 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
249 * @section: The section of the RcFile to look in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
250 * @key: The name of the identifier to look up.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
251 * @value: A pointer to a memory location to place the data.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
252 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
253 * Looks up a value in an RcFile and places it in %value.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
254 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
255 * Return value: TRUE on success, FALSE otherwise.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
256 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
257 gboolean
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
258 aud_rcfile_read_bool(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
259 const gchar * key, gboolean * value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
260 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
261 gchar *str;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
262
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
263 g_return_val_if_fail(file != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
264 g_return_val_if_fail(section != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
265 g_return_val_if_fail(key != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
266 g_return_val_if_fail(value != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
267
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
268 if (!aud_rcfile_read_string(file, section, key, &str))
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
269 return FALSE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
270 if (!strcasecmp(str, "TRUE"))
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
271 *value = TRUE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
272 else
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
273 *value = FALSE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
274 g_free(str);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
275 return TRUE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
276 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
277
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
278 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
279 * aud_rcfile_read_float:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
280 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
281 * @section: The section of the RcFile to look in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
282 * @key: The name of the identifier to look up.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
283 * @value: A pointer to a memory location to place the data.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
284 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
285 * Looks up a value in an RcFile and places it in %value.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
286 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
287 * Return value: TRUE on success, FALSE otherwise.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
288 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
289 gboolean
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
290 aud_rcfile_read_float(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
291 const gchar * key, gfloat * value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
292 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
293 gchar *str, *locale;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
294
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
295 g_return_val_if_fail(file != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
296 g_return_val_if_fail(section != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
297 g_return_val_if_fail(key != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
298 g_return_val_if_fail(value != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
299
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
300 if (!aud_rcfile_read_string(file, section, key, &str))
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
301 return FALSE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
302
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
303 locale = g_strdup(setlocale(LC_NUMERIC, NULL));
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
304 setlocale(LC_NUMERIC, "C");
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
305 *value = strtod(str, NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
306 setlocale(LC_NUMERIC, locale);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
307 g_free(locale);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
308 g_free(str);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
309
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
310 return TRUE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
311 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
312
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
313 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
314 * aud_rcfile_read_double:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
315 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
316 * @section: The section of the RcFile to look in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
317 * @key: The name of the identifier to look up.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
318 * @value: A pointer to a memory location to place the data.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
319 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
320 * Looks up a value in an RcFile and places it in %value.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
321 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
322 * Return value: TRUE on success, FALSE otherwise.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
323 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
324 gboolean
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
325 aud_rcfile_read_double(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
326 const gchar * key, gdouble * value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
327 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
328 gchar *str, *locale;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
329
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
330 g_return_val_if_fail(file != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
331 g_return_val_if_fail(section != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
332 g_return_val_if_fail(key != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
333 g_return_val_if_fail(value != NULL, FALSE);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
334
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
335 if (!aud_rcfile_read_string(file, section, key, &str))
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
336 return FALSE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
337
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
338 locale = g_strdup(setlocale(LC_NUMERIC, NULL));
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
339 setlocale(LC_NUMERIC, "C");
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
340 *value = strtod(str, NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
341 setlocale(LC_NUMERIC, locale);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
342 g_free(locale);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
343 g_free(str);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
344
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
345 return TRUE;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
346 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
347
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
348 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
349 * aud_rcfile_write_string:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
350 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
351 * @section: The section of the RcFile to set the key in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
352 * @key: The name of the identifier to set.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
353 * @value: The value to set for that identifier.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
354 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
355 * Sets a value in an RcFile for %key.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
356 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
357 void
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
358 aud_rcfile_write_string(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
359 const gchar * key, const gchar * value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
360 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
361 RcSection *sect;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
362 RcLine *line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
363
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
364 g_return_if_fail(file != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
365 g_return_if_fail(section != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
366 g_return_if_fail(key != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
367 g_return_if_fail(value != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
368
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
369 sect = aud_rcfile_find_section(file, section);
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
370 if (!sect)
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
371 sect = aud_rcfile_create_section(file, section);
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
372 if ((line = aud_rcfile_find_string(sect, key))) {
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
373 g_free(line->value);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
374 line->value = g_strstrip(g_strdup(value));
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
375 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
376 else
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
377 aud_rcfile_create_string(sect, key, value);
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
378 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
379
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
380 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
381 * aud_rcfile_write_int:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
382 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
383 * @section: The section of the RcFile to set the key in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
384 * @key: The name of the identifier to set.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
385 * @value: The value to set for that identifier.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
386 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
387 * Sets a value in an RcFile for %key.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
388 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
389 void
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
390 aud_rcfile_write_int(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
391 const gchar * key, gint value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
392 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
393 gchar *strvalue;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
394
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
395 g_return_if_fail(file != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
396 g_return_if_fail(section != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
397 g_return_if_fail(key != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
398
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
399 strvalue = g_strdup_printf("%d", value);
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
400 aud_rcfile_write_string(file, section, key, strvalue);
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
401 g_free(strvalue);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
402 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
403
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
404 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
405 * aud_rcfile_write_boolean:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
406 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
407 * @section: The section of the RcFile to set the key in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
408 * @key: The name of the identifier to set.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
409 * @value: The value to set for that identifier.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
410 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
411 * Sets a value in an RcFile for %key.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
412 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
413 void
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
414 aud_rcfile_write_boolean(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
415 const gchar * key, gboolean value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
416 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
417 g_return_if_fail(file != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
418 g_return_if_fail(section != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
419 g_return_if_fail(key != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
420
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
421 if (value)
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
422 aud_rcfile_write_string(file, section, key, "TRUE");
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
423 else
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
424 aud_rcfile_write_string(file, section, key, "FALSE");
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
425 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
426
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
427 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
428 * aud_rcfile_write_float:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
429 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
430 * @section: The section of the RcFile to set the key in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
431 * @key: The name of the identifier to set.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
432 * @value: The value to set for that identifier.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
433 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
434 * Sets a value in an RcFile for %key.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
435 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
436 void
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
437 aud_rcfile_write_float(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
438 const gchar * key, gfloat value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
439 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
440 gchar *strvalue, *locale;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
441
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
442 g_return_if_fail(file != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
443 g_return_if_fail(section != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
444 g_return_if_fail(key != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
445
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
446 locale = g_strdup(setlocale(LC_NUMERIC, NULL));
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
447 setlocale(LC_NUMERIC, "C");
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
448 strvalue = g_strdup_printf("%g", value);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
449 setlocale(LC_NUMERIC, locale);
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
450 aud_rcfile_write_string(file, section, key, strvalue);
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
451 g_free(locale);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
452 g_free(strvalue);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
453 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
454
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
455 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
456 * aud_rcfile_write_double:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
457 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
458 * @section: The section of the RcFile to set the key in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
459 * @key: The name of the identifier to set.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
460 * @value: The value to set for that identifier.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
461 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
462 * Sets a value in an RcFile for %key.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
463 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
464 void
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
465 aud_rcfile_write_double(RcFile * file, const gchar * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
466 const gchar * key, gdouble value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
467 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
468 gchar *strvalue, *locale;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
469
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
470 g_return_if_fail(file != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
471 g_return_if_fail(section != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
472 g_return_if_fail(key != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
473
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
474 locale = g_strdup(setlocale(LC_NUMERIC, NULL));
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
475 setlocale(LC_NUMERIC, "C");
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
476 strvalue = g_strdup_printf("%g", value);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
477 setlocale(LC_NUMERIC, locale);
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
478 aud_rcfile_write_string(file, section, key, strvalue);
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
479 g_free(locale);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
480 g_free(strvalue);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
481 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
482
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
483 /**
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
484 * aud_rcfile_remove_key:
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
485 * @file: A #RcFile object to write to disk.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
486 * @section: The section of the RcFile to set the key in.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
487 * @key: The name of the identifier to remove.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
488 *
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
489 * Removes %key from an #RcFile object.
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
490 **/
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
491 void
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
492 aud_rcfile_remove_key(RcFile * file, const gchar * section, const gchar * key)
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
493 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
494 RcSection *sect;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
495 RcLine *line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
496
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
497 g_return_if_fail(file != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
498 g_return_if_fail(section != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
499 g_return_if_fail(key != NULL);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
500
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
501 if ((sect = aud_rcfile_find_section(file, section)) != NULL) {
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
502 if ((line = aud_rcfile_find_string(sect, key)) != NULL) {
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
503 g_free(line->key);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
504 g_free(line->value);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
505 g_free(line);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
506 sect->lines = g_list_remove(sect->lines, line);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
507 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
508 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
509 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
510
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
511 static RcSection *
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
512 aud_rcfile_create_section(RcFile * file, const gchar * name)
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
513 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
514 RcSection *section;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
515
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
516 section = g_new0(RcSection, 1);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
517 section->name = g_strdup(name);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
518 file->sections = g_list_append(file->sections, section);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
519
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
520 return section;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
521 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
522
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
523 static RcLine *
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
524 aud_rcfile_create_string(RcSection * section,
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
525 const gchar * key, const gchar * value)
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
526 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
527 RcLine *line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
528
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
529 line = g_new0(RcLine, 1);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
530 line->key = g_strstrip(g_strdup(key));
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
531 line->value = g_strstrip(g_strdup(value));
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
532 section->lines = g_list_append(section->lines, line);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
533
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
534 return line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
535 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
536
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
537 static RcSection *
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
538 aud_rcfile_find_section(RcFile * file, const gchar * name)
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
539 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
540 RcSection *section;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
541 GList *list;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
542
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
543 list = file->sections;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
544 while (list) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
545 section = (RcSection *) list->data;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
546 if (!strcasecmp(section->name, name))
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
547 return section;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
548 list = g_list_next(list);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
549 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
550 return NULL;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
551 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
552
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
553 static RcLine *
4405
15c491f342eb Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents: 3123
diff changeset
554 aud_rcfile_find_string(RcSection * section, const gchar * key)
2537
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
555 {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
556 RcLine *line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
557 GList *list;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
558
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
559 list = section->lines;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
560 while (list) {
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
561 line = (RcLine *) list->data;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
562 if (!strcasecmp(line->key, key))
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
563 return line;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
564 list = g_list_next(list);
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
565 }
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
566 return NULL;
7aac1b5ef85d [svn] - reinstate rcfile class for now
nenolod
parents:
diff changeset
567 }