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