From 2bd75e4714f664a4cddf406a18f665b5cd590f29 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 22 Aug 2002 21:16:11 +0000 Subject: fix registry editor API for printing backend after I changed the NT_PRINTER_PARAM to a REGISTRY_VALUE (This used to be commit 8d510abe125e15a8d71c58a13d170dc3d6371368) --- source3/registry/reg_frontend.c | 39 +++++++++++++++++++-- source3/registry/reg_printing.c | 67 ++++++++++++++++++------------------- source3/rpc_server/srv_spoolss_nt.c | 4 +-- 3 files changed, 69 insertions(+), 41 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 ) @@ -285,6 +282,42 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, char *name, uint16 type, return ctr->num_values; } +/*********************************************************************** + 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; iinfo_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; ikeys[key_index].values, i) ); + + done: + if ( printer ) + free_a_printer( &printer, 2 ); + SAFE_FREE( key2 ); return num_values; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a9c09b9107..1c60e7024e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7925,7 +7925,6 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, fstring valuename; fstring keyname; char *oid_string; - UNISTR2 uni_oid; DEBUG(4,("_spoolss_setprinterdataex\n")); @@ -7988,9 +7987,8 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, * this is right. --jerry */ - init_unistr2( &uni_oid, oid_string, strlen(oid_string)+1 ); set_printer_dataex( printer, keyname, valuename, - REG_SZ, (void*)uni_oid.buffer, uni_oid.uni_str_len*sizeof(uint16) ); + REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); } free_a_printer(&printer, 2); -- cgit