Annotation of src/external/mpl/bind/dist/bin/tests/system/feature-test.c, Revision 1.1.1.2
1.1 christos 1: /* $NetBSD$ */
2:
3: /*
4: * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5: *
6: * This Source Code Form is subject to the terms of the Mozilla Public
7: * License, v. 2.0. If a copy of the MPL was not distributed with this
8: * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9: *
10: * See the COPYRIGHT file distributed with this work for additional
11: * information regarding copyright ownership.
12: */
13:
14: #include <config.h>
15:
16: #include <unistd.h>
17: #include <stdio.h>
18: #include <stdlib.h>
19: #include <string.h>
20:
21: #include <isc/print.h>
22: #include <isc/util.h>
23: #include <isc/net.h>
24: #include <dns/edns.h>
25:
26: #ifdef WIN32
27: #include <Winsock2.h>
28: #endif
29:
30: #ifndef MAXHOSTNAMELEN
31: #ifdef HOST_NAME_MAX
32: #define MAXHOSTNAMELEN HOST_NAME_MAX
33: #else
34: #define MAXHOSTNAMELEN 256
35: #endif
36: #endif
37:
38: static void
39: usage() {
40: fprintf(stderr, "usage: feature-test <arg>\n");
41: fprintf(stderr, "args:\n");
42: fprintf(stderr, " --edns-version\n");
43: fprintf(stderr, " --enable-dnsrps\n");
44: fprintf(stderr, " --gethostname\n");
45: fprintf(stderr, " --gssapi\n");
46: fprintf(stderr, " --have-dlopen\n");
47: fprintf(stderr, " --have-geoip\n");
48: fprintf(stderr, " --have-libxml2\n");
49: fprintf(stderr, " --ipv6only=no\n");
50: fprintf(stderr, " --rpz-nsdname\n");
51: fprintf(stderr, " --rpz-nsip\n");
52: fprintf(stderr, " --with-idn\n");
53: fprintf(stderr, " --with-lmdb\n");
54: }
55:
56: int
57: main(int argc, char **argv) {
58: if (argc != 2) {
59: usage();
60: return (1);
61: }
62:
63: if (strcmp(argv[1], "--enable-dnsrps") == 0) {
64: #ifdef USE_DNSRPS
65: return (0);
66: #else
67: return (1);
68: #endif
69: }
70:
71: if (strcmp(argv[1], "--edns-version") == 0) {
72: #ifdef DNS_EDNS_VERSION
73: printf("%d\n", DNS_EDNS_VERSION);
74: #else
75: printf("0\n");
76: #endif
77: return (0);
78: }
79:
80: if (strcmp(argv[1], "--gethostname") == 0) {
81: char hostname[MAXHOSTNAMELEN];
82: int n;
83: #ifdef WIN32
84: /* From InitSocket() */
85: WORD wVersionRequested;
86: WSADATA wsaData;
87: int err;
88:
89: wVersionRequested = MAKEWORD(2, 0);
90: err = WSAStartup( wVersionRequested, &wsaData );
91: if (err != 0) {
92: fprintf(stderr, "WSAStartup() failed: %d\n", err);
93: exit(1);
94: }
95: #endif
96:
97: n = gethostname(hostname, sizeof(hostname));
98: if (n == -1) {
99: perror("gethostname");
100: return(1);
101: }
102: fprintf(stdout, "%s\n", hostname);
103: #ifdef WIN32
104: WSACleanup();
105: #endif
106: return (0);
107: }
108:
109: if (strcmp(argv[1], "--gssapi") == 0) {
110: #if defined(GSSAPI)
111: return (0);
112: #else
113: return (1);
114: #endif
115: }
116:
117: if (strcmp(argv[1], "--have-dlopen") == 0) {
118: #if defined(HAVE_DLOPEN) && defined(ISC_DLZ_DLOPEN)
119: return (0);
120: #else
121: return (1);
122: #endif
123: }
124:
125: if (strcmp(argv[1], "--have-geoip") == 0) {
126: #ifdef HAVE_GEOIP
127: return (0);
128: #else
129: return (1);
130: #endif
131: }
132:
133: if (strcmp(argv[1], "--have-libxml2") == 0) {
134: #ifdef HAVE_LIBXML2
135: return (0);
136: #else
137: return (1);
138: #endif
139: }
140:
141: if (strcmp(argv[1], "--rpz-nsip") == 0) {
142: #ifdef ENABLE_RPZ_NSIP
143: return (0);
144: #else
145: return (1);
146: #endif
147: }
148:
149: if (strcmp(argv[1], "--rpz-nsdname") == 0) {
150: #ifdef ENABLE_RPZ_NSDNAME
151: return (0);
152: #else
153: return (1);
154: #endif
155: }
156:
157: if (strcmp(argv[1], "--with-idn") == 0) {
1.1.1.2 ! christos 158: #ifdef HAVE_LIBIDN2
1.1 christos 159: return (0);
160: #else
161: return (1);
162: #endif
163: }
164:
165: if (strcmp(argv[1], "--with-lmdb") == 0) {
166: #ifdef HAVE_LMDB
167: return (0);
168: #else
169: return (1);
170: #endif
171: }
172:
173: if (strcmp(argv[1], "--ipv6only=no") == 0) {
174: #ifdef WIN32
175: return (0);
176: #elif defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
177: int s;
178: int n = -1;
179: int v6only = -1;
1.1.1.2 ! christos 180: socklen_t len = sizeof(v6only);
1.1 christos 181:
182: s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
183: if (s >= 0) {
184: n = getsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
185: (void *)&v6only, &len);
186: close(s);
187: }
188: return ((n == 0 && v6only == 0) ? 0 : 1);
189: #else
190: return (1);
191: #endif
192: }
193:
194: fprintf(stderr, "unknown arg: %s\n", argv[1]);
195: usage();
196: return (1);
197: }
CVSweb <webmaster@jp.NetBSD.org>