environ.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. /*====================================================================*
  2. - Copyright (C) 2001 Leptonica. All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions
  6. - are met:
  7. - 1. Redistributions of source code must retain the above copyright
  8. - notice, this list of conditions and the following disclaimer.
  9. - 2. Redistributions in binary form must reproduce the above
  10. - copyright notice, this list of conditions and the following
  11. - disclaimer in the documentation and/or other materials
  12. - provided with the distribution.
  13. -
  14. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
  18. - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21. - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  22. - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23. - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *====================================================================*/
  26. #ifndef LEPTONICA_ENVIRON_H
  27. #define LEPTONICA_ENVIRON_H
  28. /*------------------------------------------------------------------------*
  29. * Defines and includes differ for Unix and Windows. Also for Windows, *
  30. * differentiate between conditionals based on platform and compiler. *
  31. * For platforms: *
  32. * _WIN32 => Windows, 32- or 64-bit *
  33. * _WIN64 => Windows, 64-bit only *
  34. * __CYGWIN__ => Cygwin *
  35. * For compilers: *
  36. * __GNUC__ => gcc *
  37. * _MSC_VER => msvc *
  38. *------------------------------------------------------------------------*/
  39. /* MS VC++ does not provide stdint.h, so define the missing types here */
  40. #ifndef _MSC_VER
  41. #include <stdint.h>
  42. #else
  43. /* Note that _WIN32 is defined for both 32 and 64 bit applications,
  44. whereas _WIN64 is defined only for the latter */
  45. #ifdef _WIN64
  46. typedef __int64 intptr_t;
  47. typedef unsigned __int64 uintptr_t;
  48. #else
  49. typedef int intptr_t;
  50. typedef unsigned int uintptr_t;
  51. #endif
  52. /* VC++6 doesn't seem to have powf, expf. */
  53. #if (_MSC_VER < 1400)
  54. #define powf(x, y) (float)pow((double)(x), (double)(y))
  55. #define expf(x) (float)exp((double)(x))
  56. #endif
  57. #endif /* _MSC_VER */
  58. /* Windows specifics */
  59. #ifdef _WIN32
  60. /* DLL EXPORTS and IMPORTS */
  61. #if defined(LIBLEPT_EXPORTS)
  62. #define LEPT_DLL __declspec(dllexport)
  63. #elif defined(LIBLEPT_IMPORTS)
  64. #define LEPT_DLL __declspec(dllimport)
  65. #else
  66. #define LEPT_DLL
  67. #endif
  68. #else /* non-Windows specifics */
  69. #include <stdint.h>
  70. #define LEPT_DLL
  71. #endif /* _WIN32 */
  72. typedef intptr_t l_intptr_t;
  73. typedef uintptr_t l_uintptr_t;
  74. /*--------------------------------------------------------------------*
  75. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
  76. * USER CONFIGURABLE *
  77. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
  78. * Environment variables with I/O libraries *
  79. * Manual Configuration Only: NOT AUTO_CONF *
  80. *--------------------------------------------------------------------*/
  81. /*
  82. * Leptonica provides interfaces to link to several external image
  83. * I/O libraries, plus zlib. Setting any of these to 0 here causes
  84. * non-functioning stubs to be linked.
  85. */
  86. #if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(OS_IOS)
  87. #define HAVE_LIBJPEG 1
  88. #define HAVE_LIBTIFF 1
  89. #define HAVE_LIBPNG 1
  90. #define HAVE_LIBZ 1
  91. #define HAVE_LIBGIF 0
  92. #define HAVE_LIBUNGIF 0
  93. #define HAVE_LIBWEBP 0
  94. #define HAVE_LIBJP2K 0
  95. /*-------------------------------------------------------------------------*
  96. * Leptonica supports OpenJPEG 2.0+. If you have a version of openjpeg *
  97. * (HAVE_LIBJP2K == 1) that is >= 2.0, set the path to the openjpeg.h *
  98. * header in angle brackets here. *
  99. *-------------------------------------------------------------------------*/
  100. #define LIBJP2K_HEADER <openjpeg-2.3/openjpeg.h>
  101. #endif /* ! HAVE_CONFIG_H etc. */
  102. /*--------------------------------------------------------------------*
  103. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
  104. * USER CONFIGURABLE *
  105. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
  106. * Environ variables for image I/O without external libraries *
  107. *--------------------------------------------------------------------*/
  108. /*
  109. * Leptonica supplies I/O support without using external libraries for:
  110. * * image read/write for bmp, pnm
  111. * * header read for jp2k
  112. * * image wrapping write for pdf and ps.
  113. * Setting any of these to 0 causes non-functioning stubs to be linked.
  114. */
  115. #define USE_BMPIO 1
  116. #define USE_PNMIO 1
  117. #define USE_JP2KHEADER 1
  118. #define USE_PDFIO 1
  119. #define USE_PSIO 1
  120. /*-------------------------------------------------------------------------*
  121. * On linux systems, you can do I/O between Pix and memory. Specifically,
  122. * you can compress (write compressed data to memory from a Pix) and
  123. * uncompress (read from compressed data in memory to a Pix).
  124. * For jpeg, png, jp2k, gif, pnm and bmp, these use the non-posix GNU
  125. * functions fmemopen() and open_memstream(). These functions are not
  126. * available on other systems.
  127. * To use these functions in linux, you must define HAVE_FMEMOPEN to 1.
  128. * To use them on MacOS, which does not support these functions, set it to 0.
  129. *-------------------------------------------------------------------------*/
  130. #if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(OS_IOS) && \
  131. !defined(_WIN32)
  132. #define HAVE_FMEMOPEN 1
  133. #endif /* ! HAVE_CONFIG_H etc. */
  134. /*-------------------------------------------------------------------------*
  135. * fstatat() is defined by POSIX, but some systems do not support it. *
  136. * One example is older macOS systems (pre-10.10). *
  137. * Play it safe and set the default value to 0. *
  138. *-------------------------------------------------------------------------*/
  139. #if !defined(HAVE_CONFIG_H)
  140. #define HAVE_FSTATAT 0
  141. #endif /* ! HAVE_CONFIG_H */
  142. /*--------------------------------------------------------------------*
  143. * It is desirable on Windows to have all temp files written to the same
  144. * subdirectory of the Windows <Temp> directory, because files under <Temp>
  145. * persist after reboot, and the regression tests write a lot of files.
  146. * We write all test files to /tmp/lept or subdirectories of /tmp/lept.
  147. * Windows temp files are specified as in unix, but have the translation
  148. * /tmp/lept/xxx --> <Temp>/lept/xxx
  149. *--------------------------------------------------------------------*/
  150. /*--------------------------------------------------------------------*
  151. * Built-in types *
  152. *--------------------------------------------------------------------*/
  153. typedef signed char l_int8; /*!< signed 8-bit value */
  154. typedef unsigned char l_uint8; /*!< unsigned 8-bit value */
  155. typedef short l_int16; /*!< signed 16-bit value */
  156. typedef unsigned short l_uint16; /*!< unsigned 16-bit value */
  157. typedef int l_int32; /*!< signed 32-bit value */
  158. typedef unsigned int l_uint32; /*!< unsigned 32-bit value */
  159. typedef float l_float32; /*!< 32-bit floating point value */
  160. typedef double l_float64; /*!< 64-bit floating point value */
  161. #ifdef COMPILER_MSVC
  162. typedef __int64 l_int64; /*!< signed 64-bit value */
  163. typedef unsigned __int64 l_uint64; /*!< unsigned 64-bit value */
  164. #else
  165. typedef long long l_int64; /*!< signed 64-bit value */
  166. typedef unsigned long long l_uint64; /*!< unsigned 64-bit value */
  167. #endif /* COMPILER_MSVC */
  168. /*-------------------------------------------------------------------------*
  169. * For security, the library is distributed in a configuration that does *
  170. * not permit (1) forking with 'system', which is used for displaying *
  171. * images and generating gnuplots, and (2) writing files with specified *
  172. * compiled-in file names. All such writes are with functions such as *
  173. * pixWriteDebug() where the "Debug" is appended to the usual name. *
  174. * Whether the "Debug" version defaults to the standard version or is a *
  175. * no-op depends on the value of this global variable. The default value *
  176. * of LeptDebugOK is 0, and it is set in writefile.c. This value can be *
  177. * over-ridden, for development and debugging, by setLeptDebugOK(). *
  178. *-------------------------------------------------------------------------*/
  179. LEPT_DLL extern l_int32 LeptDebugOK; /* default is 0 */
  180. /*------------------------------------------------------------------------*
  181. * Standard macros *
  182. *------------------------------------------------------------------------*/
  183. #ifndef L_MIN
  184. /*! Minimum of %x and %y */
  185. #define L_MIN(x,y) (((x) < (y)) ? (x) : (y))
  186. #endif
  187. #ifndef L_MAX
  188. /*! Maximum of %x and %y */
  189. #define L_MAX(x,y) (((x) > (y)) ? (x) : (y))
  190. #endif
  191. #ifndef L_ABS
  192. /*! Absoulute value of %x */
  193. #define L_ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
  194. #endif
  195. #ifndef L_SIGN
  196. /*! Sign of %x */
  197. #define L_SIGN(x) (((x) < 0) ? -1 : 1)
  198. #endif
  199. #ifndef UNDEF
  200. /*! Undefined value */
  201. #define UNDEF -1
  202. #endif
  203. #ifndef NULL
  204. /*! NULL value */
  205. #define NULL 0
  206. #endif
  207. #ifndef TRUE
  208. /*! True value */
  209. #define TRUE 1
  210. #endif
  211. #ifndef FALSE
  212. /*! False value */
  213. #define FALSE 0
  214. #endif
  215. /*--------------------------------------------------------------------*
  216. * Environment variables for endian dependence *
  217. *--------------------------------------------------------------------*/
  218. /*
  219. * To control conditional compilation, one of two variables
  220. *
  221. * L_LITTLE_ENDIAN (e.g., for Intel X86)
  222. * L_BIG_ENDIAN (e.g., for Sun SPARC, Mac Power PC)
  223. *
  224. * is defined when the GCC compiler is invoked.
  225. * All code should compile properly for both hardware architectures.
  226. */
  227. /*------------------------------------------------------------------------*
  228. * Simple search state variables *
  229. *------------------------------------------------------------------------*/
  230. /*! Simple search state variables */
  231. enum {
  232. L_NOT_FOUND = 0,
  233. L_FOUND = 1
  234. };
  235. /*------------------------------------------------------------------------*
  236. * Path separator conversion *
  237. *------------------------------------------------------------------------*/
  238. /*! Path separator conversion */
  239. enum {
  240. UNIX_PATH_SEPCHAR = 0,
  241. WIN_PATH_SEPCHAR = 1
  242. };
  243. /*------------------------------------------------------------------------*
  244. * Timing structs *
  245. *------------------------------------------------------------------------*/
  246. typedef void *L_TIMER;
  247. /*! Timing struct */
  248. struct L_WallTimer {
  249. l_int32 start_sec;
  250. l_int32 start_usec;
  251. l_int32 stop_sec;
  252. l_int32 stop_usec;
  253. };
  254. typedef struct L_WallTimer L_WALLTIMER;
  255. /*------------------------------------------------------------------------*
  256. * Standard memory allocation *
  257. * *
  258. * These specify the memory management functions that are used *
  259. * on all heap data except for Pix. Memory management for Pix *
  260. * also defaults to malloc and free. See pix1.c for details. *
  261. *------------------------------------------------------------------------*/
  262. #define LEPT_MALLOC(blocksize) malloc(blocksize)
  263. #define LEPT_CALLOC(numelem, elemsize) calloc(numelem, elemsize)
  264. #define LEPT_REALLOC(ptr, blocksize) realloc(ptr, blocksize)
  265. #define LEPT_FREE(ptr) free(ptr)
  266. /*------------------------------------------------------------------------*
  267. * Control printing of error, warning, and info messages *
  268. * *
  269. * To omit all messages to stderr, simply define NO_CONSOLE_IO on the *
  270. * command line. For finer grained control, we have a mechanism *
  271. * based on the message severity level. The following assumes that *
  272. * NO_CONSOLE_IO is not defined. *
  273. * *
  274. * Messages are printed if the message severity is greater than or equal *
  275. * to the current severity threshold. The current severity threshold *
  276. * is the greater of the compile-time severity, which is the minimum *
  277. * severity that can be reported, and the run-time severity, which is *
  278. * the severity threshold at the moment. *
  279. * *
  280. * The compile-time threshold determines which messages are compiled *
  281. * into the library for potential printing. Messages below the *
  282. * compile-time threshold are omitted and can never be printed. The *
  283. * default compile-time threshold is L_SEVERITY_INFO, but this may be *
  284. * overridden by defining MINIMUM_SEVERITY to the desired enumeration *
  285. * identifier on the compiler command line. Defining NO_CONSOLE_IO on *
  286. * the command line is the same as setting MINIMUM_SEVERITY to *
  287. * L_SEVERITY_NONE. *
  288. * *
  289. * The run-time threshold determines which messages are printed during *
  290. * library execution. It defaults to the compile-time threshold but *
  291. * may be changed either statically by defining DEFAULT_SEVERITY to *
  292. * the desired enumeration identifier on the compiler command line, or *
  293. * dynamically by calling setMsgSeverity() to specify a new threshold. *
  294. * The run-time threshold may also be set from the value of the *
  295. * environment variable LEPT_MSG_SEVERITY by calling setMsgSeverity() *
  296. * and specifying L_SEVERITY_EXTERNAL. *
  297. * *
  298. * In effect, the compile-time threshold setting says, "Generate code *
  299. * to permit messages of equal or greater severity than this to be *
  300. * printed, if desired," whereas the run-time threshold setting says, *
  301. * "Print messages that have an equal or greater severity than this." *
  302. *------------------------------------------------------------------------*/
  303. /*! Control printing of error, warning and info messages */
  304. enum {
  305. L_SEVERITY_EXTERNAL = 0, /* Get the severity from the environment */
  306. L_SEVERITY_ALL = 1, /* Lowest severity: print all messages */
  307. L_SEVERITY_DEBUG = 2, /* Print debugging and higher messages */
  308. L_SEVERITY_INFO = 3, /* Print informational and higher messages */
  309. L_SEVERITY_WARNING = 4, /* Print warning and higher messages */
  310. L_SEVERITY_ERROR = 5, /* Print error and higher messages */
  311. L_SEVERITY_NONE = 6 /* Highest severity: print no messages */
  312. };
  313. /* No message less than the compile-time threshold will ever be
  314. * reported, regardless of the current run-time threshold. This allows
  315. * selection of the set of messages to include in the library. For
  316. * example, setting the threshold to L_SEVERITY_WARNING eliminates all
  317. * informational messages from the library. With that setting, both
  318. * warning and error messages would be printed unless setMsgSeverity()
  319. * was called, or DEFAULT_SEVERITY was redefined, to set the run-time
  320. * severity to L_SEVERITY_ERROR. In that case, only error messages
  321. * would be printed.
  322. *
  323. * This mechanism makes the library smaller and faster, by eliminating
  324. * undesired message reporting and the associated run-time overhead for
  325. * message threshold checking, because code for messages whose severity
  326. * is lower than MINIMUM_SEVERITY won't be generated.
  327. *
  328. * A production library might typically permit ERROR messages to be
  329. * generated, and a development library might permit DEBUG and higher.
  330. * The actual messages printed (as opposed to generated) would depend
  331. * on the current run-time severity threshold.
  332. *
  333. * This is a complex mechanism and a few examples may help.
  334. * (1) No output permitted under any circumstances.
  335. * Use: -DNO_CONSOLE_IO or -DMINIMUM_SEVERITY=6
  336. * (2) Suppose you want to only allow error messages, and you don't
  337. * want to permit info or warning messages at runtime.
  338. * Use: -DMINIMUM_SEVERITY=5
  339. * (3) Suppose you want to only allow error messages by default,
  340. * but you will permit this to be over-ridden at runtime.
  341. * Use: -DDEFAULT_SEVERITY=5
  342. * and to allow info and warning override:
  343. * setMsgSeverity(L_SEVERITY_INFO);
  344. */
  345. #ifdef NO_CONSOLE_IO
  346. #undef MINIMUM_SEVERITY
  347. #undef DEFAULT_SEVERITY
  348. #define MINIMUM_SEVERITY L_SEVERITY_NONE /*!< Compile-time default */
  349. #define DEFAULT_SEVERITY L_SEVERITY_NONE /*!< Run-time default */
  350. #else
  351. #ifndef MINIMUM_SEVERITY
  352. #define MINIMUM_SEVERITY L_SEVERITY_INFO /*!< Compile-time default */
  353. #endif
  354. #ifndef DEFAULT_SEVERITY
  355. #define DEFAULT_SEVERITY MINIMUM_SEVERITY /*!< Run-time default */
  356. #endif
  357. #endif
  358. /*! The run-time message severity threshold is defined in utils.c. */
  359. LEPT_DLL extern l_int32 LeptMsgSeverity;
  360. /*
  361. * <pre>
  362. * Usage
  363. * =====
  364. * Messages are of two types.
  365. *
  366. * (1) The messages
  367. * ERROR_INT(a,b,c) : returns l_int32
  368. * ERROR_FLOAT(a,b,c) : returns l_float32
  369. * ERROR_PTR(a,b,c) : returns void*
  370. * are used to return from functions and take a fixed set of parameters:
  371. * a : <message string>
  372. * b : procName
  373. * c : <return value from function>
  374. * where procName is the name of the local variable naming the function.
  375. *
  376. * (2) The purely informational L_* messages
  377. * L_ERROR(a,...)
  378. * L_WARNING(a,...)
  379. * L_INFO(a,...)
  380. * do not take a return value, but they take at least two parameters:
  381. * a : <message string> with optional format conversions
  382. * v1 : procName (this must be included as the first vararg)
  383. * v2, ... : optional varargs to match format converters in the message
  384. *
  385. * To return an error from a function that returns void, use:
  386. * L_ERROR(<message string>, procName, [...])
  387. * return;
  388. *
  389. * Implementation details
  390. * ======================
  391. * Messages are defined with the IF_SEV macro. The first parameter is
  392. * the message severity, the second is the function to call if the
  393. * message is to be printed, and the third is the return value if the
  394. * message is to be suppressed. For example, we might have an
  395. * informational message defined as:
  396. *
  397. * IF_SEV(L_SEVERITY_INFO, fprintf(.......), 0)
  398. *
  399. * The macro expands into a conditional. Because the first comparison
  400. * is between two constants, an optimizing compiler will remove either
  401. * the comparison (if it's true) or the entire macro expansion (if it
  402. * is false). This means that there is no run-time overhead for
  403. * messages whose severity falls below the minimum specified at compile
  404. * time, and for others the overhead is one (not two) comparisons.
  405. *
  406. * The L_nnn() macros below do not return a value, but because the
  407. * conditional operator requires one for the false condition, we
  408. * specify a void expression.
  409. * </pre>
  410. */
  411. #ifdef NO_CONSOLE_IO
  412. #define PROCNAME(name)
  413. #define ERROR_INT(a,b,c) ((l_int32)(c))
  414. #define ERROR_FLOAT(a,b,c) ((l_float32)(c))
  415. #define ERROR_PTR(a,b,c) ((void *)(c))
  416. #define L_ERROR(a,...)
  417. #define L_WARNING(a,...)
  418. #define L_INFO(a,...)
  419. #else
  420. #define PROCNAME(name) static const char procName[] = name
  421. #define IF_SEV(l,t,f) \
  422. ((l) >= MINIMUM_SEVERITY && (l) >= LeptMsgSeverity ? (t) : (f))
  423. #define ERROR_INT(a,b,c) \
  424. IF_SEV(L_SEVERITY_ERROR, returnErrorInt((a),(b),(c)), (l_int32)(c))
  425. #define ERROR_FLOAT(a,b,c) \
  426. IF_SEV(L_SEVERITY_ERROR, returnErrorFloat((a),(b),(c)), (l_float32)(c))
  427. #define ERROR_PTR(a,b,c) \
  428. IF_SEV(L_SEVERITY_ERROR, returnErrorPtr((a),(b),(c)), (void *)(c))
  429. #define L_ERROR(a,...) \
  430. IF_SEV(L_SEVERITY_ERROR, \
  431. (void)fprintf(stderr, "Error in %s: " a, __VA_ARGS__), \
  432. (void)0)
  433. #define L_WARNING(a,...) \
  434. IF_SEV(L_SEVERITY_WARNING, \
  435. (void)fprintf(stderr, "Warning in %s: " a, __VA_ARGS__), \
  436. (void)0)
  437. #define L_INFO(a,...) \
  438. IF_SEV(L_SEVERITY_INFO, \
  439. (void)fprintf(stderr, "Info in %s: " a, __VA_ARGS__), \
  440. (void)0)
  441. #if 0 /* Alternative method for controlling L_* message output */
  442. #define L_ERROR(a,...) \
  443. { if (L_SEVERITY_ERROR >= MINIMUM_SEVERITY && \
  444. L_SEVERITY_ERROR >= LeptMsgSeverity) \
  445. fprintf(stderr, "Error in %s: " a, __VA_ARGS__) \
  446. }
  447. #define L_WARNING(a,...) \
  448. { if (L_SEVERITY_WARNING >= MINIMUM_SEVERITY && \
  449. L_SEVERITY_WARNING >= LeptMsgSeverity) \
  450. fprintf(stderr, "Warning in %s: " a, __VA_ARGS__) \
  451. }
  452. #define L_INFO(a,...) \
  453. { if (L_SEVERITY_INFO >= MINIMUM_SEVERITY && \
  454. L_SEVERITY_INFO >= LeptMsgSeverity) \
  455. fprintf(stderr, "Info in %s: " a, __VA_ARGS__) \
  456. }
  457. #endif
  458. #endif /* NO_CONSOLE_IO */
  459. /*------------------------------------------------------------------------*
  460. * snprintf() renamed in MSVC (pre-VS2015) *
  461. *------------------------------------------------------------------------*/
  462. #if defined _MSC_VER && _MSC_VER < 1900
  463. #define snprintf(buf, size, ...) _snprintf_s(buf, size, _TRUNCATE, __VA_ARGS__)
  464. #endif
  465. #endif /* LEPTONICA_ENVIRON_H */