4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
32 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
36 #include "sys/types.h"
43 ** getpwheel() - GET PRINT WHEEL INFO FROM DISK
56 static long lastdir
= -1;
63 if (!name
|| !*name
) {
69 * Getting ``all''? If so, jump into the directory
70 * wherever we left off.
72 if (STREQU(NAME_ALL
, name
)) {
73 if (!(name
= next_dir(Lp_A_PrintWheels
, &lastdir
)))
79 * Get the information for the alert.
81 if (!(pa
= getalert(Lp_A_PrintWheels
, name
))) {
84 * Unless the world has turned weird, we shouldn't
85 * get ENOTDIR if we're doing the ``all'' case--because
86 * getting here in the all case meant the printwheel
87 * directory exists, but ENOTDIR means it doesn't!
90 errno
= ENOENT
; /* printwheel doesn't exist */
95 pwp
= calloc(1, sizeof (*pwp
));
97 pwp
->name
= Strdup(name
);
103 ** putpwheel() - PUT PRINT WHEEL INFO TO DISK
107 #if defined(__STDC__)
113 putpwheel (name
, pwheelp
)
123 if (!name
|| !*name
) {
128 if (STREQU(name
, NAME_ALL
)) {
134 * Create the parent directory for this printer
135 * if it doesn't yet exist.
137 if (!(path
= makepath(Lp_A_PrintWheels
, name
, (char *)0)))
139 if (Stat(path
, &statbuf
) == 0) {
140 if (!S_ISDIR(statbuf
.st_mode
)) {
145 } else if (errno
!= ENOENT
|| mkdir_lpdir(path
, MODE_DIR
) == -1) {
152 * Now write out the alert condition.
154 if (putalert(Lp_A_PrintWheels
, name
, &(pwheelp
->alert
)) == -1)
161 ** delpwheel() - DELETE PRINT WHEEL INFO FROM DISK
164 #if defined(__STDC__)
165 static int _delpwheel ( char * );
167 static int _delpwheel();
171 #if defined(__STDC__)
183 if (!name
|| !*name
) {
188 if (STREQU(NAME_ALL
, name
)) {
190 while ((name
= next_dir(Lp_A_PrintWheels
, &lastdir
)))
191 if (_delpwheel(name
) == -1)
195 return (_delpwheel(name
));
203 #if defined(__STDC__)
214 if (delalert(Lp_A_PrintWheels
, name
) == -1)
216 if (!(path
= makepath(Lp_A_PrintWheels
, name
, (char *)0)))
227 ** freepwheel() - FREE MEMORY ALLOCATED FOR PRINT WHEEL STRUCTURE
231 #if defined(__STDC__)
244 if (ppw
->alert
.shcmd
)
245 Free (ppw
->alert
.shcmd
);