s_sinf.c: Replace floor with simple casts
[glibc.git] / inet / tst-getni2.c
blob66e78062bafc8ea1f41977c5cd75a5115f6ebf2b
1 #include <netdb.h>
2 #include <stdio.h>
3 #include <sys/socket.h>
5 static int
6 do_test (void)
8 int retval = 0;
10 struct sockaddr_in6 s;
11 s.sin6_family = AF_INET6;
12 s.sin6_port = htons (80);
13 s.sin6_flowinfo = 0;
14 s.sin6_addr = (struct in6_addr) IN6ADDR_ANY_INIT;
15 s.sin6_scope_id = 0;
16 char buf[1000];
17 buf[0] = '\0';
18 int r = getnameinfo((struct sockaddr *) &s, sizeof (s), buf, sizeof (buf),
19 NULL, 0, NI_NUMERICSERV);
20 printf("r = %d, buf = \"%s\"\n", r, buf);
21 if (r != 0)
23 puts ("failed without NI_NAMEREQD");
24 retval = 1;
27 buf[0] = '\0';
28 r = getnameinfo((struct sockaddr *) &s, sizeof (s), buf, sizeof (buf),
29 NULL, 0, NI_NUMERICSERV | NI_NAMEREQD);
30 printf("r = %d, buf = \"%s\"\n", r, buf);
31 if (r != EAI_NONAME)
33 puts ("did not fail with EAI_NONAME with NI_NAMEREQD set");
34 retval = 1;
37 return retval;
40 #define TEST_FUNCTION do_test ()
41 #include "../test-skeleton.c"