1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 1991 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29
30 #include <stdio.h>
31 #include <string.h>
32 #include <errno.h>
33 #include <sys/types.h>
34 #include <stdlib.h>
35 #include <libintl.h>
36
37 #include "lp.h"
38 #include "printers.h"
39 #include "msgs.h"
40
41 #define WHO_AM_I I_AM_LPADMIN
42 #include "oam.h"
43
44 #include "lpadmin.h"
45
46
47 extern char *nameit(),
48 *label;
49
50 static void configure_pwheel();
51
52 /**
53 ** do_pwheel() - SET ALERT FOR NEED TO MOUNT PRINT WHEEL
54 **/
55
do_pwheel()56 void do_pwheel ()
57 {
58 int rc;
59
60
61 if (A && STREQU(A, NAME_NONE)) {
62 BEGIN_CRITICAL
63 if (delpwheel(*S) == -1) {
64 LP_ERRMSG1 (WARNING, E_ADM_BADPWHEEL, *S);
65 return;
66 }
67 END_CRITICAL
68
69 } else if (strlen(modifications))
70 configure_pwheel (modifications);
71
72 if (A && STREQU(A, NAME_LIST)) {
73 if (label)
74 (void) printf(gettext("Print wheel %s: "), label);
75 printalert (stdout, &(oldS->alert), 0);
76 return;
77 }
78
79 if (A && STREQU(A, NAME_QUIET)) {
80
81 send_message(S_QUIET_ALERT, *S, (char *)QA_PRINTWHEEL, "");
82 rc = output(R_QUIET_ALERT);
83
84 switch(rc) {
85 case MOK:
86 break;
87
88 case MNODEST: /* not quite, but not a lie either */
89 case MERRDEST:
90 LP_ERRMSG1 (WARNING, E_LP_NOQUIET, *S);
91 break;
92
93 case MNOPERM: /* taken care of up front */
94 default:
95 LP_ERRMSG1 (ERROR, E_LP_BADSTATUS, rc);
96 done (1);
97 /*NOTREACHED*/
98 }
99
100 return;
101 }
102
103 if (A && STREQU(A, NAME_NONE)) {
104 send_message(S_UNLOAD_PRINTWHEEL, *S);
105 rc = output(R_UNLOAD_PRINTWHEEL);
106 } else {
107 send_message(S_LOAD_PRINTWHEEL, *S);
108 rc = output(R_LOAD_PRINTWHEEL);
109 }
110
111 switch(rc) {
112 case MOK:
113 break;
114
115 case MNODEST:
116 /*
117 * Should only occur if we're deleting a print wheel
118 * alert that doesn't exist.
119 */
120 break;
121
122 case MERRDEST:
123 LP_ERRMSG (ERROR, E_ADM_ERRDEST);
124 done (1);
125 /*NOTREACHED*/
126
127 case MNOSPACE:
128 LP_ERRMSG (WARNING, E_ADM_NOPWSPACE);
129 break;
130
131 case MNOPERM: /* taken care of up front */
132 default:
133 LP_ERRMSG1 (ERROR, E_LP_BADSTATUS, rc);
134 done (1);
135 /*NOTREACHED*/
136 }
137 return;
138 }
139
140 /**
141 ** configure_pwheel() - SET OR CHANGE CONFIGURATION OF A PRINT WHEEL
142 **/
143
configure_pwheel(list)144 static void configure_pwheel (list)
145 char *list;
146 {
147 register PWHEEL *ppw;
148
149 PWHEEL pwheel_buf;
150
151 char type;
152
153
154 if (oldS)
155 ppw = oldS;
156 else {
157 ppw = &pwheel_buf;
158 ppw->alert.shcmd = 0;
159 ppw->alert.Q = 0;
160 ppw->alert.W = 0;
161 }
162
163 while ((type = *list++) != '\0') switch(type) {
164
165 case 'A':
166 if (STREQU(A, NAME_MAIL) || STREQU(A, NAME_WRITE))
167 ppw->alert.shcmd = nameit(A);
168 else
169 ppw->alert.shcmd = A;
170
171 break;
172
173 case 'Q':
174 ppw->alert.Q = Q;
175 break;
176
177 case 'W':
178 ppw->alert.W = W;
179 break;
180
181 }
182
183 BEGIN_CRITICAL
184 if (putpwheel(*S, ppw) == -1) {
185 LP_ERRMSG2 (
186 ERROR,
187 E_ADM_PUTPWHEEL,
188 *S,
189 PERROR
190 );
191 done(1);
192 }
193 END_CRITICAL
194
195 return;
196 }
197