Leptonica 1.68
C Image Processing Library

environ.h

Go to the documentation of this file.
00001 /*====================================================================*
00002  -  Copyright (C) 2001 Leptonica.  All rights reserved.
00003  -  This software is distributed in the hope that it will be
00004  -  useful, but with NO WARRANTY OF ANY KIND.
00005  -  No author or distributor accepts responsibility to anyone for the
00006  -  consequences of using this software, or for whether it serves any
00007  -  particular purpose or works at all, unless he or she says so in
00008  -  writing.  Everyone is granted permission to copy, modify and
00009  -  redistribute this source code, for commercial or non-commercial
00010  -  purposes, with the following restrictions: (1) the origin of this
00011  -  source code must not be misrepresented; (2) modified versions must
00012  -  be plainly marked as such; and (3) this notice may not be removed
00013  -  or altered from any source or modified source distribution.
00014  *====================================================================*/
00015 
00016 #ifndef  LEPTONICA_ENVIRON_H
00017 #define  LEPTONICA_ENVIRON_H
00018 
00019 /*------------------------------------------------------------------------*
00020  *  Defines and includes differ for Unix and Windows.  Also for Windows,  *
00021  *  differentiate between conditionals based on platform and compiler.    *
00022  *      For platforms:                                                    *
00023  *          _WIN32       =>     Windows, 32- or 64-bit                    *
00024  *          _WIN64       =>     Windows, 64-bit only                      *
00025  *          __CYGWIN__   =>     Cygwin                                    *
00026  *      For compilers:                                                    *
00027  *          __GNUC__     =>     gcc                                       *
00028  *          _MSC_VER     =>     msvc                                      *
00029  *------------------------------------------------------------------------*/
00030 
00031 /* MS VC++ does not provide stdint.h, so define the missing types here */
00032 
00033 #ifndef _MSC_VER
00034 #include <stdint.h>
00035 
00036 #else
00037 /* Note that _WIN32 is defined for both 32 and 64 bit applications,
00038    whereas _WIN64 is defined only for the latter */
00039 
00040 #ifdef _WIN64
00041 typedef __int64 intptr_t;
00042 typedef unsigned __int64 uintptr_t;
00043 #else
00044 typedef int intptr_t;
00045 typedef unsigned int uintptr_t;
00046 #endif
00047 
00048 /* VC++6 doesn't seem to have powf, expf. */
00049 #if (_MSC_VER < 1400)
00050 #define powf(x, y) (float)pow((double)(x), (double)(y))
00051 #define expf(x) (float)exp((double)(x))
00052 #endif
00053 
00054 #endif /* _MSC_VER */
00055 
00056 /* Windows specifics */
00057 
00058 #ifdef _WIN32
00059 
00060 /* DLL EXPORTS and IMPORTS:
00061  * Important: LEPTONLIB_* is deprected.  It is retained here only for
00062  * compatibility with tesseract 3.00.  In your project files, use
00063  * LIBLEPT_EXPORTS and LIBLEPT_IMPORTS  */
00064 #if defined(LIBLEPT_EXPORTS) || defined(LEPTONLIB_EXPORTS)
00065 #define LEPT_DLL __declspec(dllexport)
00066 #elif defined(LIBLEPT_IMPORTS) || defined(LEPTONLIB_IMPORTS)
00067 #define LEPT_DLL __declspec(dllimport)
00068 #else
00069 #define LEPT_DLL
00070 #endif
00071 
00072 #else  /* non-WINDOWS-SPECIFICS */
00073 #include <stdint.h>
00074 #define LEPT_DLL
00075 #endif  /* _WIN32 */
00076 
00077 typedef intptr_t l_intptr_t;
00078 typedef uintptr_t l_uintptr_t;
00079 typedef void *L_TIMER;
00080 
00081 
00082 /*--------------------------------------------------------------------*
00083  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
00084  *                          USER CONFIGURABLE                         *
00085  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
00086  *                 Environ variables with I/O libraries               *
00087  *               Manual Configuration Only: NOT AUTO_CONF             *
00088  *--------------------------------------------------------------------*/
00089 /*
00090  *  Leptonica provides interfaces to link to five external image I/O
00091  *  libraries, plus zlib.  Setting any of these to 0 here causes
00092  *  non-functioning stubs to be linked.
00093  */
00094 #ifndef HAVE_CONFIG_H
00095 #define  HAVE_LIBJPEG     1
00096 #define  HAVE_LIBTIFF     1
00097 #define  HAVE_LIBPNG      1
00098 #define  HAVE_LIBZ        1
00099 #define  HAVE_LIBGIF      0
00100 #define  HAVE_LIBUNGIF    0
00101 #define  HAVE_LIBWEBP     0
00102 #endif  /* ~HAVE_CONFIG_H */
00103 
00104 /*
00105  * On linux systems, you can do I/O between Pix and memory.  Specifically,
00106  * you can compress (write compressed data to memory from a Pix) and
00107  * uncompress (read from compressed data in memory to a Pix).
00108  * For jpeg, png, pnm and bmp, these use the non-posix GNU functions
00109  * fmemopen() and open_memstream().  These functions are not
00110  * available on other systems.  To use these functions in linux,
00111  * you must define HAVE_FMEMOPEN to be 1 here.
00112  */
00113 #ifndef HAVE_CONFIG_H
00114 #define  HAVE_FMEMOPEN    0
00115 #endif  /* ~HAVE_CONFIG_H */
00116 
00117 
00118 /*--------------------------------------------------------------------*
00119  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
00120  *                          USER CONFIGURABLE                         *
00121  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
00122  *       Environ variables for uncompressed formatted image I/O       *
00123  *--------------------------------------------------------------------*/
00124 /*
00125  *  Leptonica supplies image I/O for pnm, bmp, ps, and pdf.
00126  *  Setting any of these to 0 causes non-functioning stubs to be linked.
00127  */
00128 #define  USE_BMPIO        1
00129 #define  USE_PNMIO        1
00130 #define  USE_PSIO         1
00131 #define  USE_PDFIO        1
00132 
00133 
00134 /*--------------------------------------------------------------------*
00135  *                          Built-in types                            *
00136  *--------------------------------------------------------------------*/
00137 typedef signed char             l_int8;
00138 typedef unsigned char           l_uint8;
00139 typedef short                   l_int16;
00140 typedef unsigned short          l_uint16;
00141 typedef int                     l_int32;
00142 typedef unsigned int            l_uint32;
00143 typedef float                   l_float32;
00144 typedef double                  l_float64;
00145 
00146 
00147 /*------------------------------------------------------------------------*
00148  *                            Standard macros                             *
00149  *------------------------------------------------------------------------*/
00150 #ifndef L_MIN
00151 #define L_MIN(x,y)   (((x) < (y)) ? (x) : (y))
00152 #endif
00153 
00154 #ifndef L_MAX
00155 #define L_MAX(x,y)   (((x) > (y)) ? (x) : (y))
00156 #endif
00157 
00158 #ifndef L_ABS
00159 #define L_ABS(x)     (((x) < 0) ? (-1 * (x)) : (x))
00160 #endif
00161 
00162 #ifndef L_SIGN
00163 #define L_SIGN(x)    (((x) < 0) ? -1 : 1)
00164 #endif
00165 
00166 #ifndef UNDEF
00167 #define UNDEF        -1
00168 #endif
00169 
00170 #ifndef NULL
00171 #define NULL          0
00172 #endif
00173 
00174 #ifndef TRUE
00175 #define TRUE          1
00176 #endif
00177 
00178 #ifndef FALSE
00179 #define FALSE         0
00180 #endif
00181 
00182 
00183 /*--------------------------------------------------------------------*
00184  *         Environ variables used within compiler invocation          *
00185  *--------------------------------------------------------------------*/
00186 /*
00187  *  To control conditional compilation, one of two variables
00188  *
00189  *       L_LITTLE_ENDIAN  (e.g., for Intel X86)
00190  *       L_BIG_ENDIAN     (e.g., for Sun SPARC, Mac Power PC)
00191  *
00192  *  is defined when the GCC compiler is invoked.
00193  *  All code should compile properly for both hardware architectures.
00194  */
00195 
00196 
00197 /*------------------------------------------------------------------------*
00198  *                   Simple search state variables                        *
00199  *------------------------------------------------------------------------*/
00200 enum {
00201     L_NOT_FOUND = 0,
00202     L_FOUND = 1
00203 };
00204 
00205 
00206 /*------------------------------------------------------------------------*
00207  *                      Standard memory allocation                        *
00208  *
00209  *  These specify the memory management functions that are used
00210  *  on all heap data except for Pix.  Memory management for Pix
00211  *  also defaults to malloc and free.  See pix1.c for details.
00212  *------------------------------------------------------------------------*/
00213 #define MALLOC(blocksize)           malloc(blocksize)
00214 #define CALLOC(numelem, elemsize)   calloc(numelem, elemsize)
00215 #define REALLOC(ptr, blocksize)     realloc(ptr, blocksize)
00216 #define FREE(ptr)                   free(ptr)
00217 
00218 
00219 /*------------------------------------------------------------------------*
00220  *         Control printing of error, warning, and info messages         *
00221  *                                                                        *
00222  *      (Use -DNO_CONSOLE_IO on compiler line to prevent text output)     *
00223  *------------------------------------------------------------------------*/
00224 #ifdef  NO_CONSOLE_IO
00225 
00226 #define PROCNAME(name)
00227 #define ERROR_PTR(a,b,c)            ((void *)(c))
00228 #define ERROR_INT(a,b,c)            ((l_int32)(c))
00229 #define ERROR_FLOAT(a,b,c)          ((l_float32)(c))
00230 #define L_ERROR(a,b)
00231 #define L_ERROR_STRING(a,b,c)
00232 #define L_ERROR_INT(a,b,c)
00233 #define L_ERROR_FLOAT(a,b,c)
00234 #define L_WARNING(a,b)
00235 #define L_WARNING_STRING(a,b,c)
00236 #define L_WARNING_INT(a,b,c)
00237 #define L_WARNING_INT2(a,b,c,d)
00238 #define L_WARNING_FLOAT(a,b,c)
00239 #define L_WARNING_FLOAT2(a,b,c,d)
00240 #define L_INFO(a,b)
00241 #define L_INFO_STRING(a,b,c)
00242 #define L_INFO_INT(a,b,c)
00243 #define L_INFO_INT2(a,b,c,d)
00244 #define L_INFO_FLOAT(a,b,c)
00245 #define L_INFO_FLOAT2(a,b,c,d)
00246 
00247 #else
00248 
00249 #define PROCNAME(name)              static const char procName[] = name
00250 #define ERROR_PTR(a,b,c)            returnErrorPtr((a),(b),(c))
00251 #define ERROR_INT(a,b,c)            returnErrorInt((a),(b),(c))
00252 #define ERROR_FLOAT(a,b,c)          returnErrorFloat((a),(b),(c))
00253 #define L_ERROR(a,b)                l_error((a),(b))
00254 #define L_ERROR_STRING(a,b,c)       l_errorString((a),(b),(c))
00255 #define L_ERROR_INT(a,b,c)          l_errorInt((a),(b),(c))
00256 #define L_ERROR_FLOAT(a,b,c)        l_errorFloat((a),(b),(c))
00257 #define L_WARNING(a,b)              l_warning((a),(b))
00258 #define L_WARNING_STRING(a,b,c)     l_warningString((a),(b),(c))
00259 #define L_WARNING_INT(a,b,c)        l_warningInt((a),(b),(c))
00260 #define L_WARNING_INT2(a,b,c,d)     l_warningInt2((a),(b),(c),(d))
00261 #define L_WARNING_FLOAT(a,b,c)      l_warningFloat((a),(b),(c))
00262 #define L_WARNING_FLOAT2(a,b,c,d)   l_warningFloat2((a),(b),(c),(d))
00263 #define L_INFO(a,b)                 l_info((a),(b))
00264 #define L_INFO_STRING(a,b,c)        l_infoString((a),(b),(c))
00265 #define L_INFO_INT(a,b,c)           l_infoInt((a),(b),(c))
00266 #define L_INFO_INT2(a,b,c,d)        l_infoInt2((a),(b),(c),(d))
00267 #define L_INFO_FLOAT(a,b,c)         l_infoFloat((a),(b),(c))
00268 #define L_INFO_FLOAT2(a,b,c,d)      l_infoFloat2((a),(b),(c),(d))
00269 
00270 #endif  /* NO_CONSOLE_IO */
00271 
00272 
00273 /*------------------------------------------------------------------------*
00274  *                        snprintf() renamed in MSVC                      *
00275  *------------------------------------------------------------------------*/
00276 #ifdef _MSC_VER
00277 #define snprintf(buf, size, ...)  _snprintf_s(buf, size, _TRUNCATE, __VA_ARGS__)
00278 #endif
00279 
00280 
00281 #endif /* LEPTONICA_ENVIRON_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines