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);
256 char *ptr, *totrim=NULL;
262 ptr = strchr(str,
'.');
268 for (i=len-1; i; i--)
270 if ( ptr[i] !=
'0' )
break;
275 if ( ptr == totrim-1 ) *ptr =
'\0';
300 output =
lwalloc(maxlength + 4);
304 if (truncdirection == 0)
307 if (endpos - startpos < maxlength)
309 outstart = str + startpos;
310 strncat(output, outstart, endpos - startpos + 1);
317 outstart = str + endpos + 1 - maxlength + 3;
318 strncat(output,
"...", 3);
319 strncat(output, outstart, maxlength - 3);
324 strncat(output,
"...", 3);
330 if (truncdirection == 1)
333 if (endpos - startpos < maxlength)
335 outstart = str + startpos;
336 strncat(output, outstart, endpos - startpos + 1);
343 outstart = str + startpos;
344 strncat(output, outstart, maxlength - 3);
345 strncat(output,
"...", 3);
350 strncat(output,
"...", 3);
362 static int endian_check_int = 1;
364 return *((
char *) &endian_check_int);
373 if ( srid1 != srid2 )
375 lwerror(
"Operation on mixed SRID geometries");
384 if ( newsrid <= 0 ) {
387 lwnotice(
"SRID value %d converted to the officially unknown SRID value %d", srid, newsrid);
394 lwnotice(
"SRID value %d > SRID_MAXIMUM converted to %d", srid, newsrid);
void lwdebug(int level, const char *fmt,...)
Write a debug message out.
static void * default_allocator(size_t size)
char getMachineEndian(void)
static void default_debuglogger(int level, const char *fmt, va_list ap)
static void default_freeor(void *mem)
void lwgeom_set_debuglogger(lwdebuglogger debuglogger)
int clamp_srid(int srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
void(* lwfreeor)(void *mem)
static char * lwgeomTypeName[]
#define SRID_USER_MAXIMUM
Maximum valid SRID value for the user We reserve 1000 values for internal use.
void * lwrealloc(void *mem, size_t size)
void *(* lwallocator)(size_t size)
Global functions for memory/logging handlers.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
#define SRID_UNKNOWN
Unknown SRID value.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
void(* lwreporter)(const char *fmt, va_list ap) __attribute__((format(printf
void *(* lwreallocator)(void *mem, size_t size)
static void default_errorreporter(const char *fmt, va_list ap)
static void default_noticereporter(const char *fmt, va_list ap)
void(*) typedef void(* lwdebuglogger)(int level, const char *fmt, va_list ap) __attribute__((format(printf
static void * default_reallocator(void *mem, size_t size)
lwreallocator lwrealloc_var
#define SRID_MAXIMUM
Maximum allowed SRID value in serialized geometry.
void trim_trailing_zeros(char *str)
#define LWDEBUGF(level, msg,...)
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...
lwdebuglogger lwdebug_var
char * lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
void * lwalloc(size_t size)
void error_if_srid_mismatch(int srid1, int srid2)