source: trunk-3.0/source/printing/print_svid.c@ 101

Last change on this file since 101 was 1, checked in by Paul Smedley, 18 years ago

Initial code import

File size: 3.2 KB
Line 
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
5 *
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.
10 *
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.
15 *
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.
19 */
20
21/*
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)".
25 *
26 * The expectations is that execution of the command "lpstat -v" will
27 * generate responses in the form of:
28 *
29 * device for serial: /dev/term/b
30 * system for fax: server
31 * system for color: server (as printer chroma)
32 */
33
34
35#include "includes.h"
36
37#if defined(SYSV) || defined(HPUX)
38BOOL sysv_cache_reload(void)
39{
40 char **lines;
41 int i;
42
43#if defined(HPUX)
44 DEBUG(5, ("reloading hpux printcap cache\n"));
45#else
46 DEBUG(5, ("reloading sysv printcap cache\n"));
47#endif
48
49 if ((lines = file_lines_pload("/usr/bin/lpstat -v", NULL)) == NULL)
50 {
51#if defined(HPUX)
52
53 /*
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.
57 */
58
59 char **scheduler;
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 file_lines_free(scheduler);
64 return True;
65 }
66 else{
67 DEBUG(3,("Scheduler is not running!!!\n"));
68 file_lines_free(scheduler);
69 return False;
70 }
71#else
72 DEBUG(3,("No Printers found!!!\n"));
73 return False;
74#endif
75 }
76
77 for (i = 0; lines[i]; i++) {
78 char *name, *tmp;
79 char *buf = lines[i];
80
81 /* eat "system/device for " */
82 if (((tmp = strchr_m(buf, ' ')) == NULL) ||
83 ((tmp = strchr_m(++tmp, ' ')) == NULL))
84 continue;
85
86 /*
87 * In case we're only at the "for ".
88 */
89
90 if(!strncmp("for ", ++tmp, 4)) {
91 tmp=strchr_m(tmp, ' ');
92 tmp++;
93 }
94
95 /* Eat whitespace. */
96
97 while(*tmp == ' ')
98 ++tmp;
99
100 /*
101 * On HPUX there is an extra line that can be ignored.
102 * d.thibadeau 2001/08/09
103 */
104 if(!strncmp("remote to", tmp, 9))
105 continue;
106
107 name = tmp;
108
109 /* truncate the ": ..." */
110 if ((tmp = strchr_m(name, ':')) != NULL)
111 *tmp = '\0';
112
113 /* add it to the cache */
114 if (!pcap_cache_add(name, NULL)) {
115 file_lines_free(lines);
116 return False;
117 }
118 }
119
120 file_lines_free(lines);
121 return True;
122}
123
124#else
125/* this keeps fussy compilers happy */
126 void print_svid_dummy(void);
127 void print_svid_dummy(void) {}
128#endif
Note: See TracBrowser for help on using the repository browser.