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