+ if (errno == ECONNREFUSED)
+ return (_gethtbyaddr(addr, len, type));
+ return ((struct hostent *) NULL);
+ }
+ hp = getanswer(&buf, n, 1);
+ if (hp == NULL)
+ return ((struct hostent *) NULL);
+ hp->h_addrtype = type;
+ hp->h_length = len;
+ h_addr_ptrs[0] = (char *)&host_addr;
+ h_addr_ptrs[1] = (char *)0;
+ host_addr = *(struct in_addr *)addr;
+ return(hp);
+}
+
+_sethtent(f)
+ int f;
+{
+ if (hostf == NULL)
+ hostf = fopen(HOSTDB, "r" );
+ else
+ rewind(hostf);
+ stayopen |= f;
+}
+
+_endhtent()
+{
+ if (hostf && !stayopen) {
+ (void) fclose(hostf);
+ hostf = NULL;
+ }
+}
+
+struct hostent *
+_gethtent()
+{
+ char *p;
+ register char *cp, **q;
+
+ if (hostf == NULL && (hostf = fopen(HOSTDB, "r" )) == NULL)
+ return (NULL);
+again:
+ if ((p = fgets(hostbuf, BUFSIZ, hostf)) == NULL)