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 1995 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) 1984, 1986, 1987, 1988, 1989 AT&T */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate /* This is a new line.c, which consists of line.c and culine.c 347c478bd9Sstevel@tonic-gate * merged together. 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include "uucp.h" 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate static struct sg_spds { 407c478bd9Sstevel@tonic-gate int sp_val, 417c478bd9Sstevel@tonic-gate sp_name; 427c478bd9Sstevel@tonic-gate } spds[] = { 437c478bd9Sstevel@tonic-gate { 50, B50}, 447c478bd9Sstevel@tonic-gate { 75, B75}, 457c478bd9Sstevel@tonic-gate { 110, B110}, 467c478bd9Sstevel@tonic-gate { 134, B134}, 477c478bd9Sstevel@tonic-gate { 150, B150}, 487c478bd9Sstevel@tonic-gate { 200, B200}, 497c478bd9Sstevel@tonic-gate { 300, B300}, 507c478bd9Sstevel@tonic-gate { 600, B600}, 517c478bd9Sstevel@tonic-gate {1200, B1200}, 527c478bd9Sstevel@tonic-gate {1800, B1800}, 537c478bd9Sstevel@tonic-gate {2400, B2400}, 547c478bd9Sstevel@tonic-gate {4800, B4800}, 557c478bd9Sstevel@tonic-gate {9600, B9600}, 567c478bd9Sstevel@tonic-gate #ifdef EXTA 577c478bd9Sstevel@tonic-gate {19200, EXTA}, 587c478bd9Sstevel@tonic-gate #endif 597c478bd9Sstevel@tonic-gate #ifdef B19200 607c478bd9Sstevel@tonic-gate {19200, B19200}, 617c478bd9Sstevel@tonic-gate #endif 627c478bd9Sstevel@tonic-gate #ifdef B38400 637c478bd9Sstevel@tonic-gate {38400, B38400}, 647c478bd9Sstevel@tonic-gate #endif 657c478bd9Sstevel@tonic-gate {57600, B57600}, 667c478bd9Sstevel@tonic-gate {76800, B76800}, 677c478bd9Sstevel@tonic-gate {115200, B115200}, 687c478bd9Sstevel@tonic-gate {153600, B153600}, 697c478bd9Sstevel@tonic-gate {230400, B230400}, 707c478bd9Sstevel@tonic-gate {307200, B307200}, 717c478bd9Sstevel@tonic-gate {460800, B460800}, 727c478bd9Sstevel@tonic-gate {0, 0} 737c478bd9Sstevel@tonic-gate }; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #define PACKSIZE 64 767c478bd9Sstevel@tonic-gate #define HEADERSIZE 6 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate GLOBAL int 797c478bd9Sstevel@tonic-gate packsize = PACKSIZE, 807c478bd9Sstevel@tonic-gate xpacksize = PACKSIZE; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate #define SNDFILE 'S' 837c478bd9Sstevel@tonic-gate #define RCVFILE 'R' 847c478bd9Sstevel@tonic-gate #define RESET 'X' 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #ifdef PKSPEEDUP 877c478bd9Sstevel@tonic-gate GLOBAL int linebaudrate; /* for speedup hook in pk1.c */ 887c478bd9Sstevel@tonic-gate #endif /* PKSPEEDUP */ 897c478bd9Sstevel@tonic-gate static int Saved_line; /* was savline() successful? */ 907c478bd9Sstevel@tonic-gate static int Saved_termios; /* was termios saved? */ 917c478bd9Sstevel@tonic-gate GLOBAL int 927c478bd9Sstevel@tonic-gate Oddflag = 0, /* Default is no parity */ 937c478bd9Sstevel@tonic-gate Evenflag = 0, /* Default is no parity */ 947c478bd9Sstevel@tonic-gate Duplex = 1, /* Default is full duplex */ 957c478bd9Sstevel@tonic-gate Terminal = 0, /* Default is no terminal */ 967c478bd9Sstevel@tonic-gate term_8bit = -1, /* Default to terminal setting or 8 bit */ 977c478bd9Sstevel@tonic-gate line_8bit = -1; /* Default is same as terminal */ 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate static char *P_PARITY = "Parity option error\r\n"; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #ifdef ATTSVTTY 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate static struct termio Savettyb; 1047c478bd9Sstevel@tonic-gate static struct termios Savettybs; 1057c478bd9Sstevel@tonic-gate /* 1067c478bd9Sstevel@tonic-gate * set speed/echo/mode... 1077c478bd9Sstevel@tonic-gate * tty -> terminal name 1087c478bd9Sstevel@tonic-gate * spwant -> speed 1097c478bd9Sstevel@tonic-gate * type -> type 1107c478bd9Sstevel@tonic-gate * 1117c478bd9Sstevel@tonic-gate * if spwant == 0, speed is untouched 1127c478bd9Sstevel@tonic-gate * type is unused, but needed for compatibility 1137c478bd9Sstevel@tonic-gate * 1147c478bd9Sstevel@tonic-gate * return: 1157c478bd9Sstevel@tonic-gate * none 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1187c478bd9Sstevel@tonic-gate GLOBAL void 1197c478bd9Sstevel@tonic-gate fixline(tty, spwant, type) 1207c478bd9Sstevel@tonic-gate int tty, spwant, type; 1217c478bd9Sstevel@tonic-gate { 1227c478bd9Sstevel@tonic-gate register struct sg_spds *ps; 1237c478bd9Sstevel@tonic-gate struct termio ttbuf; 1247c478bd9Sstevel@tonic-gate struct termios ttbufs; 1257c478bd9Sstevel@tonic-gate int speed = -1; 1267c478bd9Sstevel@tonic-gate int i, istermios, ospeed; 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate DEBUG(6, "fixline(%d, ", tty); 1297c478bd9Sstevel@tonic-gate DEBUG(6, "%d)\n", spwant); 1307c478bd9Sstevel@tonic-gate if ((istermios = (*Ioctl)(tty, TCGETS, &ttbufs)) < 0) { 1317c478bd9Sstevel@tonic-gate if ((*Ioctl)(tty, TCGETA, &ttbuf) != 0) { 1327c478bd9Sstevel@tonic-gate return; 1337c478bd9Sstevel@tonic-gate } else { 1347c478bd9Sstevel@tonic-gate ttbufs.c_lflag = ttbuf.c_lflag; 1357c478bd9Sstevel@tonic-gate ttbufs.c_oflag = ttbuf.c_oflag; 1367c478bd9Sstevel@tonic-gate ttbufs.c_iflag = ttbuf.c_iflag; 1377c478bd9Sstevel@tonic-gate ttbufs.c_cflag = ttbuf.c_cflag; 1387c478bd9Sstevel@tonic-gate for(i = 0; i < NCC; i++) 1397c478bd9Sstevel@tonic-gate ttbufs.c_cc[i] = ttbuf.c_cc[i]; 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate if (spwant > 0) { 1437c478bd9Sstevel@tonic-gate for (ps = spds; ps->sp_val; ps++) 1447c478bd9Sstevel@tonic-gate if (ps->sp_val == spwant) { 1457c478bd9Sstevel@tonic-gate speed = ps->sp_name; 1467c478bd9Sstevel@tonic-gate break; 1477c478bd9Sstevel@tonic-gate } 1487c478bd9Sstevel@tonic-gate if ( speed < 0 ) 1497c478bd9Sstevel@tonic-gate DEBUG(5, "speed (%d) not supported\n", spwant); 1507c478bd9Sstevel@tonic-gate ASSERT(speed >= 0, "BAD SPEED", "", spwant); 1517c478bd9Sstevel@tonic-gate ttbufs.c_cflag &= 0xffff0000; 1527c478bd9Sstevel@tonic-gate cfsetospeed(&ttbufs, speed); 1537c478bd9Sstevel@tonic-gate } else { /* determine the current speed setting */ 1547c478bd9Sstevel@tonic-gate ospeed = cfgetospeed(&ttbufs); 1557c478bd9Sstevel@tonic-gate ttbufs.c_cflag &= 0xffff0000; 1567c478bd9Sstevel@tonic-gate cfsetospeed(&ttbufs, ospeed); 1577c478bd9Sstevel@tonic-gate for (ps = spds; ps->sp_val; ps++) 1587c478bd9Sstevel@tonic-gate if (ps->sp_name == ospeed) { 1597c478bd9Sstevel@tonic-gate spwant = ps->sp_val; 1607c478bd9Sstevel@tonic-gate break; 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate } 163*e0f3b92fSsv204098 /* 164*e0f3b92fSsv204098 * In order to prevent attempts at split speed, all baud rate 165*e0f3b92fSsv204098 * bitfields should be cleared. Thus cfsetispeed is used to 166*e0f3b92fSsv204098 * set the speed to zero. 167*e0f3b92fSsv204098 */ 168*e0f3b92fSsv204098 (void) cfsetispeed(&ttbufs, 0); 1697c478bd9Sstevel@tonic-gate ttbufs.c_iflag &= 0xffff0000; 1707c478bd9Sstevel@tonic-gate ttbufs.c_oflag &= 0xffff0000; 1717c478bd9Sstevel@tonic-gate ttbufs.c_lflag &= 0xffff0000; 1727c478bd9Sstevel@tonic-gate #ifdef PKSPEEDUP 1737c478bd9Sstevel@tonic-gate linebaudrate = spwant; 1747c478bd9Sstevel@tonic-gate #endif /* PKSPEEDUP */ 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate #ifdef NO_MODEM_CTRL 1777c478bd9Sstevel@tonic-gate /* CLOCAL may cause problems on pdp11s with DHs */ 1787c478bd9Sstevel@tonic-gate if (type == D_DIRECT) { 1797c478bd9Sstevel@tonic-gate DEBUG(4, "fixline - direct\n%s", ""); 1807c478bd9Sstevel@tonic-gate ttbufs.c_cflag |= CLOCAL; 1817c478bd9Sstevel@tonic-gate } else 1827c478bd9Sstevel@tonic-gate #endif /* NO_MODEM_CTRL */ 1837c478bd9Sstevel@tonic-gate ttbufs.c_cflag &= ~CLOCAL; 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate if ( !EQUALS(Progname, "uucico") ) { 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate /* set attributes associated with -h, -t, -e, and -o options */ 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate ttbufs.c_iflag = (IGNPAR | IGNBRK | IXON | IXOFF); 1907c478bd9Sstevel@tonic-gate ttbufs.c_cc[VEOF] = '\1'; 1917c478bd9Sstevel@tonic-gate ttbufs.c_cflag |= ( CREAD | (speed ? HUPCL : 0)); 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate if ( line_8bit ) { 1947c478bd9Sstevel@tonic-gate ttbufs.c_cflag |= CS8; 1957c478bd9Sstevel@tonic-gate ttbufs.c_iflag &= ~ISTRIP; 1967c478bd9Sstevel@tonic-gate } else { 1977c478bd9Sstevel@tonic-gate if (Evenflag) { /*even parity -e */ 1987c478bd9Sstevel@tonic-gate ttbufs.c_cflag &= ~PARODD; 1997c478bd9Sstevel@tonic-gate } else if(Oddflag) { /*odd parity -o */ 2007c478bd9Sstevel@tonic-gate ttbufs.c_cflag |= PARODD; 2017c478bd9Sstevel@tonic-gate } 2027c478bd9Sstevel@tonic-gate ttbufs.c_cflag |= CS7|PARENB; 2037c478bd9Sstevel@tonic-gate ttbufs.c_iflag |= ISTRIP; 2047c478bd9Sstevel@tonic-gate } 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate if(!Duplex) /*half duplex -h */ 2077c478bd9Sstevel@tonic-gate ttbufs.c_iflag &= ~(IXON | IXOFF); 2087c478bd9Sstevel@tonic-gate if(Terminal) /* -t */ 2097c478bd9Sstevel@tonic-gate ttbufs.c_oflag |= (OPOST | ONLCR); 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate } else { /* non-uucico */ 2127c478bd9Sstevel@tonic-gate ttbufs.c_cflag |= (CS8 | CREAD | (speed ? HUPCL : 0)); 2137c478bd9Sstevel@tonic-gate ttbufs.c_cc[VMIN] = HEADERSIZE; 2147c478bd9Sstevel@tonic-gate ttbufs.c_cc[VTIME] = 1; 2157c478bd9Sstevel@tonic-gate } 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate if (istermios < 0) { 2187c478bd9Sstevel@tonic-gate ttbuf.c_lflag = ttbufs.c_lflag; 2197c478bd9Sstevel@tonic-gate ttbuf.c_oflag = ttbufs.c_oflag; 2207c478bd9Sstevel@tonic-gate ttbuf.c_iflag = ttbufs.c_iflag; 2217c478bd9Sstevel@tonic-gate ttbuf.c_cflag = ttbufs.c_cflag; 2227c478bd9Sstevel@tonic-gate for(i = 0; i < NCC; i++) 2237c478bd9Sstevel@tonic-gate ttbuf.c_cc[i] = ttbufs.c_cc[i]; 2247c478bd9Sstevel@tonic-gate ASSERT((*Ioctl)(tty, TCSETAW, &ttbuf) >= 0, 2257c478bd9Sstevel@tonic-gate "RETURN FROM fixline ioctl", "", errno); 2267c478bd9Sstevel@tonic-gate } else { 2277c478bd9Sstevel@tonic-gate ASSERT((*Ioctl)(tty, TCSETSW, &ttbufs) >= 0, 2287c478bd9Sstevel@tonic-gate "RETURN FROM fixline ioctl", "", errno); 2297c478bd9Sstevel@tonic-gate } 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate return; 2327c478bd9Sstevel@tonic-gate } 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate GLOBAL void 2357c478bd9Sstevel@tonic-gate sethup(dcf) 2367c478bd9Sstevel@tonic-gate int dcf; 2377c478bd9Sstevel@tonic-gate { 2387c478bd9Sstevel@tonic-gate struct termio ttbuf; 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate if ((*Ioctl)(dcf, TCGETA, &ttbuf) != 0) 2417c478bd9Sstevel@tonic-gate return; 2427c478bd9Sstevel@tonic-gate if (!(ttbuf.c_cflag & HUPCL)) { 2437c478bd9Sstevel@tonic-gate ttbuf.c_cflag |= HUPCL; 2447c478bd9Sstevel@tonic-gate (void) (*Ioctl)(dcf, TCSETAW, &ttbuf); 2457c478bd9Sstevel@tonic-gate } 2467c478bd9Sstevel@tonic-gate return; 2477c478bd9Sstevel@tonic-gate } 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate GLOBAL void 2507c478bd9Sstevel@tonic-gate ttygenbrk(fn) 2517c478bd9Sstevel@tonic-gate register int fn; 2527c478bd9Sstevel@tonic-gate { 2537c478bd9Sstevel@tonic-gate if (isatty(fn)) 2547c478bd9Sstevel@tonic-gate (void) (*Ioctl)(fn, TCSBRK, 0); 2557c478bd9Sstevel@tonic-gate return; 2567c478bd9Sstevel@tonic-gate } 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate /* 2607c478bd9Sstevel@tonic-gate * optimize line setting for sending or receiving files 2617c478bd9Sstevel@tonic-gate * return: 2627c478bd9Sstevel@tonic-gate * none 2637c478bd9Sstevel@tonic-gate */ 2647c478bd9Sstevel@tonic-gate GLOBAL void 2657c478bd9Sstevel@tonic-gate setline(type) 2667c478bd9Sstevel@tonic-gate register char type; 2677c478bd9Sstevel@tonic-gate { 2687c478bd9Sstevel@tonic-gate static struct termio tbuf; 2697c478bd9Sstevel@tonic-gate static struct termios tbufs; 2707c478bd9Sstevel@tonic-gate int i, vtime, istermios, ospeed; 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate DEBUG(2, "setline - %c\n", type); 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate if ((istermios = (*Ioctl)(Ifn, TCGETS, &tbufs)) < 0) { 2757c478bd9Sstevel@tonic-gate if ((*Ioctl)(Ifn, TCGETA, &tbuf) != 0) { 2767c478bd9Sstevel@tonic-gate return; 2777c478bd9Sstevel@tonic-gate } else { 2787c478bd9Sstevel@tonic-gate tbufs.c_lflag = tbuf.c_lflag; 2797c478bd9Sstevel@tonic-gate tbufs.c_oflag = tbuf.c_oflag; 2807c478bd9Sstevel@tonic-gate tbufs.c_iflag = tbuf.c_iflag; 2817c478bd9Sstevel@tonic-gate tbufs.c_cflag = tbuf.c_cflag; 2827c478bd9Sstevel@tonic-gate for(i = 0; i < NCC; i++) 2837c478bd9Sstevel@tonic-gate tbufs.c_cc[i] = tbuf.c_cc[i]; 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate } 2867c478bd9Sstevel@tonic-gate switch (type) { 2877c478bd9Sstevel@tonic-gate case RCVFILE: 2887c478bd9Sstevel@tonic-gate ospeed = cfgetospeed(&tbufs); 2897c478bd9Sstevel@tonic-gate switch (ospeed) { 2907c478bd9Sstevel@tonic-gate #ifdef B19200 2917c478bd9Sstevel@tonic-gate case B19200: 2927c478bd9Sstevel@tonic-gate #else 2937c478bd9Sstevel@tonic-gate #ifdef EXTA 2947c478bd9Sstevel@tonic-gate case EXTA: 2957c478bd9Sstevel@tonic-gate #endif 2967c478bd9Sstevel@tonic-gate #endif 2977c478bd9Sstevel@tonic-gate #ifdef B38400 2987c478bd9Sstevel@tonic-gate case B38400: 2997c478bd9Sstevel@tonic-gate #endif 3007c478bd9Sstevel@tonic-gate case B57600: 3017c478bd9Sstevel@tonic-gate case B76800: 3027c478bd9Sstevel@tonic-gate case B115200: 3037c478bd9Sstevel@tonic-gate case B153600: 3047c478bd9Sstevel@tonic-gate case B230400: 3057c478bd9Sstevel@tonic-gate case B307200: 3067c478bd9Sstevel@tonic-gate case B460800: 3077c478bd9Sstevel@tonic-gate case B9600: 3087c478bd9Sstevel@tonic-gate vtime = 1; 3097c478bd9Sstevel@tonic-gate break; 3107c478bd9Sstevel@tonic-gate case B4800: 3117c478bd9Sstevel@tonic-gate vtime = 4; 3127c478bd9Sstevel@tonic-gate break; 3137c478bd9Sstevel@tonic-gate default: 3147c478bd9Sstevel@tonic-gate vtime = 8; 3157c478bd9Sstevel@tonic-gate break; 3167c478bd9Sstevel@tonic-gate } 3177c478bd9Sstevel@tonic-gate if (tbufs.c_cc[VMIN] != packsize || 3187c478bd9Sstevel@tonic-gate tbufs.c_cc[VTIME] != vtime) { 3197c478bd9Sstevel@tonic-gate tbufs.c_cc[VMIN] = packsize; 3207c478bd9Sstevel@tonic-gate tbufs.c_cc[VTIME] = vtime; 3217c478bd9Sstevel@tonic-gate if (istermios < 0) { 3227c478bd9Sstevel@tonic-gate tbuf.c_lflag = tbufs.c_lflag; 3237c478bd9Sstevel@tonic-gate tbuf.c_oflag = tbufs.c_oflag; 3247c478bd9Sstevel@tonic-gate tbuf.c_iflag = tbufs.c_iflag; 3257c478bd9Sstevel@tonic-gate tbuf.c_cflag = tbufs.c_cflag; 3267c478bd9Sstevel@tonic-gate for(i = 0; i < NCC; i++) 3277c478bd9Sstevel@tonic-gate tbuf.c_cc[i] = tbufs.c_cc[i]; 3287c478bd9Sstevel@tonic-gate if ( (*Ioctl)(Ifn, TCSETAW, &tbuf) != 0 ) 3297c478bd9Sstevel@tonic-gate DEBUG(4, "setline Ioctl failed errno=%d\n", errno); 3307c478bd9Sstevel@tonic-gate } else { 3317c478bd9Sstevel@tonic-gate if ( (*Ioctl)(Ifn, TCSETSW, &tbufs) != 0 ) 3327c478bd9Sstevel@tonic-gate DEBUG(4, "setline Ioctl failed errno=%d\n", errno); 3337c478bd9Sstevel@tonic-gate } 3347c478bd9Sstevel@tonic-gate } 3357c478bd9Sstevel@tonic-gate break; 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate case SNDFILE: 3387c478bd9Sstevel@tonic-gate case RESET: 3397c478bd9Sstevel@tonic-gate if (tbufs.c_cc[VMIN] != HEADERSIZE) { 3407c478bd9Sstevel@tonic-gate tbufs.c_cc[VMIN] = HEADERSIZE; 3417c478bd9Sstevel@tonic-gate if (istermios < 0) { 3427c478bd9Sstevel@tonic-gate tbuf.c_lflag = tbufs.c_lflag; 3437c478bd9Sstevel@tonic-gate tbuf.c_oflag = tbufs.c_oflag; 3447c478bd9Sstevel@tonic-gate tbuf.c_iflag = tbufs.c_iflag; 3457c478bd9Sstevel@tonic-gate tbuf.c_cflag = tbufs.c_cflag; 3467c478bd9Sstevel@tonic-gate for(i = 0; i < NCC; i++) 3477c478bd9Sstevel@tonic-gate tbuf.c_cc[i] = tbufs.c_cc[i]; 3487c478bd9Sstevel@tonic-gate if ( (*Ioctl)(Ifn, TCSETAW, &tbuf) != 0 ) 3497c478bd9Sstevel@tonic-gate DEBUG(4, "setline Ioctl failed errno=%d\n", errno); 3507c478bd9Sstevel@tonic-gate } else { 3517c478bd9Sstevel@tonic-gate if ( (*Ioctl)(Ifn, TCSETSW, &tbufs) != 0 ) 3527c478bd9Sstevel@tonic-gate DEBUG(4, "setline Ioctl failed errno=%d\n", errno); 3537c478bd9Sstevel@tonic-gate } 3547c478bd9Sstevel@tonic-gate } 3557c478bd9Sstevel@tonic-gate break; 3567c478bd9Sstevel@tonic-gate } 3577c478bd9Sstevel@tonic-gate return; 3587c478bd9Sstevel@tonic-gate } 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate GLOBAL int 3617c478bd9Sstevel@tonic-gate savline() 3627c478bd9Sstevel@tonic-gate { 3637c478bd9Sstevel@tonic-gate if ((Saved_termios = (*Ioctl)(0, TCGETS, &Savettybs)) < 0) { 3647c478bd9Sstevel@tonic-gate if ( (*Ioctl)(0, TCGETA, &Savettyb) != 0 ) { 3657c478bd9Sstevel@tonic-gate Saved_line = FALSE; 3667c478bd9Sstevel@tonic-gate } else { 3677c478bd9Sstevel@tonic-gate Saved_line = TRUE; 3687c478bd9Sstevel@tonic-gate Savettyb.c_cflag = (Savettyb.c_cflag & ~CS8) | CS7 | PARENB; 3697c478bd9Sstevel@tonic-gate Savettyb.c_oflag |= OPOST; 3707c478bd9Sstevel@tonic-gate Savettyb.c_lflag |= (ISIG|ICANON|ECHO); 3717c478bd9Sstevel@tonic-gate } 3727c478bd9Sstevel@tonic-gate } else { 3737c478bd9Sstevel@tonic-gate Saved_line = TRUE; 3747c478bd9Sstevel@tonic-gate Savettybs.c_cflag = (Savettybs.c_cflag & ~CS8) | CS7 | PARENB; 3757c478bd9Sstevel@tonic-gate Savettybs.c_oflag |= OPOST; 3767c478bd9Sstevel@tonic-gate Savettybs.c_lflag |= (ISIG|ICANON|ECHO); 3777c478bd9Sstevel@tonic-gate } 3787c478bd9Sstevel@tonic-gate return(0); 3797c478bd9Sstevel@tonic-gate } 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate #ifdef SYTEK 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate /* 3847c478bd9Sstevel@tonic-gate * sytfixline(tty, spwant) set speed/echo/mode... 3857c478bd9Sstevel@tonic-gate * int tty, spwant; 3867c478bd9Sstevel@tonic-gate * 3877c478bd9Sstevel@tonic-gate * return codes: none 3887c478bd9Sstevel@tonic-gate */ 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate GLOBAL void 3917c478bd9Sstevel@tonic-gate sytfixline(tty, spwant) 3927c478bd9Sstevel@tonic-gate int tty, spwant; 3937c478bd9Sstevel@tonic-gate { 3947c478bd9Sstevel@tonic-gate struct termio ttbuf; 3957c478bd9Sstevel@tonic-gate struct termios ttbufs; 3967c478bd9Sstevel@tonic-gate struct sg_spds *ps; 3977c478bd9Sstevel@tonic-gate int speed = -1; 3987c478bd9Sstevel@tonic-gate int i, ret, istermios; 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate if ((istermios = (*Ioctl)(tty, TCGETS, &ttbufs)) < 0) { 4017c478bd9Sstevel@tonic-gate if ( (*Ioctl)(tty, TCGETA, &ttbuf) != 0 ) { 4027c478bd9Sstevel@tonic-gate return; 4037c478bd9Sstevel@tonic-gate } else { 4047c478bd9Sstevel@tonic-gate ttbufs.c_lflag = ttbuf.c_lflag; 4057c478bd9Sstevel@tonic-gate ttbufs.c_oflag = ttbuf.c_oflag; 4067c478bd9Sstevel@tonic-gate ttbufs.c_iflag = ttbuf.c_iflag; 4077c478bd9Sstevel@tonic-gate ttbufs.c_cflag = ttbuf.c_cflag; 4087c478bd9Sstevel@tonic-gate for(i = 0; i < NCC; i++) 4097c478bd9Sstevel@tonic-gate ttbufs.c_cc[i] = ttbuf.c_cc[i]; 4107c478bd9Sstevel@tonic-gate } 4117c478bd9Sstevel@tonic-gate } 4127c478bd9Sstevel@tonic-gate for (ps = spds; ps->sp_val >= 0; ps++) 4137c478bd9Sstevel@tonic-gate if (ps->sp_val == spwant) 4147c478bd9Sstevel@tonic-gate speed = ps->sp_name; 4157c478bd9Sstevel@tonic-gate DEBUG(4, "sytfixline - speed= %d\n", speed); 4167c478bd9Sstevel@tonic-gate ASSERT(speed >= 0, "BAD SPEED", "", spwant); 4177c478bd9Sstevel@tonic-gate ttbufs.c_iflag &= 0xffff0000; 4187c478bd9Sstevel@tonic-gate ttbufs.c_oflag &= 0xffff0000; 4197c478bd9Sstevel@tonic-gate ttbufs.c_lflag &= 0xffff0000; 4207c478bd9Sstevel@tonic-gate ttbufs.c_cflag &= 0xffff0000; 4217c478bd9Sstevel@tonic-gate cfsetospeed(&ttbufs, speed); 4227c478bd9Sstevel@tonic-gate ttbufs.c_cflag |= (CS8|CLOCAL); 4237c478bd9Sstevel@tonic-gate ttbufs.c_cc[VMIN] = 6; 4247c478bd9Sstevel@tonic-gate ttbufs.c_cc[VTIME] = 1; 4257c478bd9Sstevel@tonic-gate if (istermios < 0) { 4267c478bd9Sstevel@tonic-gate ttbuf.c_lflag = ttbufs.c_lflag; 4277c478bd9Sstevel@tonic-gate ttbuf.c_oflag = ttbufs.c_oflag; 4287c478bd9Sstevel@tonic-gate ttbuf.c_iflag = ttbufs.c_iflag; 4297c478bd9Sstevel@tonic-gate ttbuf.c_cflag = ttbufs.c_cflag; 4307c478bd9Sstevel@tonic-gate for(i = 0; i < NCC; i++) 4317c478bd9Sstevel@tonic-gate ttbuf.c_cc[i] = ttbufs.c_cc[i]; 4327c478bd9Sstevel@tonic-gate ret = (*Ioctl)(tty, TCSETAW, &ttbuf); 4337c478bd9Sstevel@tonic-gate } else 4347c478bd9Sstevel@tonic-gate ret = (*Ioctl)(tty, TCSETAWS &ttbufs); 4357c478bd9Sstevel@tonic-gate ASSERT(ret >= 0, "RETURN FROM sytfixline", "", ret); 4367c478bd9Sstevel@tonic-gate return; 4377c478bd9Sstevel@tonic-gate } 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate GLOBAL void 4407c478bd9Sstevel@tonic-gate sytfix2line(tty) 4417c478bd9Sstevel@tonic-gate int tty; 4427c478bd9Sstevel@tonic-gate { 4437c478bd9Sstevel@tonic-gate struct termio ttbuf; 4447c478bd9Sstevel@tonic-gate int ret; 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate if ( (*Ioctl)(tty, TCGETA, &ttbuf) != 0 ) 4477c478bd9Sstevel@tonic-gate return; 4487c478bd9Sstevel@tonic-gate ttbuf.c_cflag &= ~CLOCAL; 4497c478bd9Sstevel@tonic-gate ttbuf.c_cflag |= CREAD|HUPCL; 4507c478bd9Sstevel@tonic-gate ret = (*Ioctl)(tty, TCSETAW, &ttbuf); 4517c478bd9Sstevel@tonic-gate ASSERT(ret >= 0, "RETURN FROM sytfix2line", "", ret); 4527c478bd9Sstevel@tonic-gate return; 4537c478bd9Sstevel@tonic-gate } 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate #endif /* SYTEK */ 4567c478bd9Sstevel@tonic-gate 4577c478bd9Sstevel@tonic-gate GLOBAL int 4587c478bd9Sstevel@tonic-gate restline() 4597c478bd9Sstevel@tonic-gate { 4607c478bd9Sstevel@tonic-gate if ( Saved_line == TRUE ) { 4617c478bd9Sstevel@tonic-gate if (Saved_termios < 0) 4627c478bd9Sstevel@tonic-gate return((*Ioctl)(0, TCSETAW, &Savettyb)); 4637c478bd9Sstevel@tonic-gate else 4647c478bd9Sstevel@tonic-gate return((*Ioctl)(0, TCSETSW, &Savettybs)); 4657c478bd9Sstevel@tonic-gate } 4667c478bd9Sstevel@tonic-gate return(0); 4677c478bd9Sstevel@tonic-gate } 4687c478bd9Sstevel@tonic-gate 4697c478bd9Sstevel@tonic-gate #else /* !ATTSVTTY */ 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate static struct sgttyb Savettyb; 4727c478bd9Sstevel@tonic-gate 4737c478bd9Sstevel@tonic-gate /* 4747c478bd9Sstevel@tonic-gate * fixline(tty, spwant, type) set speed/echo/mode... 4757c478bd9Sstevel@tonic-gate * int tty, spwant; 4767c478bd9Sstevel@tonic-gate * 4777c478bd9Sstevel@tonic-gate * if spwant == 0, speed is untouched 4787c478bd9Sstevel@tonic-gate * type is unused, but needed for compatibility 4797c478bd9Sstevel@tonic-gate * 4807c478bd9Sstevel@tonic-gate * return codes: none 4817c478bd9Sstevel@tonic-gate */ 4827c478bd9Sstevel@tonic-gate 4837c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 4847c478bd9Sstevel@tonic-gate GLOBAL void 4857c478bd9Sstevel@tonic-gate fixline(tty, spwant, type) 4867c478bd9Sstevel@tonic-gate int tty, spwant, type; 4877c478bd9Sstevel@tonic-gate { 4887c478bd9Sstevel@tonic-gate struct sgttyb ttbuf; 4897c478bd9Sstevel@tonic-gate struct sg_spds *ps; 4907c478bd9Sstevel@tonic-gate int speed = -1; 4917c478bd9Sstevel@tonic-gate 4927c478bd9Sstevel@tonic-gate DEBUG(6, "fixline(%d, ", tty); 4937c478bd9Sstevel@tonic-gate DEBUG(6, "%d)\n", spwant); 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate if ((*Ioctl)(tty, TIOCGETP, &ttbuf) != 0) 4967c478bd9Sstevel@tonic-gate return; 4977c478bd9Sstevel@tonic-gate if (spwant > 0) { 4987c478bd9Sstevel@tonic-gate for (ps = spds; ps->sp_val; ps++) 4997c478bd9Sstevel@tonic-gate if (ps->sp_val == spwant) { 5007c478bd9Sstevel@tonic-gate speed = ps->sp_name; 5017c478bd9Sstevel@tonic-gate break; 5027c478bd9Sstevel@tonic-gate } 5037c478bd9Sstevel@tonic-gate ASSERT(speed >= 0, "BAD SPEED", "", spwant); 5047c478bd9Sstevel@tonic-gate ttbuf.sg_ispeed = ttbuf.sg_ospeed = speed; 5057c478bd9Sstevel@tonic-gate } else { 5067c478bd9Sstevel@tonic-gate for (ps = spds; ps->sp_val; ps++) 5077c478bd9Sstevel@tonic-gate if (ps->sp_name == ttbuf.sg_ispeed) { 5087c478bd9Sstevel@tonic-gate spwant = ps->sp_val; 5097c478bd9Sstevel@tonic-gate break; 5107c478bd9Sstevel@tonic-gate } 5117c478bd9Sstevel@tonic-gate ASSERT(spwant >= 0, "BAD SPEED", "", ttbuf.sg_ispeed); 5127c478bd9Sstevel@tonic-gate } 5137c478bd9Sstevel@tonic-gate ttbuf.sg_flags = (ANYP | RAW); 5147c478bd9Sstevel@tonic-gate #ifdef PKSPEEDUP 5157c478bd9Sstevel@tonic-gate linebaudrate = spwant; 5167c478bd9Sstevel@tonic-gate #endif /* PKSPEEDUP */ 5177c478bd9Sstevel@tonic-gate (void) (*Ioctl)(tty, TIOCSETP, &ttbuf); 5187c478bd9Sstevel@tonic-gate (void) (*Ioctl)(tty, TIOCHPCL, STBNULL); 5197c478bd9Sstevel@tonic-gate (void) (*Ioctl)(tty, TIOCEXCL, STBNULL); 5207c478bd9Sstevel@tonic-gate return; 5217c478bd9Sstevel@tonic-gate } 5227c478bd9Sstevel@tonic-gate 5237c478bd9Sstevel@tonic-gate GLOBAL void 5247c478bd9Sstevel@tonic-gate sethup(dcf) 5257c478bd9Sstevel@tonic-gate int dcf; 5267c478bd9Sstevel@tonic-gate { 5277c478bd9Sstevel@tonic-gate if (isatty(dcf)) 5287c478bd9Sstevel@tonic-gate (void) (*Ioctl)(dcf, TIOCHPCL, STBNULL); 5297c478bd9Sstevel@tonic-gate return; 5307c478bd9Sstevel@tonic-gate } 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate /* 5337c478bd9Sstevel@tonic-gate * genbrk send a break 5347c478bd9Sstevel@tonic-gate * 5357c478bd9Sstevel@tonic-gate * return codes; none 5367c478bd9Sstevel@tonic-gate */ 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate GLOBAL void 5397c478bd9Sstevel@tonic-gate ttygenbrk(fn) 5407c478bd9Sstevel@tonic-gate { 5417c478bd9Sstevel@tonic-gate if (isatty(fn)) { 5427c478bd9Sstevel@tonic-gate (void) (*Ioctl)(fn, TIOCSBRK, 0); 5437c478bd9Sstevel@tonic-gate #ifndef V8 5447c478bd9Sstevel@tonic-gate nap(HZ/10); /* 0.1 second break */ 5457c478bd9Sstevel@tonic-gate (void) (*Ioctl)(fn, TIOCCBRK, 0); 5467c478bd9Sstevel@tonic-gate #endif 5477c478bd9Sstevel@tonic-gate } 5487c478bd9Sstevel@tonic-gate return; 5497c478bd9Sstevel@tonic-gate } 5507c478bd9Sstevel@tonic-gate 5517c478bd9Sstevel@tonic-gate /* 5527c478bd9Sstevel@tonic-gate * V7 and RT aren't smart enough for this -- linebaudrate is the best 5537c478bd9Sstevel@tonic-gate * they can do. 5547c478bd9Sstevel@tonic-gate */ 5557c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 5567c478bd9Sstevel@tonic-gate GLOBAL void 5577c478bd9Sstevel@tonic-gate setline(dummy) { } 5587c478bd9Sstevel@tonic-gate 5597c478bd9Sstevel@tonic-gate GLOBAL int 5607c478bd9Sstevel@tonic-gate savline() 5617c478bd9Sstevel@tonic-gate { 5627c478bd9Sstevel@tonic-gate if ( (*Ioctl)(0, TIOCGETP, &Savettyb) != 0 ) 5637c478bd9Sstevel@tonic-gate Saved_line = FALSE; 5647c478bd9Sstevel@tonic-gate else { 5657c478bd9Sstevel@tonic-gate Saved_line = TRUE; 5667c478bd9Sstevel@tonic-gate Savettyb.sg_flags |= ECHO; 5677c478bd9Sstevel@tonic-gate Savettyb.sg_flags &= ~RAW; 5687c478bd9Sstevel@tonic-gate } 5697c478bd9Sstevel@tonic-gate return(0); 5707c478bd9Sstevel@tonic-gate } 5717c478bd9Sstevel@tonic-gate 5727c478bd9Sstevel@tonic-gate GLOBAL int 5737c478bd9Sstevel@tonic-gate restline() 5747c478bd9Sstevel@tonic-gate { 5757c478bd9Sstevel@tonic-gate if ( Saved_line == TRUE ) 5767c478bd9Sstevel@tonic-gate return((*Ioctl)(0, TIOCSETP, &Savettyb)); 5777c478bd9Sstevel@tonic-gate return(0); 5787c478bd9Sstevel@tonic-gate } 5797c478bd9Sstevel@tonic-gate #endif 580