source: branches/libc-0.6/src/libctests/glibc/inet/tst-ntoa.c

Last change on this file was 2046, checked in by bird, 20 years ago

Porting to FreeBSD 64-bit

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 743 bytes
Line 
1#include <stdio.h>
2#include <string.h>
3#ifdef __BSD__
4# include <sys/types.h>
5# include <sys/socket.h>
6#endif
7#include <arpa/inet.h>
8#include <netinet/in.h>
9
10
11static int
12test (unsigned int inaddr, const char *expected)
13{
14 struct in_addr addr;
15 char *res;
16 int fail;
17
18 addr.s_addr = htonl (inaddr);
19 res = inet_ntoa (addr);
20 fail = strcmp (res, expected);
21
22 printf ("%#010x -> \"%s\" -> %s%s\n", inaddr, res,
23 fail ? "fail, expected" : "ok", fail ? expected : "");
24
25 return fail;
26}
27
28
29int
30main (void)
31{
32 int result = 0;
33
34 result |= test (INADDR_LOOPBACK, "127.0.0.1");
35 result |= test (INADDR_BROADCAST, "255.255.255.255");
36 result |= test (INADDR_ANY, "0.0.0.0");
37 result |= test (0xc0060746, "192.6.7.70");
38
39 return result;
40}
Note: See TracBrowser for help on using the repository browser.