xref: /illumos-gate/usr/src/cmd/lp/lib/printers/chkprinter.c (revision 8b80e8cb6855118d46f605e91b5ed4ce83417395)
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.8	*/
27 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
28 
29 #include "sys/types.h"
30 
31 #include "lp.h"
32 #include "lp.set.h"
33 #include "printers.h"
34 
35 extern short		output_res_char,
36 			output_res_line,
37 			output_res_horz_inch,
38 			output_res_vert_inch;
39 
40 /**
41  ** chkprinter() - CHECK VALIDITY OF PITCH/SIZE/CHARSET FOR TERMINFO TYPE
42  **/
43 
44 unsigned long
45 #if	defined(__STDC__)
46 chkprinter (
47 	char *			type,
48 	char *			cpi,
49 	char *			lpi,
50 	char *			len,
51 	char *			wid,
52 	char *			cs
53 )
54 #else
55 chkprinter (type, cpi, lpi, len, wid, cs)
56 	char			*type,
57 				*cpi,
58 				*lpi,
59 				*len,
60 				*wid,
61 				*cs;
62 #endif
63 {
64 	register unsigned long	retflags	= 0;
65 
66 
67 	if (tidbit(type, (char *)0) == -1)
68 		return (retflags | PCK_TYPE);
69 
70 	output_res_char = -1;
71 	output_res_line = -1;
72 	output_res_horz_inch = -1;
73 	output_res_vert_inch = -1;
74 
75 	if (cpi && *cpi && set_pitch(cpi, 'H', 0) != E_SUCCESS)
76 		retflags |= PCK_CPI;
77 
78 	if (lpi && *lpi && set_pitch(lpi, 'V', 0) != E_SUCCESS)
79 		retflags |= PCK_LPI;
80 
81 	if (len && *len && set_size(len, 'L', 0) != E_SUCCESS)
82 		retflags |= PCK_LENGTH;
83 
84 	if (wid && *wid && set_size(wid, 'W', 0) != E_SUCCESS)
85 		retflags |= PCK_WIDTH;
86 
87 	if (cs && *cs && set_charset(cs, 0, type) != E_SUCCESS)
88 		retflags |= PCK_CHARSET;
89 
90 	return (retflags);
91 }
92