|
|
1.1 ! root 1: /* ! 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: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)hunt.c 5.6 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: #include "tip.h" ! 25: ! 26: extern char *getremote(); ! 27: extern char *rindex(); ! 28: ! 29: static jmp_buf deadline; ! 30: static int deadfl; ! 31: ! 32: void ! 33: dead() ! 34: { ! 35: deadfl = 1; ! 36: longjmp(deadline, 1); ! 37: } ! 38: ! 39: hunt(name) ! 40: char *name; ! 41: { ! 42: register char *cp; ! 43: sig_t f; ! 44: ! 45: f = signal(SIGALRM, dead); ! 46: while (cp = getremote(name)) { ! 47: deadfl = 0; ! 48: uucplock = rindex(cp, '/')+1; ! 49: if (uu_lock(uucplock) < 0) ! 50: continue; ! 51: /* ! 52: * Straight through call units, such as the BIZCOMP, ! 53: * VADIC and the DF, must indicate they're hardwired in ! 54: * order to get an open file descriptor placed in FD. ! 55: * Otherwise, as for a DN-11, the open will have to ! 56: * be done in the "open" routine. ! 57: */ ! 58: if (!HW) ! 59: break; ! 60: if (setjmp(deadline) == 0) { ! 61: alarm(10); ! 62: FD = open(cp, O_RDWR); ! 63: } ! 64: alarm(0); ! 65: if (FD < 0) { ! 66: perror(cp); ! 67: deadfl = 1; ! 68: } ! 69: if (!deadfl) { ! 70: ioctl(FD, TIOCEXCL, 0); ! 71: ioctl(FD, TIOCHPCL, 0); ! 72: signal(SIGALRM, SIG_DFL); ! 73: return ((int)cp); ! 74: } ! 75: (void)uu_unlock(uucplock); ! 76: } ! 77: signal(SIGALRM, f); ! 78: return (deadfl ? -1 : (int)cp); ! 79: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.