$NetBSD: patch-ab,v 1.4 2012/09/25 11:45:11 ryoon Exp $ Avoid dependence on "liblwres". Based on this patch for "pupnp": http://pupnp.git.sourceforge.net/git/gitweb.cgi?p=pupnp/pupnp;a=commitdiff;h=5151d4520308f59c71764423c3853a35cf23e279#patch9 --- tombupnp/upnp/src/genlib/net/uri/uri.c.orig 2010-03-25 14:58:12.000000000 +0000 +++ tombupnp/upnp/src/genlib/net/uri/uri.c @@ -657,11 +657,38 @@ parse_hostport( const char *in, if ( h == NULL ) { errCode = 1; } -#else +#elif defined(__linux__) errCode = gethostbyname_r( temp_host_name, &h_buf, temp_hostbyname_buff, BUFFER_SIZE, &h, &errcode ); +#else +{ + struct addrinfo hints, *res, *res0; + + h = NULL; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_INET; + hints.ai_socktype = SOCK_STREAM; + errCode = getaddrinfo(temp_host_name, "http", &hints, &res0); + + if (!errCode) { + for (res = res0; res; res = res->ai_next) { + if (res->ai_family == PF_INET && + res->ai_addr->sa_family == AF_INET) + { + h = &h_buf; + h->h_addrtype = res->ai_addr->sa_family; + h->h_length = 4; + h->h_addr = (void *) temp_hostbyname_buff; + *(struct in_addr *)h->h_addr = + ((struct sockaddr_in *)res->ai_addr)->sin_addr; + break; + } + } + freeaddrinfo(res0); + } +} #endif if( errCode == 0 ) {