1 /* 2 * CDDL HEADER START 3 * 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 7 * with the License. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1995, by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * baudrate.c 31 * 32 * XCurses Library 33 * 34 * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 35 * 36 */ 37 38 #ifdef M_RCSID 39 #ifndef lint 40 static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/baudrate.c 1.2 1995/09/27 19:09:07 ant Exp $"; 41 #endif 42 #endif 43 44 #include <private.h> 45 46 typedef struct { 47 speed_t speed; 48 int value; 49 } t_baud; 50 51 static t_baud speeds[] = { 52 { B0, 0 }, 53 { B50, 50 }, 54 { B75, 75 }, 55 { B110, 110 }, 56 { B134, 134 }, 57 { B150, 150 }, 58 { B200, 200 }, 59 { B300, 300 }, 60 { B600, 600 }, 61 { B1200, 1200 }, 62 { B1800, 1800 }, 63 { B2400, 2400 }, 64 { B4800, 4800 }, 65 { B9600, 9600 }, 66 { B19200, 19200 }, 67 { B38400, 38400 }, 68 { (speed_t) -1, -1 } 69 }; 70 71 /*f 72 * Return the output speed of the terminal. The number returned is in 73 * bits per second and is an integer. 74 */ 75 int 76 baudrate() 77 { 78 int i; 79 speed_t value; 80 81 #ifdef M_CURSES_TRACE 82 __m_trace("baudrate(void)"); 83 #endif 84 85 value = cfgetospeed(&cur_term->_prog); 86 87 for (i = 0; speeds[i].speed != (speed_t) -1; ++i) 88 if (speeds[i].speed == value) 89 break; 90 91 return __m_return_int("baudrate", speeds[i].value); 92 } 93