summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-09-13 22:41:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:44 -0500
commit34991bbd0c5d5f85cdbaf7d847ea1570235c29f7 (patch)
tree209b7b59e0406add3331f8cb350d307c192a5d03 /source3/registry
parentaaa0afaa268e97dafea1ec9b03fa9630880a4fe7 (diff)
downloadsamba-34991bbd0c5d5f85cdbaf7d847ea1570235c29f7.tar.gz
samba-34991bbd0c5d5f85cdbaf7d847ea1570235c29f7.tar.bz2
samba-34991bbd0c5d5f85cdbaf7d847ea1570235c29f7.zip
r25140: Less red bars to hurt my eyes...
(This used to be commit f935d21200294c8d29ce527300f605e721cb3620)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_objects.c98
1 files changed, 51 insertions, 47 deletions
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c
index 89fdae7b8c..5b294abb90 100644
--- a/source3/registry/reg_objects.c
+++ b/source3/registry/reg_objects.c
@@ -1,4 +1,4 @@
-/*
+/*
* Unix SMB/CIFS implementation.
* Virtual Windows Registry Layer
* Copyright (C) Gerald Carter 2002-2005
@@ -7,12 +7,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
@@ -27,11 +27,11 @@
/**********************************************************************
Note that the REGSUB_CTR and REGVAL_CTR objects *must* be talloc()'d
- since the methods use the object pointer as the talloc context for
+ since the methods use the object pointer as the talloc context for
internal private data.
There is no longer a regXXX_ctr_intit() and regXXX_ctr_destroy()
- pair of functions. Simply TALLOC_ZERO_P() and TALLOC_FREE() the
+ pair of functions. Simply TALLOC_ZERO_P() and TALLOC_FREE() the
object.
**********************************************************************/
@@ -72,7 +72,7 @@ WERROR regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, const char *keyname )
return WERR_OK;
}
-
+
/***********************************************************************
Delete a key from the array
**********************************************************************/
@@ -90,15 +90,16 @@ int regsubkey_ctr_delkey( REGSUBKEY_CTR *ctr, const char *keyname )
if ( strequal( ctr->subkeys[i], keyname ) )
break;
}
-
+
if ( i == ctr->num_subkeys )
return ctr->num_subkeys;
/* update if we have any keys left */
ctr->num_subkeys--;
if ( i < ctr->num_subkeys )
- memmove( &ctr->subkeys[i], &ctr->subkeys[i+1], sizeof(char*) * (ctr->num_subkeys-i) );
-
+ memmove(&ctr->subkeys[i], &ctr->subkeys[i+1],
+ sizeof(char*) * (ctr->num_subkeys-i));
+
return ctr->num_subkeys;
}
@@ -109,7 +110,7 @@ int regsubkey_ctr_delkey( REGSUBKEY_CTR *ctr, const char *keyname )
BOOL regsubkey_ctr_key_exists( REGSUBKEY_CTR *ctr, const char *keyname )
{
int i;
-
+
if (!ctr->subkeys) {
return False;
}
@@ -118,7 +119,7 @@ BOOL regsubkey_ctr_key_exists( REGSUBKEY_CTR *ctr, const char *keyname )
if ( strequal( ctr->subkeys[i],keyname ) )
return True;
}
-
+
return False;
}
@@ -139,7 +140,7 @@ char* regsubkey_ctr_specific_key( REGSUBKEY_CTR *ctr, uint32 key_index )
{
if ( ! (key_index < ctr->num_subkeys) )
return NULL;
-
+
return ctr->subkeys[key_index];
}
@@ -164,49 +165,49 @@ int regval_ctr_numvals( REGVAL_CTR *ctr )
REGISTRY_VALUE* dup_registry_value( REGISTRY_VALUE *val )
{
REGISTRY_VALUE *copy = NULL;
-
+
if ( !val )
return NULL;
-
+
if ( !(copy = SMB_MALLOC_P( REGISTRY_VALUE)) ) {
DEBUG(0,("dup_registry_value: malloc() failed!\n"));
return NULL;
}
-
+
/* copy all the non-pointer initial data */
-
+
memcpy( copy, val, sizeof(REGISTRY_VALUE) );
-
+
copy->size = 0;
copy->data_p = NULL;
-
- if ( val->data_p && val->size )
+
+ if ( val->data_p && val->size )
{
if ( !(copy->data_p = (uint8 *)memdup( val->data_p,
val->size )) ) {
- DEBUG(0,("dup_registry_value: memdup() failed for [%d] bytes!\n",
- val->size));
+ DEBUG(0,("dup_registry_value: memdup() failed for [%d] "
+ "bytes!\n", val->size));
SAFE_FREE( copy );
return NULL;
}
copy->size = val->size;
}
-
- return copy;
+
+ return copy;
}
/**********************************************************************
- free the memory allocated to a REGISTRY_VALUE
+ free the memory allocated to a REGISTRY_VALUE
*********************************************************************/
-
+
void free_registry_value( REGISTRY_VALUE *val )
{
if ( !val )
return;
-
+
SAFE_FREE( val->data_p );
SAFE_FREE( val );
-
+
return;
}
@@ -251,7 +252,7 @@ REGISTRY_VALUE* regval_ctr_specific_value( REGVAL_CTR *ctr, uint32 idx )
{
if ( !(idx < ctr->num_values) )
return NULL;
-
+
return ctr->values[idx];
}
@@ -262,12 +263,12 @@ REGISTRY_VALUE* regval_ctr_specific_value( REGVAL_CTR *ctr, uint32 idx )
BOOL regval_ctr_key_exists( REGVAL_CTR *ctr, const char *value )
{
int i;
-
+
for ( i=0; i<ctr->num_values; i++ ) {
if ( strequal( ctr->values[i]->valuename, value) )
return True;
}
-
+
return False;
}
@@ -304,7 +305,7 @@ REGISTRY_VALUE *regval_compose(TALLOC_CTX *ctx, const char *name, uint16 type,
Add a new registry value to the array
**********************************************************************/
-int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type,
+int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type,
const char *data_p, size_t size )
{
if ( !name )
@@ -315,11 +316,13 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type,
regval_ctr_delvalue( ctr, name );
/* allocate a slot in the array of pointers */
-
+
if ( ctr->num_values == 0 ) {
ctr->values = TALLOC_P( ctr, REGISTRY_VALUE *);
} else {
- ctr->values = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
+ ctr->values = TALLOC_REALLOC_ARRAY(ctr, ctr->values,
+ REGISTRY_VALUE *,
+ ctr->num_values+1);
}
if (!ctr->values) {
@@ -328,7 +331,7 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type,
}
/* allocate a new value and store the pointer in the arrya */
-
+
ctr->values[ctr->num_values] = regval_compose(ctr, name, type, data_p,
size);
if (ctr->values[ctr->num_values] == NULL) {
@@ -362,22 +365,23 @@ int regval_ctr_copyvalue( REGVAL_CTR *ctr, REGISTRY_VALUE *val )
int regval_ctr_delvalue( REGVAL_CTR *ctr, const char *name )
{
int i;
-
+
for ( i=0; i<ctr->num_values; i++ ) {
if ( strequal( ctr->values[i]->valuename, name ) )
break;
}
-
+
/* just return if we don't find it */
-
+
if ( i == ctr->num_values )
return ctr->num_values;
-
+
/* If 'i' was not the last element, just shift everything down one */
ctr->num_values--;
if ( i < ctr->num_values )
- memmove( &ctr->values[i], &ctr->values[i+1], sizeof(REGISTRY_VALUE*)*(ctr->num_values-i) );
-
+ memmove(&ctr->values[i], &ctr->values[i+1],
+ sizeof(REGISTRY_VALUE*)*(ctr->num_values-i));
+
return ctr->num_values;
}
@@ -389,14 +393,14 @@ int regval_ctr_delvalue( REGVAL_CTR *ctr, const char *name )
REGISTRY_VALUE* regval_ctr_getvalue( REGVAL_CTR *ctr, const char *name )
{
int i;
-
+
/* search for the value */
-
+
for ( i=0; i<ctr->num_values; i++ ) {
if ( strequal( ctr->values[i]->valuename, name ) )
return ctr->values[i];
}
-
+
return NULL;
}
@@ -407,9 +411,9 @@ REGISTRY_VALUE* regval_ctr_getvalue( REGVAL_CTR *ctr, const char *name )
uint32 regval_dword( REGISTRY_VALUE *val )
{
uint32 data;
-
+
data = IVAL( regval_data_p(val), 0 );
-
+
return data;
}
@@ -421,7 +425,7 @@ char* regval_sz( REGISTRY_VALUE *val )
{
pstring data;
- rpcstr_pull( data, regval_data_p(val), sizeof(data), regval_size(val), 0 );
-
+ rpcstr_pull(data, regval_data_p(val), sizeof(data), regval_size(val),0);
+
return talloc_strdup(talloc_tos(), data);
}