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