loc_29.c revision 4529cdaedaf1a0a5f8ff89aeca510b7a4475446c
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.7 1999/08/12 01:32:30 halley Exp $ */
/* RFC 1876 */
#ifndef RDATA_GENERIC_LOC_29_C
#define RDATA_GENERIC_LOC_29_C
static inline dns_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;
/* degree */
return (DNS_R_RANGE);
/* minute */
goto getlong;
if (*e != 0)
return (DNS_R_SYNTAX);
return (DNS_R_RANGE);
return (DNS_R_RANGE);
/* second */
goto getlong;
if (*e != 0 && *e != '.')
return (DNS_R_SYNTAX);
return (DNS_R_RANGE);
if (*e == '.') {
e++;
for (i = 0; i < 3 ; i++) {
if (*e == 0)
break;
return (DNS_R_SYNTAX);
s1 *= 10;
}
for ( ; i < 3 ; i++)
s1 *= 10;
if (*e != 0)
return (DNS_R_SYNTAX);
} else
s1 *= 1000;
return (DNS_R_RANGE);
/* direction */
return (DNS_R_SYNTAX);
/* degree */
return (DNS_R_RANGE);
/* minute */
goto getalt;
if (*e != 0)
return (DNS_R_SYNTAX);
return (DNS_R_RANGE);
return (DNS_R_RANGE);
/* second */
goto getalt;
if (*e != 0 && *e != '.')
return (DNS_R_SYNTAX);
return (DNS_R_RANGE);
if (*e == '.') {
e++;
for (i = 0; i < 3 ; i++) {
if (*e == 0)
break;
return (DNS_R_SYNTAX);
s2 *= 10;
}
for ( ; i < 3 ; i++)
s2 *= 10;
if (*e != 0)
return (DNS_R_SYNTAX);
} else
s2 *= 1000;
return (DNS_R_RANGE);
/* direction */
return (DNS_R_SYNTAX);
/* alt */
if (*e != 0 && *e != '.' && *e != 'm')
return (DNS_R_SYNTAX);
if (m < -100000 || m > 42849672)
return (DNS_R_RANGE);
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)
return (DNS_R_SYNTAX);
if (m == -100000 && cm != 0)
return (DNS_R_RANGE);
return (DNS_R_RANGE);
/* adjust base */
altitude = m + 100000;
altitude *= 100;
/* size: optional */
goto encode;
}
if (*e != 0 && *e != '.' && *e != 'm')
return (DNS_R_SYNTAX);
if (m < 0 || m > 90000000)
return (DNS_R_RANGE);
cm = 0;
if (*e == '.') {
e++;
for (i = 0; i < 2 ; i++) {
if (*e == 0 || *e == 'm')
break;
return (DNS_R_SYNTAX);
cm *= 10;
}
for ( ; i < 2 ; i++)
cm *= 10;
}
if (*e == 'm')
e++;
if (*e != 0)
return (DNS_R_SYNTAX);
/* 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;
}
}
/* hp: optional */
goto encode;
}
if (*e != 0 && *e != '.' && *e != 'm')
return (DNS_R_SYNTAX);
if (m < 0 || m > 90000000)
return (DNS_R_RANGE);
cm = 0;
if (*e == '.') {
e++;
for (i = 0; i < 2 ; i++) {
if (*e == 0 || *e == 'm')
break;
return (DNS_R_SYNTAX);
cm *= 10;
}
for ( ; i < 2 ; i++)
cm *= 10;
}
if (*e == 'm')
e++;
if (*e != 0)
return (DNS_R_SYNTAX);
/* 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;
}
/* vp: optional */
goto encode;
}
if (*e != 0 && *e != '.' && *e != 'm')
return (DNS_R_SYNTAX);
if (m < 0 || m > 90000000)
return (DNS_R_RANGE);
cm = 0;
if (*e == '.') {
e++;
for (i = 0; i < 2 ; i++) {
if (*e == 0 || *e == 'm')
break;
return (DNS_R_SYNTAX);
cm *= 10;
}
for ( ; i < 2 ; i++)
cm *= 10;
}
if (*e == 'm')
e++;
if (*e != 0)
return (DNS_R_SYNTAX);
/* 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 dns_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 < 10000000) {
} else {
altitude -= 10000000;
}
}
static inline dns_result_t
{
unsigned char c;
unsigned long latitude;
unsigned long longitude;
return (DNS_R_UNEXPECTEDEND);
return (DNS_R_NOTIMPLEMENTED);
return (DNS_R_UNEXPECTEDEND);
/* size */
if (c != 0)
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (DNS_R_RANGE);
/* horiz pre */
if (c != 0)
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (DNS_R_RANGE);
/* vert pre */
if (c != 0)
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (DNS_R_RANGE);
/* latitude */
return (DNS_R_RANGE);
/* longitude */
return (DNS_R_RANGE);
/* altitiude */
/* all values possible */
}
static inline dns_result_t
}
static inline int
}
static inline dns_result_t
{
return (DNS_R_NOTIMPLEMENTED);
}
static inline dns_result_t
return (DNS_R_NOTIMPLEMENTED);
}
static inline void
freestruct_loc(void *source) {
}
static inline dns_result_t
void *arg)
{
(void)add;
(void)arg;
return (DNS_R_SUCCESS);
}
#endif /* RDATA_GENERIC_LOC_29_C */