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 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
24
25
26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
27
28 #include "stdio.h"
29 #include "errno.h"
30
31 #include "lp.h"
32 #include "class.h"
33 #include "msgs.h"
34
35 #define WHO_AM_I I_AM_LPADMIN
36 #include "oam.h"
37
38 #include "lpadmin.h"
39
40
41 static void _fromclass();
42
43 /**
44 ** fromclass() - REMOVE PRINTER FROM A CLASS
45 **/
46
fromclass(printer,class)47 void fromclass (printer, class)
48 char *printer,
49 *class;
50 {
51 CLASS *pc;
52
53 if (!(pc = getclass(class))) {
54 LP_ERRMSG1 (ERROR, E_LP_NOCLASS, class);
55 done (1);
56 }
57
58 if (!searchlist(printer, pc->members)) {
59 LP_ERRMSG2 (ERROR, E_ADM_NOTMEM, printer, class);
60 done (1);
61 }
62
63 _fromclass (printer, class, pc);
64
65 return;
66 }
67
68 /**
69 ** fromallclasses() - DELETE A PRINTER FROM ALL CLASSES
70 **/
71
fromallclasses(printer)72 void fromallclasses (printer)
73 char *printer;
74 {
75 register CLASS *pc;
76
77
78 while ((pc = getclass(NAME_ALL)))
79 if (searchlist(printer, pc->members))
80 _fromclass (printer, pc->name, pc);
81
82 if (errno != ENOENT) {
83 LP_ERRMSG1 (ERROR, E_ADM_GETCLASSES, PERROR);
84 done (1);
85 }
86
87 return;
88 }
89
90 /**
91 ** _fromclass() - REALLY DELETE PRINTER FROM CLASS
92 **/
93
_fromclass(printer,class,pc)94 static void _fromclass (printer, class, pc)
95 char *printer,
96 *class;
97 CLASS *pc;
98 {
99 int rc;
100
101
102 if (dellist(&pc->members, printer) == -1) {
103 LP_ERRMSG (ERROR, E_LP_MALLOC);
104 done(1);
105 }
106
107 if (!pc->members)
108 rmdest (1, class);
109
110 else {
111 BEGIN_CRITICAL
112 if (putclass(class, pc) == -1) {
113 LP_ERRMSG2 (
114 ERROR,
115 E_LP_PUTCLASS,
116 class,
117 PERROR
118 );
119 done(1);
120 }
121 END_CRITICAL
122
123 send_message(S_LOAD_CLASS, class, "", "");
124 rc = output(R_LOAD_CLASS);
125
126 switch(rc) {
127 case MOK:
128 break;
129
130 case MNODEST:
131 case MERRDEST:
132 LP_ERRMSG (ERROR, E_ADM_ERRDEST);
133 done (1);
134 /*NOTREACHED*/
135
136 case MNOSPACE:
137 LP_ERRMSG (WARNING, E_ADM_NOCSPACE);
138 break;
139
140 case MNOPERM: /* taken care of up front */
141 default:
142 LP_ERRMSG1 (ERROR, E_LP_BADSTATUS, rc);
143 done (1);
144 /*NOTREACHED*/
145 }
146
147 }
148 return;
149 }
150