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
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.
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]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright (c) 2016 by Delphix. All rights reserved.
28 /* Copyright (c) 1988 AT&T */
29 /* All Rights Reserved */
31 /* Copyright (c) 1979 Regents of the University of California */
33 #pragma ident "%Z%%M% %I% %E% SMI"
37 #include <sys/types.h>
39 #include "curses_inc.h"
42 * Put the character string cp out, with padding.
43 * The number of affected lines is affcnt, and the routine
44 * used to output one character is outc.
49 _tpad(char *, int, int (*)(char));
52 _tpad(char *cp
, int affcnt
, int (*outc
)(char x
))
56 int ignorexon
= 0, doaffcnt
= 0;
58 #ifdef _VR2_COMPAT_CODE
61 * Because mandatory padding must be used for flash_screen
62 * and bell. We cannot force users to code mandatory padding
63 * in their terminfo entries, as that would break compatibility.
64 * We therefore, do it here.
66 * When compatibility is to be broken, it will go away
67 * and users will be informed that they MUST use mandatory
68 * padding for flash and bell.
70 if (ocp
== bell
|| ocp
== flash_screen
)
72 #endif /* _VR2_COMPAT_CODE */
77 /* Convert the number representing the delay. */
80 delay
= delay
* 10 + *cp
++ - '0';
88 /* Only one digit to the right of the decimal point. */
94 * If the delay is followed by a `*', then
95 * multiply by the affected lines count.
96 * If the delay is followed by a '/', then
97 * the delay is done irregardless of xon/xoff.
113 cp
++; /* Eat trailing '>' */
116 * We got a "$<" with no ">". This is usually caused by
117 * a cursor addressing sequence that happened to generate
118 * $ < . To avoid an infinite loop, we output the $ here
119 * and pass back the rest.
126 * If no delay needed, or output speed is
127 * not comprehensible, then don't try to delay.
132 * Let handshaking take care of it - no extra cpu load from pads.
133 * Also, this will be more optimal since the pad info is usually
134 * worst case. We only use padding info for such terminals to
135 * estimate the cost of a capability in choosing the cheapest one.
136 * Some capabilities, such as flash_screen, really want the
137 * padding irregardless.
139 if (xon_xoff
&& !ignorexon
)
141 (void) _delay(delay
, outc
);
146 tputs(char *cp
, int affcnt
, int (*outc
)(char))
151 /* The guts of the string. */
153 if (*cp
== '$' && cp
[1] == '<')
154 cp
= _tpad(cp
, affcnt
, outc
);