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);
223 return "Invalid type";
232 LWDEBUGF(5,
"lwalloc: %d@%p", size, mem);
239 LWDEBUGF(5,
"lwrealloc: %d@%p", size, mem);
267 output =
lwalloc(maxlength + 4);
271 if (truncdirection == 0)
274 if (endpos - startpos < maxlength)
276 outstart = str + startpos;
277 strncat(output, outstart, endpos - startpos + 1);
284 outstart = str + endpos + 1 - maxlength + 3;
285 strncat(output,
"...", 4);
286 strncat(output, outstart, maxlength - 3);
291 strncat(output,
"...", 4);
297 if (truncdirection == 1)
300 if (endpos - startpos < maxlength)
302 outstart = str + startpos;
303 strncat(output, outstart, endpos - startpos + 1);
310 outstart = str + startpos;
311 strncat(output, outstart, maxlength - 3);
312 strncat(output,
"...", 4);
317 strncat(output,
"...", 4);
329 static int endian_check_int = 1;
331 return *((
char *) &endian_check_int);
340 if ( srid1 != srid2 )
342 lwerror(
"Operation on mixed SRID geometries");
351 if ( newsrid <= 0 ) {
354 lwnotice(
"SRID value %d converted to the officially unknown SRID value %d", srid, newsrid);
361 lwnotice(
"SRID value %d > SRID_MAXIMUM converted to %d", srid, newsrid);
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 SRID_MAXIMUM
Maximum allowed SRID value in serialized geometry.
void(* lwreporter)(const char *fmt, va_list ap) __attribute__((format(printf
void *(* lwreallocator)(void *mem, size_t size)
void *(* lwallocator)(size_t size)
Global functions for memory/logging handlers.
#define SRID_UNKNOWN
Unknown SRID value.
#define LWDEBUGF(level, msg,...)
static void default_noticereporter(const char *fmt, va_list ap)
static char * lwgeomTypeName[]
char getMachineEndian(void)
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)
static void * default_reallocator(void *mem, size_t size)
void * lwrealloc(void *mem, size_t size)
lwdebuglogger lwdebug_var
int clamp_srid(int srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
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...
void * lwalloc(size_t size)
void error_if_srid_mismatch(int srid1, int srid2)
void lwdebug(int level, const char *fmt,...)
Write a debug message out.
static void default_freeor(void *mem)
lwreallocator lwrealloc_var
static void default_debuglogger(int level, const char *fmt, va_list ap)