* locales/hy_AM: Remove special collation rules. Fix yesexpr, noexpr,
[glibc.git] / resolv / ga_test.c
blob673162f0157d0245994552686d54c1204c8978b4
1 #include <arpa/inet.h>
2 #include <netinet/in.h>
3 #include <netdb.h>
4 #include <signal.h>
5 #include <stdio.h>
6 #include <stdlib.h>
9 int
10 main (void)
12 #define N 10
13 struct gaicb reqmem[N];
14 struct gaicb *req[N];
15 int n;
17 for (n = 0; n < N; ++n)
19 asprintf (&reqmem[n].ar_name, "test%d.test.redhat.com", 140 + n);
20 reqmem[n].ar_service = NULL;
21 reqmem[n].ar_request = NULL;
22 reqmem[n].ar_result = NULL;
23 req[n] = &reqmem[n];
26 if (getaddrinfo_a (GAI_NOWAIT, req, N, NULL) != 0)
28 puts ("queue call failed");
29 exit (1);
31 else
32 puts ("queue call successful");
34 while (1)
36 int any = 0;
38 for (n = 0; n < N; ++n)
39 if (req[n] != NULL && gai_error (req[n]) != EAI_INPROGRESS)
41 if (gai_error (req[n]) == 0)
43 struct addrinfo *runp = req[n]->ar_result;
45 while (runp != NULL)
47 switch (runp->ai_family)
49 case PF_INET:
51 struct sockaddr_in *sinp;
53 sinp = (struct sockaddr_in *) runp->ai_addr;
54 printf ("%2d: %s = %s\n", n,
55 req[n]->ar_name, inet_ntoa (sinp->sin_addr));
57 break;
58 default:
59 printf ("%2d: family %d\n", n, runp->ai_family);
60 break;
62 runp = runp->ai_next;
65 else
66 printf ("error for %d: %s\n", n,
67 gai_strerror (gai_error (req[n])));
68 req[n] = NULL;
69 break;
71 else if (req[n] != NULL)
72 any = 1;
74 if (n == N)
76 if (any)
77 gai_suspend (req, N, NULL);
78 else
79 break;
83 __libc_write(1,"got all\n", 8);
85 for (n = 0; n < N; ++n)
86 if (gai_error (&reqmem[n]) == 0)
88 struct addrinfo *runp = reqmem[n].ar_result;
90 while (runp != NULL)
92 struct addrinfo *oldp = runp;
93 runp = runp->ai_next;
94 freeaddrinfo (oldp);
98 return 0;