Commit | Line | Data |
---|---|---|
051b1e55 | 1 | /* |
c9686c12 KB |
2 | * Copyright (c) 1983 The Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that the above copyright notice and this paragraph are | |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
051b1e55 DF |
16 | */ |
17 | ||
05862919 | 18 | #ifndef lint |
c9686c12 KB |
19 | static char sccsid[] = "@(#)hunt.c 5.4 (Berkeley) %G%"; |
20 | #endif /* not lint */ | |
60d5f7dd | 21 | |
05862919 | 22 | #include "tip.h" |
60d5f7dd BJ |
23 | |
24 | extern char *getremote(); | |
25 | extern char *rindex(); | |
26 | ||
05862919 SL |
27 | static jmp_buf deadline; |
28 | static int deadfl; | |
60d5f7dd BJ |
29 | |
30 | dead() | |
31 | { | |
05862919 | 32 | |
60d5f7dd | 33 | deadfl = 1; |
05862919 | 34 | longjmp(deadline, 1); |
60d5f7dd BJ |
35 | } |
36 | ||
37 | hunt(name) | |
d8feebc2 | 38 | char *name; |
60d5f7dd BJ |
39 | { |
40 | register char *cp; | |
05862919 | 41 | int (*f)(); |
60d5f7dd | 42 | |
05862919 | 43 | f = signal(SIGALRM, dead); |
3f48242d | 44 | while (cp = getremote(name)) { |
8f1963b9 | 45 | deadfl = 0; |
60d5f7dd | 46 | uucplock = rindex(cp, '/')+1; |
5d369851 | 47 | if (uu_lock(uucplock) < 0) |
60d5f7dd | 48 | continue; |
f0211bf2 | 49 | /* |
6b46907f RC |
50 | * Straight through call units, such as the BIZCOMP, |
51 | * VADIC and the DF, must indicate they're hardwired in | |
f0211bf2 SL |
52 | * order to get an open file descriptor placed in FD. |
53 | * Otherwise, as for a DN-11, the open will have to | |
54 | * be done in the "open" routine. | |
55 | */ | |
56 | if (!HW) | |
57 | break; | |
05862919 SL |
58 | if (setjmp(deadline) == 0) { |
59 | alarm(10); | |
60 | FD = open(cp, O_RDWR); | |
60d5f7dd BJ |
61 | } |
62 | alarm(0); | |
274c3d56 MK |
63 | if (FD < 0) { |
64 | perror(cp); | |
65 | deadfl = 1; | |
66 | } | |
05862919 SL |
67 | if (!deadfl) { |
68 | ioctl(FD, TIOCEXCL, 0); | |
69 | ioctl(FD, TIOCHPCL, 0); | |
70 | signal(SIGALRM, SIG_DFL); | |
71 | return ((int)cp); | |
72 | } | |
5d369851 | 73 | (void)uu_unlock(uucplock); |
60d5f7dd | 74 | } |
05862919 | 75 | signal(SIGALRM, f); |
3f48242d | 76 | return (deadfl ? -1 : (int)cp); |
60d5f7dd | 77 | } |