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 2 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, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * This module implements support for gathering and comparing available
23 * printer information on a SVID or XPG4 compliant system. It does this
24 * through the use of the SVID/XPG4 command "lpstat(1)".
26 * The expectations is that execution of the command "lpstat -v" will
27 * generate responses in the form of:
29 * device for serial: /dev/term/b
30 * system for fax: server
31 * system for color: server (as printer chroma)
38 BOOL
sysv_cache_reload(void)
43 DEBUG(5, ("reloading sysv printcap cache\n"));
45 if ((lines
= file_lines_pload("/usr/bin/lpstat -v", NULL
)) == NULL
)
48 for (i
= 0; lines
[i
]; i
++) {
52 /* eat "system/device for " */
53 if (((tmp
= strchr_m(buf
, ' ')) == NULL
) ||
54 ((tmp
= strchr_m(++tmp
, ' ')) == NULL
))
58 * In case we're only at the "for ".
61 if(!strncmp("for ", ++tmp
, 4)) {
62 tmp
=strchr_m(tmp
, ' ');
72 * On HPUX there is an extra line that can be ignored.
73 * d.thibadeau 2001/08/09
75 if(!strncmp("remote to", tmp
, 9))
80 /* truncate the ": ..." */
81 if ((tmp
= strchr_m(name
, ':')) != NULL
)
84 /* add it to the cache */
85 if (!pcap_cache_add(name
, NULL
)) {
86 file_lines_free(lines
);
91 file_lines_free(lines
);
96 /* this keeps fussy compilers happy */
97 void print_svid_dummy(void);
98 void print_svid_dummy(void) {}