projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace sleep calls for 'wake up'.
[unix-history]
/
usr
/
src
/
usr.bin
/
tip
/
aculib
/
biz31.c
diff --git
a/usr/src/usr.bin/tip/aculib/biz31.c
b/usr/src/usr.bin/tip/aculib/biz31.c
index
aea769f
..
bb5e277
100644
(file)
--- a/
usr/src/usr.bin/tip/aculib/biz31.c
+++ b/
usr/src/usr.bin/tip/aculib/biz31.c
@@
-1,21
+1,24
@@
-/* biz31.c 4.1 81/05/09 */
+#ifndef lint
+static char sccsid[] = "@(#)biz31.c 4.7 (Berkeley) %G%";
+#endif
+
#include "tip.h"
#include "tip.h"
-#if BIZCOMP
#define MAXRETRY 3 /* sync up retry count */
#define MAXRETRY 3 /* sync up retry count */
-#define DISCONNECT
"\21\25\11\24" /* disconnection string */
+#define DISCONNECT
_CMD
"\21\25\11\24" /* disconnection string */
-static int sigALRM();
-static int timeout = 0;
+static int sigALRM();
+static int timeout = 0;
+static jmp_buf timeoutbuf;
/*
/*
- * Dial up on a BIZCOMP with either
+ * Dial up on a BIZCOMP
Model 1031
with either
* tone dialing (mod = "f")
* pulse dialing (mod = "w")
*/
static int
biz_dialer(num, mod)
* tone dialing (mod = "f")
* pulse dialing (mod = "w")
*/
static int
biz_dialer(num, mod)
-char *num, *mod;
+
char *num, *mod;
{
register int connected = 0;
{
register int connected = 0;
@@
-32,7
+35,7
@@
char *num, *mod;
echo(mod);
echo("$\r$\n");
echo("$>$.$ #\re$ "); /* disconnection sequence */
echo(mod);
echo("$\r$\n");
echo("$>$.$ #\re$ "); /* disconnection sequence */
- echo(DISCONNECT);
+ echo(DISCONNECT
_CMD
);
echo("\r$\n$\r$\n");
echo("$>$.$ #\rr$ "); /* repeat dial */
echo(num);
echo("\r$\n$\r$\n");
echo("$>$.$ #\rr$ "); /* repeat dial */
echo(num);
@@
-59,107
+62,112
@@
char *num, *mod;
else
flush("CONNECTION\r\n\07");
if (timeout)
else
flush("CONNECTION\r\n\07");
if (timeout)
- biz
_disconnect();
/* insurance */
- return(connected);
+ biz
31_disconnect();
/* insurance */
+ return
(connected);
}
}
-bizw_dialer(num, acu)
-char *num, *acu;
+biz
31
w_dialer(num, acu)
+
char *num, *acu;
{
{
- return(biz_dialer(num, "w"));
+
+ return (biz_dialer(num, "w"));
}
}
-bizf_dialer(num, acu)
-char *num, *acu;
+biz
31
f_dialer(num, acu)
+
char *num, *acu;
{
{
- return(biz_dialer(num, "f"));
+
+ return (biz_dialer(num, "f"));
}
}
-biz_disconnect()
+biz
31
_disconnect()
{
{
- write(FD, DISCONNECT, 4);
+
+ write(FD, DISCONNECT_CMD, 4);
sleep(2);
ioctl(FD, TIOCFLUSH);
}
sleep(2);
ioctl(FD, TIOCFLUSH);
}
-biz_abort()
+biz
31
_abort()
{
{
+
write(FD, "\33", 1);
write(FD, "\33", 1);
- timeout = 1;
}
static int
echo(s)
}
static int
echo(s)
-register char *s;
+
register char *s;
{
char c;
{
char c;
- while (c = *s++)
- switch(c)
- {
- case '$':
- read(FD, &c, 1);
- s++;
- break;
- case '#':
- c = *s++;
- write(FD, &c, 1);
- break;
- default:
- write(FD, &c, 1);
- read(FD, &c, 1);
- }
+ while (c = *s++) switch (c) {
+
+ case '$':
+ read(FD, &c, 1);
+ s++;
+ break;
+
+ case '#':
+ c = *s++;
+ write(FD, &c, 1);
+ break;
+
+ default:
+ write(FD, &c, 1);
+ read(FD, &c, 1);
+ }
}
static int
sigALRM()
{
}
static int
sigALRM()
{
- signal(SIGALRM, SIG_IGN);
- printf("\07timeout waiting for reply\n");
+
timeout = 1;
timeout = 1;
+ longjmp(timeoutbuf, 1);
}
static int
detect(s)
}
static int
detect(s)
-register char *s;
+
register char *s;
{
char c;
{
char c;
+ int (*f)();
-
signal(SIGALRM, biz_abort
);
+
f = signal(SIGALRM, sigALRM
);
timeout = 0;
timeout = 0;
- while (*s)
- {
+ while (*s) {
+ if (setjmp(timeoutbuf)) {
+ printf("\07timeout waiting for reply\n");
+ biz31_abort();
+ break;
+ }
alarm(number(value(DIALTIMEOUT)));
read(FD, &c, 1);
alarm(0);
alarm(number(value(DIALTIMEOUT)));
read(FD, &c, 1);
alarm(0);
- if (timeout)
- return(0);
if (c != *s++)
if (c != *s++)
-
return(0)
;
+
break
;
}
}
- signal(SIGALRM,
SIG_DFL
);
- return
(1
);
+ signal(SIGALRM,
f
);
+ return
(timeout == 0
);
}
static int
flush(s)
}
static int
flush(s)
-register char *s;
+
register char *s;
{
char c;
{
char c;
+ int (*f)();
- signal(SIGALRM, sigALRM);
- timeout = 0;
-
while (*s++
)
- {
+
f =
signal(SIGALRM, sigALRM);
+ while (*s++) {
+
if (setjmp(timeoutbuf)
)
+ break;
alarm(10);
read(FD, &c, 1);
alarm(0);
alarm(10);
read(FD, &c, 1);
alarm(0);
- if (timeout)
- break;
}
}
- signal(SIGALRM,
SIG_DFL
);
+ signal(SIGALRM,
f
);
timeout = 0; /* guard against disconnection */
timeout = 0; /* guard against disconnection */
- return(1);
}
/*
}
/*
@@
-192,8
+200,8
@@
retry:
if (chars(b) != 10) {
nono:
if (already > MAXRETRY)
if (chars(b) != 10) {
nono:
if (already > MAXRETRY)
- return(0);
- write(fd, DISCONNECT, 4);
+ return
(0);
+ write(fd, DISCONNECT
_CMD
, 4);
sleep(2);
already++;
goto retry;
sleep(2);
already++;
goto retry;
@@
-203,6
+211,5
@@
retry:
goto nono;
}
}
goto nono;
}
}
- return(1);
+ return
(1);
}
}
-#endif