svn commit: samba r8064 - in branches/SAMBA_3_0/source: libsmb registry

jerry at samba.org jerry at samba.org
Fri Jul 1 22:24:01 GMT 2005


Author: jerry
Date: 2005-07-01 22:24:00 +0000 (Fri, 01 Jul 2005)
New Revision: 8064

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8064

Log:
* add the REG_XXX error codes to the pretty error messages
* more work on the store_values() functions for the Printers key
* add Control\Print\Monitors key to list for reg_db



Modified:
   branches/SAMBA_3_0/source/libsmb/doserr.c
   branches/SAMBA_3_0/source/registry/reg_db.c
   branches/SAMBA_3_0/source/registry/reg_printing.c


Changeset:
Modified: branches/SAMBA_3_0/source/libsmb/doserr.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/doserr.c	2005-07-01 20:56:27 UTC (rev 8063)
+++ branches/SAMBA_3_0/source/libsmb/doserr.c	2005-07-01 22:24:00 UTC (rev 8064)
@@ -72,6 +72,9 @@
 	{ "WERR_IO_PENDING", WERR_IO_PENDING },
 	{ "WERR_INVALID_SERVICE_CONTROL", WERR_INVALID_SERVICE_CONTROL },
 	{ "WERR_NET_NAME_NOT_FOUND", WERR_NET_NAME_NOT_FOUND },
+	{ "WERR_REG_CORRUPT", WERR_REG_CORRUPT },
+	{ "WERR_REG_IO_FAILURE", WERR_REG_IO_FAILURE },
+	{ "WERR_REG_FILE_INVALID", WERR_REG_FILE_INVALID },
 	{ NULL, W_ERROR(0) }
 };
 

Modified: branches/SAMBA_3_0/source/registry/reg_db.c
===================================================================
--- branches/SAMBA_3_0/source/registry/reg_db.c	2005-07-01 20:56:27 UTC (rev 8063)
+++ branches/SAMBA_3_0/source/registry/reg_db.c	2005-07-01 22:24:00 UTC (rev 8064)
@@ -45,6 +45,7 @@
 	KEY_PRINTING,
 	KEY_SHARES,
 	KEY_EVENTLOG,
+	"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors",
 	"HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
 	"HKLM\\SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
 	"HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters",
@@ -63,8 +64,12 @@
 };
 
 static struct builtin_regkey_value builtin_registry_values[] = {
-	{ "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",         "SystemRoot",          REG_SZ,  { "c:\\Windows" } },
-	{ "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports",  "Samba Printer Port",  REG_SZ,  { "" } },
+	{ "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",         
+		"SystemRoot", REG_SZ, { "c:\\Windows" } },
+	{ "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports",  
+		"Samba Printer Port", REG_SZ, { "" } },
+	{ "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers",  
+		"DefaultSpoolDirectory", REG_SZ, { "c:\\windows\\system32\\spool\\printers" } },
 	{ NULL, NULL, 0, { NULL } }
 };
 

Modified: branches/SAMBA_3_0/source/registry/reg_printing.c
===================================================================
--- branches/SAMBA_3_0/source/registry/reg_printing.c	2005-07-01 20:56:27 UTC (rev 8063)
+++ branches/SAMBA_3_0/source/registry/reg_printing.c	2005-07-01 22:24:00 UTC (rev 8064)
@@ -189,6 +189,32 @@
  *********************************************************************
  *********************************************************************/
 
