xref: /titanic_44/usr/src/cmd/lp/model/lp.set.c (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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.4	*/
27 
28 #include "stdio.h"
29 
30 #include "lp.h"
31 #include "lp.set.h"
32 
33 extern char		*getenv();
34 
35 /**
36  ** main()
37  **/
38 
39 int			main (argc, argv)
40 	int			argc;
41 	char			*argv[];
42 {
43 	static char		not_set[10]	= "H V W L S";
44 
45 	int			exit_code;
46 
47 	char			*TERM		= getenv("TERM");
48 
49 
50 	if (!TERM || !*TERM || tidbit(TERM, (char *)0) == -1)
51 		exit (1);
52 
53 	/*
54 	 * Very simple calling sequence:
55 	 *
56 	 *	lpset horz-pitch vert-pitch width length char-set
57 	 *
58 	 * The first four can be scaled with 'i' (inches) or
59 	 * 'c' (centimeters). A pitch scaled with 'i' is same
60 	 * as an unscaled pitch.
61 	 * Blank arguments will skip the corresponding setting.
62 	 */
63 	if (argc != 6)
64 		exit (1);
65 
66 	exit_code = 0;
67 
68 	if (argv[1][0]) {
69 		switch (set_pitch(argv[1], 'H', 1)) {
70 		case E_SUCCESS:
71 			not_set[0] = ' ';
72 			break;
73 		case E_FAILURE:
74 			break;
75 		default:
76 			exit_code = 1;
77 			break;
78 		}
79 	} else
80 		not_set[0] = ' ';
81 
82 	if (argv[2][0]) {
83 		switch (set_pitch(argv[2], 'V', 1)) {
84 		case E_SUCCESS:
85 			not_set[2] = ' ';
86 			break;
87 		case E_FAILURE:
88 			break;
89 		default:
90 			exit_code = 1;
91 			break;
92 		}
93 	} else
94 		not_set[2] = ' ';
95 
96 	if (argv[3][0]) {
97 		switch (set_size(argv[3], 'W', 1)) {
98 		case E_SUCCESS:
99 			not_set[4] = ' ';
100 			break;
101 		case E_FAILURE:
102 			break;
103 		default:
104 			exit_code = 1;
105 			break;
106 		}
107 	} else
108 		not_set[4] = ' ';
109 
110 	if (argv[4][0]) {
111 		switch (set_size(argv[4], 'L', 1)) {
112 		case E_SUCCESS:
113 			not_set[6] = ' ';
114 			break;
115 		case E_FAILURE:
116 			break;
117 		default:
118 			exit_code = 1;
119 			break;
120 		}
121 	} else
122 		not_set[6] = ' ';
123 
124 	if (argv[5][0]) {
125 		switch (set_charset(argv[5], 1, TERM)) {
126 		case E_SUCCESS:
127 			not_set[8] = ' ';
128 			break;
129 		case E_FAILURE:
130 			break;
131 		default:
132 			exit_code = 1;
133 			break;
134 		}
135 	} else
136 		not_set[8] = ' ';
137 
138 	fprintf (stderr, "%s\n", not_set);
139 
140 	exit (exit_code);
141 	/*NOTREACHED*/
142 }
143