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 /*
237c478bd9Sstevel@tonic-gate * Copyright (c) 1995, by Sun Microsystems, Inc.
247c478bd9Sstevel@tonic-gate * All rights reserved.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate * baudrate.c
297c478bd9Sstevel@tonic-gate *
307c478bd9Sstevel@tonic-gate * XCurses Library
317c478bd9Sstevel@tonic-gate *
327c478bd9Sstevel@tonic-gate * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
337c478bd9Sstevel@tonic-gate *
347c478bd9Sstevel@tonic-gate */
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate #include <private.h>
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate typedef struct {
397c478bd9Sstevel@tonic-gate speed_t speed;
407c478bd9Sstevel@tonic-gate int value;
417c478bd9Sstevel@tonic-gate } t_baud;
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gate static t_baud speeds[] = {
44*d9c3e05cSJoshua M. Clulow { B0, 0 },
45*d9c3e05cSJoshua M. Clulow { B50, 50 },
46*d9c3e05cSJoshua M. Clulow { B75, 75 },
47*d9c3e05cSJoshua M. Clulow { B110, 110 },
48*d9c3e05cSJoshua M. Clulow { B134, 134 },
49*d9c3e05cSJoshua M. Clulow { B150, 150 },
50*d9c3e05cSJoshua M. Clulow { B200, 200 },
51*d9c3e05cSJoshua M. Clulow { B300, 300 },
52*d9c3e05cSJoshua M. Clulow { B600, 600 },
53*d9c3e05cSJoshua M. Clulow { B1200, 1200 },
54*d9c3e05cSJoshua M. Clulow { B1800, 1800 },
55*d9c3e05cSJoshua M. Clulow { B2400, 2400 },
56*d9c3e05cSJoshua M. Clulow { B4800, 4800 },
57*d9c3e05cSJoshua M. Clulow { B9600, 9600 },
58*d9c3e05cSJoshua M. Clulow { B19200, 19200 },
59*d9c3e05cSJoshua M. Clulow { B38400, 38400 },
60*d9c3e05cSJoshua M. Clulow { B57600, 57600 },
61*d9c3e05cSJoshua M. Clulow { B76800, 76800 },
62*d9c3e05cSJoshua M. Clulow { B115200, 115200 },
63*d9c3e05cSJoshua M. Clulow { B153600, 153600 },
64*d9c3e05cSJoshua M. Clulow { B230400, 230400 },
65*d9c3e05cSJoshua M. Clulow { B307200, 307200 },
66*d9c3e05cSJoshua M. Clulow { B460800, 460800 },
67*d9c3e05cSJoshua M. Clulow { B921600, 921600 },
68*d9c3e05cSJoshua M. Clulow { B1000000, 1000000 },
69*d9c3e05cSJoshua M. Clulow { B1152000, 1152000 },
70*d9c3e05cSJoshua M. Clulow { B1500000, 1500000 },
71*d9c3e05cSJoshua M. Clulow { B2000000, 2000000 },
72*d9c3e05cSJoshua M. Clulow { B2500000, 2500000 },
73*d9c3e05cSJoshua M. Clulow { B3000000, 3000000 },
74*d9c3e05cSJoshua M. Clulow { B3500000, 3500000 },
75*d9c3e05cSJoshua M. Clulow { B4000000, 4000000 },
76*d9c3e05cSJoshua M. Clulow { (speed_t)-1, -1 }
777c478bd9Sstevel@tonic-gate };
787c478bd9Sstevel@tonic-gate
79*d9c3e05cSJoshua M. Clulow /*
807c478bd9Sstevel@tonic-gate * Return the output speed of the terminal. The number returned is in
817c478bd9Sstevel@tonic-gate * bits per second and is an integer.
827c478bd9Sstevel@tonic-gate */
837c478bd9Sstevel@tonic-gate int
baudrate()847c478bd9Sstevel@tonic-gate baudrate()
857c478bd9Sstevel@tonic-gate {
867c478bd9Sstevel@tonic-gate int i;
877c478bd9Sstevel@tonic-gate speed_t value;
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate #ifdef M_CURSES_TRACE
907c478bd9Sstevel@tonic-gate __m_trace("baudrate(void)");
917c478bd9Sstevel@tonic-gate #endif
927c478bd9Sstevel@tonic-gate
937c478bd9Sstevel@tonic-gate value = cfgetospeed(&cur_term->_prog);
947c478bd9Sstevel@tonic-gate
95*d9c3e05cSJoshua M. Clulow for (i = 0; speeds[i].speed != (speed_t) -1; ++i) {
96*d9c3e05cSJoshua M. Clulow if (speeds[i].speed == value) {
977c478bd9Sstevel@tonic-gate break;
98*d9c3e05cSJoshua M. Clulow }
99*d9c3e05cSJoshua M. Clulow }
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate return __m_return_int("baudrate", speeds[i].value);
1027c478bd9Sstevel@tonic-gate }
103