mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-23 16:42:35 +00:00
Changed byte to uchar to avoid clashes with win32 headers.
git-svn-id: http://svn.osgeo.org/postgis/trunk@1415 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
6e62a5d8ff
commit
593a8032ac
|
@ -1,10 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include "wktparse.h"
|
||||
|
||||
//#include "lwgeom_pg.h"
|
||||
#include "liblwgeom.h"
|
||||
#include "wktparse.h"
|
||||
|
||||
//#define PGIS_DEBUG_CALLS 1
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
* www.telogis.com
|
||||
*
|
||||
*/
|
||||
#include "wktparse.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "liblwgeom.h"
|
||||
#include "wktparse.h"
|
||||
|
||||
/*
|
||||
//To get byte order
|
||||
|
@ -26,7 +27,7 @@ typedef unsigned long int4;
|
|||
typedef struct tag_tuple tuple;
|
||||
|
||||
struct tag_outputstate{
|
||||
byte* pos;
|
||||
uchar* pos;
|
||||
};
|
||||
|
||||
typedef struct tag_outputstate output_state;
|
||||
|
@ -129,10 +130,10 @@ void alloc_multipolygon(void);
|
|||
void alloc_geomertycollection(void);
|
||||
void alloc_counter(void);
|
||||
void alloc_empty(void);
|
||||
byte* make_lwgeom(void);
|
||||
byte strhex_readbyte(const char* in);
|
||||
byte read_wkb_byte(const char** in);
|
||||
void read_wkb_bytes(const char** in,byte* out, int cnt);
|
||||
uchar* make_lwgeom(void);
|
||||
uchar strhex_readbyte(const char* in);
|
||||
uchar read_wkb_byte(const char** in);
|
||||
void read_wkb_bytes(const char** in,uchar* out, int cnt);
|
||||
int4 read_wkb_int(const char** in);
|
||||
double read_wbk_double(const char** in,int convert_from_int);
|
||||
void read_wkb_point(const char** b);
|
||||
|
@ -140,9 +141,9 @@ void read_collection(const char** b,read_col_func f);
|
|||
void read_collection2(const char** b);
|
||||
void parse_wkb(const char** b);
|
||||
void alloc_wkb(const char* parser);
|
||||
byte* parse_it(const char* geometry,allocator allocfunc,report_error errfunc);
|
||||
byte* parse_lwg(const char* geometry,allocator allocfunc,report_error errfunc);
|
||||
byte* parse_lwgi(const char* geometry,allocator allocfunc,report_error errfunc);
|
||||
uchar* parse_it(const char* geometry,allocator allocfunc,report_error errfunc);
|
||||
uchar* parse_lwg(const char* geometry,allocator allocfunc,report_error errfunc);
|
||||
uchar* parse_lwgi(const char* geometry,allocator allocfunc,report_error errfunc);
|
||||
|
||||
void
|
||||
set_srid(double d_srid)
|
||||
|
@ -300,7 +301,7 @@ WRITE_INT4(output_state * out,int4 val)
|
|||
val |=0x80;
|
||||
}
|
||||
|
||||
*out->pos++ = (byte)val;
|
||||
*out->pos++ = (uchar)val;
|
||||
the_geom.alloc_size-=3;
|
||||
}
|
||||
else{
|
||||
|
@ -460,7 +461,7 @@ alloc_point_4d(double x,double y,double z,double m)
|
|||
void
|
||||
write_type(tuple* this,output_state* out)
|
||||
{
|
||||
byte type=0;
|
||||
uchar type=0;
|
||||
|
||||
//Empty handler - switch back
|
||||
if ( this->uu.nn.type == 0xff )
|
||||
|
@ -596,13 +597,13 @@ alloc_empty()
|
|||
|
||||
}
|
||||
|
||||
byte *
|
||||
uchar *
|
||||
make_lwgeom()
|
||||
{
|
||||
byte* out_c;
|
||||
uchar* out_c;
|
||||
output_state out;
|
||||
tuple* cur;
|
||||
out_c = (byte*)local_malloc(the_geom.alloc_size);
|
||||
out_c = (uchar*)local_malloc(the_geom.alloc_size);
|
||||
out.pos = out_c;
|
||||
cur = the_geom.first ;
|
||||
|
||||
|
@ -634,7 +635,7 @@ lwg_parse_yyerror(char* s)
|
|||
puts '{'+a.join(",")+'}'
|
||||
|
||||
*/
|
||||
static const byte to_hex[] = {
|
||||
static const uchar to_hex[] = {
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
|
@ -652,7 +653,7 @@ static const byte to_hex[] = {
|
|||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255};
|
||||
|
||||
byte
|
||||
uchar
|
||||
strhex_readbyte(const char* in)
|
||||
{
|
||||
if ( *in == 0 ){
|
||||
|
@ -664,10 +665,10 @@ strhex_readbyte(const char* in)
|
|||
return to_hex[(int)*in]<<4 | to_hex[(int)*(in+1)];
|
||||
}
|
||||
|
||||
byte
|
||||
uchar
|
||||
read_wkb_byte(const char** in)
|
||||
{
|
||||
byte ret = strhex_readbyte(*in);
|
||||
uchar ret = strhex_readbyte(*in);
|
||||
(*in)+=2;
|
||||
return ret;
|
||||
}
|
||||
|
@ -675,7 +676,7 @@ read_wkb_byte(const char** in)
|
|||
int swap_order;
|
||||
|
||||
void
|
||||
read_wkb_bytes(const char** in,byte* out, int cnt)
|
||||
read_wkb_bytes(const char** in,uchar* out, int cnt)
|
||||
{
|
||||
if ( ! swap_order ){
|
||||
while(cnt--) *out++ = read_wkb_byte(in);
|
||||
|
@ -690,7 +691,7 @@ int4
|
|||
read_wkb_int(const char** in)
|
||||
{
|
||||
int4 ret;
|
||||
read_wkb_bytes(in,(byte*)&ret,4);
|
||||
read_wkb_bytes(in,(uchar*)&ret,4);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -700,7 +701,7 @@ read_wbk_double(const char** in,int convert_from_int)
|
|||
double ret;
|
||||
|
||||
if ( ! convert_from_int){
|
||||
read_wkb_bytes(in,(byte*)&ret,8);
|
||||
read_wkb_bytes(in,(uchar*)&ret,8);
|
||||
return ret;
|
||||
}else{
|
||||
ret = read_wkb_int(in);
|
||||
|
@ -771,7 +772,7 @@ void
|
|||
parse_wkb(const char** b)
|
||||
{
|
||||
int4 type;
|
||||
byte xdr = read_wkb_byte(b);
|
||||
uchar xdr = read_wkb_byte(b);
|
||||
int4 localsrid;
|
||||
|
||||
swap_order=0;
|
||||
|
@ -883,7 +884,7 @@ alloc_wkb(const char* parser)
|
|||
/*
|
||||
Parse a string and return a LW_GEOM
|
||||
*/
|
||||
byte *
|
||||
uchar *
|
||||
parse_it(const char* geometry,allocator allocfunc,report_error errfunc)
|
||||
{
|
||||
|
||||
|
@ -902,14 +903,14 @@ parse_it(const char* geometry,allocator allocfunc,report_error errfunc)
|
|||
return make_lwgeom();
|
||||
}
|
||||
|
||||
byte *
|
||||
uchar *
|
||||
parse_lwg(const char* geometry,allocator allocfunc,report_error errfunc)
|
||||
{
|
||||
the_geom.lwgi=0;
|
||||
return parse_it(geometry,allocfunc,errfunc);
|
||||
}
|
||||
|
||||
byte *
|
||||
uchar *
|
||||
parse_lwgi(const char* geometry,allocator allocfunc,report_error errfunc)
|
||||
{
|
||||
the_geom.lwgi=1;
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef unsigned char byte;
|
||||
#ifndef _LIBLWGEOM_H
|
||||
typedef unsigned char uchar;
|
||||
#endif
|
||||
typedef void* (*allocator)(size_t size);
|
||||
typedef void (*freeor)(void* mem);
|
||||
typedef void (*report_error)(const char* string);
|
||||
|
@ -64,10 +66,10 @@ void alloc_wkb(const char* parser);
|
|||
You are responsible for freeing the returned memory.
|
||||
*/
|
||||
|
||||
byte* parse_lwg(const char* wkt,allocator allocfunc,report_error errfunc);
|
||||
byte* parse_lwgi(const char* wkt,allocator allocfunc,report_error errfunc);
|
||||
char* unparse_WKT(byte* serialized, allocator alloc,freeor free);
|
||||
char* unparse_WKB(byte* serialized, allocator alloc,freeor free, char endian, size_t *outsize, byte hexform);
|
||||
uchar* parse_lwg(const char* wkt,allocator allocfunc,report_error errfunc);
|
||||
uchar* parse_lwgi(const char* wkt,allocator allocfunc,report_error errfunc);
|
||||
char* unparse_WKT(uchar* serialized, allocator alloc,freeor free);
|
||||
char* unparse_WKB(uchar* serialized, allocator alloc,freeor free, char endian, size_t *outsize, uchar hexform);
|
||||
int lwg_parse_yyparse(void);
|
||||
int lwg_parse_yyerror(char* s);
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "wktparse.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
@ -20,12 +19,14 @@
|
|||
//#include <netinet/ip.h>
|
||||
|
||||
#include "liblwgeom.h"
|
||||
#include "wktparse.h"
|
||||
|
||||
|
||||
//-- Typedefs ----------------------------------------------
|
||||
|
||||
typedef unsigned long int4;
|
||||
typedef byte* (*outfunc)(byte*,int);
|
||||
typedef byte* (*outwkbfunc)(byte*);
|
||||
typedef uchar* (*outfunc)(uchar*,int);
|
||||
typedef uchar* (*outwkbfunc)(uchar*);
|
||||
|
||||
//-- Prototypes --------------------------------------------
|
||||
|
||||
|
@ -34,24 +35,24 @@ void to_end(void);
|
|||
void write_str(const char* str);
|
||||
void write_double(double val);
|
||||
void write_int(int i);
|
||||
int4 read_int(byte** geom);
|
||||
double read_double(byte** geom);
|
||||
byte* output_point(byte* geom,int supress);
|
||||
byte* output_single(byte* geom,int supress);
|
||||
byte* output_collection(byte* geom,outfunc func,int supress);
|
||||
byte* output_collection_2(byte* geom,int suppress);
|
||||
byte* output_multipoint(byte* geom,int suppress);
|
||||
int4 read_int(uchar** geom);
|
||||
double read_double(uchar** geom);
|
||||
uchar* output_point(uchar* geom,int supress);
|
||||
uchar* output_single(uchar* geom,int supress);
|
||||
uchar* output_collection(uchar* geom,outfunc func,int supress);
|
||||
uchar* output_collection_2(uchar* geom,int suppress);
|
||||
uchar* output_multipoint(uchar* geom,int suppress);
|
||||
|
||||
void write_wkb_hex_bytes(byte* ptr, unsigned int cnt, size_t size);
|
||||
void write_wkb_bin_bytes(byte* ptr, unsigned int cnt, size_t size);
|
||||
void write_wkb_bin_flip_bytes(byte* ptr, unsigned int cnt, size_t size);
|
||||
void write_wkb_hex_flip_bytes(byte* ptr, unsigned int cnt, size_t size);
|
||||
void write_wkb_hex_bytes(uchar* ptr, unsigned int cnt, size_t size);
|
||||
void write_wkb_bin_bytes(uchar* ptr, unsigned int cnt, size_t size);
|
||||
void write_wkb_bin_flip_bytes(uchar* ptr, unsigned int cnt, size_t size);
|
||||
void write_wkb_hex_flip_bytes(uchar* ptr, unsigned int cnt, size_t size);
|
||||
|
||||
void write_wkb_int(int i);
|
||||
byte* output_wkb_collection(byte* geom,outwkbfunc func);
|
||||
byte* output_wkb_collection_2(byte* geom);
|
||||
byte* output_wkb_point(byte* geom);
|
||||
byte* output_wkb(byte* geom);
|
||||
uchar* output_wkb_collection(uchar* geom,outwkbfunc func);
|
||||
uchar* output_wkb_collection_2(uchar* geom);
|
||||
uchar* output_wkb_point(uchar* geom);
|
||||
uchar* output_wkb(uchar* geom);
|
||||
|
||||
//-- Globals -----------------------------------------------
|
||||
|
||||
|
@ -63,8 +64,8 @@ static char* out_pos;
|
|||
static int len;
|
||||
static int lwgi;
|
||||
//static int flipbytes;
|
||||
static byte endianbyte;
|
||||
void (*write_wkb_bytes)(byte* ptr,unsigned int cnt,size_t size);
|
||||
static uchar endianbyte;
|
||||
void (*write_wkb_bytes)(uchar* ptr,unsigned int cnt,size_t size);
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
||||
|
@ -119,7 +120,7 @@ write_int(int i){
|
|||
}
|
||||
|
||||
int4
|
||||
read_int(byte** geom)
|
||||
read_int(uchar** geom)
|
||||
{
|
||||
int4 ret;
|
||||
#ifdef SHRINK_INTS
|
||||
|
@ -152,7 +153,7 @@ read_int(byte** geom)
|
|||
|
||||
double round(double);
|
||||
|
||||
double read_double(byte** geom){
|
||||
double read_double(uchar** geom){
|
||||
if (lwgi){
|
||||
double ret = *((int4*)*geom);
|
||||
ret /= 0xb60b60;
|
||||
|
@ -168,8 +169,8 @@ double read_double(byte** geom){
|
|||
}
|
||||
}
|
||||
|
||||
byte *
|
||||
output_point(byte* geom,int supress)
|
||||
uchar *
|
||||
output_point(uchar* geom,int supress)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -181,8 +182,8 @@ output_point(byte* geom,int supress)
|
|||
return geom;
|
||||
}
|
||||
|
||||
byte *
|
||||
output_single(byte* geom,int supress)
|
||||
uchar *
|
||||
output_single(uchar* geom,int supress)
|
||||
{
|
||||
write_str("(");
|
||||
geom=output_point(geom,supress);
|
||||
|
@ -190,8 +191,8 @@ output_single(byte* geom,int supress)
|
|||
return geom;
|
||||
}
|
||||
|
||||
byte *
|
||||
output_collection(byte* geom,outfunc func,int supress)
|
||||
uchar *
|
||||
output_collection(uchar* geom,outfunc func,int supress)
|
||||
{
|
||||
int cnt = read_int(&geom);
|
||||
if ( cnt == 0 ){
|
||||
|
@ -210,16 +211,16 @@ output_collection(byte* geom,outfunc func,int supress)
|
|||
return geom;
|
||||
}
|
||||
|
||||
byte *
|
||||
output_collection_2(byte* geom,int suppress)
|
||||
uchar *
|
||||
output_collection_2(uchar* geom,int suppress)
|
||||
{
|
||||
return output_collection(geom,output_point,suppress);
|
||||
}
|
||||
|
||||
byte *output_wkt(byte* geom, int supress);
|
||||
uchar *output_wkt(uchar* geom, int supress);
|
||||
|
||||
/* special case for multipoint to supress extra brackets */
|
||||
byte *output_multipoint(byte* geom,int suppress){
|
||||
uchar *output_multipoint(uchar* geom,int suppress){
|
||||
unsigned type = *geom & 0x0f;
|
||||
|
||||
if ( type == POINTTYPE )
|
||||
|
@ -237,8 +238,8 @@ byte *output_multipoint(byte* geom,int suppress){
|
|||
// Suppress=0 // write TYPE, M, coords
|
||||
// Suppress=1 // write TYPE, coords
|
||||
// Suppress=2 // write only coords
|
||||
byte *
|
||||
output_wkt(byte* geom, int supress)
|
||||
uchar *
|
||||
output_wkt(uchar* geom, int supress)
|
||||
{
|
||||
|
||||
unsigned type=*geom++;
|
||||
|
@ -351,7 +352,7 @@ output_wkt(byte* geom, int supress)
|
|||
}
|
||||
|
||||
char *
|
||||
unparse_WKT(byte* serialized, allocator alloc, freeor free)
|
||||
unparse_WKT(uchar* serialized, allocator alloc, freeor free)
|
||||
{
|
||||
|
||||
if (serialized==NULL)
|
||||
|
@ -372,7 +373,7 @@ static char outchr[]={"0123456789ABCDEF" };
|
|||
|
||||
/* Write HEX bytes flipping */
|
||||
void
|
||||
write_wkb_hex_flip_bytes(byte* ptr, unsigned int cnt, size_t size)
|
||||
write_wkb_hex_flip_bytes(uchar* ptr, unsigned int cnt, size_t size)
|
||||
{
|
||||
unsigned int bc; // byte count
|
||||
|
||||
|
@ -390,7 +391,7 @@ write_wkb_hex_flip_bytes(byte* ptr, unsigned int cnt, size_t size)
|
|||
|
||||
/* Write HEX bytes w/out flipping */
|
||||
void
|
||||
write_wkb_hex_bytes(byte* ptr, unsigned int cnt, size_t size)
|
||||
write_wkb_hex_bytes(uchar* ptr, unsigned int cnt, size_t size)
|
||||
{
|
||||
unsigned int bc; // byte count
|
||||
|
||||
|
@ -408,7 +409,7 @@ write_wkb_hex_bytes(byte* ptr, unsigned int cnt, size_t size)
|
|||
|
||||
/* Write BIN bytes flipping */
|
||||
void
|
||||
write_wkb_bin_flip_bytes(byte* ptr, unsigned int cnt, size_t size)
|
||||
write_wkb_bin_flip_bytes(uchar* ptr, unsigned int cnt, size_t size)
|
||||
{
|
||||
unsigned int bc; // byte count
|
||||
|
||||
|
@ -425,7 +426,7 @@ write_wkb_bin_flip_bytes(byte* ptr, unsigned int cnt, size_t size)
|
|||
|
||||
/* Write BIN bytes w/out flipping */
|
||||
void
|
||||
write_wkb_bin_bytes(byte* ptr, unsigned int cnt, size_t size)
|
||||
write_wkb_bin_bytes(uchar* ptr, unsigned int cnt, size_t size)
|
||||
{
|
||||
unsigned int bc; // byte count
|
||||
|
||||
|
@ -440,8 +441,8 @@ write_wkb_bin_bytes(byte* ptr, unsigned int cnt, size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
byte *
|
||||
output_wkb_point(byte* geom)
|
||||
uchar *
|
||||
output_wkb_point(uchar* geom)
|
||||
{
|
||||
if ( lwgi ){
|
||||
write_wkb_bytes(geom,dims,4);
|
||||
|
@ -455,11 +456,11 @@ output_wkb_point(byte* geom)
|
|||
|
||||
void
|
||||
write_wkb_int(int i){
|
||||
write_wkb_bytes((byte*)&i,1,4);
|
||||
write_wkb_bytes((uchar*)&i,1,4);
|
||||
}
|
||||
|
||||
byte *
|
||||
output_wkb_collection(byte* geom,outwkbfunc func)
|
||||
uchar *
|
||||
output_wkb_collection(uchar* geom,outwkbfunc func)
|
||||
{
|
||||
int cnt = read_int(&geom);
|
||||
#ifdef PGIS_DEBUG
|
||||
|
@ -470,14 +471,14 @@ output_wkb_collection(byte* geom,outwkbfunc func)
|
|||
return geom;
|
||||
}
|
||||
|
||||
byte *
|
||||
output_wkb_collection_2(byte* geom){
|
||||
uchar *
|
||||
output_wkb_collection_2(uchar* geom){
|
||||
return output_wkb_collection(geom,output_wkb_point);
|
||||
}
|
||||
|
||||
|
||||
byte *
|
||||
output_wkb(byte* geom)
|
||||
uchar *
|
||||
output_wkb(uchar* geom)
|
||||
{
|
||||
unsigned char type=*geom++;
|
||||
int4 wkbtype;
|
||||
|
@ -558,7 +559,7 @@ output_wkb(byte* geom)
|
|||
}
|
||||
|
||||
char *
|
||||
unparse_WKB(byte* serialized, allocator alloc, freeor free, char endian, size_t *outsize, byte hex)
|
||||
unparse_WKB(uchar* serialized, allocator alloc, freeor free, char endian, size_t *outsize, uchar hex)
|
||||
{
|
||||
#ifdef PGIS_DEBUG
|
||||
lwnotice("unparse_WKB(%p,...) called", serialized);
|
||||
|
@ -609,6 +610,9 @@ unparse_WKB(byte* serialized, allocator alloc, freeor free, char endian, size_t
|
|||
|
||||
/******************************************************************
|
||||
* $Log$
|
||||
* Revision 1.18 2005/02/21 16:16:14 strk
|
||||
* Changed byte to uchar to avoid clashes with win32 headers.
|
||||
*
|
||||
* Revision 1.17 2005/02/07 13:21:10 strk
|
||||
* Replaced DEBUG* macros with PGIS_DEBUG*, to avoid clashes with postgresql DEBUG
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue