Esempio n. 1
0
struct hostent* gethostbyname(char *name)
{
    static char buffer[ME_MAX_PATH];

    if(!DNSGetHostByName(name, buffer, ME_MAX_PATH)) {
        return 0;
    }
    return (struct hostent*) buffer;
}
Esempio n. 2
0
// **************************************************************************************
static inline int_least32_t ConStrToIPN( uint_least8_t *str, IPN *pIPN )
{
  uint_least8_t   *buffer;
  struct in_addr in1;
  int_least32_t    retcode = 0;

  // If the string is an IP, we're done
  if( inet_aton( (char *) str, &in1 ) )
  {
     *pIPN = in1.s_addr;
      return(1);
  }

  // All the DNS functions need a scrap buffer
  buffer = mmAlloc( 512 );
  if( buffer )
  {
    // We can treat buffer as a HOSTENT structure after
    // DNSGetHostByXxx calls
    HOSTENT *phe = (HOSTENT *)buffer;

    retcode = DNSGetHostByName( (char *) str, buffer, 512 );
    if( !retcode && phe->h_addrcnt )
    {
#ifndef _INCLUDE_IPv6_CODE
      *pIPN = phe->h_addr[0];
#else
      pIPN = (IPN *)phe->h_addr_list[0];
#endif
      retcode = 1;
    }
    else
      retcode = 0;

    mmFree( buffer );
  }
  return( retcode );
}