2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Gerald Carter 2002.
5 * Copyright (C) Jelmer Vernooij 2003-2004.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 /* Implementation of registry frontend view functions. */
25 #include "lib/registry/common/registry.h"
28 #define DBGC_CLASS DBGC_RPC_SRV
30 /***********************************************************************
31 allocate memory for and duplicate a REG_VAL.
32 This is malloc'd memory so the caller should free it when done
33 **********************************************************************/
35 REG_VAL* reg_val_dup( REG_VAL *val )
41 /**********************************************************************
42 free the memory allocated to a REG_VAL
43 *********************************************************************/
45 void reg_val_free( REG_VAL *val )
53 if(val->handle->functions->free_val_backend_data)
54 val->handle->functions->free_val_backend_data(val);
56 talloc_destroy( val->mem_ctx );
61 /**********************************************************************
62 *********************************************************************/
64 uint8_t * reg_val_data_blk( REG_VAL *val )
69 /**********************************************************************
70 *********************************************************************/
72 int reg_val_size( REG_VAL *val )
77 /**********************************************************************
78 *********************************************************************/
80 char *reg_val_name( REG_VAL *val )
85 /**********************************************************************
86 *********************************************************************/
88 uint32_t reg_val_type( REG_VAL *val )
90 return val->data_type;
93 /**********************************************************************
94 *********************************************************************/
96 REG_HANDLE *reg_key_handle (REG_KEY *key)
101 char *reg_key_name( REG_KEY *key )
106 REG_KEY *reg_key_dup(REG_KEY *key)
112 void reg_key_free(REG_KEY *key)
120 if(key->handle->functions->free_key_backend_data)
121 key->handle->functions->free_key_backend_data(key);
123 if(key->cache_values) {
125 for(i = 0; i < key->cache_values_count; i++) {
126 reg_val_free(key->cache_values[i]);
130 if(key->cache_subkeys) {
132 for(i = 0; i < key->cache_subkeys_count; i++) {
133 reg_key_free(key->cache_subkeys[i]);
137 talloc_destroy(key->mem_ctx);
140 char *reg_val_get_path(REG_VAL *v)
146 const char *reg_key_get_path(REG_KEY *k)
149 return strchr(k->path, '\\')?strchr(k->path, '\\')+1:"";
152 const char *reg_key_get_path_abs(REG_KEY *k)
158 /* For use by the backends _ONLY_ */
159 REG_KEY *reg_key_new_abs(const char *path, REG_HANDLE *h, void *data)
162 TALLOC_CTX *mem_ctx = talloc_init(path);
163 r = talloc(mem_ctx, sizeof(REG_KEY));
166 r->mem_ctx = mem_ctx;
167 r->path = talloc_strdup(mem_ctx, path);
168 r->name = talloc_strdup(mem_ctx, strrchr(path, '\\')?strrchr(path,'\\')+1:path);
169 r->backend_data = data;
174 REG_KEY *reg_key_new_rel(const char *name, REG_KEY *k, void *data)
177 const char *parent_path = k?reg_key_get_path(k):"";
178 TALLOC_CTX *mem_ctx = talloc_init(name);
179 r = talloc(mem_ctx, sizeof(REG_KEY));
181 r->handle = k->handle;
183 r->name = talloc_strdup(mem_ctx, name);
185 r->path = talloc_asprintf(mem_ctx, "%s%s%s", parent_path, *parent_path && parent_path[strlen(parent_path)-1] != '\\'?"\\":"", name);
186 r->backend_data = data;
187 r->mem_ctx = mem_ctx;
192 REG_VAL *reg_val_new(REG_KEY *parent, void *data)
195 TALLOC_CTX *mem_ctx = talloc_init("value");
196 r = talloc(mem_ctx, sizeof(REG_VAL));
198 r->mem_ctx = mem_ctx;
199 r->handle = parent->handle;
200 r->backend_data = data;