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
5*de81e71eSTim Marsland * Common Development and Distribution License (the "License").
6*de81e71eSTim Marsland * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
21*de81e71eSTim Marsland
227c478bd9Sstevel@tonic-gate /*
23*de81e71eSTim Marsland * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
327c478bd9Sstevel@tonic-gate * The Regents of the University of California
337c478bd9Sstevel@tonic-gate * All Rights Reserved
347c478bd9Sstevel@tonic-gate *
357c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
367c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
377c478bd9Sstevel@tonic-gate * contributors.
387c478bd9Sstevel@tonic-gate */
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate #include <sys/types.h>
437c478bd9Sstevel@tonic-gate #include "curses_inc.h"
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate * The following array gives the number of tens of milliseconds per
477c478bd9Sstevel@tonic-gate * character for each speed as returned by gtty. Thus since 300
487c478bd9Sstevel@tonic-gate * baud returns a 7, there are 33.3 milliseconds per char at 300 baud.
497c478bd9Sstevel@tonic-gate */
507c478bd9Sstevel@tonic-gate static short tmspc10[] =
517c478bd9Sstevel@tonic-gate {
527c478bd9Sstevel@tonic-gate /* 0 50 75 110 134.5 150 200 300 baud */
537c478bd9Sstevel@tonic-gate 0, 2000, 1333, 909, 743, 666, 500, 333,
547c478bd9Sstevel@tonic-gate /* 600 1200 1800 2400 4800 9600 19200 38400 baud */
557c478bd9Sstevel@tonic-gate 166, 83, 55, 41, 20, 10, 5, 2,
56*de81e71eSTim Marsland /* 57600, 76800, 115200, 153600, 230400, 307200 baud */
577c478bd9Sstevel@tonic-gate 2, 1, 1, 1, 1, 1,
58*de81e71eSTim Marsland /* 460800, 921600 baud */
59*de81e71eSTim Marsland 1, 1
607c478bd9Sstevel@tonic-gate };
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate * Insert a delay into the output stream for "delay/10" milliseconds.
647c478bd9Sstevel@tonic-gate * Round up by a half a character frame, and then do the delay.
657c478bd9Sstevel@tonic-gate * Too bad there are no user program accessible programmed delays.
667c478bd9Sstevel@tonic-gate * Transmitting pad characters slows many terminals down and also
677c478bd9Sstevel@tonic-gate * loads the system.
687c478bd9Sstevel@tonic-gate */
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gate int
_delay(int delay,int (* outc)(char))717c478bd9Sstevel@tonic-gate _delay(int delay, int (*outc)(char))
727c478bd9Sstevel@tonic-gate {
737c478bd9Sstevel@tonic-gate int mspc10;
747c478bd9Sstevel@tonic-gate char pc;
757c478bd9Sstevel@tonic-gate int outspeed;
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate /* if there is no pad character, then just return */
787c478bd9Sstevel@tonic-gate if (no_pad_char)
797c478bd9Sstevel@tonic-gate goto good;
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate #ifdef SYSV
827c478bd9Sstevel@tonic-gate outspeed = _BRS(PROGTTYS);
837c478bd9Sstevel@tonic-gate #else /* SYSV */
847c478bd9Sstevel@tonic-gate outspeed = _BR(PROGTTY);
857c478bd9Sstevel@tonic-gate #endif /* SYSV */
867c478bd9Sstevel@tonic-gate if (outspeed <= 0 || outspeed >=
877c478bd9Sstevel@tonic-gate (sizeof (tmspc10) / sizeof (tmspc10[0])))
887c478bd9Sstevel@tonic-gate return (ERR);
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gate mspc10 = tmspc10[outspeed];
917c478bd9Sstevel@tonic-gate delay += mspc10 / 2;
927c478bd9Sstevel@tonic-gate if (pad_char)
937c478bd9Sstevel@tonic-gate pc = *pad_char;
947c478bd9Sstevel@tonic-gate else
957c478bd9Sstevel@tonic-gate pc = 0;
967c478bd9Sstevel@tonic-gate for (delay /= mspc10; delay-- > 0; )
977c478bd9Sstevel@tonic-gate (*outc)(pc);
987c478bd9Sstevel@tonic-gate good:
997c478bd9Sstevel@tonic-gate return (OK);
1007c478bd9Sstevel@tonic-gate }
101