/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.13 */
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "string.h"
#include "stdlib.h"
#include "lp.h"
#include "lp.set.h"
#if defined(__STDC__)
char * tparm ( char * , ... );
int putp ( char * );
int tidbit ( char * , char * , ... );
#else
extern char *tparm();
int putp();
int tidbit();
#endif
extern short output_res_char,
/**
** set_size()
**/
int
#if defined(__STDC__)
set_size (
char * str,
int which,
int putout
)
#else
char *str;
int which,
#endif
{
static int cleared_margins_already = 0;
double size;
int i,
ret;
short curval,
char *rest,
*set_both_margins = 0,
*move1,
*move2,
*step2,
*p1,
*p2,
*sp1,
*sp2,
*finale,
*slines;
if (which == 'W') {
if (output_res_char == -1)
if (output_res_horz_inch == -1)
} else {
if (output_res_line == -1)
if (output_res_vert_inch == -1)
}
if (size <= 0)
return (E_BAD_ARGS);
switch (*rest) {
case ' ':
case 0:
break;
case 'c':
/*
* Convert to inches.
*/
size /= 2.54;
/* fall through */
case 'i':
/*
*/
return (E_FAILURE);
break;
default:
return (E_BAD_ARGS);
}
return (E_SUCCESS);
/*
* We number things 0 through N (e.g. an 80 column
* page is numbered 0 to 79). Thus if we are asked
* to set a width of 132, we set the left margin at
* 0 and the right at 131.
* Of course, if we're using the "slines" string,
* we give the length as N+1.
*/
isize--;
/*
* When the width or length is set using the set-margin-at-
* current-position caps (e.g. smgl and smgr, smgt, smgb):
* If a parameterized motion capability exists, then we'll try
* to use it. However, if the instantiation of the capability
* (through tparm()) gives nothing, assume this means the motion
* is not allowed--don't try the next choice. This is the only
* way we have of checking for a width or length beyond the
* limits of the printer. If a parameterized motion capability
* doesn't exist, we have no way to check out-of-bounds width
* and length, sorry.
*
* When the width or length is set using parameterized caps
* (e.g. smglp and smgrp, or slines for length), the above is not
* a problem, of course.
*/
if (which == 'W') {
if (OKAY(carriage_return))
else
move1 = "\r";
if (OKAY(parm_right_cursor)) {
step2 = 0;
} else if (OKAY(column_address)) {
step2 = 0;
} else if (OKAY(repeat_char)) {
step2 = 0;
} else if (OKAY(cursor_right)) {
move2 = 0;
} else {
move2 = 0;
step2 = " ";
}
} else {
/*
* For compatibility with SVR3.2 era Terminfo files,
* we check "u9" as an alias for "slines" IF a check
* of "slines" comes up empty.
*/
slines = 0; /* (in case compiled with old tidbit) */
if (OKAY(parm_down_cursor)) {
step2 = 0;
} else if (OKAY(row_address)) {
step2 = 0;
} else if (OKAY(cursor_down)) {
move2 = 0;
step2 = cursor_down;
} else {
move2 = 0;
step2 = "\n";
}
/*
* This has to be smarter, but we don't have the
* smarts ourselves, yet; i.e. what do we do if
* there is no "ff"?
*/
}
/*
* For a short while we needed a kludge in Terminfo
* parameterized margin setters was defined, it was
* a parm-string that could set BOTH margins. We now have
* separate strings for setting both margins, but we still
* allow the kludge.
*/
if (!OKAY(set_both_margins)) {
}
if (
which == 'L'
) {
if (putout)
finale = 0;
} else if (
&& *p1
) {
if (putout) {
if (!cleared_margins_already) {
if (OKAY(clear_margins)) {
}
}
}
/*
* The "smgbp" string takes two parameters; each defines the
* position of the margin, the first counting lines from the top
* of the page, the second counting lines from the bottom of the
* page. This shows the flaw in using the set-margin commands
* for setting the page length, because BY DEFINITION the second
* parameter must be 0 for us. But giving 0 won't cause a change
* in the page length, will it!
*
* Anyway, the "smgrp" expects just one parameter (thus will
* ignore a second parameter) so we can safely give the second
* parameter without caring which of width or length we're
* setting.
*/
} else if (
&& *p1
&& OKAY(set_margin2_parm)
&& *p2
) {
if (putout) {
if (!cleared_margins_already) {
if (OKAY(clear_margins)) {
}
}
}
} else if (
&& OKAY(set_margin2)
) {
register char *p,
*q;
register int free_it = 0;
if (putout) {
if (!cleared_margins_already) {
if (OKAY(clear_margins)) {
}
}
putp (set_margin1);
if (!move2) {
if (!move2)
return (E_MALLOC);
for (q = step2; *q; )
*p++ = *q++;
*p = 0;
free_it = 1;
}
putp (set_margin2);
if (free_it)
}
} else
if (sp1)
if (sp2)
return (ret);
}