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))
68 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
69 #include <stdatomic.h>
70 typedef atomic_int l_atomic;
79 #if defined(LIBLEPT_EXPORTS)
80 #define LEPT_DLL __declspec(dllexport)
81 #elif defined(LIBLEPT_IMPORTS)
82 #define LEPT_DLL __declspec(dllimport)
96 #include <Availability.h>
99 typedef intptr_t l_intptr_t;
100 typedef uintptr_t l_uintptr_t;
115 #if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(OS_IOS)
117 #if !defined(HAVE_LIBJPEG)
118 #define HAVE_LIBJPEG 1
120 #if !defined(HAVE_LIBTIFF)
121 #define HAVE_LIBTIFF 1
123 #if !defined(HAVE_LIBPNG)
124 #define HAVE_LIBPNG 1
126 #if !defined(HAVE_LIBZ)
129 #if !defined(HAVE_LIBGIF)
130 #define HAVE_LIBGIF 0
132 #if !defined(HAVE_LIBUNGIF)
133 #define HAVE_LIBUNGIF 0
135 #if !defined(HAVE_LIBWEBP)
136 #define HAVE_LIBWEBP 0
138 #if !defined(HAVE_LIBWEBP_ANIM)
139 #define HAVE_LIBWEBP_ANIM 0
141 #if !defined(HAVE_LIBJP2K)
142 #define HAVE_LIBJP2K 0
151 #define LIBJP2K_HEADER <openjpeg-2.3/openjpeg.h>
170 #define USE_JP2KHEADER 1
189 #if !defined(HAVE_CONFIG_H) && \
190 (!defined(ANDROID_BUILD) || __ANDROID_API__ >= 23) && \
191 (!defined(__IPHONE_OS_VERSION_MIN_REQUIRED) || \
192 __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) && \
193 (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || \
194 __MAC_OS_X_VERSION_MIN_REQUIRED > 101200) && \
196 #define HAVE_FMEMOPEN 1
205 #if !defined(HAVE_CONFIG_H)
206 #define HAVE_FSTATAT 0
224 typedef signed char l_int8;
225 typedef unsigned char l_uint8;
226 typedef short l_int16;
227 typedef unsigned short l_uint16;
229 typedef unsigned int l_uint32;
230 typedef float l_float32;
231 typedef double l_float64;
233 typedef __int64 l_int64;
234 typedef unsigned __int64 l_uint64;
236 typedef long long l_int64;
237 typedef unsigned long long l_uint64;
252 LEPT_DLL
extern l_int32 LeptDebugOK;
260 #define L_MIN(x, y) (((x) < (y)) ? (x) : (y))
265 #define L_MAX(x, y) (((x) > (y)) ? (x) : (y))
270 #define L_ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
275 #define L_SIGN(x) (((x) < 0) ? -1 : 1)
328 UNIX_PATH_SEPCHAR = 0,
336 typedef void *L_TIMER;
366 #ifdef LEPTONICA_INTERCEPT_ALLOC
367 #define LEPT_MALLOC(blocksize) leptonica_malloc(blocksize)
368 #define LEPT_CALLOC(numelem, elemsize) leptonica_calloc(numelem, elemsize)
369 #define LEPT_REALLOC(ptr, blocksize) leptonica_realloc(ptr, blocksize)
370 #define LEPT_FREE(ptr) leptonica_free(ptr)
371 void *leptonica_malloc(
size_t blocksize);
372 void *leptonica_calloc(
size_t numelem,
size_t elemsize);
373 void *leptonica_realloc(
void *ptr,
size_t blocksize);
374 void leptonica_free(
void *ptr);
376 #define LEPT_MALLOC(blocksize) malloc(blocksize)
377 #define LEPT_CALLOC(numelem, elemsize) calloc(numelem, elemsize)
378 #define LEPT_REALLOC(ptr, blocksize) realloc(ptr, blocksize)
379 #define LEPT_FREE(ptr) free(ptr)
428 L_SEVERITY_EXTERNAL = 0,
430 L_SEVERITY_DEBUG = 2,
432 L_SEVERITY_WARNING = 4,
433 L_SEVERITY_ERROR = 5,
471 #undef MINIMUM_SEVERITY
472 #undef DEFAULT_SEVERITY
474 #define MINIMUM_SEVERITY L_SEVERITY_NONE
475 #define DEFAULT_SEVERITY L_SEVERITY_NONE
478 #ifndef MINIMUM_SEVERITY
479 #define MINIMUM_SEVERITY L_SEVERITY_INFO
482 #ifndef DEFAULT_SEVERITY
483 #define DEFAULT_SEVERITY MINIMUM_SEVERITY
545 #define PROCNAME(name)
546 #define ERROR_INT(a, b, c) ((l_int32)(c))
547 #define ERROR_FLOAT(a, b, c) ((l_float32)(c))
548 #define ERROR_PTR(a, b, c) ((void *)(c))
549 #define L_ERROR(a, ...)
550 #define L_WARNING(a, ...)
551 #define L_INFO(a, ...)
555 #define PROCNAME(name) static const char procName[] = name
556 #define IF_SEV(l, t, f) \
557 ((l) >= MINIMUM_SEVERITY && (l) >= LeptMsgSeverity ? (t) : (f))
559 #define ERROR_INT(a, b, c) \
560 IF_SEV(L_SEVERITY_ERROR, returnErrorInt((a), (b), (c)), (l_int32)(c))
561 #define ERROR_FLOAT(a, b, c) \
562 IF_SEV(L_SEVERITY_ERROR, returnErrorFloat((a), (b), (c)), (l_float32)(c))
563 #define ERROR_PTR(a, b, c) \
564 IF_SEV(L_SEVERITY_ERROR, returnErrorPtr((a), (b), (c)), (void *)(c))
566 #define L_ERROR(a, ...) \
567 IF_SEV(L_SEVERITY_ERROR, \
568 (void)lept_stderr("Error in %s: " a, __VA_ARGS__), \
570 #define L_WARNING(a, ...) \
571 IF_SEV(L_SEVERITY_WARNING, \
572 (void)lept_stderr("Warning in %s: " a, __VA_ARGS__), \
574 #define L_INFO(a, ...) \
575 IF_SEV(L_SEVERITY_INFO, \
576 (void)lept_stderr("Info in %s: " a, __VA_ARGS__), \
580 #define L_ERROR(a, ...) \
581 { if (L_SEVERITY_ERROR >= MINIMUM_SEVERITY && \
582 L_SEVERITY_ERROR >= LeptMsgSeverity) \
583 lept_stderr("Error in %s: " a, __VA_ARGS__) \
585 #define L_WARNING(a, ...) \
586 { if (L_SEVERITY_WARNING >= MINIMUM_SEVERITY && \
587 L_SEVERITY_WARNING >= LeptMsgSeverity) \
588 lept_stderr("Warning in %s: " a, __VA_ARGS__) \
590 #define L_INFO(a, ...) \
591 { if (L_SEVERITY_INFO >= MINIMUM_SEVERITY && \
592 L_SEVERITY_INFO >= LeptMsgSeverity) \
593 lept_stderr("Info in %s: " a, __VA_ARGS__) \
603 #if defined _MSC_VER && _MSC_VER < 1900
604 #define snprintf(buf, size, ...) _snprintf_s(buf, size, _TRUNCATE, __VA_ARGS__)
LEPT_DLL l_int32 LeptMsgSeverity