annotate src/audacious/rcfile.c @ 2537:7aac1b5ef85d trunk

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