source: branches/samba-3.0/source/printing/print_aix.c

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

Initial code import

File size: 2.8 KB
Line 
1/*
2 AIX-specific printcap loading
3 Copyright (C) Jean-Pierre.Boulard@univ-rennes1.fr 1996
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/
19
20/*
21 * This module implements AIX-specific printcap loading. Most of the code
22 * here was originally provided by Jean-Pierre.Boulard@univ-rennes1.fr in
23 * the Samba 1.9.14 release, and was formerly contained in pcap.c. It has
24 * been moved here and condensed as part of a larger effort to clean up and
25 * simplify the printcap code. -- Rob Foehl, 2004/12/06
26 */
27
28#include "includes.h"
29
30#ifdef AIX
31BOOL aix_cache_reload(void)
32{
33 int iEtat;
34 XFILE *pfile;
35 char *line = NULL, *p;
36 pstring name, comment;
37
38 *name = 0;
39 *comment = 0;
40
41 DEBUG(5, ("reloading aix printcap cache\n"));
42
43 if ((pfile = x_fopen(lp_printcapname(), O_RDONLY, 0)) == NULL) {
44 DEBUG(0,( "Unable to open qconfig file %s for read!\n", lp_printcapname()));
45 return False;
46 }
47
48 iEtat = 0;
49 /* scan qconfig file for searching <printername>: */
50 for (;(line = fgets_slash(NULL, sizeof(pstring), pfile)); safe_free(line)) {
51 if (*line == '*' || *line == 0)
52 continue;
53
54 switch (iEtat) {
55 case 0: /* locate an entry */
56 if (*line == '\t' || *line == ' ')
57 continue;
58
59 if ((p = strchr_m(line, ':'))) {
60 *p = '\0';
61 p = strtok(line, ":");
62 if (strcmp(p, "bsh") != 0) {
63 pstrcpy(name, p);
64 iEtat = 1;
65 continue;
66 }
67 }
68 break;
69
70 case 1: /* scanning device stanza */
71 if (*line == '*' || *line == 0)
72 continue;
73
74 if (*line != '\t' && *line != ' ') {
75 /* name is found without stanza device */
76 /* probably a good printer ??? */
77 iEtat = 0;
78 if (!pcap_cache_add(name, NULL)) {
79 safe_free(line);
80 x_fclose(pfile);
81 return False;
82 }
83 continue;
84 }
85
86 if (strstr_m(line, "backend")) {
87 /* it's a device, not a virtual printer */
88 iEtat = 0;
89 } else if (strstr_m(line, "device")) {
90 /* it's a good virtual printer */
91 iEtat = 0;
92 if (!pcap_cache_add(name, NULL)) {
93 safe_free(line);
94 x_fclose(pfile);
95 return False;
96 }
97 continue;
98 }
99 break;
100 }
101 }
102
103 x_fclose(pfile);
104 return True;
105}
106
107#else
108/* this keeps fussy compilers happy */
109 void print_aix_dummy(void);
110 void print_aix_dummy(void) {}
111#endif /* AIX */
Note: See TracBrowser for help on using the repository browser.