summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/printing/printing.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index c453eb796c..1efd932749 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -24,7 +24,6 @@
#include "printing.h"
/* Current printer interface */
-static struct printif *current_printif = &generic_printif;
static BOOL remove_from_jobs_changed(int snum, uint32 jobid);
/*
@@ -206,12 +205,6 @@ BOOL print_backend_init(void)
close_all_print_db(); /* Don't leave any open. */
- /* select the appropriate printing interface... */
-#ifdef HAVE_CUPS
- if (strcmp(lp_printcapname(), "cups") == 0)
- current_printif = &cups_printif;
-#endif /* HAVE_CUPS */
-
/* do NT print initialization... */
return nt_printing_init();
}
@@ -226,6 +219,28 @@ void printing_end(void)
}
/****************************************************************************
+ Retrieve the set of printing functions for a given service. This allows
+ us to set the printer function table based on the value of the 'printing'
+ service parameter.
+
+ Use the generic interface as the default and only use cups interface only
+ when asked for (and only when supported)
+****************************************************************************/
+
+static struct printif *get_printer_fns( int snum )
+{
+ struct printif *printer_fns = &generic_printif;
+
+#ifdef HAVE_CUPS
+ if ( lp_printing(snum) == PRINT_CUPS ) {
+ printer_fns = &cups_printif;
+ }
+#endif /* HAVE_CUPS */
+
+ return printer_fns;
+}
+
+/****************************************************************************
Useful function to generate a tdb key.
****************************************************************************/
@@ -951,6 +966,7 @@ static void print_queue_update(int snum)
TDB_DATA data, key;
TDB_DATA jcdata;
struct tdb_print_db *pdb;
+ struct printif *current_printif = get_printer_fns( snum );
fstrcpy(printer_name, lp_const_servicename(snum));
pdb = get_print_db_byname(printer_name);
@@ -1448,6 +1464,7 @@ static BOOL print_job_delete1(int snum, uint32 jobid)
{
struct printjob *pjob = print_job_find(snum, jobid);
int result = 0;
+ struct printif *current_printif = get_printer_fns( snum );
if (!pjob)
return False;
@@ -1589,6 +1606,7 @@ BOOL print_job_pause(struct current_user *user, int snum, uint32 jobid, WERROR *
{
struct printjob *pjob = print_job_find(snum, jobid);
int ret = -1;
+ struct printif *current_printif = get_printer_fns( snum );
if (!pjob || !user)
return False;
@@ -1639,6 +1657,7 @@ BOOL print_job_resume(struct current_user *user, int snum, uint32 jobid, WERROR
{
struct printjob *pjob = print_job_find(snum, jobid);
int ret;
+ struct printif *current_printif = get_printer_fns( snum );
if (!pjob || !user)
return False;
@@ -2040,6 +2059,7 @@ BOOL print_job_end(int snum, uint32 jobid, BOOL normal_close)
struct printjob *pjob = print_job_find(snum, jobid);
int ret;
SMB_STRUCT_STAT sbuf;
+ struct printif *current_printif = get_printer_fns( snum );
if (!pjob)
return False;
@@ -2296,6 +2316,7 @@ int print_queue_status(int snum,
BOOL print_queue_pause(struct current_user *user, int snum, WERROR *errcode)
{
int ret;
+ struct printif *current_printif = get_printer_fns( snum );
if (!print_access_check(user, snum, PRINTER_ACCESS_ADMINISTER)) {
*errcode = WERR_ACCESS_DENIED;
@@ -2326,6 +2347,7 @@ BOOL print_queue_pause(struct current_user *user, int snum, WERROR *errcode)
BOOL print_queue_resume(struct current_user *user, int snum, WERROR *errcode)
{
int ret;
+ struct printif *current_printif = get_printer_fns( snum );
if (!print_access_check(user, snum, PRINTER_ACCESS_ADMINISTER)) {
*errcode = WERR_ACCESS_DENIED;