26
26
#include <sys/stat.h>
27
27
#include <unistd.h>
30
/* Don't allow special characters in configuration source addresses.
31
* The important one here is not to allow ';' because we use that
32
* internally as a list delimiter. See GCONF_DATABASE_LIST_DELIM
34
static const char invalid_chars[] =
36
/* Space is common in user names (and thus home directories) on Windows */
39
"\t\r\n\"$&<>,+=#!()'|{}[]?~`;%\\";
42
gconf_address_valid (const char *address,
47
g_return_val_if_fail (address != NULL, FALSE);
55
const char *inv = invalid_chars;
62
*why_invalid = g_strdup_printf(_("`%c' is an invalid character in a configuration storage address"), *s);
30
75
gconf_address_backend(const gchar* address)
179
228
static GHashTable* loaded_backends = NULL;
231
gconf_backend_verify_vtable (GConfBackendVTable *vtable,
232
GConfBackendVTable *vtable_copy,
233
const char *backend_name,
241
} required_vtable_functions[] = {
242
{ "shutdown", G_STRUCT_OFFSET(GConfBackendVTable, shutdown) },
243
{ "resolve_address", G_STRUCT_OFFSET(GConfBackendVTable, resolve_address) },
244
{ "query_value", G_STRUCT_OFFSET(GConfBackendVTable, query_value) },
245
{ "query_metainfo", G_STRUCT_OFFSET(GConfBackendVTable, query_metainfo) },
246
{ "set_value", G_STRUCT_OFFSET(GConfBackendVTable, set_value) },
247
{ "all_entries", G_STRUCT_OFFSET(GConfBackendVTable, all_entries) },
248
{ "all_subdirs", G_STRUCT_OFFSET(GConfBackendVTable, all_subdirs) },
249
{ "unset_value", G_STRUCT_OFFSET(GConfBackendVTable, unset_value) },
250
{ "dir_exists", G_STRUCT_OFFSET(GConfBackendVTable, dir_exists) },
251
{ "remove_dir", G_STRUCT_OFFSET(GConfBackendVTable, remove_dir) },
252
{ "set_schema", G_STRUCT_OFFSET(GConfBackendVTable, set_schema) },
253
{ "sync_all", G_STRUCT_OFFSET(GConfBackendVTable, sync_all) },
254
{ "destroy_source", G_STRUCT_OFFSET(GConfBackendVTable, destroy_source) },
255
{ "blow_away_locks", G_STRUCT_OFFSET(GConfBackendVTable, blow_away_locks) }
261
GCONF_ERROR_FAILED, _("Backend `%s' failed return a vtable\n"),
266
/* Create a copy in case vtable size doesn't match */
267
memcpy(vtable_copy, vtable, MIN(vtable->vtable_size, sizeof(GConfBackendVTable)));
269
vtable_copy->vtable_size = sizeof(GConfBackendVTable);
271
for (i = 0; i < G_N_ELEMENTS(required_vtable_functions); i++)
273
if (G_STRUCT_MEMBER_P(vtable_copy, required_vtable_functions[i].offset) == NULL)
276
GCONF_ERROR_FAILED, _("Backend `%s' missing required vtable member `%s'\n"),
278
required_vtable_functions[i].name);
182
287
gconf_get_backend(const gchar* address, GError** err)
184
289
GConfBackend* backend;
187
293
if (loaded_backends == NULL)
189
295
loaded_backends = g_hash_table_new(g_str_hash, g_str_equal);
299
if (!gconf_address_valid (address, &why_invalid))
301
g_assert (why_invalid != NULL);
302
gconf_set_error (err, GCONF_ERROR_BAD_ADDRESS, _("Bad address `%s': %s"),
303
address, why_invalid);
304
g_free (why_invalid);
191
308
name = gconf_address_backend(address);
193
310
if (name == NULL)