diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-04-08 22:39:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:09 -0500 |
commit | aebfb3b9f415d3c1f6b2a39aee27b072d48893cb (patch) | |
tree | 4eebbcafdd559216ef8ad952f11ebe05f947b5f0 /source4/lib/registry/reg_backend_gconf | |
parent | d907dcf383fcdf82add4fd7c397885eab5bb57af (diff) | |
download | samba-aebfb3b9f415d3c1f6b2a39aee27b072d48893cb.tar.gz samba-aebfb3b9f415d3c1f6b2a39aee27b072d48893cb.tar.bz2 samba-aebfb3b9f415d3c1f6b2a39aee27b072d48893cb.zip |
r128: Another registry update. Changes:
- Start with the LDB backend
- The API is now more windows-like, which should make it easier to use
in rpc_server
- Added a GTK+ front-end
- Added some more IDL
More updates will follow, especially in the RPC field..
(This used to be commit 3adffa021779b26047a20f16a3c0b53d74751560)
Diffstat (limited to 'source4/lib/registry/reg_backend_gconf')
-rw-r--r-- | source4/lib/registry/reg_backend_gconf/reg_backend_gconf.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/source4/lib/registry/reg_backend_gconf/reg_backend_gconf.c b/source4/lib/registry/reg_backend_gconf/reg_backend_gconf.c index 71d3361ce2..1acb3cbcec 100644 --- a/source4/lib/registry/reg_backend_gconf/reg_backend_gconf.c +++ b/source4/lib/registry/reg_backend_gconf/reg_backend_gconf.c @@ -22,18 +22,26 @@ #include "lib/registry/common/registry.h" #include <gconf/gconf-client.h> -static BOOL reg_open_gconf(REG_HANDLE *h, const char *location, BOOL try_complete_load) +static WERROR gerror_to_werror(GError *error) +{ + if(error == NULL) return WERR_OK; + /* FIXME */ + return WERR_FOOBAR; +} + +static WERROR reg_open_gconf(REG_HANDLE *h, const char *location, const char *credentials) { h->backend_data = (void *)gconf_client_get_default(); - return True; + if(!h->backend_data) return WERR_FOOBAR; + return WERR_OK; } -static BOOL reg_close_gconf(REG_HANDLE *h) +static WERROR reg_close_gconf(REG_HANDLE *h) { - return True; + return WERR_OK; } -static REG_KEY *gconf_open_key (REG_HANDLE *h, const char *name) +static WERROR gconf_open_key (REG_HANDLE *h, const char *name, REG_KEY **key) { REG_KEY *ret; char *fullpath = reg_path_win2unix(strdup(name)); @@ -41,16 +49,17 @@ static REG_KEY *gconf_open_key (REG_HANDLE *h, const char *name) /* Check if key exists */ if(!gconf_client_dir_exists((GConfClient *)h->backend_data, fullpath, NULL)) { SAFE_FREE(fullpath); - return NULL; + return WERR_DEST_NOT_FOUND; } ret = reg_key_new_abs(name, h, NULL); ret->backend_data = talloc_strdup(ret->mem_ctx, fullpath); SAFE_FREE(fullpath); - return ret; + *key = ret; + return WERR_OK; } -static BOOL gconf_fetch_values(REG_KEY *p, int *count, REG_VAL ***vals) +static WERROR gconf_fetch_values(REG_KEY *p, int *count, REG_VAL ***vals) { GSList *entries; GSList *cur; @@ -113,22 +122,24 @@ static BOOL gconf_fetch_values(REG_KEY *p, int *count, REG_VAL ***vals) g_slist_free(entries); *vals = ar; - return True; + return WERR_OK; } -static BOOL gconf_fetch_subkeys(REG_KEY *p, int *count, REG_KEY ***subs) +static WERROR gconf_fetch_subkeys(REG_KEY *p, int *count, REG_KEY ***subs) { GSList *dirs; GSList *cur; - REG_KEY **ar = malloc(sizeof(REG_KEY *)); + REG_KEY **ar = talloc_array_p(p->mem_ctx, REG_KEY *, 1); char *fullpath = p->backend_data; cur = dirs = gconf_client_all_dirs((GConfClient*)p->handle->backend_data, fullpath,NULL); (*count) = 0; while(cur) { - ar[(*count)] = reg_key_new_abs(reg_path_unix2win((char *)cur->data), p->handle,NULL); - ar[(*count)]->backend_data = talloc_strdup(ar[*count]->mem_ctx, cur->data); - ar = realloc(ar, sizeof(REG_KEY *) * ((*count)+2)); + char *winpath = reg_path_unix2win(strdup((char *)cur->data)); + ar[(*count)] = reg_key_new_abs(winpath, p->handle,NULL); + free(winpath); + ar[(*count)]->backend_data = reg_path_win2unix(talloc_strdup(ar[*count]->mem_ctx, cur->data)); + ar = talloc_realloc_p(p->mem_ctx, ar, REG_KEY *, (*count)+2); (*count)++; g_free(cur->data); cur = cur->next; @@ -136,10 +147,10 @@ static BOOL gconf_fetch_subkeys(REG_KEY *p, int *count, REG_KEY ***subs) g_slist_free(dirs); *subs = ar; - return True; + return WERR_OK; } -static BOOL gconf_update_value(REG_VAL *val, int type, void *data, int len) +static WERROR gconf_update_value(REG_VAL *val, int type, void *data, int len) { GError *error = NULL; char *keypath = val->backend_data; @@ -152,22 +163,23 @@ static BOOL gconf_update_value(REG_VAL *val, int type, void *data, int len) case REG_EXPAND_SZ: gconf_client_set_string((GConfClient *)val->handle->backend_data, valpath, data, &error); free(valpath); - return (error == NULL); + return gerror_to_werror(error); case REG_DWORD: gconf_client_set_int((GConfClient *)val->handle->backend_data, valpath, *((int *)data), &error); free(valpath); - return (error == NULL); + return gerror_to_werror(error); default: DEBUG(0, ("Unsupported type: %d\n", type)); free(valpath); - return False; + return WERR_NOT_SUPPORTED; } - return False; + + return WERR_NOT_SUPPORTED; } -static REG_OPS reg_backend_gconf = { +static struct registry_ops reg_backend_gconf = { .name = "gconf", .open_registry = reg_open_gconf, .close_registry = reg_close_gconf, |