xref: /titanic_53/usr/src/cmd/lp/model/lp.set.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.4	*/
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate #include "stdio.h"
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #include "lp.h"
31*7c478bd9Sstevel@tonic-gate #include "lp.set.h"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate extern char		*getenv();
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate /**
36*7c478bd9Sstevel@tonic-gate  ** main()
37*7c478bd9Sstevel@tonic-gate  **/
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate int			main (argc, argv)
40*7c478bd9Sstevel@tonic-gate 	int			argc;
41*7c478bd9Sstevel@tonic-gate 	char			*argv[];
42*7c478bd9Sstevel@tonic-gate {
43*7c478bd9Sstevel@tonic-gate 	static char		not_set[10]	= "H V W L S";
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate 	int			exit_code;
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate 	char			*TERM		= getenv("TERM");
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate 	if (!TERM || !*TERM || tidbit(TERM, (char *)0) == -1)
51*7c478bd9Sstevel@tonic-gate 		exit (1);
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate 	/*
54*7c478bd9Sstevel@tonic-gate 	 * Very simple calling sequence:
55*7c478bd9Sstevel@tonic-gate 	 *
56*7c478bd9Sstevel@tonic-gate 	 *	lpset horz-pitch vert-pitch width length char-set
57*7c478bd9Sstevel@tonic-gate 	 *
58*7c478bd9Sstevel@tonic-gate 	 * The first four can be scaled with 'i' (inches) or
59*7c478bd9Sstevel@tonic-gate 	 * 'c' (centimeters). A pitch scaled with 'i' is same
60*7c478bd9Sstevel@tonic-gate 	 * as an unscaled pitch.
61*7c478bd9Sstevel@tonic-gate 	 * Blank arguments will skip the corresponding setting.
62*7c478bd9Sstevel@tonic-gate 	 */
63*7c478bd9Sstevel@tonic-gate 	if (argc != 6)
64*7c478bd9Sstevel@tonic-gate 		exit (1);
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate 	exit_code = 0;
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate 	if (argv[1][0]) {
69*7c478bd9Sstevel@tonic-gate 		switch (set_pitch(argv[1], 'H', 1)) {
70*7c478bd9Sstevel@tonic-gate 		case E_SUCCESS:
71*7c478bd9Sstevel@tonic-gate 			not_set[0] = ' ';
72*7c478bd9Sstevel@tonic-gate 			break;
73*7c478bd9Sstevel@tonic-gate 		case E_FAILURE:
74*7c478bd9Sstevel@tonic-gate 			break;
75*7c478bd9Sstevel@tonic-gate 		default:
76*7c478bd9Sstevel@tonic-gate 			exit_code = 1;
77*7c478bd9Sstevel@tonic-gate 			break;
78*7c478bd9Sstevel@tonic-gate 		}
79*7c478bd9Sstevel@tonic-gate 	} else
80*7c478bd9Sstevel@tonic-gate 		not_set[0] = ' ';
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate 	if (argv[2][0]) {
83*7c478bd9Sstevel@tonic-gate 		switch (set_pitch(argv[2], 'V', 1)) {
84*7c478bd9Sstevel@tonic-gate 		case E_SUCCESS:
85*7c478bd9Sstevel@tonic-gate 			not_set[2] = ' ';
86*7c478bd9Sstevel@tonic-gate 			break;
87*7c478bd9Sstevel@tonic-gate 		case E_FAILURE:
88*7c478bd9Sstevel@tonic-gate 			break;
89*7c478bd9Sstevel@tonic-gate 		default:
90*7c478bd9Sstevel@tonic-gate 			exit_code = 1;
91*7c478bd9Sstevel@tonic-gate 			break;
92*7c478bd9Sstevel@tonic-gate 		}
93*7c478bd9Sstevel@tonic-gate 	} else
94*7c478bd9Sstevel@tonic-gate 		not_set[2] = ' ';
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate 	if (argv[3][0]) {
97*7c478bd9Sstevel@tonic-gate 		switch (set_size(argv[3], 'W', 1)) {
98*7c478bd9Sstevel@tonic-gate 		case E_SUCCESS:
99*7c478bd9Sstevel@tonic-gate 			not_set[4] = ' ';
100*7c478bd9Sstevel@tonic-gate 			break;
101*7c478bd9Sstevel@tonic-gate 		case E_FAILURE:
102*7c478bd9Sstevel@tonic-gate 			break;
103*7c478bd9Sstevel@tonic-gate 		default:
104*7c478bd9Sstevel@tonic-gate 			exit_code = 1;
105*7c478bd9Sstevel@tonic-gate 			break;
106*7c478bd9Sstevel@tonic-gate 		}
107*7c478bd9Sstevel@tonic-gate 	} else
108*7c478bd9Sstevel@tonic-gate 		not_set[4] = ' ';
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate 	if (argv[4][0]) {
111*7c478bd9Sstevel@tonic-gate 		switch (set_size(argv[4], 'L', 1)) {
112*7c478bd9Sstevel@tonic-gate 		case E_SUCCESS:
113*7c478bd9Sstevel@tonic-gate 			not_set[6] = ' ';
114*7c478bd9Sstevel@tonic-gate 			break;
115*7c478bd9Sstevel@tonic-gate 		case E_FAILURE:
116*7c478bd9Sstevel@tonic-gate 			break;
117*7c478bd9Sstevel@tonic-gate 		default:
118*7c478bd9Sstevel@tonic-gate 			exit_code = 1;
119*7c478bd9Sstevel@tonic-gate 			break;
120*7c478bd9Sstevel@tonic-gate 		}
121*7c478bd9Sstevel@tonic-gate 	} else
122*7c478bd9Sstevel@tonic-gate 		not_set[6] = ' ';
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate 	if (argv[5][0]) {
125*7c478bd9Sstevel@tonic-gate 		switch (set_charset(argv[5], 1, TERM)) {
126*7c478bd9Sstevel@tonic-gate 		case E_SUCCESS:
127*7c478bd9Sstevel@tonic-gate 			not_set[8] = ' ';
128*7c478bd9Sstevel@tonic-gate 			break;
129*7c478bd9Sstevel@tonic-gate 		case E_FAILURE:
130*7c478bd9Sstevel@tonic-gate 			break;
131*7c478bd9Sstevel@tonic-gate 		default:
132*7c478bd9Sstevel@tonic-gate 			exit_code = 1;
133*7c478bd9Sstevel@tonic-gate 			break;
134*7c478bd9Sstevel@tonic-gate 		}
135*7c478bd9Sstevel@tonic-gate 	} else
136*7c478bd9Sstevel@tonic-gate 		not_set[8] = ' ';
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate 	fprintf (stderr, "%s\n", not_set);
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate 	exit (exit_code);
141*7c478bd9Sstevel@tonic-gate 	/*NOTREACHED*/
142*7c478bd9Sstevel@tonic-gate }
143