summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-08-22 21:16:11 +0000
committerGerald Carter <jerry@samba.org>2002-08-22 21:16:11 +0000
commit2bd75e4714f664a4cddf406a18f665b5cd590f29 (patch)
tree8c3fd886a9d5668ac47b98795adc96ad31990587 /source3/registry
parent02f8ed71103ca57135980a203d99785a97563455 (diff)
downloadsamba-2bd75e4714f664a4cddf406a18f665b5cd590f29.tar.gz
samba-2bd75e4714f664a4cddf406a18f665b5cd590f29.tar.bz2
samba-2bd75e4714f664a4cddf406a18f665b5cd590f29.zip
fix registry editor API for printing backend after I changed
the NT_PRINTER_PARAM to a REGISTRY_VALUE (This used to be commit 8d510abe125e15a8d71c58a13d170dc3d6371368)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_frontend.c39
-rw-r--r--source3/registry/reg_printing.c67
2 files changed, 68 insertions, 38 deletions
diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c
index f31f675997..05bcd989b4 100644
--- a/source3/registry/reg_frontend.c
+++ b/source3/registry/reg_frontend.c
@@ -253,12 +253,9 @@ 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 );
-
/* allocate a slot in the array of pointers */
if ( ctr->num_values == 0 )
@@ -286,6 +283,42 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, char *name, uint16 type,
}
/***********************************************************************
+ Add a new registry value to the array
+ **********************************************************************/
+
+int regval_ctr_copyvalue( REGVAL_CTR *ctr, REGISTRY_VALUE *val )
+{
+ REGISTRY_VALUE **ppreg;
+
+ if ( val )
+ {
+ /* allocate a slot in the array of pointers */
+
+ 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;
+ }
+
+ /* allocate a new value and store the pointer in the arrya */
+
+ ctr->values[ctr->num_values] = talloc( ctr->ctx, sizeof(REGISTRY_VALUE) );
+
+ /* init the value */
+
+ fstrcpy( ctr->values[ctr->num_values]->valuename, val->valuename );
+ ctr->values[ctr->num_values]->type = val->type;
+ ctr->values[ctr->num_values]->data_p = talloc_memdup( ctr->ctx, val->data_p, val->size );
+ ctr->values[ctr->num_values]->size = val->size;
+ ctr->num_values++;
+ }
+
+ return ctr->num_values;
+}
+
+/***********************************************************************
Delete a single value from the registry container.
No need to free memory since it is talloc'd.
**********************************************************************/
diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c
index 8ab0abba9b..2bc9d056e4 100644
--- a/source3/registry/reg_printing.c
+++ b/source3/registry/reg_printing.c
@@ -453,11 +453,12 @@ static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys )
int n_services = lp_numservices();
int snum;
fstring sname;
+ int i;
int num_subkeys = 0;
char *keystr, *key2 = NULL;
char *base, *new_path;
NT_PRINTER_INFO_LEVEL *printer = NULL;
-
+ fstring *subkey_names = NULL;
DEBUG(10,("print_subpath_printers: key=>[%s]\n", key ? key : "NULL" ));
@@ -483,22 +484,23 @@ static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys )
key2 = strdup( key );
keystr = key2;
reg_split_path( keystr, &base, &new_path );
+
+ if ( !W_ERROR_IS_OK( get_a_printer(&printer, 2, base) ) )
+ goto done;
+
+ num_subkeys = get_printer_subkeys( &printer->info_2->data, new_path?new_path:"", &subkey_names );
+ for ( i=0; i<num_subkeys; i++ )
+ regsubkey_ctr_addkey( subkeys, subkey_names[i] );
- if ( !new_path ) {
- /* sanity check on the printer name */
- if ( !W_ERROR_IS_OK( get_a_printer(&printer, 2, base) ) )
- goto done;
-
- free_a_printer( &printer, 2 );
-
- regsubkey_ctr_addkey( subkeys, SPOOL_PRINTERDATA_KEY );
- }
-
+ free_a_printer( &printer, 2 );
+
/* no other subkeys below here */
done:
SAFE_FREE( key2 );
+ SAFE_FREE( subkey_names );
+
return num_subkeys;
}
@@ -517,7 +519,9 @@ static int print_subpath_values_printers( char *key, REGVAL_CTR *val )
prs_struct prs;
uint32 offset;
int snum;
- fstring printername;
+ fstring printername;
+ NT_PRINTER_DATA *p_data;
+ int i, key_index;
/*
* There are tw cases to deal with here
@@ -603,43 +607,36 @@ static int print_subpath_values_printers( char *key, REGVAL_CTR *val )
prs_mem_free( &prs );
- free_a_printer( &printer, 2 );
num_values = regval_ctr_numvals( val );
+
goto done;
}
-
-
- keystr = new_path;
- reg_split_path( keystr, &base, &new_path );
-
- /* here should be no more path components here */
-
- if ( new_path || strcmp(base, SPOOL_PRINTERDATA_KEY) )
- goto done;
- /* now enumerate the PrinterDriverData key */
+ /* now enumerate the key */
+
if ( !W_ERROR_IS_OK( get_a_printer(&printer, 2, printername) ) )
goto done;
-
- info2 = printer->info_2;
-
/* iterate over all printer data and fill the regval container */
-#if 0 /* JERRY */
- for ( i=0; get_specific_param_by_index(*printer, 2, i, valuename, &data, &type, &data_len); i++ )
- {
- regval_ctr_addvalue( val, valuename, type, data, data_len );
+ p_data = &printer->info_2->data;
+ if ( (key_index = lookup_printerkey( p_data, new_path )) == -1 ) {
+ DEBUG(10,("print_subpath_values_printer: Unknown keyname [%s]\n", new_path));
+ goto done;
}
-#endif
-
- free_a_printer( &printer, 2 );
-
- num_values = regval_ctr_numvals( val );
+ num_values = regval_ctr_numvals( &p_data->keys[key_index].values );
+
+ for ( i=0; i<num_values; i++ )
+ regval_ctr_copyvalue( val, regval_ctr_specific_value(&p_data->keys[key_index].values, i) );
+
+
done:
+ if ( printer )
+ free_a_printer( &printer, 2 );
+
SAFE_FREE( key2 );
return num_values;