Logo Search packages:      
Sourcecode: egoboo version File versions  Download package

int enet_address_get_host ( const ENetAddress address,
char *  hostName,
size_t  nameLength 
)

Attempts to do a reserve lookup of the host field in the address parameter.

Parameters:
address address used for reverse lookup
hostName destination for name, must not be NULL
nameLength maximum length of hostName.
Returns:
the null-terminated name of the host in hostName on success
Return values:
0 on success
< 0 on failure

Definition at line 93 of file unix.c.

{
    struct in_addr in;
    struct hostent * hostEntry = NULL;
#ifdef HAS_GETHOSTBYADDR_R
    struct hostent hostData;
    char buffer [2048];
    int errnum;

    in.s_addr = address -> host;

#ifdef linux
    gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
#else
    hostEntry = gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & errnum);
#endif
#else
    in.s_addr = address -> host;

    hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET);
#endif

    if (hostEntry == NULL)
      return -1;

    strncpy (name, hostEntry -> h_name, nameLength);

    return 0;
}


Generated by  Doxygen 1.6.0   Back to index