Detect FPU by checking CPUID features.
[dragonfly.git] / contrib / bind-9.5.2 / lib / dns / rdata / in_1 / nsap-ptr_23.c
blob2da78695994329e00073c515ad587587f016f92b
1 /*
2 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: nsap-ptr_23.c,v 1.38 2007/06/19 23:47:17 tbox Exp $ */
20 /* Reviewed: Fri Mar 17 10:16:02 PST 2000 by gson */
22 /* RFC1348. Obsoleted in RFC 1706 - use PTR instead. */
24 #ifndef RDATA_IN_1_NSAP_PTR_23_C
25 #define RDATA_IN_1_NSAP_PTR_23_C
27 #define RRTYPE_NSAP_PTR_ATTRIBUTES (0)
29 static inline isc_result_t
30 fromtext_in_nsap_ptr(ARGS_FROMTEXT) {
31 isc_token_t token;
32 dns_name_t name;
33 isc_buffer_t buffer;
35 REQUIRE(type == 23);
36 REQUIRE(rdclass == 1);
38 UNUSED(type);
39 UNUSED(rdclass);
40 UNUSED(callbacks);
42 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
43 ISC_FALSE));
45 dns_name_init(&name, NULL);
46 buffer_fromregion(&buffer, &token.value.as_region);
47 origin = (origin != NULL) ? origin : dns_rootname;
48 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
49 return (ISC_R_SUCCESS);
52 static inline isc_result_t
53 totext_in_nsap_ptr(ARGS_TOTEXT) {
54 isc_region_t region;
55 dns_name_t name;
56 dns_name_t prefix;
57 isc_boolean_t sub;
59 REQUIRE(rdata->type == 23);
60 REQUIRE(rdata->rdclass == 1);
61 REQUIRE(rdata->length != 0);
63 dns_name_init(&name, NULL);
64 dns_name_init(&prefix, NULL);
66 dns_rdata_toregion(rdata, &region);
67 dns_name_fromregion(&name, &region);
69 sub = name_prefix(&name, tctx->origin, &prefix);
71 return (dns_name_totext(&prefix, sub, target));
74 static inline isc_result_t
75 fromwire_in_nsap_ptr(ARGS_FROMWIRE) {
76 dns_name_t name;
78 REQUIRE(type == 23);
79 REQUIRE(rdclass == 1);
81 UNUSED(type);
82 UNUSED(rdclass);
84 dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
86 dns_name_init(&name, NULL);
87 return (dns_name_fromwire(&name, source, dctx, options, target));
90 static inline isc_result_t
91 towire_in_nsap_ptr(ARGS_TOWIRE) {
92 dns_name_t name;
93 dns_offsets_t offsets;
94 isc_region_t region;
96 REQUIRE(rdata->type == 23);
97 REQUIRE(rdata->rdclass == 1);
98 REQUIRE(rdata->length != 0);
100 dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
101 dns_name_init(&name, offsets);
102 dns_rdata_toregion(rdata, &region);
103 dns_name_fromregion(&name, &region);
105 return (dns_name_towire(&name, cctx, target));
108 static inline int
109 compare_in_nsap_ptr(ARGS_COMPARE) {
110 dns_name_t name1;
111 dns_name_t name2;
112 isc_region_t region1;
113 isc_region_t region2;
115 REQUIRE(rdata1->type == rdata2->type);
116 REQUIRE(rdata1->rdclass == rdata2->rdclass);
117 REQUIRE(rdata1->type == 23);
118 REQUIRE(rdata1->rdclass == 1);
119 REQUIRE(rdata1->length != 0);
120 REQUIRE(rdata2->length != 0);
122 dns_name_init(&name1, NULL);
123 dns_name_init(&name2, NULL);
125 dns_rdata_toregion(rdata1, &region1);
126 dns_rdata_toregion(rdata2, &region2);
128 dns_name_fromregion(&name1, &region1);
129 dns_name_fromregion(&name2, &region2);
131 return (dns_name_rdatacompare(&name1, &name2));
134 static inline isc_result_t
135 fromstruct_in_nsap_ptr(ARGS_FROMSTRUCT) {
136 dns_rdata_in_nsap_ptr_t *nsap_ptr = source;
137 isc_region_t region;
139 REQUIRE(type == 23);
140 REQUIRE(rdclass == 1);
141 REQUIRE(source != NULL);
142 REQUIRE(nsap_ptr->common.rdtype == type);
143 REQUIRE(nsap_ptr->common.rdclass == rdclass);
145 UNUSED(type);
146 UNUSED(rdclass);
148 dns_name_toregion(&nsap_ptr->owner, &region);
149 return (isc_buffer_copyregion(target, &region));
152 static inline isc_result_t
153 tostruct_in_nsap_ptr(ARGS_TOSTRUCT) {
154 isc_region_t region;
155 dns_rdata_in_nsap_ptr_t *nsap_ptr = target;
156 dns_name_t name;
158 REQUIRE(rdata->type == 23);
159 REQUIRE(rdata->rdclass == 1);
160 REQUIRE(target != NULL);
161 REQUIRE(rdata->length != 0);
163 nsap_ptr->common.rdclass = rdata->rdclass;
164 nsap_ptr->common.rdtype = rdata->type;
165 ISC_LINK_INIT(&nsap_ptr->common, link);
167 dns_name_init(&name, NULL);
168 dns_rdata_toregion(rdata, &region);
169 dns_name_fromregion(&name, &region);
170 dns_name_init(&nsap_ptr->owner, NULL);
171 RETERR(name_duporclone(&name, mctx, &nsap_ptr->owner));
172 nsap_ptr->mctx = mctx;
173 return (ISC_R_SUCCESS);
176 static inline void
177 freestruct_in_nsap_ptr(ARGS_FREESTRUCT) {
178 dns_rdata_in_nsap_ptr_t *nsap_ptr = source;
180 REQUIRE(source != NULL);
181 REQUIRE(nsap_ptr->common.rdclass == 1);
182 REQUIRE(nsap_ptr->common.rdtype == 23);
184 if (nsap_ptr->mctx == NULL)
185 return;
187 dns_name_free(&nsap_ptr->owner, nsap_ptr->mctx);
188 nsap_ptr->mctx = NULL;
191 static inline isc_result_t
192 additionaldata_in_nsap_ptr(ARGS_ADDLDATA) {
193 REQUIRE(rdata->type == 23);
194 REQUIRE(rdata->rdclass == 1);
196 UNUSED(rdata);
197 UNUSED(add);
198 UNUSED(arg);
200 return (ISC_R_SUCCESS);
203 static inline isc_result_t
204 digest_in_nsap_ptr(ARGS_DIGEST) {
205 isc_region_t r;
206 dns_name_t name;
208 REQUIRE(rdata->type == 23);
209 REQUIRE(rdata->rdclass == 1);
211 dns_rdata_toregion(rdata, &r);
212 dns_name_init(&name, NULL);
213 dns_name_fromregion(&name, &r);
215 return (dns_name_digest(&name, digest, arg));
218 static inline isc_boolean_t
219 checkowner_in_nsap_ptr(ARGS_CHECKOWNER) {
221 REQUIRE(type == 23);
222 REQUIRE(rdclass == 1);
224 UNUSED(name);
225 UNUSED(type);
226 UNUSED(rdclass);
227 UNUSED(wildcard);
229 return (ISC_TRUE);
232 static inline isc_boolean_t
233 checknames_in_nsap_ptr(ARGS_CHECKNAMES) {
235 REQUIRE(rdata->type == 23);
236 REQUIRE(rdata->rdclass == 1);
238 UNUSED(rdata);
239 UNUSED(owner);
240 UNUSED(bad);
242 return (ISC_TRUE);
245 #endif /* RDATA_IN_1_NSAP_PTR_23_C */