Commit 36d7d0ca authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Rework slightly so that both sockets and old tty modes are supported,

defaulting to sockets based first. This is handy cause we oftern want
to talk to a real tty device (like the power controllers).
parent 44fe7268
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93"; static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93";
#endif #endif
static const char rcsid[] = static const char rcsid[] =
"$Id: hunt.c,v 1.3 2001-07-24 15:13:40 stoller Exp $"; "$Id: hunt.c,v 1.4 2001-07-31 21:58:35 stoller Exp $";
#endif /* not lint */ #endif /* not lint */
#include "tip.h" #include "tip.h"
...@@ -98,12 +98,16 @@ hunt(name) ...@@ -98,12 +98,16 @@ hunt(name)
if (setjmp(deadline) == 0) { if (setjmp(deadline) == 0) {
alarm(10); alarm(10);
#ifdef USESOCKETS #ifdef USESOCKETS
FD = socket_open(cp); if ((FD = socket_open(cp)) >= 0) {
#else HW = 0;
FD = open(cp, O_RDWR); alarm(0);
if (FD >= 0) signal(SIGALRM, SIG_DFL);
ioctl(FD, TIOCEXCL, 0); return ((int)cp);
}
else
#endif #endif
if ((FD = open(cp, O_RDWR)) >= 0)
ioctl(FD, TIOCEXCL, 0);
} }
alarm(0); alarm(0);
if (FD < 0) { if (FD < 0) {
...@@ -111,7 +115,6 @@ hunt(name) ...@@ -111,7 +115,6 @@ hunt(name)
deadfl = 1; deadfl = 1;
} }
if (!deadfl) { if (!deadfl) {
#ifndef USESOCKETS
#if HAVE_TERMIOS #if HAVE_TERMIOS
struct termios t; struct termios t;
...@@ -124,7 +127,6 @@ hunt(name) ...@@ -124,7 +127,6 @@ hunt(name)
ioctl(FD, TIOCHPCL, 0); ioctl(FD, TIOCHPCL, 0);
#endif #endif
#endif /* HAVE_TERMIOS */ #endif /* HAVE_TERMIOS */
#endif /* USESOCKETS */
signal(SIGALRM, SIG_DFL); signal(SIGALRM, SIG_DFL);
return ((int)cp); return ((int)cp);
} }
...@@ -152,7 +154,7 @@ socket_open(char *devname) ...@@ -152,7 +154,7 @@ socket_open(char *devname)
(void) sprintf(aclname, "%s.acl", devname); (void) sprintf(aclname, "%s.acl", devname);
if ((fp = fopen(aclname, "r")) < 0) { if ((fp = fopen(aclname, "r")) == NULL) {
return -1; return -1;
} }
fscanf(fp, "%d %x %x %x", &port, fscanf(fp, "%d %x %x %x", &port,
......
...@@ -42,7 +42,7 @@ static const char copyright[] = ...@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93"; static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif #endif
static const char rcsid[] = static const char rcsid[] =
"$Id: tip.c,v 1.3 2001-07-24 15:13:40 stoller Exp $"; "$Id: tip.c,v 1.4 2001-07-31 21:58:35 stoller Exp $";
#endif /* not lint */ #endif /* not lint */
/* /*
...@@ -725,7 +725,6 @@ help(c) ...@@ -725,7 +725,6 @@ help(c)
void void
ttysetup (int speed) ttysetup (int speed)
{ {
#ifndef USESOCKETS
#if HAVE_TERMIOS #if HAVE_TERMIOS
struct termios termios; struct termios termios;
tcgetattr (FD, &termios); tcgetattr (FD, &termios);
...@@ -750,7 +749,6 @@ ttysetup (int speed) ...@@ -750,7 +749,6 @@ ttysetup (int speed)
ioctl(FD, TIOCSETP, (char *)&arg); ioctl(FD, TIOCSETP, (char *)&arg);
ioctl(FD, TIOCLBIS, (char *)&bits); ioctl(FD, TIOCLBIS, (char *)&bits);
#endif /* HAVE_TERMIOS */ #endif /* HAVE_TERMIOS */
#endif /* USESOCKETS */
} }
/* /*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment