2 * Copyright (C) 1997-1998 by Norm Jacobs, Colorado Springs, Colorado, USA
3 * Copyright (C) 1997-1998 by Sun Microsystem, Inc.
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)
35 #include "printing/pcap.h"
37 #if defined(SYSV) || defined(HPUX)
38 bool sysv_cache_reload(void)
44 DEBUG(5, ("reloading hpux printcap cache\n"));
46 DEBUG(5, ("reloading sysv printcap cache\n"));
49 if ((lines
= file_lines_pload("/usr/bin/lpstat -v", NULL
)) == NULL
)
54 * if "lpstat -v" is NULL then we check if schedular is running if it is
55 * that means no printers are added on the HP-UX system, if schedular is not
56 * running we display reload error.
60 scheduler
= file_lines_pload("/usr/bin/lpstat -r", NULL
);
61 if(!strcmp(*scheduler
,"scheduler is running")){
62 DEBUG(3,("No Printers found!!!\n"));
63 TALLOC_FREE(scheduler
);
67 DEBUG(3,("Scheduler is not running!!!\n"));
68 TALLOC_FREE(scheduler
);
72 DEBUG(3,("No Printers found!!!\n"));
77 for (i
= 0; lines
[i
]; i
++) {
81 /* eat "system/device for " */
82 if (((tmp
= strchr_m(buf
, ' ')) == NULL
) ||
83 ((tmp
= strchr_m(++tmp
, ' ')) == NULL
))
87 * In case we're only at the "for ".
90 if(!strncmp("for ", ++tmp
, 4)) {
91 tmp
=strchr_m(tmp
, ' ');
101 * On HPUX there is an extra line that can be ignored.
102 * d.thibadeau 2001/08/09
104 if(!strncmp("remote to", tmp
, 9))
109 /* truncate the ": ..." */
110 if ((tmp
= strchr_m(name
, ':')) != NULL
)
113 /* add it to the cache */
114 if (!pcap_cache_add(name
, NULL
)) {
125 /* this keeps fussy compilers happy */
126 void print_svid_dummy(void);
127 void print_svid_dummy(void) {}