summaryrefslogtreecommitdiff
path: root/source3/printing/nt_printing.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-04-26 14:46:33 -0400
committerSimo Sorce <idra@samba.org>2010-07-27 10:27:10 -0400
commitd17d73f4be6938b942f1eed875c6dd629d8bec88 (patch)
treed65661a8b89de86281fa7c774c670652667b9e59 /source3/printing/nt_printing.c
parent017a305fede73b3f61517f38dec2bf706e2648df (diff)
downloadsamba-d17d73f4be6938b942f1eed875c6dd629d8bec88.tar.gz
samba-d17d73f4be6938b942f1eed875c6dd629d8bec88.tar.bz2
samba-d17d73f4be6938b942f1eed875c6dd629d8bec88.zip
s3-printing: Convert print_driver_in_use.
Use spoolss_PrintInfo2 and winreg calls. Signed-off-by: Jim McDonough <jmcd@samba.org>
Diffstat (limited to 'source3/printing/nt_printing.c')
-rw-r--r--source3/printing/nt_printing.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index a36e40be77..0369ce8ed1 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -4197,8 +4197,9 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
{
int snum;
int n_services = lp_numservices();
- NT_PRINTER_INFO_LEVEL *printer = NULL;
bool in_use = False;
+ struct spoolss_PrinterInfo2 *pinfo2 = NULL;
+ WERROR result;
if (!r) {
return false;
@@ -4209,16 +4210,21 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
/* loop through the printers.tdb and check for the drivername */
for (snum=0; snum<n_services && !in_use; snum++) {
- if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) )
+ if (!lp_snum_ok(snum) || !lp_print_ok(snum)) {
continue;
+ }
- if ( !W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_servicename(snum))) )
- continue;
+ result = winreg_get_printer(mem_ctx, server_info, NULL,
+ lp_servicename(snum), &pinfo2);
+ if (!W_ERROR_IS_OK(result)) {
+ continue; /* skip */
+ }
- if (strequal(r->driver_name, printer->info_2->drivername))
+ if (strequal(r->driver_name, pinfo2->drivername)) {
in_use = True;
+ }
- free_a_printer( &printer, 2 );
+ TALLOC_FREE(pinfo2);
}
DEBUG(10,("printer_driver_in_use: Completed search through ntprinters.tdb...\n"));