summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-07-20 13:23:57 +0000
committerGerald Carter <jerry@samba.org>2002-07-20 13:23:57 +0000
commit6dd9f24d05e5db92e15dc53399a0f78ccb69f718 (patch)
tree234454eee6950cf09745f658eebad80756ef6590 /source3/registry
parent29075c97d3b7111e2565ede1cd0f000fd2534375 (diff)
downloadsamba-6dd9f24d05e5db92e15dc53399a0f78ccb69f718.tar.gz
samba-6dd9f24d05e5db92e15dc53399a0f78ccb69f718.tar.bz2
samba-6dd9f24d05e5db92e15dc53399a0f78ccb69f718.zip
another intermediate checkin on the way to enumerating forms
via the registry. There is a seg fault here which shouldn't bother anyone until I can get it fixed. I just need a check point in case I need to roll back to this version later on. (This used to be commit e62ae94823461e142978a786b2860ea97906cfb3)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_frontend.c53
-rw-r--r--source3/registry/reg_printing.c86
2 files changed, 116 insertions, 23 deletions
diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c
index 4e3f09fe4e..6e550c1a0d 100644
--- a/source3/registry/reg_frontend.c
+++ b/source3/registry/reg_frontend.c
@@ -32,7 +32,6 @@ extern REGISTRY_OPS regdb_ops; /* these are the default */
REGISTRY_HOOK reg_hooks[] = {
- { KEY_TREE_ROOT, &regdb_ops },
{ KEY_PRINTING, &printing_ops },
{ NULL, NULL }
};
@@ -283,6 +282,58 @@ int regval_ctr_numvals( REGVAL_CTR *ctr )
return ctr->num_values;
}
+REGISTRY_VALUE* regval_ctr_specific_value( REGVAL_CTR *ctr, uint32 idx )
+{
+ if ( !(idx < ctr->num_values) )
+ return NULL;
+
+ return ctr->values[idx];
+}
+
+/***********************************************************************
+ Ad a new regostry value to the array
+ **********************************************************************/
+
+int regval_ctr_addvalue( REGVAL_CTR *ctr, char *name, uint16 type,
+ char *data_p, size_t size )
+{
+ REGISTRY_VALUE **ppreg;
+ uint16 len;
+
+ if ( name )
+ {
+ len = strlen( name );
+
+ if ( ctr->num_values == 0 )
+ ctr->values = talloc( ctr->ctx, sizeof(REGISTRY_VALUE*) );
+ else {
+ ppreg = talloc_realloc( ctr->ctx, ctr->values, sizeof(REGISTRY_VALUE*)*(ctr->num_values+1) );
+ if ( ppreg )
+ ctr->values = ppreg;
+ }
+
+ fstrcpy( ctr->values[ctr->num_values]->valuename, name );
+ ctr->values[ctr->num_values]->type = type;
+ switch ( type )
+ {
+ case REG_SZ:
+ ctr->values[ctr->num_values]->data.string = talloc_strdup( ctr->ctx, data_p );
+ break;
+ case REG_DWORD:
+ break;
+ case REG_BINARY:
+ ctr->values[ctr->num_values]->data.binary = talloc_memdup( ctr->ctx, data_p, size );
+ break;
+
+ }
+ ctr->values[ctr->num_values]->size = size;
+
+ ctr->num_values++;
+ }
+
+ return ctr->num_values;
+}
+
/***********************************************************************
free memory held by a REGVAL_CTR structure
**********************************************************************/
diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c
index 99bdb4771f..993d793c1e 100644
--- a/source3/registry/reg_printing.c
+++ b/source3/registry/reg_printing.c
@@ -39,6 +39,7 @@ static char *top_level_keys[MAX_TOP_LEVEL_KEYS] = {
"Printers"
};
+
/**********************************************************************
It is safe to assume that every registry path passed into on of
the exported functions here begins with KEY_PRINTING else
@@ -97,12 +98,19 @@ static int print_subpath_environments( char *key, REGSUBKEY_CTR *subkeys )
/**********************************************************************
handle enumeration of subkeys below KEY_PRINTING\Forms
+ Really just a stub function, but left here in case it needs to
+ be expanded later on
*********************************************************************/
static int print_subpath_forms( char *key, REGSUBKEY_CTR *subkeys )
{
DEBUG(10,("print_subpath_forms: key=>[%s]\n", key ? key : "NULL" ));
+ /* there are no subkeys */
+
+ if ( key )
+ return -1;
+
return 0;
}
@@ -110,36 +118,74 @@ static int print_subpath_forms( char *key, REGSUBKEY_CTR *subkeys )
handle enumeration of values below KEY_PRINTING\Forms
*********************************************************************/
-static int print_values_forms( char *key, REGVAL_CTR *val )
+static int print_subpath_values_forms( char *key, REGVAL_CTR *val )
{
- int num_values = 0;
+ int num_values = 0;
+ uint32 data[7];
DEBUG(10,("print_values_forms: key=>[%s]\n", key ? key : "NULL" ));
/* handle ..\Forms\ */
-#if 0 /* JERRY */
if ( !key )
{
- nt_forms_struct *forms = NULL;
+ nt_forms_struct *forms_list = NULL;
+ nt_forms_struct *form = NULL;
int i;
- if ( (num_values = get_ntforms( &forms )) == 0 )
+ if ( (num_values = get_ntforms( &forms_list )) == 0 )
return 0;
- if ( !(*values = malloc(sizeof(REGISTRY_VALUE) * num_values)) ) {
- DEBUG(0,("print_values_forms: Failed to malloc memory for [%d] REGISTRY_VALUE structs!\n",
- num_values));
- return -1;
+ DEBUG(10,("print_subpath_values_forms: [%d] user defined forms returned\n",
+ num_values));
+
+ /* handle user defined forms */
+
+ for ( i=0; i<num_values; i++ )
+ {
+ form = &forms_list[i];
+
+ data[0] = form->flag;
+ data[1] = form->width;
+ data[2] = form->length;
+ data[3] = form->left;
+ data[4] = form->top;
+ data[5] = form->right;
+ data[6] = form->bottom;
+
+ regval_ctr_addvalue( val, form->name, REG_BINARY, (char*)data, sizeof(data) );
+
}
+ SAFE_FREE( forms_list );
+ forms_list = NULL;
+
+ /* handle built-on forms */
+
+ if ( (num_values = get_builtin_ntforms( &forms_list )) == 0 )
+ return 0;
+
+ DEBUG(10,("print_subpath_values_forms: [%d] built-in forms returned\n",
+ num_values));
+
for ( i=0; i<num_values; i++ )
{
+ form = &forms_list[i];
+ data[0] = form->flag;
+ data[1] = form->width;
+ data[2] = form->length;
+ data[3] = form->left;
+ data[4] = form->top;
+ data[5] = form->right;
+ data[6] = form->bottom;
+
+ regval_ctr_addvalue( val, form->name, REG_BINARY, (char*)data, sizeof(data) );
}
+
+ SAFE_FREE( forms_list );
}
-#endif
return num_values;
}
@@ -150,7 +196,7 @@ static int print_values_forms( char *key, REGVAL_CTR *val )
static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys )
{
- int n_services = lp_numservices();
+ int n_services = lp_numservices();
int snum;
fstring sname;
@@ -208,29 +254,25 @@ static int handle_printing_subpath( char *key, REGSUBKEY_CTR *subkeys, REGVAL_CT
if ( !(i < MAX_TOP_LEVEL_KEYS) )
return -1;
-
- /* quick hack for now */
- if ( !subkeys )
- return 0;
-
+
/* Call routine to handle each top level key */
switch ( i )
{
case KEY_INDEX_ENVIR:
if ( subkeys )
print_subpath_environments( p, subkeys );
-#if 0 /* JERRY */
- if ( val )
- print_subpath_values_environments( p, val );
-#endif
break;
case KEY_INDEX_FORMS:
- result = print_subpath_forms( p, subkeys );
+ if ( subkeys )
+ print_subpath_forms( p, subkeys );
+ if ( val )
+ print_subpath_values_forms( p, val );
break;
case KEY_INDEX_PRINTER:
- result = print_subpath_printers( p, subkeys );
+ if ( subkeys )
+ print_subpath_printers( p, subkeys );
break;
/* default case for top level key that has no handler */