Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / bin / tests / gxbn_test.c
blob5d669466dcccf91cea68bb893cce58f198bd5251
1 /* $NetBSD: gxbn_test.c,v 1.6 2014/12/10 04:37:53 christos Exp $ */
3 /*
4 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2000, 2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: gxbn_test.c,v 1.16 2007/06/19 23:46:59 tbox Exp */
22 /*! \file */
23 #include <config.h>
25 #include <stdio.h>
27 #include <isc/net.h>
29 #include <lwres/netdb.h>
31 static void
32 print_he(struct hostent *he, int error, const char *fun, const char *name) {
33 char **c;
34 int i;
36 if (he != NULL) {
37 printf("%s(%s):\n", fun, name);
38 printf("\tname = %s\n", he->h_name);
39 printf("\taddrtype = %d\n", he->h_addrtype);
40 printf("\tlength = %d\n", he->h_length);
41 c = he->h_aliases;
42 i = 1;
43 while (*c != NULL) {
44 printf("\talias[%d] = %s\n", i, *c);
45 i++;
46 c++;
48 c = he->h_addr_list;
49 i = 1;
50 while (*c != NULL) {
51 char buf[128];
52 inet_ntop(he->h_addrtype, *c, buf, sizeof(buf));
53 printf("\taddress[%d] = %s\n", i, buf);
54 c++;
55 i++;
57 } else {
58 printf("%s(%s): error = %d (%s)\n", fun, name, error,
59 hstrerror(error));
63 int
64 main(int argc, char **argv) {
65 struct hostent *he;
66 int error;
68 (void)argc;
70 while (argv[1] != NULL) {
71 he = gethostbyname(argv[1]);
72 print_he(he, h_errno, "gethostbyname", argv[1]);
74 he = getipnodebyname(argv[1], AF_INET6, AI_DEFAULT|AI_ALL,
75 &error);
76 print_he(he, error, "getipnodebyname", argv[1]);
77 if (he != NULL)
78 freehostent(he);
80 he = getipnodebyname(argv[1], AF_INET6, AI_DEFAULT,
81 &error);
82 print_he(he, error, "getipnodebyname", argv[1]);
83 if (he != NULL)
84 freehostent(he);
85 argv++;
87 return (0);