summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tip/cu.c25
-rw-r--r--usr.bin/tip/tip.c59
-rw-r--r--usr.bin/tip/tip.h5
3 files changed, 40 insertions, 49 deletions
diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c
index adc990d908a..e815d0a958b 100644
--- a/usr.bin/tip/cu.c
+++ b/usr.bin/tip/cu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cu.c,v 1.12 2002/05/07 06:56:50 hugh Exp $ */
+/* $OpenBSD: cu.c,v 1.13 2002/05/29 22:58:56 millert Exp $ */
/* $NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: cu.c,v 1.12 2002/05/07 06:56:50 hugh Exp $";
+static const char rcsid[] = "$OpenBSD: cu.c,v 1.13 2002/05/29 22:58:56 millert Exp $";
#endif /* not lint */
#include "tip.h"
@@ -83,8 +83,7 @@ cumain(argc, argv)
break;
case 's':
l = strtol(optarg, &cp, 10);
- if (*cp != '\0' || l < 0 || l >= INT_MAX ||
- speed((int)l) == 0) {
+ if (*cp != '\0' || l < 0 || l >= INT_MAX) {
fprintf(stderr, "%s: unsupported speed %s\n",
__progname, optarg);
exit(3);
@@ -171,16 +170,26 @@ cumain(argc, argv)
break;
}
setboolean(value(VERBOSE), FALSE);
- if (HW)
- ttysetup(speed(BR));
+ if (HW && ttysetup(BR)) {
+ fprintf(stderr, "%s: unsupported speed %ld\n",
+ __progname, BR);
+ daemon_uid();
+ (void)uu_unlock(uucplock);
+ exit(3);
+ }
if (connect()) {
printf("Connect failed\n");
daemon_uid();
(void)uu_unlock(uucplock);
exit(1);
}
- if (!HW)
- ttysetup(speed(BR));
+ if (!HW && ttysetup(BR)) {
+ fprintf(stderr, "%s: unsupported speed %ld\n",
+ __progname, BR);
+ daemon_uid();
+ (void)uu_unlock(uucplock);
+ exit(3);
+ }
}
void
diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c
index dddf296f320..67457f249b9 100644
--- a/usr.bin/tip/tip.c
+++ b/usr.bin/tip/tip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.c,v 1.18 2002/05/07 06:56:50 hugh Exp $ */
+/* $OpenBSD: tip.c,v 1.19 2002/05/29 22:58:56 millert Exp $ */
/* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */
/*
@@ -44,7 +44,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: tip.c,v 1.18 2002/05/07 06:56:50 hugh Exp $";
+static const char rcsid[] = "$OpenBSD: tip.c,v 1.19 2002/05/29 22:58:56 millert Exp $";
#endif /* not lint */
/*
@@ -56,14 +56,6 @@ static const char rcsid[] = "$OpenBSD: tip.c,v 1.18 2002/05/07 06:56:50 hugh Exp
#include "tip.h"
#include "pathnames.h"
-/*
- * Baud rate mapping table
- */
-int rates[] = {
- 0, 50, 75, 110, 134, 150, 200, 300, 600,
- 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, -1
-};
-
int disc = TTYDISC; /* tip normally runs this way */
void intprompt();
void timeout();
@@ -180,29 +172,32 @@ notnumber:
PH = _PATH_PHONES;
vinit(); /* init variables */
setparity("none"); /* set the parity table */
- if ((i = speed(number(value(BAUDRATE)))) == 0) {
- printf("%s: bad baud rate %ld\n", __progname,
- number(value(BAUDRATE)));
- daemon_uid();
- (void)uu_unlock(uucplock);
- exit(3);
- }
/*
* Hardwired connections require the
* line speed set before they make any transmissions
* (this is particularly true of things like a DF03-AC)
*/
- if (HW)
- ttysetup(i);
+ if (HW && ttysetup(number(value(BAUDRATE)))) {
+ fprintf(stderr, "%s: bad baud rate %ld\n", __progname,
+ number(value(BAUDRATE)));
+ daemon_uid();
+ (void)uu_unlock(uucplock);
+ exit(3);
+ }
if ((p = connect())) {
printf("\07%s\n[EOT]\n", p);
daemon_uid();
(void)uu_unlock(uucplock);
exit(1);
}
- if (!HW)
- ttysetup(i);
+ if (!HW && ttysetup(number(value(BAUDRATE)))) {
+ fprintf(stderr, "%s: bad baud rate %ld\n", __progname,
+ number(value(BAUDRATE)));
+ daemon_uid();
+ (void)uu_unlock(uucplock);
+ exit(3);
+ }
cucommon:
/*
* From here down the code is shared with
@@ -446,18 +441,6 @@ escape()
}
int
-speed(n)
- int n;
-{
- int *p;
-
- for (p = rates; *p != -1; p++)
- if (*p == n)
- return n;
- return 0;
-}
-
-int
any(cc, p)
int cc;
char *p;
@@ -545,15 +528,15 @@ help(c)
/*
* Set up the "remote" tty's state
*/
-void
+int
ttysetup(speed)
int speed;
{
struct termios cntrl;
- tcgetattr(FD, &cntrl);
- cfsetospeed(&cntrl, speed);
- cfsetispeed(&cntrl, speed);
+ if (tcgetattr(FD, &cntrl))
+ return (-1);
+ cfsetspeed(&cntrl, speed);
cntrl.c_cflag &= ~(CSIZE|PARENB);
cntrl.c_cflag |= CS8;
if (boolean(value(DC)))
@@ -565,7 +548,7 @@ ttysetup(speed)
cntrl.c_cc[VTIME] = 0;
if (boolean(value(TAND)))
cntrl.c_iflag |= IXOFF;
- tcsetattr(FD, TCSAFLUSH, &cntrl);
+ return (tcsetattr(FD, TCSAFLUSH, &cntrl));
}
static char partab[0200];
diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h
index cb750a62015..fdfed66fcde 100644
--- a/usr.bin/tip/tip.h
+++ b/usr.bin/tip/tip.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.h,v 1.12 2002/02/16 21:27:55 millert Exp $ */
+/* $OpenBSD: tip.h,v 1.13 2002/05/29 22:58:56 millert Exp $ */
/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */
/*
@@ -281,7 +281,7 @@ int args(char *buf, char *a[], int num);
int escape(void);
int prompt(char *s, char *p, size_t sz);
int size(char *s);
-int speed(int n);
+int ttysetup(int speed);
int uu_lock(char *ttyname);
int uu_unlock(char *ttyname);
int vstring(char *s, char *v);
@@ -305,7 +305,6 @@ void tipin(void);
void tipout(void);
void transfer(char *buf, int fd, char *eofchars);
void transmit(FILE *fd, char *eofchars, char *command);
-void ttysetup(int speed);
void unraw(void);
void user_uid(void);
void vinit(void);