3 * Test program to see whether gethostbyaddr_r takes 8 arguments and returns
7 static const char rcsid[] = "$Id: int_ghba_r.c,v 1.1 2002/11/04 12:27:35 chris Exp $";
15 #include <netinet/in.h>
18 struct in_addr localhost;
19 struct hostent hostbuf, *hp;
24 localhost.s_addr = htonl(INADDR_LOOPBACK);
26 while ((res = gethostbyaddr_r((char*)&localhost, sizeof localhost, AF_INET,
27 &hostbuf, buf, buflen, &hp, &herr))
29 buf = (char*)realloc(buf, buflen *= 2);
31 /* We assume that the loopback address can always be resolved if
32 * gethostbyaddr_r is actually working. */
33 if (res || hp == NULL) {
34 fprintf(stderr, "errno = %d, herr = %d, res = %d\n", errno, herr, res);