From d097ea490525e7a35739dae6a295fd03ba52cfc0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 5 Jan 2005 16:20:35 +0000 Subject: r4539: patch from Rob -- adding real printcap name cache function to speed up printcap reloads (This used to be commit 1cad5250932b963c2eb9b775221b13db386d601b) --- source3/printing/load.c | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'source3/printing/load.c') diff --git a/source3/printing/load.c b/source3/printing/load.c index 59306aa104..a925a63e17 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -21,45 +21,30 @@ #include "includes.h" -/*************************************************************************** -auto-load printer services -***************************************************************************/ -void add_all_printers(void) -{ - int printers = lp_servicenumber(PRINTERS_NAME); - - if (printers < 0) return; - - pcap_printer_fn(lp_add_one_printer); -} - /*************************************************************************** auto-load some homes and printer services ***************************************************************************/ static void add_auto_printers(void) { const char *p; - int printers; - char *str = SMB_STRDUP(lp_auto_services()); + int pnum = lp_servicenumber(PRINTERS_NAME); + char *str; - if (!str) return; - - printers = lp_servicenumber(PRINTERS_NAME); + if (pnum < 0) + return; - if (printers < 0) { - SAFE_FREE(str); + if ((str = SMB_STRDUP(lp_auto_services())) == NULL) return; - } - - for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) { - if (lp_servicenumber(p) >= 0) continue; + + for (p = strtok(str, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) { + if (lp_servicenumber(p) >= 0) + continue; - if (pcap_printername_ok(p,NULL)) { - lp_add_printer(p,printers); - } + if (pcap_printername_ok(p)) + lp_add_printer(p, pnum); } - SAFE_FREE(str); + SAFE_FREE(str); } /*************************************************************************** @@ -67,7 +52,12 @@ load automatic printer services ***************************************************************************/ void load_printers(void) { + if (!pcap_cache_loaded()) + pcap_cache_reload(); + add_auto_printers(); - if (lp_load_printers()) - add_all_printers(); + + /* load all printcap printers */ + if (lp_load_printers() && lp_servicenumber(PRINTERS_NAME) >= 0) + pcap_printer_fn(lp_add_one_printer); } -- cgit