> I keep meaning to look for/write a utility to provide a command-line
> front-end to the gethostbyname(). (Yes, I know about dig(1), nslookup(8), and
> host(1) -- those all make wonderful DNS clients, but they deliberately bypass
> gethostbyname(), so you can test your DNS servers directly. But there are
> times where I want to test what the *client* thinks is going on.)
>
I agree. I decided to write it. Here it is. Distributable under the GPL.
--Pete
PS: no, I dont have a .rpm, but I am willing to make a tarball ;-)
//-------------------------------------------------------------------
#include <netdb.h>
#include <stdio.h>
main(int argc, char *argv[])
{
unsigned char *p, **pp;
struct hostent *h;
int i;
if(argc != 2) {
printf("Usage: gethostbyname <host_name>\n");
exit(1);
}
h = gethostbyname(argv[1]);
if(h == NULL) {
printf("'%s' not found.\n",argv[1]);
exit(1);
}
printf("h_name: '%s'\n",h->h_name);
pp = (unsigned char **)(h->h_aliases);
for(p = *pp; p != NULL; pp++, p = *pp)
printf("h_aliases: '%s'\n",p);
printf("h_addrtype: %d\n",h->h_addrtype);
printf("h_length: %d\n",h->h_length);
pp = (unsigned char **)(h->h_addr_list);
for(p = *pp; p != NULL; pp++, p = *pp){
printf("h_addr: ");
for(i = 0; i < h->h_length; i++)
printf("%d%c",p[i],i<(h->h_length-1)?'.':'\n');
}
}
**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************