Mercurial > audlegacy
annotate src/audacious/configdb.c @ 4011:c19c8d47e221
vseparator in fileinfo came back
| author | Eugene Zagidullin <e.asphyx@gmail.com> |
|---|---|
| date | Sun, 25 Nov 2007 04:44:40 +0300 |
| parents | 259b7d3e0976 |
| children | a6a2e84e2b2e |
| rev | line source |
|---|---|
|
3112
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
1 /* 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
|
2 * 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
|
3 * the Free Software Foundation; under version 3 of the License. |
| 2313 | 4 * |
|
3112
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
5 * 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
|
6 * 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
|
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
8 * GNU General Public License for more details. |
| 2313 | 9 * |
|
3112
4c758281fe8f
Backed out changeset d226b83fa3298fc92f25f9519befcd754f44b0ef
William Pitcock <nenolod@atheme-project.org>
parents:
2865
diff
changeset
|
10 * 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
|
11 * 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
|
12 * |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
13 * 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
|
14 * Audacious or using our public API to be a derived work. |
| 2313 | 15 */ |
| 16 | |
| 17 #ifdef HAVE_CONFIG_H | |
| 18 # include "config.h" | |
| 19 #endif | |
| 20 | |
| 21 #include "configdb.h" | |
| 22 | |
|
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
|
23 #include <stdlib.h> |
| 2313 | 24 #include <string.h> |
| 2358 | 25 |
| 26 #include <libmcs/mcs.h> | |
| 2313 | 27 |
| 28 | |
| 29 #define RCFILE_DEFAULT_SECTION_NAME "audacious" | |
| 30 | |
| 2358 | 31 static gboolean mcs_initted = FALSE; |
| 2313 | 32 |
| 33 struct _ConfigDb | |
| 34 { | |
| 2358 | 35 mcs_handle_t *handle; |
| 2313 | 36 }; |
| 37 | |
| 38 | |
| 39 ConfigDb * | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
40 cfg_db_open() |
| 2313 | 41 { |
| 42 ConfigDb *db; | |
| 43 | |
| 44 db = g_new(ConfigDb, 1); | |
| 45 | |
| 2358 | 46 if (!mcs_initted) |
| 47 { | |
| 48 mcs_init(); | |
| 49 mcs_initted = TRUE; | |
|
2325
63c9a2724e73
[svn] - revert r3646 because it is not a user-friendly method of transitioning.
nenolod
parents:
2318
diff
changeset
|
50 } |
| 2313 | 51 |
| 2358 | 52 db->handle = mcs_new(RCFILE_DEFAULT_SECTION_NAME); |
| 2313 | 53 |
| 54 return db; | |
| 55 } | |
| 56 | |
| 57 void | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
58 cfg_db_close(ConfigDb * db) |
| 2313 | 59 { |
| 2358 | 60 mcs_destroy(db->handle); |
| 61 g_free(db); | |
| 2313 | 62 } |
| 63 | |
| 64 gboolean | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
65 cfg_db_get_string(ConfigDb * db, |
| 2313 | 66 const gchar * section, |
| 67 const gchar * key, | |
| 68 gchar ** value) | |
| 69 { | |
| 70 if (!section) | |
| 71 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 72 | |
| 2358 | 73 return mcs_get_string(db->handle, section, key, value); |
| 2313 | 74 } |
| 75 | |
| 76 gboolean | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
77 cfg_db_get_int(ConfigDb * db, |
| 2313 | 78 const gchar * section, const gchar * key, gint * value) |
| 79 { | |
| 80 if (!section) | |
| 81 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 82 | |
| 2358 | 83 return mcs_get_int(db->handle, section, key, value); |
| 2313 | 84 } |
| 85 | |
| 86 gboolean | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
87 cfg_db_get_bool(ConfigDb * db, |
| 2313 | 88 const gchar * section, |
| 89 const gchar * key, | |
| 90 gboolean * value) | |
| 91 { | |
| 92 if (!section) | |
| 93 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 94 | |
| 2358 | 95 return mcs_get_bool(db->handle, section, key, value); |
| 2313 | 96 } |
| 97 | |
| 98 gboolean | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
99 cfg_db_get_float(ConfigDb * db, |
| 2313 | 100 const gchar * section, |
| 101 const gchar * key, | |
| 102 gfloat * value) | |
| 103 { | |
| 104 if (!section) | |
| 105 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 106 | |
| 2358 | 107 return mcs_get_float(db->handle, section, key, value); |
| 2313 | 108 } |
| 109 | |
| 110 gboolean | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
111 cfg_db_get_double(ConfigDb * db, |
| 2313 | 112 const gchar * section, |
| 113 const gchar * key, | |
| 114 gdouble * value) | |
| 115 { | |
| 116 if (!section) | |
| 117 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 118 | |
| 2358 | 119 return mcs_get_double(db->handle, section, key, value); |
| 2313 | 120 } |
| 121 | |
| 122 void | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
123 cfg_db_set_string(ConfigDb * db, |
| 2313 | 124 const gchar * section, |
| 125 const gchar * key, | |
|
2346
0b98ad8c8b17
[svn] removed xmms_create_dirbrowser, small config db fixes
mf0102
parents:
2326
diff
changeset
|
126 const gchar * value) |
| 2313 | 127 { |
| 128 if (!section) | |
| 129 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 130 | |
| 2358 | 131 mcs_set_string(db->handle, section, key, value); |
| 2313 | 132 } |
| 133 | |
| 134 void | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
135 cfg_db_set_int(ConfigDb * db, |
| 2313 | 136 const gchar * section, |
| 137 const gchar * key, | |
| 138 gint value) | |
| 139 { | |
| 140 if (!section) | |
| 141 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 142 | |
| 2358 | 143 mcs_set_int(db->handle, section, key, value); |
| 2313 | 144 } |
| 145 | |
| 146 void | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
147 cfg_db_set_bool(ConfigDb * db, |
| 2313 | 148 const gchar * section, |
| 149 const gchar * key, | |
| 150 gboolean value) | |
| 151 { | |
| 152 if (!section) | |
| 153 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 154 | |
|
2359
75598f596c92
[svn] - support for libmcs (pass --enable-mcs to configure)
nenolod
parents:
2358
diff
changeset
|
155 mcs_set_bool(db->handle, section, key, value); |
| 2313 | 156 } |
| 157 | |
| 158 void | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
159 cfg_db_set_float(ConfigDb * db, |
| 2313 | 160 const gchar * section, |
| 161 const gchar * key, | |
| 162 gfloat value) | |
| 163 { | |
| 164 if (!section) | |
| 165 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 166 | |
| 2358 | 167 mcs_set_float(db->handle, section, key, value); |
| 2313 | 168 } |
| 169 | |
| 170 void | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
171 cfg_db_set_double(ConfigDb * db, |
| 2313 | 172 const gchar * section, |
| 173 const gchar * key, | |
| 174 gdouble value) | |
| 175 { | |
| 176 if (!section) | |
| 177 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 178 | |
| 2358 | 179 mcs_set_double(db->handle, section, key, value); |
| 2313 | 180 } |
| 181 | |
| 182 void | |
|
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
183 cfg_db_unset_key(ConfigDb * db, |
| 2313 | 184 const gchar * section, |
| 185 const gchar * key) | |
| 186 { | |
| 187 g_return_if_fail(db != NULL); | |
| 188 g_return_if_fail(key != NULL); | |
| 189 | |
| 190 if (!section) | |
| 191 section = RCFILE_DEFAULT_SECTION_NAME; | |
| 192 | |
| 2358 | 193 mcs_unset_key(db->handle, section, key); |
| 2313 | 194 } |
