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.4 2011/10/03 18:19:13 pdw Exp $";
9 #include <sys/socket.h>
10 #include <sys/types.h>
16 #include <netinet/in.h>
19 struct in_addr localhost;
20 struct hostent hostbuf, *hp;
25 localhost.s_addr = htonl(INADDR_LOOPBACK);
27 while ((res = gethostbyaddr_r((char*)&localhost, sizeof localhost, AF_INET,
28 &hostbuf, buf, buflen, &hp, &herr))
30 buf = (char*)realloc(buf, buflen *= 2);
32 /* We assume that the loopback address can always be resolved if
33 * gethostbyaddr_r is actually working. */
34 if (res || hp == NULL) {
35 fprintf(stderr, "errno = %d, herr = %d, res = %d\n", errno, herr, res);