xref: /onnv-gate/usr/src/cmd/lp/model/lp.set.c (revision 320:7e1ecf3ab9be)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
22*320Sceastha /*
23*320Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*320Sceastha  * Use is subject to license terms.
25*320Sceastha  */
26*320Sceastha 
270Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
280Sstevel@tonic-gate /*	  All Rights Reserved  	*/
290Sstevel@tonic-gate 
30*320Sceastha #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include "stdio.h"
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #include "lp.h"
350Sstevel@tonic-gate #include "lp.set.h"
360Sstevel@tonic-gate 
370Sstevel@tonic-gate extern char		*getenv();
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /**
400Sstevel@tonic-gate  ** main()
410Sstevel@tonic-gate  **/
420Sstevel@tonic-gate 
43*320Sceastha int
main(int argc,char * argv[])44*320Sceastha main(int argc, char *argv[])
450Sstevel@tonic-gate {
460Sstevel@tonic-gate 	static char		not_set[10]	= "H V W L S";
470Sstevel@tonic-gate 
480Sstevel@tonic-gate 	int			exit_code;
490Sstevel@tonic-gate 
500Sstevel@tonic-gate 	char			*TERM		= getenv("TERM");
510Sstevel@tonic-gate 
520Sstevel@tonic-gate 
530Sstevel@tonic-gate 	if (!TERM || !*TERM || tidbit(TERM, (char *)0) == -1)
540Sstevel@tonic-gate 		exit (1);
550Sstevel@tonic-gate 
560Sstevel@tonic-gate 	/*
570Sstevel@tonic-gate 	 * Very simple calling sequence:
580Sstevel@tonic-gate 	 *
590Sstevel@tonic-gate 	 *	lpset horz-pitch vert-pitch width length char-set
600Sstevel@tonic-gate 	 *
610Sstevel@tonic-gate 	 * The first four can be scaled with 'i' (inches) or
620Sstevel@tonic-gate 	 * 'c' (centimeters). A pitch scaled with 'i' is same
630Sstevel@tonic-gate 	 * as an unscaled pitch.
640Sstevel@tonic-gate 	 * Blank arguments will skip the corresponding setting.
650Sstevel@tonic-gate 	 */
660Sstevel@tonic-gate 	if (argc != 6)
670Sstevel@tonic-gate 		exit (1);
680Sstevel@tonic-gate 
690Sstevel@tonic-gate 	exit_code = 0;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 	if (argv[1][0]) {
720Sstevel@tonic-gate 		switch (set_pitch(argv[1], 'H', 1)) {
730Sstevel@tonic-gate 		case E_SUCCESS:
740Sstevel@tonic-gate 			not_set[0] = ' ';
750Sstevel@tonic-gate 			break;
760Sstevel@tonic-gate 		case E_FAILURE:
770Sstevel@tonic-gate 			break;
780Sstevel@tonic-gate 		default:
790Sstevel@tonic-gate 			exit_code = 1;
800Sstevel@tonic-gate 			break;
810Sstevel@tonic-gate 		}
820Sstevel@tonic-gate 	} else
830Sstevel@tonic-gate 		not_set[0] = ' ';
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 	if (argv[2][0]) {
860Sstevel@tonic-gate 		switch (set_pitch(argv[2], 'V', 1)) {
870Sstevel@tonic-gate 		case E_SUCCESS:
880Sstevel@tonic-gate 			not_set[2] = ' ';
890Sstevel@tonic-gate 			break;
900Sstevel@tonic-gate 		case E_FAILURE:
910Sstevel@tonic-gate 			break;
920Sstevel@tonic-gate 		default:
930Sstevel@tonic-gate 			exit_code = 1;
940Sstevel@tonic-gate 			break;
950Sstevel@tonic-gate 		}
960Sstevel@tonic-gate 	} else
970Sstevel@tonic-gate 		not_set[2] = ' ';
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	if (argv[3][0]) {
1000Sstevel@tonic-gate 		switch (set_size(argv[3], 'W', 1)) {
1010Sstevel@tonic-gate 		case E_SUCCESS:
1020Sstevel@tonic-gate 			not_set[4] = ' ';
1030Sstevel@tonic-gate 			break;
1040Sstevel@tonic-gate 		case E_FAILURE:
1050Sstevel@tonic-gate 			break;
1060Sstevel@tonic-gate 		default:
1070Sstevel@tonic-gate 			exit_code = 1;
1080Sstevel@tonic-gate 			break;
1090Sstevel@tonic-gate 		}
1100Sstevel@tonic-gate 	} else
1110Sstevel@tonic-gate 		not_set[4] = ' ';
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate 	if (argv[4][0]) {
1140Sstevel@tonic-gate 		switch (set_size(argv[4], 'L', 1)) {
1150Sstevel@tonic-gate 		case E_SUCCESS:
1160Sstevel@tonic-gate 			not_set[6] = ' ';
1170Sstevel@tonic-gate 			break;
1180Sstevel@tonic-gate 		case E_FAILURE:
1190Sstevel@tonic-gate 			break;
1200Sstevel@tonic-gate 		default:
1210Sstevel@tonic-gate 			exit_code = 1;
1220Sstevel@tonic-gate 			break;
1230Sstevel@tonic-gate 		}
1240Sstevel@tonic-gate 	} else
1250Sstevel@tonic-gate 		not_set[6] = ' ';
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate 	if (argv[5][0]) {
1280Sstevel@tonic-gate 		switch (set_charset(argv[5], 1, TERM)) {
1290Sstevel@tonic-gate 		case E_SUCCESS:
1300Sstevel@tonic-gate 			not_set[8] = ' ';
1310Sstevel@tonic-gate 			break;
1320Sstevel@tonic-gate 		case E_FAILURE:
1330Sstevel@tonic-gate 			break;
1340Sstevel@tonic-gate 		default:
1350Sstevel@tonic-gate 			exit_code = 1;
1360Sstevel@tonic-gate 			break;
1370Sstevel@tonic-gate 		}
1380Sstevel@tonic-gate 	} else
1390Sstevel@tonic-gate 		not_set[8] = ' ';
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate 	fprintf (stderr, "%s\n", not_set);
1420Sstevel@tonic-gate 
143*320Sceastha 	return (exit_code);
1440Sstevel@tonic-gate }
145