loc_29.c revision d362465c77b375be2707bc83cebc731d0645d12d
/*
* Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: loc_29.c,v 1.47 2009/01/17 23:47:43 tbox 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 };
/* version = sr.base[0]; */
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);
return (ISC_R_NOTIMPLEMENTED);
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);
}
#endif /* RDATA_GENERIC_LOC_29_C */