summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2004-03-02 14:26:45 +0000
committerGerald Carter <jerry@samba.org>2004-03-02 14:26:45 +0000
commitef36785beb02f56c44b62d427ef15e6b6fb22744 (patch)
tree398bad539918ee130c0f76a297128d74b81dafd2 /source3/printing
parent62a7e258a3c67fc653af83bc2e728cff70f8bea1 (diff)
downloadsamba-ef36785beb02f56c44b62d427ef15e6b6fb22744.tar.gz
samba-ef36785beb02f56c44b62d427ef15e6b6fb22744.tar.bz2
samba-ef36785beb02f56c44b62d427ef15e6b6fb22744.zip
allow the 'printing' parameter to be set on a per share basis.
The problem was that the current_printif struct was set during print_backend_init() based on the 'printcap name'. So you could not use cups and then override the setting for a specific printer by setting 'printing = bsd' (a common setup for pdf generation print services. There is a subtle change in behavior in that the print interface functions are selecting on the basis of lp_printing() and not lp_printcap_name(), but the new behavior seems more intuitive IMHO. (This used to be commit 14de9c065787bd1675021a6cd6555f81ea965f17)
Diffstat (limited to 'source3/printing')
-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;