2000-04-16 10:20:02 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2000-04-16 10:20:02 +04: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 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2000-04-16 10:20:02 +04: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 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2000-04-16 10:20:02 +04:00
*/
# include "includes.h"
2010-05-14 16:39:40 +04:00
# include "printing/pcap.h"
2011-02-22 21:24:31 +03:00
# include "printing/load.h"
2011-06-29 09:33:54 +04:00
# include "lib/param/loadparm.h"
2000-04-16 10:20:02 +04:00
/***************************************************************************
auto - load some homes and printer services
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void add_auto_printers ( void )
{
2002-08-17 20:31:24 +04:00
const char * p ;
2005-01-05 19:20:35 +03:00
int pnum = lp_servicenumber ( PRINTERS_NAME ) ;
char * str ;
2008-01-23 13:04:10 +03:00
char * saveptr ;
2012-06-01 02:06:58 +04:00
char * auto_serv = NULL ;
2000-04-16 10:20:02 +04:00
2010-08-16 22:07:44 +04:00
if ( pnum < 0 )
if ( process_registry_service ( PRINTERS_NAME ) )
pnum = lp_servicenumber ( PRINTERS_NAME ) ;
2005-01-05 19:20:35 +03:00
if ( pnum < 0 )
return ;
2000-04-16 10:20:02 +04:00
2012-07-18 09:37:23 +04:00
auto_serv = lp_auto_services ( talloc_tos ( ) ) ;
2012-06-01 02:06:58 +04:00
str = SMB_STRDUP ( auto_serv ) ;
TALLOC_FREE ( auto_serv ) ;
if ( str = = NULL ) {
2002-08-17 20:31:24 +04:00
return ;
2012-06-01 02:06:58 +04:00
}
2005-01-05 19:20:35 +03:00
2008-01-23 13:04:10 +03:00
for ( p = strtok_r ( str , LIST_SEP , & saveptr ) ; p ;
p = strtok_r ( NULL , LIST_SEP , & saveptr ) ) {
2005-01-05 19:20:35 +03:00
if ( lp_servicenumber ( p ) > = 0 )
continue ;
2000-04-16 10:20:02 +04:00
2005-01-05 19:20:35 +03:00
if ( pcap_printername_ok ( p ) )
lp_add_printer ( p , pnum ) ;
2000-04-16 10:20:02 +04:00
}
2001-01-17 21:47:46 +03:00
2005-01-05 19:20:35 +03:00
SAFE_FREE ( str ) ;
2000-04-16 10:20:02 +04:00
}
/***************************************************************************
2010-12-19 21:52:08 +03:00
load automatic printer services from pre - populated pcap cache
2000-04-16 10:20:02 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-08-09 00:54:43 +04:00
void load_printers ( struct tevent_context * ev ,
struct messaging_context * msg_ctx )
2000-04-16 10:20:02 +04:00
{
2010-12-19 21:52:08 +03:00
SMB_ASSERT ( pcap_cache_loaded ( ) ) ;
2005-01-05 19:20:35 +03:00
2000-04-16 10:20:02 +04:00
add_auto_printers ( ) ;
2005-01-05 19:20:35 +03:00
/* load all printcap printers */
if ( lp_load_printers ( ) & & lp_servicenumber ( PRINTERS_NAME ) > = 0 )
2014-07-10 02:18:10 +04:00
pcap_printer_read_fn ( lp_add_one_printer , NULL ) ;
2000-04-16 10:20:02 +04:00
}