Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / gpos_27.c
blob643d593a58677c0bff6f6656d339e670313f529d
1 /* $NetBSD: gpos_27.c,v 1.4 2014/12/10 04:37:59 christos Exp $ */
3 /*
4 * Copyright (C) 2004, 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-2002 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: gpos_27.c,v 1.43 2009/12/04 22:06:37 tbox Exp */
22 /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */
24 /* RFC1712 */
26 #ifndef RDATA_GENERIC_GPOS_27_C
27 #define RDATA_GENERIC_GPOS_27_C
29 #define RRTYPE_GPOS_ATTRIBUTES (0)
31 static inline isc_result_t
32 fromtext_gpos(ARGS_FROMTEXT) {
33 isc_token_t token;
34 int i;
36 REQUIRE(type == 27);
38 UNUSED(type);
39 UNUSED(rdclass);
40 UNUSED(origin);
41 UNUSED(options);
42 UNUSED(callbacks);
44 for (i = 0; i < 3; i++) {
45 RETERR(isc_lex_getmastertoken(lexer, &token,
46 isc_tokentype_qstring,
47 ISC_FALSE));
48 RETTOK(txt_fromtext(&token.value.as_textregion, target));
50 return (ISC_R_SUCCESS);
53 static inline isc_result_t
54 totext_gpos(ARGS_TOTEXT) {
55 isc_region_t region;
56 int i;
58 REQUIRE(rdata->type == 27);
59 REQUIRE(rdata->length != 0);
61 UNUSED(tctx);
63 dns_rdata_toregion(rdata, &region);
65 for (i = 0; i < 3; i++) {
66 RETERR(txt_totext(&region, ISC_TRUE, target));
67 if (i != 2)
68 RETERR(str_totext(" ", target));
71 return (ISC_R_SUCCESS);
74 static inline isc_result_t
75 fromwire_gpos(ARGS_FROMWIRE) {
76 int i;
78 REQUIRE(type == 27);
80 UNUSED(type);
81 UNUSED(dctx);
82 UNUSED(rdclass);
83 UNUSED(options);
85 for (i = 0; i < 3; i++)
86 RETERR(txt_fromwire(source, target));
87 return (ISC_R_SUCCESS);
90 static inline isc_result_t
91 towire_gpos(ARGS_TOWIRE) {
93 REQUIRE(rdata->type == 27);
94 REQUIRE(rdata->length != 0);
96 UNUSED(cctx);
98 return (mem_tobuffer(target, rdata->data, rdata->length));
101 static inline int
102 compare_gpos(ARGS_COMPARE) {
103 isc_region_t r1;
104 isc_region_t r2;
106 REQUIRE(rdata1->type == rdata2->type);
107 REQUIRE(rdata1->rdclass == rdata2->rdclass);
108 REQUIRE(rdata1->type == 27);
109 REQUIRE(rdata1->length != 0);
110 REQUIRE(rdata2->length != 0);
112 dns_rdata_toregion(rdata1, &r1);
113 dns_rdata_toregion(rdata2, &r2);
114 return (isc_region_compare(&r1, &r2));
117 static inline isc_result_t
118 fromstruct_gpos(ARGS_FROMSTRUCT) {
119 dns_rdata_gpos_t *gpos = source;
121 REQUIRE(type == 27);
122 REQUIRE(source != NULL);
123 REQUIRE(gpos->common.rdtype == type);
124 REQUIRE(gpos->common.rdclass == rdclass);
126 UNUSED(type);
127 UNUSED(rdclass);
129 RETERR(uint8_tobuffer(gpos->long_len, target));
130 RETERR(mem_tobuffer(target, gpos->longitude, gpos->long_len));
131 RETERR(uint8_tobuffer(gpos->lat_len, target));
132 RETERR(mem_tobuffer(target, gpos->latitude, gpos->lat_len));
133 RETERR(uint8_tobuffer(gpos->alt_len, target));
134 return (mem_tobuffer(target, gpos->altitude, gpos->alt_len));
137 static inline isc_result_t
138 tostruct_gpos(ARGS_TOSTRUCT) {
139 dns_rdata_gpos_t *gpos = target;
140 isc_region_t region;
142 REQUIRE(rdata->type == 27);
143 REQUIRE(target != NULL);
144 REQUIRE(rdata->length != 0);
146 gpos->common.rdclass = rdata->rdclass;
147 gpos->common.rdtype = rdata->type;
148 ISC_LINK_INIT(&gpos->common, link);
150 dns_rdata_toregion(rdata, &region);
151 gpos->long_len = uint8_fromregion(&region);
152 isc_region_consume(&region, 1);
153 gpos->longitude = mem_maybedup(mctx, region.base, gpos->long_len);
154 if (gpos->longitude == NULL)
155 return (ISC_R_NOMEMORY);
156 isc_region_consume(&region, gpos->long_len);
158 gpos->lat_len = uint8_fromregion(&region);
159 isc_region_consume(&region, 1);
160 gpos->latitude = mem_maybedup(mctx, region.base, gpos->lat_len);
161 if (gpos->latitude == NULL)
162 goto cleanup_longitude;
163 isc_region_consume(&region, gpos->lat_len);
165 gpos->alt_len = uint8_fromregion(&region);
166 isc_region_consume(&region, 1);
167 if (gpos->lat_len > 0) {
168 gpos->altitude =
169 mem_maybedup(mctx, region.base, gpos->alt_len);
170 if (gpos->altitude == NULL)
171 goto cleanup_latitude;
172 } else
173 gpos->altitude = NULL;
175 gpos->mctx = mctx;
176 return (ISC_R_SUCCESS);
178 cleanup_latitude:
179 if (mctx != NULL && gpos->longitude != NULL)
180 isc_mem_free(mctx, gpos->longitude);
182 cleanup_longitude:
183 if (mctx != NULL && gpos->latitude != NULL)
184 isc_mem_free(mctx, gpos->latitude);
185 return (ISC_R_NOMEMORY);
188 static inline void
189 freestruct_gpos(ARGS_FREESTRUCT) {
190 dns_rdata_gpos_t *gpos = source;
192 REQUIRE(source != NULL);
193 REQUIRE(gpos->common.rdtype == 27);
195 if (gpos->mctx == NULL)
196 return;
198 if (gpos->longitude != NULL)
199 isc_mem_free(gpos->mctx, gpos->longitude);
200 if (gpos->latitude != NULL)
201 isc_mem_free(gpos->mctx, gpos->latitude);
202 if (gpos->altitude != NULL)
203 isc_mem_free(gpos->mctx, gpos->altitude);
204 gpos->mctx = NULL;
207 static inline isc_result_t
208 additionaldata_gpos(ARGS_ADDLDATA) {
209 REQUIRE(rdata->type == 27);
211 UNUSED(rdata);
212 UNUSED(add);
213 UNUSED(arg);
215 return (ISC_R_SUCCESS);
218 static inline isc_result_t
219 digest_gpos(ARGS_DIGEST) {
220 isc_region_t r;
222 REQUIRE(rdata->type == 27);
224 dns_rdata_toregion(rdata, &r);
226 return ((digest)(arg, &r));
229 static inline isc_boolean_t
230 checkowner_gpos(ARGS_CHECKOWNER) {
232 REQUIRE(type == 27);
234 UNUSED(name);
235 UNUSED(type);
236 UNUSED(rdclass);
237 UNUSED(wildcard);
239 return (ISC_TRUE);
242 static inline isc_boolean_t
243 checknames_gpos(ARGS_CHECKNAMES) {
245 REQUIRE(rdata->type == 27);
247 UNUSED(rdata);
248 UNUSED(owner);
249 UNUSED(bad);
251 return (ISC_TRUE);
254 static inline int
255 casecompare_gpos(ARGS_COMPARE) {
256 return (compare_gpos(rdata1, rdata2));
259 #endif /* RDATA_GENERIC_GPOS_27_C */