Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

xxx_name_to_inet.c

Go to the documentation of this file.
00001 #include <sys/types.h>
00002 #include <sys/socket.h>
00003 #include <netinet/in.h>
00004 #include <netdb.h>
00005 #include <stdio.h>
00006 #include <arpa/inet.h>
00007 
00008 /*----------------------------------------------------------------
00009    Return the Internet address (in 'dot' format, as a string)
00010    given the name of the host.  If NULL is returned, some
00011    error occurrrrred.
00012 ------------------------------------------------------------------*/
00013 
00014 char * xxx_name_to_inet( char * host )
00015 {
00016    struct hostent * hostp ;
00017    char * iname = NULL , * str ;
00018    int ll ;
00019 
00020    if( host == NULL || host[0] == '\0' ) return NULL ;
00021 
00022    hostp = gethostbyname(host) ; if( hostp == NULL ) return NULL :
00023 
00024    str = inet_ntoa(*((struct in_addr *)(hostp->h_addr))) ;
00025    if( str == NULL || str[0] == '\0' ) return NULL ;
00026 
00027    ll = strlen(str) ; iname = AFMALL(char, ll+1) ; strcpy(iname,str) ;
00028    return iname ;
00029 }
 

Powered by Plone

This site conforms to the following standards: