2000-04-16 06:20:02 +00:00
/*
2002-01-30 06:08:46 +00:00
Unix SMB / CIFS implementation .
2000-04-16 06:20:02 +00:00
load printer lists
Copyright ( C ) Andrew Tridgell 1992 - 2000
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 19:25:36 +00:00
the Free Software Foundation ; either version 3 of the License , or
2000-04-16 06:20:02 +00:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 00:52:41 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2000-04-16 06:20:02 +00:00
*/
# include "includes.h"
2010-05-14 14:39:40 +02:00
# include "printing/pcap.h"
2011-02-22 19:24:31 +01:00
# include "printing/load.h"
2011-06-29 15:33:54 +10:00
# include "lib/param/loadparm.h"
2000-04-16 06:20:02 +00:00
/***************************************************************************
auto - load some homes and printer services
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void add_auto_printers ( void )
{
2019-11-04 15:11:04 +01:00
const struct loadparm_substitution * lp_sub =
loadparm_s3_global_substitution ( ) ;
2002-08-17 16:31:24 +00:00
const char * p ;
2005-01-05 16:20:35 +00:00
int pnum = lp_servicenumber ( PRINTERS_NAME ) ;
char * str ;
2008-01-23 11:04:10 +01:00
char * saveptr ;
2012-05-31 15:06:58 -07:00
char * auto_serv = NULL ;
2000-04-16 06:20:02 +00:00
2010-08-16 14:07:44 -04:00
if ( pnum < 0 )
if ( process_registry_service ( PRINTERS_NAME ) )
pnum = lp_servicenumber ( PRINTERS_NAME ) ;
2005-01-05 16:20:35 +00:00
if ( pnum < 0 )
return ;
2000-04-16 06:20:02 +00:00
2019-11-04 15:11:04 +01:00
auto_serv = lp_auto_services ( talloc_tos ( ) , lp_sub ) ;
2012-05-31 15:06:58 -07:00
str = SMB_STRDUP ( auto_serv ) ;
TALLOC_FREE ( auto_serv ) ;
if ( str = = NULL ) {
2002-08-17 16:31:24 +00:00
return ;
2012-05-31 15:06:58 -07:00
}
2005-01-05 16:20:35 +00:00
2008-01-23 11:04:10 +01:00
for ( p = strtok_r ( str , LIST_SEP , & saveptr ) ; p ;
p = strtok_r ( NULL , LIST_SEP , & saveptr ) ) {
2005-01-05 16:20:35 +00:00
if ( lp_servicenumber ( p ) > = 0 )
continue ;
2000-04-16 06:20:02 +00:00
2005-01-05 16:20:35 +00:00
if ( pcap_printername_ok ( p ) )
lp_add_printer ( p , pnum ) ;
2000-04-16 06:20:02 +00:00
}
2001-01-17 18:47:46 +00:00
2005-01-05 16:20:35 +00:00
SAFE_FREE ( str ) ;
2000-04-16 06:20:02 +00:00
}
/***************************************************************************
2010-12-19 19:52:08 +01:00
load automatic printer services from pre - populated pcap cache
2000-04-16 06:20:02 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2018-05-23 16:35:20 +02:00
void load_printers ( void )
2000-04-16 06:20:02 +00:00
{
2019-01-29 01:50:15 +01:00
if ( ! pcap_cache_loaded ( NULL ) ) {
return ;
}
2005-01-05 16:20:35 +00:00
2000-04-16 06:20:02 +00:00
add_auto_printers ( ) ;
2005-01-05 16:20:35 +00:00
/* load all printcap printers */
if ( lp_load_printers ( ) & & lp_servicenumber ( PRINTERS_NAME ) > = 0 )
2014-07-10 00:18:10 +02:00
pcap_printer_read_fn ( lp_add_one_printer , NULL ) ;
2000-04-16 06:20:02 +00:00
}