1 /* 2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 /* 7 * Copyright (c) 1983 Regents of the University of California. 8 * All rights reserved. The Berkeley software License Agreement 9 * specifies the terms and conditions for redistribution. 10 */ 11 12 #include "tip.h" 13 14 char *uucplock; 15 static sigjmp_buf deadline; 16 static int deadfl; 17 18 void 19 dead(void) 20 { 21 22 deadfl = 1; 23 siglongjmp(deadline, 1); 24 } 25 26 int 27 hunt(char *name) 28 { 29 char *cp; 30 sig_handler_t f; 31 32 f = signal(SIGALRM, (sig_handler_t)dead); 33 while (cp = getremote(name)) { 34 deadfl = 0; 35 uucplock = cp; 36 if (tip_mlock(uucplock) < 0) { 37 delock(uucplock); 38 continue; 39 } 40 /* 41 * Straight through call units, such as the BIZCOMP, 42 * VADIC and the DF, must indicate they're hardwired in 43 * order to get an open file descriptor placed in FD. 44 * Otherwise, as for a DN-11, the open will have to 45 * be done in the "open" routine. 46 */ 47 if (!HW) 48 break; 49 if (sigsetjmp(deadline, 1) == 0) { 50 (void) alarm(10); 51 if (!trusted_device) 52 userperm(); 53 errno = 0; 54 if ((FD = open(cp, O_RDWR)) < 0 && errno != EBUSY) { 55 (void) fprintf(stderr, "tip: "); 56 perror(cp); 57 } 58 if (!trusted_device) 59 myperm(); 60 if (FD >= 0 && !isatty(FD)) { 61 (void) fprintf(stderr, "tip: %s: not a tty\n", 62 cp); 63 (void) close(FD); 64 FD = -1; 65 } 66 } 67 (void) alarm(0); 68 if (!deadfl && FD >= 0) { 69 struct termios t; 70 71 (void) ioctl(FD, TCGETS, &t); 72 t.c_cflag |= XCLUDE|HUPCL; 73 (void) ioctl(FD, TCSETSF, &t); 74 (void) signal(SIGALRM, f); 75 return ((int)cp); 76 } 77 delock(uucplock); 78 } 79 (void) signal(SIGALRM, f); 80 return (deadfl ? -1 : (int)cp); 81 } 82