27 #ifndef LEPTONICA_ENVIRON_H
28 #define LEPTONICA_ENVIRON_H
53 typedef __int64 intptr_t;
54 typedef unsigned __int64 uintptr_t;
57 typedef unsigned int uintptr_t;
62 #define powf(x, y) (float)pow((double)(x), (double)(y))
63 #define expf(x) (float)exp((double)(x))
72 #if defined(LIBLEPT_EXPORTS)
73 #define LEPT_DLL __declspec(dllexport)
74 #elif defined(LIBLEPT_IMPORTS)
75 #define LEPT_DLL __declspec(dllimport)
88 typedef intptr_t l_intptr_t;
89 typedef uintptr_t l_uintptr_t;
104 #if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(OS_IOS)
106 #if !defined(HAVE_LIBJPEG)
107 #define HAVE_LIBJPEG 1
109 #if !defined(HAVE_LIBTIFF)
110 #define HAVE_LIBTIFF 1
112 #if !defined(HAVE_LIBPNG)
113 #define HAVE_LIBPNG 1
115 #if !defined(HAVE_LIBZ)
118 #if !defined(HAVE_LIBGIF)
119 #define HAVE_LIBGIF 0
121 #if !defined(HAVE_LIBUNGIF)
122 #define HAVE_LIBUNGIF 0
124 #if !defined(HAVE_LIBWEBP)
125 #define HAVE_LIBWEBP 0
127 #if !defined(HAVE_LIBWEBP_ANIM)
128 #define HAVE_LIBWEBP_ANIM 0
130 #if !defined(HAVE_LIBJP2K)
131 #define HAVE_LIBJP2K 0
140 #define LIBJP2K_HEADER <openjpeg-2.3/openjpeg.h>
159 #define USE_JP2KHEADER 1
174 #if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(OS_IOS) && \
176 #define HAVE_FMEMOPEN 1
184 #if !defined(HAVE_CONFIG_H)
185 #define HAVE_FSTATAT 0
202 typedef signed char l_int8;
203 typedef unsigned char l_uint8;
204 typedef short l_int16;
205 typedef unsigned short l_uint16;
207 typedef unsigned int l_uint32;
208 typedef float l_float32;
209 typedef double l_float64;
211 typedef __int64 l_int64;
212 typedef unsigned __int64 l_uint64;
214 typedef long long l_int64;
215 typedef unsigned long long l_uint64;
230 LEPT_DLL
extern l_int32 LeptDebugOK;
238 #define L_MIN(x, y) (((x) < (y)) ? (x) : (y))
243 #define L_MAX(x, y) (((x) > (y)) ? (x) : (y))
248 #define L_ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
253 #define L_SIGN(x) (((x) < 0) ? -1 : 1)
306 UNIX_PATH_SEPCHAR = 0,
314 typedef void *L_TIMER;
344 #ifdef LEPTONICA_INTERCEPT_ALLOC
345 #define LEPT_MALLOC(blocksize) leptonica_malloc(blocksize)
346 #define LEPT_CALLOC(numelem, elemsize) leptonica_calloc(numelem, elemsize)
347 #define LEPT_REALLOC(ptr, blocksize) leptonica_realloc(ptr, blocksize)
348 #define LEPT_FREE(ptr) leptonica_free(ptr)
349 void *leptonica_malloc(
size_t blocksize);
350 void *leptonica_calloc(
size_t numelem,
size_t elemsize);
351 void *leptonica_realloc(
void *ptr,
size_t blocksize);
352 void leptonica_free(
void *ptr);
354 #define LEPT_MALLOC(blocksize) malloc(blocksize)
355 #define LEPT_CALLOC(numelem, elemsize) calloc(numelem, elemsize)
356 #define LEPT_REALLOC(ptr, blocksize) realloc(ptr, blocksize)
357 #define LEPT_FREE(ptr) free(ptr)
406 L_SEVERITY_EXTERNAL = 0,
408 L_SEVERITY_DEBUG = 2,
410 L_SEVERITY_WARNING = 4,
411 L_SEVERITY_ERROR = 5,
449 #undef MINIMUM_SEVERITY
450 #undef DEFAULT_SEVERITY
452 #define MINIMUM_SEVERITY L_SEVERITY_NONE
453 #define DEFAULT_SEVERITY L_SEVERITY_NONE
456 #ifndef MINIMUM_SEVERITY
457 #define MINIMUM_SEVERITY L_SEVERITY_INFO
460 #ifndef DEFAULT_SEVERITY
461 #define DEFAULT_SEVERITY MINIMUM_SEVERITY
523 #define PROCNAME(name)
524 #define ERROR_INT(a, b, c) ((l_int32)(c))
525 #define ERROR_FLOAT(a, b, c) ((l_float32)(c))
526 #define ERROR_PTR(a, b, c) ((void *)(c))
527 #define L_ERROR(a, ...)
528 #define L_WARNING(a, ...)
529 #define L_INFO(a, ...)
533 #define PROCNAME(name) static const char procName[] = name
534 #define IF_SEV(l, t, f) \
535 ((l) >= MINIMUM_SEVERITY && (l) >= LeptMsgSeverity ? (t) : (f))
537 #define ERROR_INT(a, b, c) \
538 IF_SEV(L_SEVERITY_ERROR, returnErrorInt((a), (b), (c)), (l_int32)(c))
539 #define ERROR_FLOAT(a, b, c) \
540 IF_SEV(L_SEVERITY_ERROR, returnErrorFloat((a), (b), (c)), (l_float32)(c))
541 #define ERROR_PTR(a, b, c) \
542 IF_SEV(L_SEVERITY_ERROR, returnErrorPtr((a), (b), (c)), (void *)(c))
544 #define L_ERROR(a, ...) \
545 IF_SEV(L_SEVERITY_ERROR, \
546 (void)lept_stderr("Error in %s: " a, __VA_ARGS__), \
548 #define L_WARNING(a, ...) \
549 IF_SEV(L_SEVERITY_WARNING, \
550 (void)lept_stderr("Warning in %s: " a, __VA_ARGS__), \
552 #define L_INFO(a, ...) \
553 IF_SEV(L_SEVERITY_INFO, \
554 (void)lept_stderr("Info in %s: " a, __VA_ARGS__), \
558 #define L_ERROR(a, ...) \
559 { if (L_SEVERITY_ERROR >= MINIMUM_SEVERITY && \
560 L_SEVERITY_ERROR >= LeptMsgSeverity) \
561 lept_stderr("Error in %s: " a, __VA_ARGS__) \
563 #define L_WARNING(a, ...) \
564 { if (L_SEVERITY_WARNING >= MINIMUM_SEVERITY && \
565 L_SEVERITY_WARNING >= LeptMsgSeverity) \
566 lept_stderr("Warning in %s: " a, __VA_ARGS__) \
568 #define L_INFO(a, ...) \
569 { if (L_SEVERITY_INFO >= MINIMUM_SEVERITY && \
570 L_SEVERITY_INFO >= LeptMsgSeverity) \
571 lept_stderr("Info in %s: " a, __VA_ARGS__) \
581 #if defined _MSC_VER && _MSC_VER < 1900
582 #define snprintf(buf, size, ...) _snprintf_s(buf, size, _TRUNCATE, __VA_ARGS__)
LEPT_DLL l_int32 LeptMsgSeverity