KCC: docstring for kcc.graph.InternalEdge
[Samba.git] / source3 / printing / print_svid.c
blob879661bf5f398ee1bdee46523b75f4d8fae2825c
1 /*
2 * Copyright (C) 1997-1998 by Norm Jacobs, Colorado Springs, Colorado, USA
3 * Copyright (C) 1997-1998 by Sun Microsystem, Inc.
4 * All Rights Reserved
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 * This module implements support for gathering and comparing available
22 * printer information on a SVID or XPG4 compliant system. It does this
23 * through the use of the SVID/XPG4 command "lpstat(1)".
25 * The expectations is that execution of the command "lpstat -v" will
26 * generate responses in the form of:
28 * device for serial: /dev/term/b
29 * system for fax: server
30 * system for color: server (as printer chroma)
34 #include "includes.h"
35 #include "printing/pcap.h"
37 #if defined(SYSV) || defined(HPUX)
38 bool sysv_cache_reload(struct pcap_cache **_pcache)
40 char **lines;
41 int i;
42 struct pcap_cache *pcache = NULL;
44 #if defined(HPUX)
45 DEBUG(5, ("reloading hpux printcap cache\n"));
46 #else
47 DEBUG(5, ("reloading sysv printcap cache\n"));
48 #endif
50 if ((lines = file_lines_pload("/usr/bin/lpstat -v", NULL)) == NULL)
52 #if defined(HPUX)
55 * if "lpstat -v" is NULL then we check if schedular is running if it is
56 * that means no printers are added on the HP-UX system, if schedular is not
57 * running we display reload error.
60 char **scheduler;
61 scheduler = file_lines_pload("/usr/bin/lpstat -r", NULL);
62 if(!strcmp(*scheduler,"scheduler is running")){
63 DEBUG(3,("No Printers found!!!\n"));
64 TALLOC_FREE(scheduler);
65 return True;
67 else{
68 DEBUG(3,("Scheduler is not running!!!\n"));
69 TALLOC_FREE(scheduler);
70 return False;
72 #else
73 DEBUG(3,("No Printers found!!!\n"));
74 return False;
75 #endif
78 for (i = 0; lines[i]; i++) {
79 char *name, *tmp;
80 char *buf = lines[i];
82 /* eat "system/device for " */
83 if (((tmp = strchr_m(buf, ' ')) == NULL) ||
84 ((tmp = strchr_m(++tmp, ' ')) == NULL))
85 continue;
88 * In case we're only at the "for ".
91 if(!strncmp("for ", ++tmp, 4)) {
92 tmp=strchr_m(tmp, ' ');
93 tmp++;
96 /* Eat whitespace. */
98 while(*tmp == ' ')
99 ++tmp;
102 * On HPUX there is an extra line that can be ignored.
103 * d.thibadeau 2001/08/09
105 if(!strncmp("remote to", tmp, 9))
106 continue;
108 name = tmp;
110 /* truncate the ": ..." */
111 if ((tmp = strchr_m(name, ':')) != NULL)
112 *tmp = '\0';
114 /* add it to the cache */
115 if (!pcap_cache_add_specific(&pcache, name, NULL, NULL)) {
116 TALLOC_FREE(lines);
117 pcap_cache_destroy_specific(&pcache);
118 return false;
122 TALLOC_FREE(lines);
123 *_pcache = pcache;
124 return true;
127 #else
128 /* this keeps fussy compilers happy */
129 void print_svid_dummy(void);
130 void print_svid_dummy(void) {}
131 #endif