/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that gets the ftp/tcp port number. */
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>

int main() {
    struct hostent result;
    char addr[] = "engr.ucdavis.edu";
    //char buffer[128];
    //int h_errnop;
    struct in_addr in;
    hostent_data buffer;
    //u_long address;

    //address = inet_addr(addr);
    gethostbyaddr(addr,sizeof(addr),AF_INET,&result,&buffer);
//                 &result,buffer,sizeof(buffer),&h_errnop);
    printf("%s\n",result.h_name); 
    printf("%d\n",result.h_length);
    printf("%u\n",result.h_addr_list[0]);
    in.s_addr = *(u_long *) result.h_addr_list[0];
    printf("%s\n",inet_ntoa(in)); 
}
