From e574081ad93ec5f5eb121436a889f64294fa290d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 11 Jul 2005 18:27:22 +0000 Subject: r8324: * initial cut at creating printers via the registry API Need to add delete_key support (This used to be commit 9a27f7181adca10f60c47d342a51dec34321e12b) --- source3/registry/reg_printing.c | 45 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'source3/registry') diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c index c689882d53..b1fdcea09c 100644 --- a/source3/registry/reg_printing.c +++ b/source3/registry/reg_printing.c @@ -225,6 +225,7 @@ static int key_printers_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys ) char *printername, *printerdatakey; NT_PRINTER_INFO_LEVEL *printer = NULL; fstring *subkey_names = NULL; + fstring sharename; DEBUG(10,("key_printers_fetch_keys: key=>[%s]\n", key ? key : "NULL" )); @@ -255,8 +256,13 @@ static int key_printers_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys ) reg_split_path( printers_key, &printername, &printerdatakey ); - if ( !W_ERROR_IS_OK( get_a_printer(NULL, &printer, 2, printername) ) ) - goto done; + alpha_strcpy( sharename, printername, "", sizeof(sharename)-1); + + if ( find_service(sharename) == -1 + || !W_ERROR_IS_OK( get_a_printer(NULL, &printer, 2, sharename) ) ) + { + return -1; + } num_subkeys = get_printer_subkeys( &printer->info_2->data, printerdatakey?printerdatakey:"", &subkey_names ); @@ -274,12 +280,41 @@ done: } /********************************************************************** - Take a printer name and call add_printer_hook() if necessary + Take a list of names and call add_printer_hook() if necessary + Note that we do this a little differently from Windows since the + keyname is the sharename and not the printer name. *********************************************************************/ static BOOL add_printers_by_registry( REGSUBKEY_CTR *subkeys ) { - return False; + int i, num_keys, snum; + char *printername; + NT_PRINTER_INFO_LEVEL_2 info2; + NT_PRINTER_INFO_LEVEL printer; + + ZERO_STRUCT( info2 ); + printer.info_2 = &info2; + + num_keys = regsubkey_ctr_numkeys( subkeys ); + + become_root(); + for ( i=0; i