Convert to termios (from Scott Reynolds; PR#1621).
8-bit patches (from Matthieu Herrb; PR#1384).
-/* $NetBSD: biz22.c,v 1.3 1994/12/08 09:31:31 jtc Exp $ */
+/* $NetBSD: biz22.c,v 1.4 1995/10/29 00:49:47 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: biz22.c,v 1.3 1994/12/08 09:31:31 jtc Exp $";
+static char rcsid[] = "$NetBSD: biz22.c,v 1.4 1995/10/29 00:49:47 pk Exp $";
#endif /* not lint */
#include "tip.h"
write(FD, DISCONNECT_CMD, 4);
sleep(2);
- ioctl(FD, TIOCFLUSH, &rw);
+ tcflush(FD, TCIOFLUSH);
}
biz22_abort()
-/* $NetBSD: biz31.c,v 1.3 1994/12/08 09:31:33 jtc Exp $ */
+/* $NetBSD: biz31.c,v 1.4 1995/10/29 00:49:48 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: biz31.c,v 1.3 1994/12/08 09:31:33 jtc Exp $";
+static char rcsid[] = "$NetBSD: biz31.c,v 1.4 1995/10/29 00:49:48 pk Exp $";
#endif /* not lint */
#include "tip.h"
write(FD, DISCONNECT_CMD, 4);
sleep(2);
- ioctl(FD, TIOCFLUSH);
+ tcflush(FD, TCIOFLUSH);
}
biz31_abort()
retry:
if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0 && chars(b) > 0)
- ioctl(fd, TIOCFLUSH);
+ tcflush(FD, TCIOFLUSH);
write(fd, "\rp>\r", 4);
sleep(1);
if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0) {
-/* $NetBSD: courier.c,v 1.4 1994/12/08 09:31:35 jtc Exp $ */
+/* $NetBSD: courier.c,v 1.5 1995/10/29 00:49:50 pk Exp $ */
/*
* Copyright (c) 1986, 1993
#if 0
static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: courier.c,v 1.4 1994/12/08 09:31:35 jtc Exp $";
+static char rcsid[] = "$NetBSD: courier.c,v 1.5 1995/10/29 00:49:50 pk Exp $";
#endif /* not lint */
/*
* Derived from Hayes driver.
*/
#include "tip.h"
+#include <sys/ioctl.h>
#include <stdio.h>
#define MAXRETRY 5
#ifdef ACULOG
char line[80];
#endif
+ struct termios cntrl;
static int cour_connect(), cour_swallow();
if (boolean(value(VERBOSE)))
printf("Using \"%s\"\n", acu);
- ioctl(FD, TIOCHPCL, 0);
+ tcgetattr(FD, &cntrl);
+ cntrl.c_cflag |= HUPCL;
+ tcsetattr(FD, TCSAFLUSH, &cntrl);
/*
* Get in synch.
*/
if (boolean(value(VERBOSE)))
cour_verbose_read();
#endif
- ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */
+ tcflush(FD, TCIOFLUSH);
cour_write(FD, "AT C1 E0 H0 Q0 X6 V1\r", 21);
if (!cour_swallow("\r\nOK\r\n"))
goto badsynch;
{
char c;
int nc, nl, n;
- struct sgttyb sb;
char dialer_buf[64];
struct baud_msg *bm;
sig_t f;
for (bm = baud_msg ; bm->msg ; bm++)
if (strcmp(bm->msg,
dialer_buf+sizeof("CONNECT")-1) == 0) {
- if (ioctl(FD, TIOCGETP, &sb) < 0) {
- perror("TIOCGETP");
- goto error;
- }
- sb.sg_ispeed = sb.sg_ospeed = bm->baud;
- if (ioctl(FD, TIOCSETP, &sb) < 0) {
- perror("TIOCSETP");
- goto error;
- }
+ struct termios cntrl;
+
+ tcgetattr(FD, &cntrl);
+ cfsetospeed(&cntrl, bm->baud);
+ cfsetispeed(&cntrl, bm->baud);
+ tcsetattr(FD, TCSAFLUSH, &cntrl);
signal(SIGALRM, f);
#ifdef DEBUG
if (boolean(value(VERBOSE)))
char buf[40];
while (already++ < MAXRETRY) {
- ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */
+ tcflush(FD, TCIOFLUSH);
cour_write(FD, "\rAT Z\r", 6); /* reset modem */
bzero(buf, sizeof(buf));
sleep(1);
char *cp;
int n;
{
- struct sgttyb sb;
#ifdef notdef
if (boolean(value(VERBOSE)))
write(1, cp, n);
#endif
- ioctl(fd, TIOCGETP, &sb);
- ioctl(fd, TIOCSETP, &sb);
+ tcdrain(fd);
cour_nap();
for ( ; n-- ; cp++) {
write(fd, cp, 1);
- ioctl(fd, TIOCGETP, &sb);
- ioctl(fd, TIOCSETP, &sb);
+ tcdrain(fd);
cour_nap();
}
}
-/* $NetBSD: df.c,v 1.3 1994/12/08 09:31:38 jtc Exp $ */
+/* $NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)df.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: df.c,v 1.3 1994/12/08 09:31:38 jtc Exp $";
+static char rcsid[] = "$NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $";
#endif /* not lint */
/*
int df03;
{
register int f = FD;
- struct sgttyb buf;
+ struct termios cntrl;
int speed = 0, rw = 2;
char c = '\0';
- ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */
+ tcgetattr(f, &cntrl);
+ cntrl.c_cflag |= HUPCL;
+ tcsetattr(f, TCSANOW, &cntrl);
if (setjmp(Sjbuf)) {
printf("connection timed out\r\n");
df_disconnect();
if (df03) {
int st = TIOCM_ST; /* secondary Transmit flag */
- ioctl(f, TIOCGETP, &buf);
- if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */
- speed = buf.sg_ospeed;
- buf.sg_ospeed = buf.sg_ispeed = B1200;
- ioctl(f, TIOCSETP, &buf);
+ tcgetattr(f, &cntrl);
+ speed = cfgetospeed(&cntrl);
+ if (speed != B1200) { /* must dial at 1200 baud */
+ cfsetospeed(&cntrl, B1200);
+ cfsetispeed(&cntrl, B1200);
+ tcsetattr(f, TCSAFLUSH, &cntrl);
ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
} else
ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
#endif
signal(SIGALRM, timeout);
alarm(5 * strlen(num) + 10);
- ioctl(f, TIOCFLUSH, &rw);
+ tcflush(f, TCIOFLUSH);
write(f, "\001", 1);
sleep(1);
write(f, "\002", 1);
write(f, num, strlen(num));
read(f, &c, 1);
#ifdef TIOCMSET
- if (df03 && speed) {
- buf.sg_ispeed = buf.sg_ospeed = speed;
- ioctl(f, TIOCSETP, &buf);
+ if (df03 && speed != B1200) {
+ cfsetospeed(&cntrl, speed);
+ cfsetispeed(&cntrl, speed);
+ tcsetattr(f, TCSAFLUSH, &cntrl);
}
#endif
return (c == 'A');
write(FD, "\001", 1);
sleep(1);
- ioctl(FD, TIOCFLUSH, &rw);
+ tcflush(FD, TCIOFLUSH);
}
-/* $NetBSD: dn11.c,v 1.3 1994/12/08 09:31:40 jtc Exp $ */
+/* $NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)dn11.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: dn11.c,v 1.3 1994/12/08 09:31:40 jtc Exp $";
+static char rcsid[] = "$NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $";
#endif /* not lint */
/*
char *p, *q, phone[40];
int lt, nw, connected = 1;
register int timelim;
+ struct termios cntrl;
if (boolean(value(VERBOSE)))
printf("\nstarting call...");
return (0);
}
alarm(0);
- ioctl(dn, TIOCHPCL, 0);
+ tcgetattr(dn, &cntrl);
+ cntrl.c_cflag |= HUPCL;
+ tcsetattr(dn, TCSANOW, &cntrl);
signal(SIGALRM, SIG_DFL);
while ((nw = wait(<)) != child && nw != -1)
;
-/* $NetBSD: hayes.c,v 1.3 1994/12/08 09:31:42 jtc Exp $ */
+/* $NetBSD: hayes.c,v 1.4 1995/10/29 00:49:54 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: hayes.c,v 1.3 1994/12/08 09:31:42 jtc Exp $";
+static char rcsid[] = "$NetBSD: hayes.c,v 1.4 1995/10/29 00:49:54 pk Exp $";
#endif /* not lint */
/*
*/
#include "tip.h"
+#include <termios.h>
+#include <sys/ioctl.h>
+
#define min(a,b) ((a < b) ? a : b)
static void sigALRM();
register char *cp;
register int connected = 0;
char dummy;
+ struct termios cntrl;
#ifdef ACULOG
char line[80];
#endif
if (boolean(value(VERBOSE)))
printf("\ndialing...");
fflush(stdout);
- ioctl(FD, TIOCHPCL, 0);
- ioctl(FD, TIOCFLUSH, 0); /* get rid of garbage */
+ tcgetattr(FD, &cntrl);
+ cntrl.c_cflag |= HUPCL;
+ tcsetattr(FD, TCSANOW, &cntrl);
+ tcflush(FD, TCIOFLUSH);
write(FD, "ATv0\r", 5); /* tell modem to use short status codes */
gobble("\r");
gobble("\r");
state = FAILED;
return (connected); /* lets get out of here.. */
}
- ioctl(FD, TIOCFLUSH, 0);
+ tcflush(FD, TCIOFLUSH);
#ifdef ACULOG
if (timeout) {
sprintf(line, "%d second dial timeout",
int len, rlen;
char c;
- ioctl(FD, TIOCFLUSH, &len); /* get rid of trash */
+ tcflush(FD, TCIOFLUSH);
if (hay_sync()) {
sleep(1);
#ifndef DEBUG
- ioctl(FD, TIOCFLUSH, 0);
+ tcflush(FD, TCIOFLUSH);
#endif
write(FD, "ATH0\r", 5); /* insurance */
#ifndef DEBUG
printf("read (%d): %s\r\n", rlen, dumbuf);
#endif
}
- ioctl(FD, TIOCFLUSH, 0); /* clear the input buffer */
+ tcflush(FD, TCIOFLUSH);
ioctl(FD, TIOCCDTR, 0); /* clear DTR (insurance) */
close(FD);
}
-/* $NetBSD: t3000.c,v 1.2 1994/12/08 09:31:45 jtc Exp $ */
+/* $NetBSD: t3000.c,v 1.3 1995/10/29 00:49:57 pk Exp $ */
/*
* Copyright (c) 1992, 1993
#if 0
static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: t3000.c,v 1.2 1994/12/08 09:31:45 jtc Exp $";
+static char rcsid[] = "$NetBSD: t3000.c,v 1.3 1995/10/29 00:49:57 pk Exp $";
#endif /* not lint */
/*
* Derived from Courier driver.
*/
#include "tip.h"
+
+#include <sys/ioctl.h>
#include <stdio.h>
#define MAXRETRY 5
char *acu;
{
register char *cp;
+ struct termios cntrl;
#ifdef ACULOG
char line[80];
#endif
if (boolean(value(VERBOSE)))
printf("Using \"%s\"\n", acu);
- ioctl(FD, TIOCHPCL, 0);
+ tcgetattr(FD, &cntrl);
+ cntrl.c_cflag |= HUPCL;
+ tcsetattr(FD, TCSANOW, &cntrl);
/*
* Get in synch.
*/
if (boolean(value(VERBOSE)))
t3000_verbose_read();
#endif
- ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */
+ tcflush(FD, TCIOFLUSH);
t3000_write(FD, "AT E0 H0 Q0 X4 V1\r", 18);
if (!t3000_swallow("\r\nOK\r\n"))
goto badsynch;
{
char c;
int nc, nl, n;
- struct sgttyb sb;
char dialer_buf[64];
struct tbaud_msg *bm;
sig_t f;
for (bm = tbaud_msg ; bm->msg ; bm++)
if (strcmp(bm->msg,
dialer_buf+sizeof("CONNECT")-1) == 0) {
- if (ioctl(FD, TIOCGETP, &sb) < 0) {
- perror("TIOCGETP");
- goto error;
- }
- sb.sg_ispeed = sb.sg_ospeed = bm->baud;
- if (ioctl(FD, TIOCSETP, &sb) < 0) {
- if (bm->baud2) {
- sb.sg_ispeed =
- sb.sg_ospeed =
- bm->baud2;
- if (ioctl(FD,
- TIOCSETP,
- &sb) >= 0)
- goto isok;
- }
- perror("TIOCSETP");
- goto error;
- }
-isok:
+ struct termios cntrl;
+
+ tcgetattr(FD, &cntrl);
+ cfsetospeed(&cntrl, bm->baud);
+ cfsetispeed(&cntrl, bm->baud);
+ tcsetattr(FD, TCSAFLUSH, &cntrl);
signal(SIGALRM, f);
#ifdef DEBUG
if (boolean(value(VERBOSE)))
char buf[40];
while (already++ < MAXRETRY) {
- ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */
+ tcflush(FD, TCIOFLUSH);
t3000_write(FD, "\rAT Z\r", 6); /* reset modem */
bzero(buf, sizeof(buf));
sleep(2);
char *cp;
int n;
{
- struct sgttyb sb;
-
#ifdef notdef
if (boolean(value(VERBOSE)))
write(1, cp, n);
#endif
- ioctl(fd, TIOCGETP, &sb);
- ioctl(fd, TIOCSETP, &sb);
+ tcdrain(fd);
t3000_nap();
for ( ; n-- ; cp++) {
write(fd, cp, 1);
- ioctl(fd, TIOCGETP, &sb);
- ioctl(fd, TIOCSETP, &sb);
+ tcdrain(fd);
t3000_nap();
}
}
-/* $NetBSD: v3451.c,v 1.3 1994/12/08 09:31:48 jtc Exp $ */
+/* $NetBSD: v3451.c,v 1.4 1995/10/29 00:49:59 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)v3451.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: v3451.c,v 1.3 1994/12/08 09:31:48 jtc Exp $";
+static char rcsid[] = "$NetBSD: v3451.c,v 1.4 1995/10/29 00:49:59 pk Exp $";
#endif /* not lint */
/*
int ok;
int slow = number(value(BAUDRATE)) < 1200, rw = 2;
char phone[50];
+ struct termios cntrl;
#ifdef ACULOG
char line[80];
#endif
#endif
return (0);
}
- ioctl(FD, TIOCHPCL, 0);
+ tcgetattr(FD, &cntrl);
+ term.c_cflag |= HUPCL;
+ tcsetattr(FD, TCSANOW, &cntrl);
sleep(1);
vawrite("D\r", 2 + slow);
if (!expect("NUMBER?")) {
#endif
return (0);
}
- ioctl(FD, TIOCFLUSH, &rw);
+ tcflush(FD, TCIOFLUSH);
return (1);
}
-/* $NetBSD: v831.c,v 1.3 1994/12/08 09:31:50 jtc Exp $ */
+/* $NetBSD: v831.c,v 1.4 1995/10/29 00:50:02 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)v831.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: v831.c,v 1.3 1994/12/08 09:31:50 jtc Exp $";
+static char rcsid[] = "$NetBSD: v831.c,v 1.4 1995/10/29 00:50:02 pk Exp $";
#endif /* not lint */
/*
* Routines for dialing up on Vadic 831
*/
#include "tip.h"
+#include <termios.h>
int v831_abort();
static void alarmtr();
return (0);
}
alarm(0);
-#ifdef notdef
- ioctl(AC, TIOCHPCL, 0);
-#endif
signal(SIGALRM, SIG_DFL);
while ((pid = wait(&status)) != child && pid != -1)
;
*/
v831_disconnect()
{
- struct sgttyb cntrl;
+ struct termios cntrl;
sleep(2);
#ifdef DEBUG
#endif
if (FD > 0) {
ioctl(FD, TIOCCDTR, 0);
- ioctl(FD, TIOCGETP, &cntrl);
- cntrl.sg_ispeed = cntrl.sg_ospeed = 0;
- ioctl(FD, TIOCSETP, &cntrl);
- ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL);
+ tcgetattr(FD, &cntrl);
+ cfsetospeed(&cntrl, 0);
+ cfsetispeed(&cntrl, 0);
+ tcsetattr(FD, TCSAFLUSH, &cntrl);
+ ioctl(FD, TIOCNXCL, NULL);
}
close(FD);
}
if (child > 0)
kill(child, SIGKILL);
if (AC > 0)
- ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL);
+ ioctl(FD, TIOCNXCL, NULL);
close(AC);
if (FD > 0)
ioctl(FD, TIOCCDTR, 0);
char *acu;
{
register struct vaconfig *vp;
- struct sgttyb cntrl;
+ struct termios cntrl;
char c;
int i, two = 2;
static char *sanitize();
printf("Unable to locate dialer (%s)\n", acu);
return ('K');
}
- ioctl(AC, TIOCGETP, &cntrl);
- cntrl.sg_ispeed = cntrl.sg_ospeed = B2400;
- cntrl.sg_flags = RAW | EVENP | ODDP;
- ioctl(AC, TIOCSETP, &cntrl);
- ioctl(AC, TIOCFLUSH, &two);
+ tcgetattr(AC, &cntrl);
+ cfsetospeed(&cntrl, B2400);
+ cfsetispeed(&cntrl, B2400);
+ cntrl.c_cflag |= PARODD | PARENB;
+ cntrl.c_lflag &= ~(ISIG | ICANON);
+ tcsetattr(AC, TCSANOW, &cntrl);
+ tcflush(AC, TCIOFLUSH);
pc(STX);
pc(vp->vc_rack);
pc(vp->vc_modem);
-/* $NetBSD: ventel.c,v 1.3 1994/12/08 09:31:52 jtc Exp $ */
+/* $NetBSD: ventel.c,v 1.4 1995/10/29 00:50:04 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: ventel.c,v 1.3 1994/12/08 09:31:52 jtc Exp $";
+static char rcsid[] = "$NetBSD: ventel.c,v 1.4 1995/10/29 00:50:04 pk Exp $";
#endif /* not lint */
/*
* The Ventel is expected to be strapped for local echo (just like uucp)
*/
#include "tip.h"
+#include <termios.h>
+#include <sys/ioctl.h>
#define MAXRETRY 5
char *msg, *index(), line[80];
static int gobble(), vensync();
static void echo();
+ struct termios cntrl;
/*
* Get in synch with a couple of carriage returns
if (boolean(value(VERBOSE)))
printf("\ndialing...");
fflush(stdout);
- ioctl(FD, TIOCHPCL, 0);
+ tcgetattr(FD, &cntrl);
+ cntrl.c_cflag |= HUPCL;
+ tcsetattr(FD, TCSANOW, &cntrl);
echo("#k$\r$\n$D$I$A$L$:$ ");
for (cp = num; *cp; cp++) {
delay(1, 10);
gobble('\n', line);
if (gobble('\n', line))
connected = gobble('!', line);
- ioctl(FD, TIOCFLUSH);
+ tcflush(FD, TCIOFLUSH);
#ifdef ACULOG
if (timeout) {
sprintf(line, "%d second dial timeout",
-/* $NetBSD: cmds.c,v 1.5 1995/09/26 06:02:08 jtc Exp $ */
+/* $NetBSD: cmds.c,v 1.6 1995/10/29 00:49:38 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: cmds.c,v 1.5 1995/09/26 06:02:08 jtc Exp $";
+static char rcsid[] = "$NetBSD: cmds.c,v 1.6 1995/10/29 00:49:38 pk Exp $";
#endif /* not lint */
#include "tip.h"
pwrite(FD, &r, 1);
do
read(FD, &c, 1);
- while ((c&0177) != '\n');
- ioctl(0, TIOCSETC, &defchars);
+ while ((c&STRIP_PAR) != '\n');
+ tcsetattr(0, TCSAFLUSH, &defchars);
(void) setjmp(intbuf);
f = signal(SIGINT, intcopy);
start = time(0);
for (ct = 0; !quit;) {
eof = read(FD, &c, 1) <= 0;
- c &= 0177;
+ c &= STRIP_PAR;
if (quit)
continue;
if (eof || any(c, eofchars))
if (boolean(value(VERBOSE)))
prtime(" lines transferred in ", time(0)-start);
- ioctl(0, TIOCSETC, &tchars);
+ tcsetattr(0, TCSAFLUSH, &term);
write(fildes[1], (char *)&ccc, 1);
signal(SIGINT, f);
close(fd);
return;
}
transmit(fd, value(EOFWRITE), NULL);
- if (!boolean(value(ECHOCHECK))) {
- struct sgttyb buf;
-
- ioctl(FD, TIOCGETP, &buf); /* this does a */
- ioctl(FD, TIOCSETP, &buf); /* wflushtty */
- }
+ if (!boolean(value(ECHOCHECK)))
+ tcdrain(FD);
}
/*
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
stop = 0;
f = signal(SIGINT, stopsnd);
- ioctl(0, TIOCSETC, &defchars);
+ tcsetattr(0, TCSAFLUSH, &defchars);
read(repdes[0], (char *)&ccc, 1);
if (command != NULL) {
for (pc = command; *pc; pc++)
if (boolean(value(ECHOCHECK)))
read(FD, (char *)&c, 1); /* trailing \n */
else {
- struct sgttyb buf;
-
- ioctl(FD, TIOCGETP, &buf); /* this does a */
- ioctl(FD, TIOCSETP, &buf); /* wflushtty */
+ tcdrain(FD);
sleep(5); /* wait for remote stty to take effect */
}
}
alarm(0);
goto out;
}
- } while ((c&0177) != character(value(PROMPT)));
+ } while ((c&STRIP_PAR) != character(value(PROMPT)));
alarm(0);
}
}
else
prtime(" lines transferred in ", stop_t-start_t);
write(fildes[1], (char *)&ccc, 1);
- ioctl(0, TIOCSETC, &tchars);
+ tcsetattr(0, TCSAFLUSH, &term);
}
/*
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
- ioctl(0, TIOCSETC, &defchars);
+ tcsetattr(0, TCSAFLUSH, &defchars);
read(repdes[0], (char *)&ccc, 1);
/*
* Set up file descriptors in the child and
if (boolean(value(VERBOSE)))
prtime("away for ", time(0)-start);
write(fildes[1], (char *)&ccc, 1);
- ioctl(0, TIOCSETC, &tchars);
+ tcsetattr(0, TCSAFLUSH, &term);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
}
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
- ioctl(0, TIOCSETC, &defchars);
+ tcsetattr(0, TCSAFLUSH, &defchars);
read(repdes[0], (char *)&ccc, 1);
/*
* Set up file descriptors in the child and
if (boolean(value(VERBOSE)))
prtime("away for ", time(0)-start);
write(fildes[1], (char *)&ccc, 1);
- ioctl(0, TIOCSETC, &tchars);
+ tcsetattr(0, TCSAFLUSH, &term);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
}
tandem(option)
char *option;
{
- struct sgttyb rmtty;
+ struct termios rmtty;
- ioctl(FD, TIOCGETP, &rmtty);
- if (strcmp(option,"on") == 0) {
- rmtty.sg_flags |= TANDEM;
- arg.sg_flags |= TANDEM;
+ tcgetattr(FD, &rmtty);
+ if (strcmp(option, "on") == 0) {
+ rmtty.c_iflag |= IXOFF;
+ term.c_iflag |= IXOFF;
} else {
- rmtty.sg_flags &= ~TANDEM;
- arg.sg_flags &= ~TANDEM;
+ rmtty.c_iflag &= ~IXOFF;
+ term.c_iflag &= ~IXOFF;
}
- ioctl(FD, TIOCSETP, &rmtty);
- ioctl(0, TIOCSETP, &arg);
+ tcsetattr(FD, TCSADRAIN, &rmtty);
+ tcsetattr(0, TCSADRAIN, &term);
}
/*
-/* $NetBSD: hunt.c,v 1.4 1994/12/24 17:56:27 cgd Exp $ */
+/* $NetBSD: hunt.c,v 1.5 1995/10/29 00:49:40 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: hunt.c,v 1.4 1994/12/24 17:56:27 cgd Exp $";
+static char rcsid[] = "$NetBSD: hunt.c,v 1.5 1995/10/29 00:49:40 pk Exp $";
#endif /* not lint */
#include "tip.h"
deadfl = 1;
}
if (!deadfl) {
+ struct termios cntrl;
+
+ tcgetattr(FD, &cntrl);
+ cntrl.c_cflag |= HUPCL;
+ tcsetattr(FD, TCSAFLUSH, &cntrl);
ioctl(FD, TIOCEXCL, 0);
- ioctl(FD, TIOCHPCL, 0);
signal(SIGALRM, SIG_DFL);
return ((long)cp);
}
-/* $NetBSD: tip.c,v 1.7 1995/08/11 00:10:40 jtc Exp $ */
+/* $NetBSD: tip.c,v 1.8 1995/10/29 00:49:42 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: tip.c,v 1.7 1995/08/11 00:10:40 jtc Exp $";
+static char rcsid[] = "$NetBSD: tip.c,v 1.8 1995/10/29 00:49:42 pk Exp $";
#endif /* not lint */
/*
/*
* Baud rate mapping table
*/
-int bauds[] = {
+int rates[] = {
0, 50, 75, 110, 134, 150, 200, 300, 600,
1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, -1
};
-int disc = OTTYDISC; /* tip normally runs this way */
+int disc = TTYDISC; /* tip normally runs this way */
void intprompt();
void timeout();
void cleanup();
PH = _PATH_PHONES;
vinit(); /* init variables */
setparity("even"); /* set the parity table */
- if ((i = speed(number(value(BAUDRATE)))) == NULL) {
+ if ((i = speed(number(value(BAUDRATE)))) == 0) {
printf("tip: bad baud rate %d\n", number(value(BAUDRATE)));
daemon_uid();
(void)uu_unlock(uucplock);
* the "cu" version of tip.
*/
- ioctl(0, TIOCGETP, (char *)&defarg);
- ioctl(0, TIOCGETC, (char *)&defchars);
- ioctl(0, TIOCGLTC, (char *)&deflchars);
- ioctl(0, TIOCGETD, (char *)&odisc);
- arg = defarg;
- arg.sg_flags = ANYP | CBREAK;
- tchars = defchars;
- tchars.t_intrc = tchars.t_quitc = -1;
- ltchars = deflchars;
- ltchars.t_suspc = ltchars.t_dsuspc = ltchars.t_flushc
- = ltchars.t_lnextc = -1;
+ tcgetattr(0, &defterm);
+ term = defterm;
+ term.c_lflag &= ~(ICANON|IEXTEN|ECHO);
+ term.c_iflag &= ~(INPCK|ICRNL);
+ term.c_oflag &= ~OPOST;
+ term.c_cc[VMIN] = 1;
+ term.c_cc[VTIME] = 0;
+ defchars = term;
+ term.c_cc[VINTR] = term.c_cc[VQUIT] = term.c_cc[VSUSP] =
+ term.c_cc[VDSUSP] = term.c_cc[VDISCARD] =
+ term.c_cc[VLNEXT] = _POSIX_VDISABLE;
raw();
pipe(fildes); pipe(repdes);
*/
raw()
{
-
- ioctl(0, TIOCSETP, &arg);
- ioctl(0, TIOCSETC, &tchars);
- ioctl(0, TIOCSLTC, <chars);
- ioctl(0, TIOCSETD, (char *)&disc);
+ tcsetattr(0, TCSADRAIN, &term);
}
*/
unraw()
{
-
- ioctl(0, TIOCSETD, (char *)&odisc);
- ioctl(0, TIOCSETP, (char *)&defarg);
- ioctl(0, TIOCSETC, (char *)&defchars);
- ioctl(0, TIOCSLTC, (char *)&deflchars);
+ tcsetattr(0, TCSADRAIN, &defterm);
}
static jmp_buf promptbuf;
}
while (1) {
- gch = getchar()&0177;
+ gch = getchar()&STRIP_PAR;
if ((gch == character(value(ESCAPE))) && bol) {
if (!(gch = escape()))
continue;
printf("\r\n");
continue;
} else if (!cumode && gch == character(value(FORCE)))
- gch = getchar()&0177;
+ gch = getchar()&STRIP_PAR;
bol = any(gch, value(EOL));
if (boolean(value(RAISE)) && islower(gch))
gch = toupper(gch);
register esctable_t *p;
char c = character(value(ESCAPE));
- gch = (getchar()&0177);
+ gch = (getchar()&STRIP_PAR);
for (p = etable; p->e_char; p++)
if (p->e_char == gch) {
if ((p->e_flags&PRIV) && uid)
{
register int *p;
- for (p = bauds; *p != -1; p++)
+ for (p = rates; *p != -1; p++)
if (*p == n)
- return (p - bauds);
- return (NULL);
+ return n;
+ return 0;
}
any(c, p)
ttysetup(speed)
int speed;
{
- unsigned bits = LDECCTQ;
-
- arg.sg_ispeed = arg.sg_ospeed = speed;
- arg.sg_flags = RAW;
+ struct termios cntrl;
+
+ tcgetattr(FD, &cntrl);
+ cfsetospeed(&cntrl, speed);
+ cfsetispeed(&cntrl, speed);
+ cntrl.c_cflag &= ~(CSIZE|PARENB);
+ cntrl.c_cflag |= CS8;
+ cntrl.c_iflag &= ~(ISTRIP|ICRNL);
+ cntrl.c_oflag &= ~OPOST;
+ cntrl.c_lflag &= ~(ICANON|ISIG|IEXTEN|ECHO);
+ cntrl.c_cc[VMIN] = 1;
+ cntrl.c_cc[VTIME] = 0;
if (boolean(value(TAND)))
- arg.sg_flags |= TANDEM;
- ioctl(FD, TIOCSETP, (char *)&arg);
- ioctl(FD, TIOCLBIS, (char *)&bits);
+ cntrl.c_iflag |= IXOFF;
+ tcsetattr(FD, TCSAFLUSH, &cntrl);
}
/*
}
static char partab[0200];
-static int bits8;
/*
* Do a write to the remote machine with the correct parity.
-/* $NetBSD: tip.h,v 1.3 1994/12/08 09:31:10 jtc Exp $ */
+/* $NetBSD: tip.h,v 1.4 1995/10/29 00:49:43 pk Exp $ */
/*
* Copyright (c) 1989, 1993
#include <sys/file.h>
#include <sys/time.h>
-#include <sgtty.h>
+#include <termios.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#define NOFILE ((FILE *)NULL)
#define NOPWD ((struct passwd *)0)
-struct sgttyb arg; /* current mode of local terminal */
-struct sgttyb defarg; /* initial mode of local terminal */
-struct tchars tchars; /* current state of terminal */
-struct tchars defchars; /* initial state of terminal */
-struct ltchars ltchars; /* current local characters of terminal */
-struct ltchars deflchars; /* initial local characters of terminal */
+struct termios term; /* current mode of terminal */
+struct termios defterm; /* initial mode of terminal */
+struct termios defchars; /* current mode with initial chars */
FILE *fscript; /* FILE for scripting */
int stoprompt; /* for interrupting a prompt session */
int timedout; /* ~> transfer timedout */
int cumode; /* simulating the "cu" program */
+int bits8; /* terminal is is 8-bit mode */
+#define STRIP_PAR (bits8 ? 0377 : 0177)
char fname[80]; /* file name buffer for ~< */
char copyname[80]; /* file name buffer for ~> */
-/* $NetBSD: tipout.c,v 1.3 1994/12/08 09:31:12 jtc Exp $ */
+/* $NetBSD: tipout.c,v 1.4 1995/10/29 00:49:45 pk Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: tipout.c,v 1.3 1994/12/08 09:31:12 jtc Exp $";
+static char rcsid[] = "$NetBSD: tipout.c,v 1.4 1995/10/29 00:49:45 pk Exp $";
#endif /* not lint */
#include "tip.h"
#define ALLSIGS sigmask(SIGEMT)|sigmask(SIGTERM)|sigmask(SIGIOT)|sigmask(SIGSYS)
omask = sigblock(ALLSIGS);
for (cp = buf; cp < buf + cnt; cp++)
- *cp &= 0177;
+ *cp &= STRIP_PAR;
write(1, buf, cnt);
if (boolean(value(SCRIPT)) && fscript != NULL) {
if (!boolean(value(BEAUTIFY))) {