17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
237c478bd9Sstevel@tonic-gate /* All Rights Reserved */
247c478bd9Sstevel@tonic-gate
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */
277c478bd9Sstevel@tonic-gate /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate #include "string.h"
307c478bd9Sstevel@tonic-gate #include "stdlib.h"
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate #include "lp.h"
337c478bd9Sstevel@tonic-gate #include "lp.set.h"
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate extern char *tparm();
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate short output_res_char = -1,
387c478bd9Sstevel@tonic-gate output_res_line = -1,
397c478bd9Sstevel@tonic-gate output_res_horz_inch = -1,
407c478bd9Sstevel@tonic-gate output_res_vert_inch = -1;
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate /**
437c478bd9Sstevel@tonic-gate ** set_pitch()
447c478bd9Sstevel@tonic-gate **/
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate int
477c478bd9Sstevel@tonic-gate #if defined(__STDC__)
set_pitch(char * str,int which,int putout)487c478bd9Sstevel@tonic-gate set_pitch (
497c478bd9Sstevel@tonic-gate char * str,
507c478bd9Sstevel@tonic-gate int which,
517c478bd9Sstevel@tonic-gate int putout
527c478bd9Sstevel@tonic-gate )
537c478bd9Sstevel@tonic-gate #else
547c478bd9Sstevel@tonic-gate set_pitch (str, which, putout)
557c478bd9Sstevel@tonic-gate char *str;
567c478bd9Sstevel@tonic-gate int which,
577c478bd9Sstevel@tonic-gate putout;
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate {
607c478bd9Sstevel@tonic-gate double xpi;
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate int ixpi;
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate short *output_res_p,
657c478bd9Sstevel@tonic-gate *output_res_inch_p;
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate unsigned short xpi_changes_res;
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gate char *rest,
707c478bd9Sstevel@tonic-gate *change_pitch,
717c478bd9Sstevel@tonic-gate *change_res,
727c478bd9Sstevel@tonic-gate *p;
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate if (which == 'H') {
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate tidbit ((char *)0, "cpi", &change_pitch);
787c478bd9Sstevel@tonic-gate tidbit ((char *)0, "chr", &change_res);
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gate output_res_inch_p = &output_res_horz_inch;
817c478bd9Sstevel@tonic-gate if (output_res_horz_inch == -1)
827c478bd9Sstevel@tonic-gate tidbit ((char *)0, "orhi", output_res_inch_p);
837c478bd9Sstevel@tonic-gate
847c478bd9Sstevel@tonic-gate output_res_p = &output_res_char;
857c478bd9Sstevel@tonic-gate if (output_res_char == -1)
867c478bd9Sstevel@tonic-gate tidbit ((char *)0, "orc", output_res_p);
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gate tidbit ((char *)0, "cpix", &xpi_changes_res);
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gate } else {
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate tidbit ((char *)0, "lpi", &change_pitch);;
937c478bd9Sstevel@tonic-gate tidbit ((char *)0, "cvr", &change_res);;
94*55fea89dSDan Cross
957c478bd9Sstevel@tonic-gate output_res_inch_p = &output_res_vert_inch;
967c478bd9Sstevel@tonic-gate if (output_res_vert_inch == -1)
977c478bd9Sstevel@tonic-gate tidbit ((char *)0, "orvi", output_res_inch_p);
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate output_res_p = &output_res_line;
1007c478bd9Sstevel@tonic-gate if (output_res_line == -1)
1017c478bd9Sstevel@tonic-gate tidbit ((char *)0, "orl", output_res_p);
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate tidbit ((char *)0, "lpix", &xpi_changes_res);;
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate }
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate xpi = strtod(str, &rest);
1087c478bd9Sstevel@tonic-gate if (which == 'H' && STREQU(str, NAME_PICA))
1097c478bd9Sstevel@tonic-gate ixpi = R(xpi = 10);
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate else if (which == 'H' && STREQU(str, NAME_ELITE))
1127c478bd9Sstevel@tonic-gate ixpi = R(xpi = 12);
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gate else if (
1157c478bd9Sstevel@tonic-gate which == 'H'
1167c478bd9Sstevel@tonic-gate && (
1177c478bd9Sstevel@tonic-gate STREQU(str, NAME_COMPRESSED)
1187c478bd9Sstevel@tonic-gate || xpi >= N_COMPRESSED
1197c478bd9Sstevel@tonic-gate )
1207c478bd9Sstevel@tonic-gate ) {
1217c478bd9Sstevel@tonic-gate if (change_pitch) {
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate for (ixpi = MAX_COMPRESSED; ixpi; ixpi--)
1247c478bd9Sstevel@tonic-gate if ((p = tparm(change_pitch, ixpi)) && *p)
1257c478bd9Sstevel@tonic-gate break;
1267c478bd9Sstevel@tonic-gate if (!ixpi)
1277c478bd9Sstevel@tonic-gate ixpi = 10;
1287c478bd9Sstevel@tonic-gate xpi = (double)ixpi;
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gate } else if (change_res && *output_res_inch_p != -1) {
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate for (xpi = MAX_COMPRESSED; xpi >= 1.; xpi -= 1.)
1337c478bd9Sstevel@tonic-gate if (
1347c478bd9Sstevel@tonic-gate (p = tparm(change_res, R(*output_res_inch_p / xpi)))
1357c478bd9Sstevel@tonic-gate && *p
1367c478bd9Sstevel@tonic-gate )
1377c478bd9Sstevel@tonic-gate break;
1387c478bd9Sstevel@tonic-gate if (xpi < 1.)
1397c478bd9Sstevel@tonic-gate xpi = 10.;
1407c478bd9Sstevel@tonic-gate ixpi = R(xpi);
1417c478bd9Sstevel@tonic-gate
1427c478bd9Sstevel@tonic-gate } else
1437c478bd9Sstevel@tonic-gate return (E_FAILURE);
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gate } else {
1467c478bd9Sstevel@tonic-gate
1477c478bd9Sstevel@tonic-gate if (xpi <= 0)
1487c478bd9Sstevel@tonic-gate return (E_BAD_ARGS);
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate switch (*rest) {
1517c478bd9Sstevel@tonic-gate case ' ':
1527c478bd9Sstevel@tonic-gate case 0:
1537c478bd9Sstevel@tonic-gate break;
1547c478bd9Sstevel@tonic-gate case 'c':
1557c478bd9Sstevel@tonic-gate /*
1567c478bd9Sstevel@tonic-gate * Convert to [lines|chars] per inch.
1577c478bd9Sstevel@tonic-gate */
1587c478bd9Sstevel@tonic-gate xpi *= 2.54;
1597c478bd9Sstevel@tonic-gate /* fall through */
1607c478bd9Sstevel@tonic-gate case 'i':
1617c478bd9Sstevel@tonic-gate break;
1627c478bd9Sstevel@tonic-gate default:
1637c478bd9Sstevel@tonic-gate return (E_BAD_ARGS);
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate
1667c478bd9Sstevel@tonic-gate ixpi = R(xpi);
1677c478bd9Sstevel@tonic-gate
1687c478bd9Sstevel@tonic-gate }
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate if (
1717c478bd9Sstevel@tonic-gate *output_res_inch_p != -1
1727c478bd9Sstevel@tonic-gate && *output_res_p != -1
1737c478bd9Sstevel@tonic-gate && R(*output_res_inch_p / (double)*output_res_p) == ixpi
1747c478bd9Sstevel@tonic-gate )
1757c478bd9Sstevel@tonic-gate return (E_SUCCESS);
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate else if (
1787c478bd9Sstevel@tonic-gate change_pitch
1797c478bd9Sstevel@tonic-gate && (p = tparm(change_pitch, ixpi))
1807c478bd9Sstevel@tonic-gate && *p
1817c478bd9Sstevel@tonic-gate ) {
1827c478bd9Sstevel@tonic-gate
1837c478bd9Sstevel@tonic-gate if (putout)
1847c478bd9Sstevel@tonic-gate putp (p);
1857c478bd9Sstevel@tonic-gate if (xpi_changes_res) {
1867c478bd9Sstevel@tonic-gate if (*output_res_inch_p != -1)
1877c478bd9Sstevel@tonic-gate *output_res_inch_p = R(*output_res_p * xpi);
1887c478bd9Sstevel@tonic-gate } else {
1897c478bd9Sstevel@tonic-gate if (*output_res_p != -1)
1907c478bd9Sstevel@tonic-gate *output_res_p = R(*output_res_inch_p / xpi);
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate return (E_SUCCESS);
1937c478bd9Sstevel@tonic-gate
1947c478bd9Sstevel@tonic-gate } else if (
1957c478bd9Sstevel@tonic-gate change_res
1967c478bd9Sstevel@tonic-gate && *output_res_inch_p != -1
1977c478bd9Sstevel@tonic-gate && (p = tparm(change_res, R(*output_res_inch_p / xpi)))
1987c478bd9Sstevel@tonic-gate && *p
1997c478bd9Sstevel@tonic-gate ) {
2007c478bd9Sstevel@tonic-gate
2017c478bd9Sstevel@tonic-gate if (putout)
2027c478bd9Sstevel@tonic-gate putp (p);
2037c478bd9Sstevel@tonic-gate if (*output_res_p != -1)
2047c478bd9Sstevel@tonic-gate *output_res_p = R(*output_res_inch_p / xpi);
2057c478bd9Sstevel@tonic-gate return (E_SUCCESS);
2067c478bd9Sstevel@tonic-gate
2077c478bd9Sstevel@tonic-gate } else
2087c478bd9Sstevel@tonic-gate
2097c478bd9Sstevel@tonic-gate return (E_FAILURE);
2107c478bd9Sstevel@tonic-gate }
211