+/*********************************************************************
+ strip off prefix for printers key.  DOes return a pointer to static 
+ memory.
+ *********************************************************************/
+
+static char* strip_printers_prefix( const char *key )
+{
+	char *subkeypath;
+	pstring path;
+	
+	pstrcpy( path, key );
+	normalize_reg_path( path );
+
+	/* normalizing the path does not change length, just key delimiters and case */
+
+	if ( strncmp( path, KEY_WINNT_PRINTERS, strlen(KEY_WINNT_PRINTERS) ) == 0 )
+		subkeypath = remaining_path( key + strlen(KEY_WINNT_PRINTERS) );
+	else
+		subkeypath = remaining_path( key + strlen(KEY_CONTROL_PRINTERS) );
+		
+	return subkeypath;
+}
+
+/*********************************************************************
+ *********************************************************************/
+ 
 static int key_printer_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
 {
 	int n_services = lp_numservices();	
@@ -196,26 +222,16 @@
 	fstring sname;
 	int i;
 	int num_subkeys = 0;
-	char *keystr;
+	char *printers_key;
 	char *base, *new_path;
 	NT_PRINTER_INFO_LEVEL *printer = NULL;
 	fstring *subkey_names = NULL;
-	pstring path;
 	
 	DEBUG(10,("print_subpath_printers: key=>[%s]\n", key ? key : "NULL" ));
 	
-	pstrcpy( path, key );
-	normalize_reg_path( path );
-
-	/* normalizing the path does not change length, just key delimiters and case */
-
-	if ( strncmp( path, KEY_WINNT_PRINTERS, strlen(KEY_WINNT_PRINTERS) ) == 0 )
-		keystr = remaining_path( key + strlen(KEY_WINNT_PRINTERS) );
-	else
-		keystr = remaining_path( key + strlen(KEY_CONTROL_PRINTERS) );
+	printers_key = strip_printers_prefix( key );	
 	
-	
-	if ( !keystr ) {
+	if ( !printers_key ) {
 		/* enumerate all printers */
 		
 		for (snum=0; snum<n_services; snum++) {
@@ -238,7 +254,7 @@
 
 	/* get information for a specific printer */
 	
-	reg_split_path( keystr, &base, &new_path );
+	reg_split_path( printers_key, &base, &new_path );
 
 		if ( !W_ERROR_IS_OK( get_a_printer(NULL, &printer, 2, base) ) )
 		goto done;
@@ -263,7 +279,16 @@
 
 static BOOL key_printer_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
 {
-	return True;
+	char *printers_key;
+	
+	printers_key = strip_printers_prefix( key );
+	
+	if ( !printers_key ) {
+		/* have to deal with some new or deleted printer */
+		return False;
+	}
+
+	return False;
 }
 
 /**********************************************************************
@@ -364,37 +389,24 @@
 static int key_printer_fetch_values( const char *key, REGVAL_CTR *values )
 {
 	int 		num_values;
-	char		*keystr;
+	char		*printers_key;
 	char		*printername, *printerdatakey;
 	NT_PRINTER_INFO_LEVEL 	*printer = NULL;
 	NT_PRINTER_DATA	*p_data;
-	pstring 	path;
 	int		i, key_index;
 	
-	/* 
-	 * Theres are tw cases to deal with here
-	 * (1) enumeration of printer_info_2 values
-	 * (2) enumeration of the PrinterDriverData subney
-	 */
-	 
-	pstrcpy( path, key );
-	normalize_reg_path( path );
-
-	/* normalizing the path does not change length, just key delimiters and case */
-
-	if ( strncmp( path, KEY_WINNT_PRINTERS, strlen(KEY_WINNT_PRINTERS) ) == 0 )
-		keystr = remaining_path( key + strlen(KEY_WINNT_PRINTERS) );
-	else
-		keystr = remaining_path( key + strlen(KEY_CONTROL_PRINTERS) );
+	printers_key = strip_printers_prefix( key );	
 	
-	/* top level key has no values */
+	/* top level key values stored in the registry has no values */
 	
-	if ( !keystr )
-		return 0;
+	if ( !printers_key ) {
+		/* normalize to the 'HKLM\SOFTWARE\...\Print\Printers' ket */
+		return regdb_fetch_values( KEY_WINNT_PRINTERS, values );
+	}
 	
 	/* lookup the printer object */
 	
-	reg_split_path( keystr, &printername, &printerdatakey );
+	reg_split_path( printers_key, &printername, &printerdatakey );
 	if ( !W_ERROR_IS_OK( get_a_printer(NULL, &printer, 2, printername) ) )
 		goto done;
 		
@@ -403,12 +415,15 @@
 		goto done;
 	}
 		
-	/* iterate over all printer data and fill the regval container */
+	/* iterate over all printer data keys and fill the regval container */
 	
 	p_data = &printer->info_2->data;
 	if ( (key_index = lookup_printerkey( p_data, printerdatakey )) == -1  ) {
+		/* failure....should never happen if the client has a valid open handle first */
 		DEBUG(10,("key_printer_fetch_values: Unknown keyname [%s]\n", printerdatakey));
-		goto done;
+		if ( printer )
+			free_a_printer( &printer, 2 );
+		return -1;
 	}
 	
 	num_values = regval_ctr_numvals( &p_data->keys[key_index].values );	
@@ -428,7 +443,18 @@
 
 static BOOL key_printer_store_values( const char *key, REGVAL_CTR *values )
 {
-	return True;
+	char *printers_key;
+	
+	printers_key = strip_printers_prefix( key );
+	
+	/* values in the top level key get stored in the registry */
+
+	if ( !printers_key ) {
+		/* normalize on thw 'HKLM\SOFTWARE\....\Print\Printers' ket */
+		return regdb_store_values( KEY_WINNT_PRINTERS, values );
+	}
+	
+	return False;
 }
 
 /*********************************************************************



More information about the samba-cvs mailing list