8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / lp / lib / printers / okprinter.c
blob006bba00abdf1a19181a9fc786ebff791da2f590
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 1997 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" /* SVr4.0 1.19 */
32 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
34 #include "stdio.h"
35 #include "sys/types.h"
36 #include "stdlib.h"
37 #include <unistd.h>
39 #include "lp.h"
40 #include "printers.h"
42 unsigned long badprinter = 0;
44 static int okinterface ( char * , PRINTER * );
46 /**
47 ** okprinter() - SEE IF PRINTER STRUCTURE IS SOUND
48 **/
50 int
51 okprinter(char *name, PRINTER *prbufp, int isput)
53 badprinter = 0;
56 * A printer can't be remote and have device, interface,
57 * fault recovery, or alerts.
59 if (
60 prbufp->remote
61 && (
62 prbufp->device
63 || prbufp->interface
64 || (
65 prbufp->fault_alert.shcmd
66 && !STREQU(NAME_NONE, prbufp->fault_alert.shcmd)
68 #if defined(CAN_DO_MODULES)
69 # if defined(FIXED)
71 * This needs some work...getprinter() initializes this to "default"
73 || (
74 !emptylist(prbufp->modules)
75 && !STREQU(NAME_NONE, prbufp->modules[0])
77 # endif
78 #endif
81 badprinter |= BAD_REMOTE;
84 * A local printer must have an interface program. This is
85 * for historical purposes (it let's someone know where the
86 * interface program came from) AND is used by "putprinter()"
87 * to copy the interface program. We must be able to read it.
89 if (!prbufp->remote && isput && !okinterface(name, prbufp))
90 badprinter |= BAD_INTERFACE;
93 * A local printer must have device or dial info.
95 if (!prbufp->remote && !prbufp->device && !prbufp->dial_info)
96 badprinter |= BAD_DEVDIAL;
99 * Fault recovery must be one of three kinds
100 * (or default).
102 if (
103 prbufp->fault_rec
104 && !STREQU(prbufp->fault_rec, NAME_CONTINUE)
105 && !STREQU(prbufp->fault_rec, NAME_BEGINNING)
106 && !STREQU(prbufp->fault_rec, NAME_WAIT)
108 badprinter |= BAD_FAULT;
111 * Alert command can't be reserved word.
113 if (
114 prbufp->fault_alert.shcmd
115 && (
116 STREQU(prbufp->fault_alert.shcmd, NAME_QUIET)
117 || STREQU(prbufp->fault_alert.shcmd, NAME_LIST)
120 badprinter |= BAD_ALERT;
122 return ((badprinter & ~ignprinter)? 0 : 1);
126 ** okinterface() - CHECK THAT THE INTERFACE PROGRAM IS OKAY
129 static int
130 canread(char *path)
132 return ((access(path, R_OK) < 0) ? 0 : 1);
135 static int
136 okinterface(char *name, PRINTER *prbufp)
138 int ret;
140 register char *path;
143 if (prbufp->interface)
144 ret = canread(prbufp->interface);
146 else
147 if (!(path = makepath(Lp_A_Interfaces, name, (char *)0)))
148 ret = 0;
149 else {
150 ret = canread(path);
151 Free (path);
154 return (ret);