|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nspr.h" |
|
7 |
|
8 #include <stdio.h> |
|
9 #include <stdlib.h> |
|
10 |
|
11 int main(int argc, char **argv) |
|
12 { |
|
13 PRAddrInfo *ai; |
|
14 void *iter; |
|
15 PRNetAddr addr; |
|
16 |
|
17 ai = PR_GetAddrInfoByName(argv[1], PR_AF_UNSPEC, PR_AI_ADDRCONFIG); |
|
18 if (ai == NULL) { |
|
19 fprintf(stderr, "PR_GetAddrInfoByName failed: (%d, %d)\n", |
|
20 PR_GetError(), PR_GetOSError()); |
|
21 exit(1); |
|
22 } |
|
23 printf("%s\n", PR_GetCanonNameFromAddrInfo(ai)); |
|
24 iter = NULL; |
|
25 while ((iter = PR_EnumerateAddrInfo(iter, ai, 0, &addr)) != NULL) { |
|
26 char buf[128]; |
|
27 PR_NetAddrToString(&addr, buf, sizeof buf); |
|
28 printf("%s\n", buf); |
|
29 } |
|
30 PR_FreeAddrInfo(ai); |
|
31 return 0; |
|
32 } |