fix registry editor API for printing backend after I changed
authorGerald Carter <jerry@samba.org>
Thu, 22 Aug 2002 21:16:11 +0000 (21:16 +0000)
committerGerald Carter <jerry@samba.org>
Thu, 22 Aug 2002 21:16:11 +0000 (21:16 +0000)
the NT_PRINTER_PARAM to a REGISTRY_VALUE
(This used to be commit 8d510abe125e15a8d71c58a13d170dc3d6371368)

source3/registry/reg_frontend.c
source3/registry/reg_printing.c
source3/rpc_server/srv_spoolss_nt.c

index f31f6759971483ade1fa06074c797513f7007bff..05bcd989b445e18bb02e3bfbc69b82435111018e 100644 (file)
@@ -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.
index 8ab0abba9b7625dd81b9306fe8601fc57386e3ad..2bc9d056e498c343b4524fcc09691b7b5e3de85d 100644 (file)
@@ -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;
index a9c09b9107d54d51ca681905bacdc221fcdf794b..1c60e7024e0481b22aa14c251a6e342b29b16405 100644 (file)
@@ -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);