merging for 2.2.6pre1
[Samba.git] / source / printing / load.c
blobae76229d773eb9717a6096fa9513f59d062a3228
1 /*
2 Unix SMB/Netbios implementation.
3 Version 3.0
4 load printer lists
5 Copyright (C) Andrew Tridgell 1992-2000
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
25 /***************************************************************************
26 auto-load printer services
27 ***************************************************************************/
28 void add_all_printers(void)
30 int printers = lp_servicenumber(PRINTERS_NAME);
32 if (printers < 0) return;
34 pcap_printer_fn(lp_add_one_printer);
37 /***************************************************************************
38 auto-load some homes and printer services
39 ***************************************************************************/
40 static void add_auto_printers(void)
42 char *p;
43 int printers;
44 char *str = strdup(lp_auto_services());
46 if (!str) return;
48 printers = lp_servicenumber(PRINTERS_NAME);
50 if (printers < 0) {
51 SAFE_FREE(str);
52 return;
55 for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
56 if (lp_servicenumber(p) >= 0) continue;
58 if (pcap_printername_ok(p,NULL)) {
59 lp_add_printer(p,printers);
63 SAFE_FREE(str);
66 /***************************************************************************
67 load automatic printer services
68 ***************************************************************************/
69 void load_printers(void)
71 add_auto_printers();
72 if (lp_load_printers())
73 add_all_printers();