From decwrl!wyse!uunet!allbery Sun Jan 29 16:45:39 PST 1989 Article 787 of comp.sources.misc: Path: granite!decwrl!wyse!uunet!allbery From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) Newsgroups: comp.sources.misc Subject: v06i012: reverse hostname lookup program Message-ID: <47277@uunet.UU.NET> Date: 24 Jan 89 03:04:46 GMT Sender: allbery@uunet.UU.NET Reply-To: koreth@ssyx.UCSC.EDU (Steven Grimm) Lines: 72 Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) Posting-number: Volume 6, Issue 12 Submitted-by: koreth@ssyx.UCSC.EDU (Steven Grimm) Archive-name: hname This is primarily useful for sites running the Berkeley Internet Name Daemon or some other form of Internet name server; it looks up a host name given the host's internet address. It looks up each of the arguments, or prompts for addresses if no arguments are given. Example: % hname 128.114.133.1 128.114.133.1 = SSYX.UCSC.EDU This program isn't robust or complex or anything, but it works. Note that your gethostbyaddr() routine must use the nameserver for this to work. --- These are my opinions, which you can probably ignore if you want to. Steven Grimm Moderator, comp.{sources,binaries}.atari.st koreth@ssyx.ucsc.edu uunet!ucbvax!ucscc!ssyx!koreth #-------------- cut here ------------- #!/bin/sh # shar: Shell Archiver (v1.22) # # Run the following text with /bin/sh to create: # hname.c # sed 's/^X//' << 'SHAR_EOF' > hname.c && X#include X#include X#include X#include X#include X Xmain(argc, argv) Xchar **argv; X{ X int i; X if (argc == 1) X { X char string[80]; X X while (! feof(stdin)) X { X printf("> "); X fflush(stdout); X lookup(gets(string)); X } X } X else X for (i=1; ih_name); X} X SHAR_EOF chmod 0600 hname.c || echo "restore of hname.c fails" exit 0