Commit | Line | Data |
---|---|---|
3f48242d | 1 | /* hunt.c 4.5 81/11/29 */ |
60d5f7dd BJ |
2 | #include "tip.h" |
3 | ||
4 | #define RD 04 | |
5 | ||
6 | extern char *getremote(); | |
7 | extern char *rindex(); | |
8 | ||
9 | int deadfl; | |
10 | ||
11 | dead() | |
12 | { | |
13 | deadfl = 1; | |
14 | } | |
15 | ||
16 | hunt(name) | |
d8feebc2 | 17 | char *name; |
60d5f7dd BJ |
18 | { |
19 | register char *cp; | |
20 | ||
21 | deadfl = 0; | |
22 | signal(SIGALRM, dead); | |
3f48242d | 23 | while (cp = getremote(name)) { |
60d5f7dd BJ |
24 | if (access(cp, RD)) |
25 | continue; | |
26 | uucplock = rindex(cp, '/')+1; | |
27 | if (mlock(uucplock) < 0) { | |
28 | delock(uucplock); | |
29 | continue; | |
30 | } | |
f0211bf2 SL |
31 | /* |
32 | * Straight through call units, such as the BIZCOMP | |
33 | * and the DF, must indicate they're hardwired in | |
34 | * order to get an open file descriptor placed in FD. | |
35 | * Otherwise, as for a DN-11, the open will have to | |
36 | * be done in the "open" routine. | |
37 | */ | |
38 | if (!HW) | |
39 | break; | |
60d5f7dd | 40 | alarm(10); |
3f48242d | 41 | if ((FD = open(cp, 2)) >= 0){ |
60d5f7dd | 42 | alarm(0); |
3f48242d | 43 | if (!deadfl) { |
673be859 SL |
44 | ioctl(FD, TIOCEXCL, 0); |
45 | signal(SIGALRM, SIG_DFL); | |
3f48242d | 46 | return ((int)cp); |
673be859 | 47 | } |
60d5f7dd BJ |
48 | } |
49 | alarm(0); | |
50 | signal(SIGALRM, dead); | |
673be859 | 51 | delock(uucplock); |
60d5f7dd | 52 | } |
60d5f7dd | 53 | signal(SIGALRM, SIG_DFL); |
3f48242d | 54 | return (deadfl ? -1 : (int)cp); |
60d5f7dd | 55 | } |