diff options
author | Gerald Carter <jerry@samba.org> | 2004-03-02 14:29:01 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2004-03-02 14:29:01 +0000 |
commit | 923a0bed5c6062e620ed3d4ba57c01e6eb86b5b6 (patch) | |
tree | 10077de2a2ca5e4cb6ff21d26b4226d6d87c4d13 /source3/printing/printing.c | |
parent | 4faa480a4a5662b73012680d3f3f2284fdc7af60 (diff) | |
download | samba-923a0bed5c6062e620ed3d4ba57c01e6eb86b5b6.tar.gz samba-923a0bed5c6062e620ed3d4ba57c01e6eb86b5b6.tar.bz2 samba-923a0bed5c6062e620ed3d4ba57c01e6eb86b5b6.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 e721255e8f7d719dbcc2cad94c9b11f6124676e6)
Diffstat (limited to 'source3/printing/printing.c')
-rw-r--r-- | source3/printing/printing.c | 36 |
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; |