From f0c650a38286c07b9f3e83139c15bfbadc70ad5f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 May 2005 16:25:31 +0000 Subject: r6942: * merging the registry changes back to the 3.0 tree * removing the testprns tool (This used to be commit 81ffb0dbbbd244623507880c323a3c37e2b8dc4d) --- source3/registry/reg_objects.c | 82 +++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 37 deletions(-) (limited to 'source3/registry/reg_objects.c') diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c index c8dc633087..add82ae0d4 100644 --- a/source3/registry/reg_objects.c +++ b/source3/registry/reg_objects.c @@ -1,7 +1,7 @@ /* * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Gerald Carter 2002. + * Virtual Windows Registry Layer + * Copyright (C) Gerald Carter 2002-2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,27 +44,35 @@ int regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, const char *keyname ) { uint32 len; char **pp; + int i; - if ( keyname ) - { - len = strlen( keyname ); + if ( !keyname ) + return ctr->num_subkeys; - /* allocate a space for the char* in the array */ - - if ( ctr->subkeys == 0 ) - ctr->subkeys = TALLOC_P( ctr->ctx, char *); - else { - pp = TALLOC_REALLOC_ARRAY( ctr->ctx, ctr->subkeys, char *, ctr->num_subkeys+1); - if ( pp ) - ctr->subkeys = pp; - } + len = strlen( keyname ); + + /* make sure the keyname is not already there */ + + for ( i=0; inum_subkeys; i++ ) { + if ( strequal( ctr->subkeys[i], keyname ) ) + return ctr->num_subkeys; + } - /* allocate the string and save it in the array */ + /* allocate a space for the char* in the array */ - ctr->subkeys[ctr->num_subkeys] = TALLOC( ctr->ctx, len+1 ); - strncpy( ctr->subkeys[ctr->num_subkeys], keyname, len+1 ); - ctr->num_subkeys++; + if ( ctr->subkeys == 0 ) + ctr->subkeys = TALLOC_P( ctr->ctx, char *); + else { + pp = TALLOC_REALLOC_ARRAY( ctr->ctx, ctr->subkeys, char *, ctr->num_subkeys+1); + if ( pp ) + ctr->subkeys = pp; } + + /* allocate the string and save it in the array */ + + ctr->subkeys[ctr->num_subkeys] = TALLOC( ctr->ctx, len+1 ); + strncpy( ctr->subkeys[ctr->num_subkeys], keyname, len+1 ); + ctr->num_subkeys++; return ctr->num_subkeys; } @@ -239,30 +247,30 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type, { REGISTRY_VALUE **ppreg; - if ( name ) - { - /* allocate a slot in the array of pointers */ + if ( !name ) + return ctr->num_values; + + /* allocate a slot in the array of pointers */ - if ( ctr->num_values == 0 ) - ctr->values = TALLOC_P( ctr->ctx, REGISTRY_VALUE *); - else { - ppreg = TALLOC_REALLOC_ARRAY( ctr->ctx, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 ); - if ( ppreg ) - ctr->values = ppreg; - } + if ( ctr->num_values == 0 ) + ctr->values = TALLOC_P( ctr->ctx, REGISTRY_VALUE *); + else { + ppreg = TALLOC_REALLOC_ARRAY( ctr->ctx, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 ); + if ( ppreg ) + ctr->values = ppreg; + } - /* allocate a new value and store the pointer in the arrya */ + /* allocate a new value and store the pointer in the arrya */ - ctr->values[ctr->num_values] = TALLOC_P( ctr->ctx, REGISTRY_VALUE); + ctr->values[ctr->num_values] = TALLOC_P( ctr->ctx, REGISTRY_VALUE); - /* init the value */ + /* init the value */ - fstrcpy( ctr->values[ctr->num_values]->valuename, name ); - ctr->values[ctr->num_values]->type = type; - ctr->values[ctr->num_values]->data_p = TALLOC_MEMDUP( ctr->ctx, data_p, size ); - ctr->values[ctr->num_values]->size = size; - ctr->num_values++; - } + fstrcpy( ctr->values[ctr->num_values]->valuename, name ); + ctr->values[ctr->num_values]->type = type; + ctr->values[ctr->num_values]->data_p = TALLOC_MEMDUP( ctr->ctx, data_p, size ); + ctr->values[ctr->num_values]->size = size; + ctr->num_values++; return ctr->num_values; } -- cgit