source: trunk/server/source3/printing/print_aix.c

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 3.2 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 3 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, see <http://www.gnu.org/licenses/>.
17*/
18
19/*
20 * This module implements AIX-specific printcap loading. Most of the code
21 * here was originally provided by Jean-Pierre.Boulard@univ-rennes1.fr in
22 * the Samba 1.9.14 release, and was formerly contained in pcap.c. It has
23 * been moved here and condensed as part of a larger effort to clean up and
24 * simplify the printcap code. -- Rob Foehl, 2004/12/06
25 */
26
27#include "includes.h"
28#include "system/filesys.h"
29#include "printing/pcap.h"
30
31#ifdef AIX
32bool aix_cache_reload(void)
33{
34 int iEtat;
35 XFILE *pfile;
36 char *line = NULL, *p;
37 char *name = NULL;
38 TALLOC_CTX *ctx = talloc_init("aix_cache_reload");
39
40 if (!ctx) {
41 return false;
42 }
43
44 DEBUG(5, ("reloading aix printcap cache\n"));
45
46 if ((pfile = x_fopen(lp_printcapname(), O_RDONLY, 0)) == NULL) {
47 DEBUG(0,( "Unable to open qconfig file %s for read!\n", lp_printcapname()));
48 TALLOC_FREE(ctx);
49 return false;
50 }
51
52 iEtat = 0;
53 /* scan qconfig file for searching <printername>: */
54 for (;(line = fgets_slash(NULL, 1024, pfile)); free(line)) {
55 if (*line == '*' || *line == 0)
56 continue;
57
58 switch (iEtat) {
59 case 0: /* locate an entry */
60 if (*line == '\t' || *line == ' ')
61 continue;
62
63 if ((p = strchr_m(line, ':'))) {
64 char *saveptr;
65 *p = '\0';
66 p = strtok_r(line, ":", &saveptr);
67 if (strcmp(p, "bsh") != 0) {
68 name = talloc_strdup(ctx, p);
69 if (!name) {
70 SAFE_FREE(line);
71 x_fclose(pfile);
72 TALLOC_FREE(ctx);
73 return false;
74 }
75 iEtat = 1;
76 continue;
77 }
78 }
79 break;
80
81 case 1: /* scanning device stanza */
82 if (*line == '*' || *line == 0)
83 continue;
84
85 if (*line != '\t' && *line != ' ') {
86 /* name is found without stanza device */
87 /* probably a good printer ??? */
88 iEtat = 0;
89 if (!pcap_cache_add(name, NULL, NULL)) {
90 SAFE_FREE(line);
91 x_fclose(pfile);
92 TALLOC_FREE(ctx);
93 return false;
94 }
95 continue;
96 }
97
98 if (strstr_m(line, "backend")) {
99 /* it's a device, not a virtual printer */
100 iEtat = 0;
101 } else if (strstr_m(line, "device")) {
102 /* it's a good virtual printer */
103 iEtat = 0;
104 if (!pcap_cache_add(name, NULL, NULL)) {
105 SAFE_FREE(line);
106 x_fclose(pfile);
107 TALLOC_FREE(ctx);
108 return false;
109 }
110 continue;
111 }
112 break;
113 }
114 }
115
116 x_fclose(pfile);
117 TALLOC_FREE(ctx);
118 return true;
119}
120
121#else
122/* this keeps fussy compilers happy */
123 void print_aix_dummy(void);
124 void print_aix_dummy(void) {}
125#endif /* AIX */
Note: See TracBrowser for help on using the repository browser.