summaryrefslogtreecommitdiff
path: root/source3/printing/print_svid.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-01-05 16:20:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:46 -0500
commitd097ea490525e7a35739dae6a295fd03ba52cfc0 (patch)
tree131dc7af2e2e944283c70d255d8ad5d6bbef0726 /source3/printing/print_svid.c
parent846b8d4cfdee815cd22d7e00b7f120668f9758a9 (diff)
downloadsamba-d097ea490525e7a35739dae6a295fd03ba52cfc0.tar.gz
samba-d097ea490525e7a35739dae6a295fd03ba52cfc0.tar.bz2
samba-d097ea490525e7a35739dae6a295fd03ba52cfc0.zip
r4539: patch from Rob -- adding real printcap name cache function to speed up printcap reloads
(This used to be commit 1cad5250932b963c2eb9b775221b13db386d601b)
Diffstat (limited to 'source3/printing/print_svid.c')
-rw-r--r--source3/printing/print_svid.c69
1 files changed, 12 insertions, 57 deletions
diff --git a/source3/printing/print_svid.c b/source3/printing/print_svid.c
index d9db500425..3a7c935634 100644
--- a/source3/printing/print_svid.c
+++ b/source3/printing/print_svid.c
@@ -35,23 +35,17 @@
#include "includes.h"
#ifdef SYSV
-
-typedef struct printer {
- char *name;
- struct printer *next;
-} printer_t;
-static printer_t *printers = NULL;
-
-static void populate_printers(void)
+BOOL sysv_cache_reload(void)
{
char **lines;
int i;
- lines = file_lines_pload("/usr/bin/lpstat -v", NULL);
- if (!lines) return;
+ DEBUG(5, ("reloading sysv printcap cache\n"));
- for (i=0;lines[i];i++) {
- printer_t *ptmp;
+ if ((lines = file_lines_pload("/usr/bin/lpstat -v", NULL)) == NULL)
+ return False;
+
+ for (i = 0; lines[i]; i++) {
char *name, *tmp;
char *buf = lines[i];
@@ -64,7 +58,7 @@ static void populate_printers(void)
* In case we're only at the "for ".
*/
- if(!strncmp("for ",++tmp,4)) {
+ if(!strncmp("for ", ++tmp, 4)) {
tmp=strchr_m(tmp, ' ');
tmp++;
}
@@ -78,7 +72,7 @@ static void populate_printers(void)
* On HPUX there is an extra line that can be ignored.
* d.thibadeau 2001/08/09
*/
- if(!strncmp("remote to",tmp,9))
+ if(!strncmp("remote to", tmp, 9))
continue;
name = tmp;
@@ -88,53 +82,14 @@ static void populate_printers(void)
*tmp = '\0';
/* add it to the cache */
- if ((ptmp = SMB_MALLOC_P(printer_t)) != NULL) {
- ZERO_STRUCTP(ptmp);
- if((ptmp->name = SMB_STRDUP(name)) == NULL)
- DEBUG(0,("populate_printers: malloc fail in strdup !\n"));
- ptmp->next = printers;
- printers = ptmp;
- } else {
- DEBUG(0,("populate_printers: malloc fail for ptmp\n"));
+ if (!pcap_cache_add(name, NULL)) {
+ file_lines_free(lines);
+ return False;
}
}
file_lines_free(lines);
-}
-
-
-/*
- * provide the equivalent of pcap_printer_fn() for SVID/XPG4 conforming
- * systems. It was unclear why pcap_printer_fn() was tossing names longer
- * than 8 characters. I suspect that its a protocol limit, but amazingly
- * names longer than 8 characters appear to work with my test
- * clients (Win95/NT).
- */
-void sysv_printer_fn(void (*fn)(char *, char *))
-{
- printer_t *tmp;
-
- if (printers == NULL)
- populate_printers();
- for (tmp = printers; tmp != NULL; tmp = tmp->next)
- (fn)(tmp->name, "");
-}
-
-
-/*
- * provide the equivalent of pcap_printername_ok() for SVID/XPG4 conforming
- * systems.
- */
-int sysv_printername_ok(const char *name)
-{
- printer_t *tmp;
-
- if (printers == NULL)
- populate_printers();
- for (tmp = printers; tmp != NULL; tmp = tmp->next)
- if (strcmp(tmp->name, name) == 0)
- return (True);
- return (False);
+ return True;
}
#else