date and time created 83/02/11 15:45:06 by rrh
[unix-history] / usr / src / usr.bin / tip / hunt.c
index d65b7a3..cdae7e2 100644 (file)
@@ -1,4 +1,4 @@
-/*     hunt.c  4.1     81/05/09        */
+/*     hunt.c  4.5     81/11/29        */
 #include "tip.h"
 
 #define RD     04
 #include "tip.h"
 
 #define RD     04
@@ -14,13 +14,13 @@ dead()
 }
 
 hunt(name)
 }
 
 hunt(name)
-char *name;
+       char *name;
 {
        register char *cp;
 
        deadfl = 0;
        signal(SIGALRM, dead);
 {
        register char *cp;
 
        deadfl = 0;
        signal(SIGALRM, dead);
-       while(cp = getremote(name)){
+       while (cp = getremote(name)) {
                if (access(cp, RD))
                        continue;
                uucplock = rindex(cp, '/')+1;
                if (access(cp, RD))
                        continue;
                uucplock = rindex(cp, '/')+1;
@@ -28,20 +28,28 @@ char *name;
                        delock(uucplock);
                        continue;
                }
                        delock(uucplock);
                        continue;
                }
+               /*
+                * Straight through call units, such as the BIZCOMP
+                *  and the DF, must indicate they're hardwired in
+                *  order to get an open file descriptor placed in FD.
+                * Otherwise, as for a DN-11, the open will have to
+                *  be done in the "open" routine.
+                */
+               if (!HW)
+                       break;
                alarm(10);
                alarm(10);
-               if((FD = open(cp, 2)) >= 0){
+               if ((FD = open(cp, 2)) >= 0){
                        alarm(0);
                        alarm(0);
-                       if(deadfl)
-                               continue;
-                       ioctl(FD, TIOCEXCL, 0);
-                       break;
+                       if (!deadfl) {
+                               ioctl(FD, TIOCEXCL, 0);
+                               signal(SIGALRM, SIG_DFL);
+                               return ((int)cp);
+                       }
                }
                alarm(0);
                signal(SIGALRM, dead);
                }
                alarm(0);
                signal(SIGALRM, dead);
+               delock(uucplock);
        }
        }
-       alarm(0);
        signal(SIGALRM, SIG_DFL);
        signal(SIGALRM, SIG_DFL);
-       if(deadfl)
-               return(-1);
-       return((int)cp);
+       return (deadfl ? -1 : (int)cp);
 }
 }