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"
/***************************************************************************
auto - load some homes and printer services
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void add_auto_printers ( void )
{
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 ;
2000-04-16 06:20:02 +00:00
2005-01-05 16:20:35 +00:00
if ( pnum < 0 )
return ;
2000-04-16 06:20:02 +00:00
2005-01-05 16:20:35 +00:00
if ( ( str = SMB_STRDUP ( lp_auto_services ( ) ) ) = = NULL )
2002-08-17 16:31:24 +00:00
return ;
2005-01-05 16:20:35 +00:00
for ( p = strtok ( str , LIST_SEP ) ; p ; p = strtok ( NULL , LIST_SEP ) ) {
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
}
/***************************************************************************
load automatic printer services
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void load_printers ( void )
{
2005-01-05 16:20:35 +00:00
if ( ! pcap_cache_loaded ( ) )
pcap_cache_reload ( ) ;
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 )
pcap_printer_fn ( lp_add_one_printer ) ;
2000-04-16 06:20:02 +00:00
}