Mercurial > audlegacy
annotate src/libaudacious/configdb_rcfile.c @ 2318:ac9f4d42d848 trunk
[svn] Remove old shit.
author | js |
---|---|
date | Sat, 13 Jan 2007 09:33:35 -0800 |
parents | d5d95a459a19 |
children | 63c9a2724e73 |
rev | line source |
---|---|
2313 | 1 /* This program is free software; you can redistribute it and/or modify |
2 * it under the terms of the GNU General Public License as published by | |
3 * the Free Software Foundation; either version 2 of the License, or | |
4 * (at your option) any later version. | |
5 * | |
6 * This program is distributed in the hope that it will be useful, | |
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9 * GNU General Public License for more details. | |
10 * | |
11 * You should have received a copy of the GNU General Public License | |
12 * along with this program; if not, write to the Free Software | |
13 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
14 */ | |
15 | |
16 #ifdef HAVE_CONFIG_H | |
17 # include "config.h" | |
18 #endif | |
19 | |
20 #include "configdb.h" | |
21 | |
2314
d5d95a459a19
[svn] - fix: E:configdb_rcfile.c(45) [bmp_cfg_db_open]:Autoconversion of integer to pointer is not allowed in C99
nenolod
parents:
2313
diff
changeset
|
22 #include <stdlib.h> |
2313 | 23 #include <string.h> |
24 #include "rcfile.h" | |
25 | |
26 | |
27 #define RCFILE_DEFAULT_SECTION_NAME "audacious" | |
28 | |
29 | |
30 struct _ConfigDb | |
31 { | |
32 RcFile *file; | |
33 gchar *filename; | |
34 gboolean dirty; | |
35 }; | |
36 | |
37 | |
38 ConfigDb * | |
39 bmp_cfg_db_open() | |
40 { | |
41 ConfigDb *db; | |
42 char *tmp; | |
43 | |
44 db = g_new(ConfigDb, 1); | |
45 | |
46 if ((tmp = getenv("XDG_CONFIG_HOME")) == NULL) | |
47 db->filename = g_build_filename(g_get_home_dir(), ".config", | |
48 "audacious", "config", NULL); | |
49 else | |
50 db->filename = g_build_filename(tmp, "audacious", "config", NULL); | |
51 | |
52 db->file = bmp_rcfile_open(db->filename); | |
53 | |
2318 | 54 if (!db->file) |
2313 | 55 db->file = bmp_rcfile_new(); |
56 | |
57 db->dirty = FALSE; | |
58 | |
59 return db; | |
60 } | |
61 | |
62 void | |
63 bmp_cfg_db_close(ConfigDb * db) | |
64 { | |
65 if (db->dirty) | |
66 bmp_rcfile_write(db->file, db->filename); | |
67 bmp_rcfile_free(db->file); | |
68 g_free(db->filename); | |
69 } | |
70 | |
71 gboolean | |
72 bmp_cfg_db_get_string(ConfigDb * db, | |
73 const gchar * section, | |
74 const gchar * key, | |
75 gchar ** value) | |
76 { | |
77 if (!section) | |
78 section = RCFILE_DEFAULT_SECTION_NAME; | |
79 | |
80 return bmp_rcfile_read_string(db->file, section, key, value); | |
81 } | |
82 | |
83 gboolean | |
84 bmp_cfg_db_get_int(ConfigDb * db, | |
85 const gchar * section, const gchar * key, gint * value) | |
86 { | |
87 if (!section) | |
88 section = RCFILE_DEFAULT_SECTION_NAME; | |
89 | |
90 return bmp_rcfile_read_int(db->file, section, key, value); | |
91 } | |
92 | |
93 gboolean | |
94 bmp_cfg_db_get_bool(ConfigDb * db, | |
95 const gchar * section, | |
96 const gchar * key, | |
97 gboolean * value) | |
98 { | |
99 if (!section) | |
100 section = RCFILE_DEFAULT_SECTION_NAME; | |
101 | |
102 return bmp_rcfile_read_bool(db->file, section, key, value); | |
103 } | |
104 | |
105 gboolean | |
106 bmp_cfg_db_get_float(ConfigDb * db, | |
107 const gchar * section, | |
108 const gchar * key, | |
109 gfloat * value) | |
110 { | |
111 if (!section) | |
112 section = RCFILE_DEFAULT_SECTION_NAME; | |
113 | |
114 return bmp_rcfile_read_float(db->file, section, key, value); | |
115 } | |
116 | |
117 gboolean | |
118 bmp_cfg_db_get_double(ConfigDb * db, | |
119 const gchar * section, | |
120 const gchar * key, | |
121 gdouble * value) | |
122 { | |
123 if (!section) | |
124 section = RCFILE_DEFAULT_SECTION_NAME; | |
125 | |
126 return bmp_rcfile_read_double(db->file, section, key, value); | |
127 } | |
128 | |
129 void | |
130 bmp_cfg_db_set_string(ConfigDb * db, | |
131 const gchar * section, | |
132 const gchar * key, | |
133 gchar * value) | |
134 { | |
135 db->dirty = TRUE; | |
136 | |
137 if (!section) | |
138 section = RCFILE_DEFAULT_SECTION_NAME; | |
139 | |
140 bmp_rcfile_write_string(db->file, section, key, value); | |
141 } | |
142 | |
143 void | |
144 bmp_cfg_db_set_int(ConfigDb * db, | |
145 const gchar * section, | |
146 const gchar * key, | |
147 gint value) | |
148 { | |
149 db->dirty = TRUE; | |
150 | |
151 if (!section) | |
152 section = RCFILE_DEFAULT_SECTION_NAME; | |
153 | |
154 bmp_rcfile_write_int(db->file, section, key, value); | |
155 } | |
156 | |
157 void | |
158 bmp_cfg_db_set_bool(ConfigDb * db, | |
159 const gchar * section, | |
160 const gchar * key, | |
161 gboolean value) | |
162 { | |
163 db->dirty = TRUE; | |
164 | |
165 if (!section) | |
166 section = RCFILE_DEFAULT_SECTION_NAME; | |
167 | |
168 bmp_rcfile_write_boolean(db->file, section, key, value); | |
169 } | |
170 | |
171 void | |
172 bmp_cfg_db_set_float(ConfigDb * db, | |
173 const gchar * section, | |
174 const gchar * key, | |
175 gfloat value) | |
176 { | |
177 db->dirty = TRUE; | |
178 | |
179 if (!section) | |
180 section = RCFILE_DEFAULT_SECTION_NAME; | |
181 | |
182 bmp_rcfile_write_float(db->file, section, key, value); | |
183 } | |
184 | |
185 void | |
186 bmp_cfg_db_set_double(ConfigDb * db, | |
187 const gchar * section, | |
188 const gchar * key, | |
189 gdouble value) | |
190 { | |
191 db->dirty = TRUE; | |
192 | |
193 if (!section) | |
194 section = RCFILE_DEFAULT_SECTION_NAME; | |
195 | |
196 bmp_rcfile_write_double(db->file, section, key, value); | |
197 } | |
198 | |
199 void | |
200 bmp_cfg_db_unset_key(ConfigDb * db, | |
201 const gchar * section, | |
202 const gchar * key) | |
203 { | |
204 db->dirty = TRUE; | |
205 | |
206 g_return_if_fail(db != NULL); | |
207 g_return_if_fail(key != NULL); | |
208 | |
209 if (!section) | |
210 section = RCFILE_DEFAULT_SECTION_NAME; | |
211 | |
212 bmp_rcfile_remove_key(db->file, section, key); | |
213 } |