loc_29.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1999-2005, 2007, 2009, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: loc_29.c,v 1.50 2009/12/04 21:09:33 marka Exp $ */
/* Reviewed: Wed Mar 15 18:13:09 PST 2000 by explorer */
/* RFC1876 */
#ifndef RDATA_GENERIC_LOC_29_C
#define RDATA_GENERIC_LOC_29_C
#define RRTYPE_LOC_ATTRIBUTES (0)
static inline isc_result_t
unsigned char size;
unsigned char hp;
unsigned char vp;
unsigned char version;
long tmp;
long m;
long cm;
10000, 100000, 1000000, 10000000 };
int man;
int exp;
char *e;
int i;
unsigned long latitude;
unsigned long longitude;
unsigned long altitude;
/*
* Defaults.
*/
version = 0;
/*
* Degrees.
*/
ISC_FALSE));
/*
* Minutes.
*/
ISC_FALSE));
goto getlong;
if (*e != 0)
/*
* Seconds.
*/
ISC_FALSE));
goto getlong;
if (*e != 0 && *e != '.')
if (*e == '.') {
const char *l;
e++;
for (i = 0; i < 3; i++) {
if (*e == 0)
break;
s1 *= 10;
}
for (; i < 3; i++)
s1 *= 10;
l = e;
while (*e != 0) {
if (decvalue(*e++) < 0)
}
file = "UNKNOWN";
"precision digits ignored",
DNS_AS_STR(token));
}
} else
s1 *= 1000;
/*
* Direction.
*/
ISC_FALSE));
/*
* Degrees.
*/
ISC_FALSE));
/*
* Minutes.
*/
ISC_FALSE));
goto getalt;
if (*e != 0)
/*
* Seconds.
*/
ISC_FALSE));
goto getalt;
if (*e != 0 && *e != '.')
if (*e == '.') {
const char *l;
e++;
for (i = 0; i < 3; i++) {
if (*e == 0)
break;
s2 *= 10;
}
for (; i < 3; i++)
s2 *= 10;
l = e;
while (*e != 0) {
if (decvalue(*e++) < 0)
}
file = "UNKNOWN";
"precision digits ignored",
"dns_rdata_fromtext",
}
} else
s2 *= 1000;
/*
* Direction.
*/
ISC_FALSE));
/*
* Altitude.
*/
ISC_FALSE));
if (*e != 0 && *e != '.' && *e != 'm')
if (m < -100000 || m > 42849672)
cm = 0;
if (*e == '.') {
e++;
for (i = 0; i < 2; i++) {
if (*e == 0 || *e == 'm')
break;
return (DNS_R_SYNTAX);
cm *= 10;
if (m < 0)
else
}
for (; i < 2; i++)
cm *= 10;
}
if (*e == 'm')
e++;
if (*e != 0)
if (m == -100000 && cm != 0)
/*
* Adjust base.
*/
altitude = m + 100000;
altitude *= 100;
/*
* Size: optional.
*/
ISC_TRUE));
goto encode;
}
if (*e != 0 && *e != '.' && *e != 'm')
if (m < 0 || m > 90000000)
cm = 0;
if (*e == '.') {
e++;
for (i = 0; i < 2; i++) {
if (*e == 0 || *e == 'm')
break;
cm *= 10;
}
for (; i < 2; i++)
cm *= 10;
}
if (*e == 'm')
e++;
if (*e != 0)
/*
* We don't just multiply out as we will overflow.
*/
if (m > 0) {
break;
exp += 2;
} else {
if (cm >= 10) {
exp = 1;
} else {
exp = 0;
}
}
/*
* Horizontal precision: optional.
*/
ISC_TRUE));
goto encode;
}
if (*e != 0 && *e != '.' && *e != 'm')
if (m < 0 || m > 90000000)
cm = 0;
if (*e == '.') {
e++;
for (i = 0; i < 2; i++) {
if (*e == 0 || *e == 'm')
break;
cm *= 10;
}
for (; i < 2; i++)
cm *= 10;
}
if (*e == 'm')
e++;
if (*e != 0)
/*
* We don't just multiply out as we will overflow.
*/
if (m > 0) {
break;
exp += 2;
} else if (cm >= 10) {
exp = 1;
} else {
exp = 0;
}
/*
* Vertical precision: optional.
*/
ISC_TRUE));
goto encode;
}
if (*e != 0 && *e != '.' && *e != 'm')
if (m < 0 || m > 90000000)
cm = 0;
if (*e == '.') {
e++;
for (i = 0; i < 2; i++) {
if (*e == 0 || *e == 'm')
break;
cm *= 10;
}
for (; i < 2; i++)
cm *= 10;
}
if (*e == 'm')
e++;
if (*e != 0)
/*
* We don't just multiply out as we will overflow.
*/
if (m > 0) {
break;
exp += 2;
} else if (cm >= 10) {
exp = 1;
} else {
exp = 0;
}
if (north)
else
if (east)
else
}
static inline isc_result_t
unsigned long latitude;
unsigned long longitude;
unsigned long altitude;
char buf[sizeof("89 59 59.999 N 179 59 59.999 E "
"42849672.95m 90000000m 90000000m 90000000m")];
char sbuf[sizeof("90000000m")];
char hbuf[sizeof("90000000m")];
char vbuf[sizeof("90000000m")];
10000, 100000, 1000000, 10000000 };
return (ISC_R_NOTIMPLEMENTED);
else
else
else
if (latitude >= 0x80000000) {
latitude -= 0x80000000;
} else {
}
latitude /= 1000;
latitude /= 60;
latitude /= 60;
if (longitude >= 0x80000000) {
longitude -= 0x80000000;
} else {
}
longitude /= 1000;
longitude /= 60;
longitude /= 60;
if (altitude < 10000000U) {
} else {
altitude -= 10000000;
}
}
static inline isc_result_t
unsigned char c;
unsigned long latitude;
unsigned long longitude;
return (ISC_R_UNEXPECTEDEND);
/* Treat as unknown. */
}
return (ISC_R_UNEXPECTEDEND);
/*
* Size.
*/
if (c != 0)
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
/*
* Horizontal precision.
*/
if (c != 0)
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
/*
* Vertical precision.
*/
if (c != 0)
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
/*
* Latitude.
*/
return (ISC_R_RANGE);
/*
* Longitude.
*/
return (ISC_R_RANGE);
/*
* Altitude.
* All values possible.
*/
}
static inline isc_result_t
}
static inline int
}
static inline isc_result_t
isc_uint8_t c;
return (ISC_R_NOTIMPLEMENTED);
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
return (ISC_R_RANGE);
return (ISC_R_RANGE);
}
static inline isc_result_t
isc_region_t r;
dns_rdata_toregion(rdata, &r);
version = uint8_fromregion(&r);
if (version != 0)
return (ISC_R_NOTIMPLEMENTED);
isc_region_consume(&r, 1);
isc_region_consume(&r, 1);
isc_region_consume(&r, 1);
isc_region_consume(&r, 1);
isc_region_consume(&r, 4);
isc_region_consume(&r, 4);
isc_region_consume(&r, 4);
return (ISC_R_SUCCESS);
}
static inline void
}
static inline isc_result_t
return (ISC_R_SUCCESS);
}
static inline isc_result_t
isc_region_t r;
dns_rdata_toregion(rdata, &r);
}
static inline isc_boolean_t
return (ISC_TRUE);
}
static inline isc_boolean_t
return (ISC_TRUE);
}
static inline int
}
#endif /* RDATA_GENERIC_LOC_29_C */