36 #include "../postgis_config.h"
58 #define LW_MSG_MAXLEN 256
104 void *ret = realloc(mem, size);
122 fprintf(stderr,
"%s\n", msg);
129 if ( POSTGIS_DEBUG_LEVEL >= level )
133 for ( i = 0; i < level; i++ )
137 fprintf(stderr,
"%s\n", msg);
147 fprintf(stderr,
"%s\n", msg);
184 (*lwnotice_var)(
fmt, ap);
197 (*lwerror_var)(
fmt, ap);
210 (*lwdebug_var)(level,
fmt, ap);
221 return "Invalid type";
230 LWDEBUGF(5,
"lwalloc: %d@%p", size, mem);
237 LWDEBUGF(5,
"lwrealloc: %d@%p", size, mem);
250 size_t l = strlen(a)+1;
274 output =
lwalloc(maxlength + 4);
278 if (truncdirection == 0)
281 if (endpos - startpos < maxlength)
283 outstart =
str + startpos;
284 strncat(output, outstart, endpos - startpos + 1);
291 outstart =
str + endpos + 1 - maxlength + 3;
292 strncat(output,
"...", 4);
293 strncat(output, outstart, maxlength - 3);
298 strncat(output,
"...", 4);
304 if (truncdirection == 1)
307 if (endpos - startpos < maxlength)
309 outstart =
str + startpos;
310 strncat(output, outstart, endpos - startpos + 1);
317 outstart =
str + startpos;
318 strncat(output, outstart, maxlength - 3);
319 strncat(output,
"...", 4);
324 strncat(output,
"...", 4);
337 if ( newsrid <= 0 ) {
340 lwnotice(
"SRID value %d converted to the officially unknown SRID value %d", srid, newsrid);
347 lwnotice(
"SRID value %d > SRID_MAXIMUM converted to %d", srid, newsrid);
377 {
"GEOMETRYZM", 0, 1, 1 },
378 {
"GEOMETRYZ", 0, 1, 0 },
379 {
"GEOMETRYM", 0, 0, 1 },
380 {
"GEOMETRY", 0, 0, 0 },
453 #define GEOMTYPE_STRUCT_ARRAY_LEN (sizeof geomtype_struct_array/sizeof(struct geomtype_struct))
462 const char dumb_upper_map[128] =
"................................................0123456789.......ABCDEFGHIJKLMNOPQRSTUVWXYZ......ABCDEFGHIJKLMNOPQRSTUVWXYZ.....";
466 if ( in < 0 || in > 127 )
492 size_t tmpstartpos, tmpendpos;
507 for (i = 0; i < strlen(
str); i++)
516 tmpendpos = strlen(
str) - 1;
517 for (i = strlen(
str) - 1; i != 0; i--)
527 tmpstr =
lwalloc(tmpendpos - tmpstartpos + 2);
528 for (i = tmpstartpos; i <= tmpendpos; i++)
532 tmpstr[i - tmpstartpos] =
'\0';
void(*) typedef void(* lwdebuglogger)(int level, const char *fmt, va_list ap) __attribute__((format(printf
void(* lwfreeor)(void *mem)
#define SRID_USER_MAXIMUM
Maximum valid SRID value for the user We reserve 1000 values for internal use.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define SRID_MAXIMUM
Maximum allowed SRID value in serialized geometry.
void(* lwreporter)(const char *fmt, va_list ap) __attribute__((format(printf
#define POLYHEDRALSURFACETYPE
void *(* lwreallocator)(void *mem, size_t size)
void *(* lwallocator)(size_t size)
Global functions for memory/logging handlers.
#define FLAGS_SET_GEODETIC(flags, value)
#define FLAGS_SET_M(flags, value)
#define SRID_UNKNOWN
Unknown SRID value.
#define FLAGS_SET_Z(flags, value)
#define LWDEBUGF(level, msg,...)
char * lwstrdup(const char *a)
static char dumb_toupper(int in)
static void default_noticereporter(const char *fmt, va_list ap)
static char * lwgeomTypeName[]
void lwgeom_set_debuglogger(lwdebuglogger debuglogger)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
char * lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
static void * default_allocator(size_t size)
static void default_errorreporter(const char *fmt, va_list ap)
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Calculate type integer and dimensional flags from string input.
const char dumb_upper_map[128]
static void * default_reallocator(void *mem, size_t size)
void * lwrealloc(void *mem, size_t size)
lwdebuglogger lwdebug_var
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
void lwgeom_set_handlers(lwallocator allocator, lwreallocator reallocator, lwfreeor freeor, lwreporter errorreporter, lwreporter noticereporter)
This function is called by programs which want to set up custom handling for memory management and er...
#define GEOMTYPE_STRUCT_ARRAY_LEN
void * lwalloc(size_t size)
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
void lwdebug(int level, const char *fmt,...)
Write a debug message out.
static void default_freeor(void *mem)
lwreallocator lwrealloc_var
struct geomtype_struct geomtype_struct_array[]
static void default_debuglogger(int level, const char *fmt, va_list ap)
int32_t clamp_srid(int32_t srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...