PageRenderTime 28ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/ocr/ocrservice/jni/hydrogen/include/leptonica/environ.h

http://eyes-free.googlecode.com/
C++ Header | 276 lines | 132 code | 46 blank | 98 comment | 0 complexity | 4850c499a1d8899ebab09761058c4591 MD5 | raw file
  1/*====================================================================*
  2 -  Copyright (C) 2001 Leptonica.  All rights reserved.
  3 -  This software is distributed in the hope that it will be
  4 -  useful, but with NO WARRANTY OF ANY KIND.
  5 -  No author or distributor accepts responsibility to anyone for the
  6 -  consequences of using this software, or for whether it serves any
  7 -  particular purpose or works at all, unless he or she says so in
  8 -  writing.  Everyone is granted permission to copy, modify and
  9 -  redistribute this source code, for commercial or non-commercial
 10 -  purposes, with the following restrictions: (1) the origin of this
 11 -  source code must not be misrepresented; (2) modified versions must
 12 -  be plainly marked as such; and (3) this notice may not be removed
 13 -  or altered from any source or modified source distribution.
 14 *====================================================================*/
 15
 16#ifndef  LEPTONICA_ENVIRON_H
 17#define  LEPTONICA_ENVIRON_H
 18
 19/*------------------------------------------------------------------------*
 20 *  Defines and includes differ for Unix and Windows.  Also for Windows,  *
 21 *  differentiate between conditionals based on platform and compiler.    *
 22 *      For platforms:                                                    *
 23 *          _WIN32       =>     Windows, 32- or 64-bit                    *
 24 *          _WIN64       =>     Windows, 64-bit only                      *
 25 *          __CYGWIN__   =>     Cygwin                                    *
 26 *      For compilers:                                                    *
 27 *          __GNUC__     =>     gcc                                       *
 28 *          _MSC_VER     =>     msvc                                      *
 29 *------------------------------------------------------------------------*/
 30
 31/* MS VC++ does not provide stdint.h, so define the missing types here */
 32
 33#ifndef _MSC_VER
 34#include <stdint.h>
 35
 36#else
 37/* Note that _WIN32 is defined for both 32 and 64 bit applications,
 38   whereas _WIN64 is defined only for the latter */
 39
 40#ifdef _WIN64
 41typedef __int64 intptr_t;
 42typedef unsigned __int64 uintptr_t;
 43#else
 44typedef int intptr_t;
 45typedef unsigned int uintptr_t;
 46#endif
 47
 48/* VC++6 doesn't seem to have powf, expf. */
 49#if (_MSC_VER <= 1400)
 50#define powf(x, y) (float)pow((double)(x), (double)(y))
 51#define expf(x) (float)exp((double)(x))
 52#endif
 53
 54#endif /* _MSC_VER */
 55
 56/* Windows specifics */
 57
 58#ifdef _WIN32
 59
 60/* DLL EXPORT/IMPORT */
 61#ifdef LEPTONLIB_EXPORTS
 62#define LEPT_DLL __declspec(dllexport)
 63#elif defined(LEPTONLIB_IMPORTS)
 64#define LEPT_DLL __declspec(dllimport)
 65#else
 66#define LEPT_DLL
 67#endif
 68
 69#else  /* non-WINDOWS-SPECIFICS */
 70#include <stdint.h>
 71#define LEPT_DLL
 72#endif  /* _WIN32 */
 73
 74typedef intptr_t l_intptr_t;
 75typedef uintptr_t l_uintptr_t;
 76
 77
 78/*--------------------------------------------------------------------*
 79 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
 80 *                          USER CONFIGURABLE                         *
 81 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
 82 *                 Environ variables with I/O libraries               *
 83 *               Manual Configuration Only: NOT AUTO_CONF             *
 84 *--------------------------------------------------------------------*/
 85/*
 86 *  Leptonica provides interfaces to link to four external image I/O
 87 *  libraries, plus zlib.  Setting any of these to 0 here causes
 88 *  non-functioning stubs to be linked.
 89 */
 90#ifndef HAVE_CONFIG_H
 91#define  HAVE_LIBJPEG     1
 92#define  HAVE_LIBTIFF     0
 93#define  HAVE_LIBPNG      0
 94#define  HAVE_LIBZ        1
 95#define  HAVE_LIBGIF      0
 96#define  HAVE_LIBUNGIF    0
 97#endif  /* ~HAVE_CONFIG_H */
 98
 99/*
100 * On linux systems, you can do I/O between Pix and memory.  Specifically,
101 * you can compress (write compressed data to memory from a Pix) and
102 * uncompress (read from compressed data in memory to a Pix).
103 * For jpeg, png, pnm and bmp, these use the non-posix GNU functions
104 * fmemopen() and open_memstream().  These functions are not
105 * available on other systems.  To use these functions in linux,
106 * you must define HAVE_FMEMOPEN to be 1 here.
107 */
108#ifndef HAVE_CONFIG_H
109#define  HAVE_FMEMOPEN    1
110#endif  /* ~HAVE_CONFIG_H */
111
112
113/*--------------------------------------------------------------------*
114 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
115 *                          USER CONFIGURABLE                         *
116 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
117 *       Environ variables for uncompressed formatted image I/O       *
118 *--------------------------------------------------------------------*/
119/*
120 *  Leptonica supplies image I/O for pnm, bmp and ps.
121 *  Setting any of these to 0 causes non-functioning stubs to be linked.
122 */
123#define  USE_BMPIO        1
124#define  USE_PNMIO        1
125#define  USE_PSIO         1
126
127
128/*--------------------------------------------------------------------*
129 *                          Built-in types                            *
130 *--------------------------------------------------------------------*/
131typedef signed char             l_int8;
132typedef unsigned char           l_uint8;
133typedef short                   l_int16;
134typedef unsigned short          l_uint16;
135typedef int                     l_int32;
136typedef unsigned int            l_uint32;
137typedef float                   l_float32;
138typedef double                  l_float64;
139
140
141/*------------------------------------------------------------------------*
142 *                            Standard macros                             *
143 *------------------------------------------------------------------------*/
144#ifndef L_MIN
145#define L_MIN(x,y)   (((x) < (y)) ? (x) : (y))
146#endif
147
148#ifndef L_MAX
149#define L_MAX(x,y)   (((x) > (y)) ? (x) : (y))
150#endif
151
152#ifndef L_ABS
153#define L_ABS(x)     (((x) < 0) ? (-1 * (x)) : (x))
154#endif
155
156#ifndef L_SIGN
157#define L_SIGN(x)    (((x) < 0) ? -1 : 1)
158#endif
159
160#ifndef UNDEF
161#define UNDEF        -1
162#endif
163
164#ifndef NULL
165#define NULL          0
166#endif
167
168#ifndef TRUE
169#define TRUE          1
170#endif
171
172#ifndef FALSE
173#define FALSE         0
174#endif
175
176
177/*--------------------------------------------------------------------*
178 *         Environ variables used within compiler invocation          *
179 *--------------------------------------------------------------------*/
180/*
181 *  To control conditional compilation, one of two variables
182 *
183 *       L_LITTLE_ENDIAN  (e.g., for Intel X86)
184 *       L_BIG_ENDIAN     (e.g., for Sun SPARC, Mac Power PC)
185 *
186 *  is defined when the GCC compiler is invoked.
187 *  All code should compile properly for both hardware architectures.
188 */
189
190
191/*------------------------------------------------------------------------*
192 *                   Simple search state variables                        *
193 *------------------------------------------------------------------------*/
194enum {
195    L_NOT_FOUND = 0,
196    L_FOUND = 1
197};
198
199
200/*------------------------------------------------------------------------*
201 *                      Standard memory allocation                        *
202 *
203 *  These specify the memory management functions that are used
204 *  on all heap data except for Pix.  Memory management for Pix
205 *  also defaults to malloc and free.  See pix1.c for details.
206 *------------------------------------------------------------------------*/
207#define MALLOC(blocksize)           malloc(blocksize)
208#define CALLOC(numelem, elemsize)   calloc(numelem, elemsize)
209#define REALLOC(ptr, blocksize)     realloc(ptr, blocksize)
210#define FREE(ptr)                   free(ptr)
211
212
213/*------------------------------------------------------------------------*
214 *         Control printing of error, warning, and info messages         *
215 *                                                                        *
216 *      (Use -DNO_CONSOLE_IO on compiler line to prevent text output)     *
217 *------------------------------------------------------------------------*/
218#ifdef  NO_CONSOLE_IO
219
220#define PROCNAME(name)
221#define ERROR_PTR(a,b,c)            ((void *)(c))
222#define ERROR_INT(a,b,c)            ((l_int32)(c))
223#define ERROR_FLOAT(a,b,c)          ((l_float32)(c))
224#define L_ERROR(a,b)
225#define L_ERROR_STRING(a,b,c)
226#define L_ERROR_INT(a,b,c)
227#define L_ERROR_FLOAT(a,b,c)
228#define L_WARNING(a,b)
229#define L_WARNING_STRING(a,b,c)
230#define L_WARNING_INT(a,b,c)
231#define L_WARNING_INT2(a,b,c,d)
232#define L_WARNING_FLOAT(a,b,c)
233#define L_WARNING_FLOAT2(a,b,c,d)
234#define L_INFO(a,b)
235#define L_INFO_STRING(a,b,c)
236#define L_INFO_INT(a,b,c)
237#define L_INFO_INT2(a,b,c,d)
238#define L_INFO_FLOAT(a,b,c)
239#define L_INFO_FLOAT2(a,b,c,d)
240
241#else
242
243#define PROCNAME(name)              static const char procName[] = name
244#define ERROR_PTR(a,b,c)            returnErrorPtr((a),(b),(c))
245#define ERROR_INT(a,b,c)            returnErrorInt((a),(b),(c))
246#define ERROR_FLOAT(a,b,c)          returnErrorFloat((a),(b),(c))
247#define L_ERROR(a,b)                l_error((a),(b))
248#define L_ERROR_STRING(a,b,c)       l_errorString((a),(b),(c))
249#define L_ERROR_INT(a,b,c)          l_errorInt((a),(b),(c))
250#define L_ERROR_FLOAT(a,b,c)        l_errorFloat((a),(b),(c))
251#define L_WARNING(a,b)              l_warning((a),(b))
252#define L_WARNING_STRING(a,b,c)     l_warningString((a),(b),(c))
253#define L_WARNING_INT(a,b,c)        l_warningInt((a),(b),(c))
254#define L_WARNING_INT2(a,b,c,d)     l_warningInt2((a),(b),(c),(d))
255#define L_WARNING_FLOAT(a,b,c)      l_warningFloat((a),(b),(c))
256#define L_WARNING_FLOAT2(a,b,c,d)   l_warningFloat2((a),(b),(c),(d))
257#define L_INFO(a,b)                 l_info((a),(b))
258#define L_INFO_STRING(a,b,c)        l_infoString((a),(b),(c))
259#define L_INFO_INT(a,b,c)           l_infoInt((a),(b),(c))
260#define L_INFO_INT2(a,b,c,d)        l_infoInt2((a),(b),(c),(d))
261#define L_INFO_FLOAT(a,b,c)         l_infoFloat((a),(b),(c))
262#define L_INFO_FLOAT2(a,b,c,d)      l_infoFloat2((a),(b),(c),(d))
263
264#endif  /* NO_CONSOLE_IO */
265
266
267/*------------------------------------------------------------------------*
268 *                        snprintf() renamed in MSVC                      *
269 *------------------------------------------------------------------------*/
270#ifdef _MSC_VER
271#define snprintf _snprintf
272#endif
273
274
275#endif /* LEPTONICA_ENVIRON_H */
276