/
driver3.2@242/autoconf/
driver3.2@242/doc/LPC/
driver3.2@242/hosts/
driver3.2@242/hosts/amiga/NetIncl/
driver3.2@242/hosts/amiga/NetIncl/netinet/
driver3.2@242/hosts/amiga/NetIncl/sys/
driver3.2@242/hosts/atari/
driver3.2@242/hosts/fcrypt/
driver3.2@242/mudlib/
driver3.2@242/mudlib/sys/
driver3.2@242/util/
driver3.2@242/util/indent/hosts/next/
driver3.2@242/util/make_docs/
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>

#if 0
#define DEBUG_MESSAGE(list) fprintf list
#else
#define DEBUG_MESSAGE(list)
#endif

main()
{
    char buf[80];
    long addr;
    struct hostent *hp;
    char *nl_pnt;

DEBUG_MESSAGE((stderr, "hname starts\n"));
    printf("\n");
    fflush(stdout);
    buf[(sizeof buf) - 1] = '\0';
    for(;;) {
	if (fgets(buf, (sizeof buf) - 1, stdin) == NULL)
	    break;
DEBUG_MESSAGE((stderr, "hname got %s.\n", buf));
	addr = inet_addr(buf);
	if (nl_pnt = strchr(buf, '\n') )
	    *nl_pnt = '\0';
	if (addr != -1) {
	    hp = gethostbyaddr(&addr, 4, AF_INET);
	    if (!hp) {
		sleep(5);
	        hp = gethostbyaddr(&addr, 4, AF_INET);
	    }
	    if (hp) {
DEBUG_MESSAGE((stderr, "hname sends %s %s...", buf, hp->h_name));
		printf("%s %s\n", buf, hp->h_name);
		fflush(stdout);
DEBUG_MESSAGE((stderr, "done\n"));
	    }
	}
    }
DEBUG_MESSAGE((stderr, "hname exits\n"));
}