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
5*9354STim.Marsland@Sun.COM * Common Development and Distribution License (the "License").
6*9354STim.Marsland@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
21*9354STim.Marsland@Sun.COM
220Sstevel@tonic-gate /*
23*9354STim.Marsland@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
280Sstevel@tonic-gate /* All Rights Reserved */
290Sstevel@tonic-gate
300Sstevel@tonic-gate /*
310Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
320Sstevel@tonic-gate * The Regents of the University of California
330Sstevel@tonic-gate * All Rights Reserved
340Sstevel@tonic-gate *
350Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
360Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
370Sstevel@tonic-gate * contributors.
380Sstevel@tonic-gate */
390Sstevel@tonic-gate
400Sstevel@tonic-gate /*LINTLIBRARY*/
410Sstevel@tonic-gate
420Sstevel@tonic-gate #include <sys/types.h>
430Sstevel@tonic-gate #include "curses_inc.h"
440Sstevel@tonic-gate
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate * The following array gives the number of tens of milliseconds per
470Sstevel@tonic-gate * character for each speed as returned by gtty. Thus since 300
480Sstevel@tonic-gate * baud returns a 7, there are 33.3 milliseconds per char at 300 baud.
490Sstevel@tonic-gate */
500Sstevel@tonic-gate static short tmspc10[] =
510Sstevel@tonic-gate {
520Sstevel@tonic-gate /* 0 50 75 110 134.5 150 200 300 baud */
530Sstevel@tonic-gate 0, 2000, 1333, 909, 743, 666, 500, 333,
540Sstevel@tonic-gate /* 600 1200 1800 2400 4800 9600 19200 38400 baud */
550Sstevel@tonic-gate 166, 83, 55, 41, 20, 10, 5, 2,
56*9354STim.Marsland@Sun.COM /* 57600, 76800, 115200, 153600, 230400, 307200 baud */
570Sstevel@tonic-gate 2, 1, 1, 1, 1, 1,
58*9354STim.Marsland@Sun.COM /* 460800, 921600 baud */
59*9354STim.Marsland@Sun.COM 1, 1
600Sstevel@tonic-gate };
610Sstevel@tonic-gate
620Sstevel@tonic-gate /*
630Sstevel@tonic-gate * Insert a delay into the output stream for "delay/10" milliseconds.
640Sstevel@tonic-gate * Round up by a half a character frame, and then do the delay.
650Sstevel@tonic-gate * Too bad there are no user program accessible programmed delays.
660Sstevel@tonic-gate * Transmitting pad characters slows many terminals down and also
670Sstevel@tonic-gate * loads the system.
680Sstevel@tonic-gate */
690Sstevel@tonic-gate
700Sstevel@tonic-gate int
_delay(int delay,int (* outc)(char))710Sstevel@tonic-gate _delay(int delay, int (*outc)(char))
720Sstevel@tonic-gate {
730Sstevel@tonic-gate int mspc10;
740Sstevel@tonic-gate char pc;
750Sstevel@tonic-gate int outspeed;
760Sstevel@tonic-gate
770Sstevel@tonic-gate /* if there is no pad character, then just return */
780Sstevel@tonic-gate if (no_pad_char)
790Sstevel@tonic-gate goto good;
800Sstevel@tonic-gate
810Sstevel@tonic-gate #ifdef SYSV
820Sstevel@tonic-gate outspeed = _BRS(PROGTTYS);
830Sstevel@tonic-gate #else /* SYSV */
840Sstevel@tonic-gate outspeed = _BR(PROGTTY);
850Sstevel@tonic-gate #endif /* SYSV */
860Sstevel@tonic-gate if (outspeed <= 0 || outspeed >=
870Sstevel@tonic-gate (sizeof (tmspc10) / sizeof (tmspc10[0])))
880Sstevel@tonic-gate return (ERR);
890Sstevel@tonic-gate
900Sstevel@tonic-gate mspc10 = tmspc10[outspeed];
910Sstevel@tonic-gate delay += mspc10 / 2;
920Sstevel@tonic-gate if (pad_char)
930Sstevel@tonic-gate pc = *pad_char;
940Sstevel@tonic-gate else
950Sstevel@tonic-gate pc = 0;
960Sstevel@tonic-gate for (delay /= mspc10; delay-- > 0; )
970Sstevel@tonic-gate (*outc)(pc);
980Sstevel@tonic-gate good:
990Sstevel@tonic-gate return (OK);
1000Sstevel@tonic-gate }
101