home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mlzo100.zip / minilzo.100 / lzoconf.h < prev    next >
C/C++ Source or Header  |  1997-07-13  |  10KB  |  296 lines

  1. /* lzoconf.h -- configuration for the LZO real-time data compression library
  2.  
  3.    This file is part of the LZO real-time data compression library.
  4.  
  5.    Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
  6.    Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
  7.  
  8.    The LZO library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU General Public License as
  10.    published by the Free Software Foundation; either version 2 of
  11.    the License, or (at your option) any later version.
  12.  
  13.    The LZO library is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    GNU General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with the LZO library; see the file COPYING.
  20.    If not, write to the Free Software Foundation, Inc.,
  21.    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.  
  23.    Markus F.X.J. Oberhumer
  24.    markus.oberhumer@jk.uni-linz.ac.at
  25.    http://www.infosys.tuwien.ac.at/Staff/lux/marco/lzo.html
  26.  */
  27.  
  28.  
  29. #ifndef __LZOCONF_H
  30. #define __LZOCONF_H
  31.  
  32. #define LZO_VERSION             0x1000
  33. #define LZO_VERSION_STRING      "1.00"
  34. #define LZO_VERSION_DATE        "Jul 13 1997"
  35.  
  36. /* internal Autoconf configuration file - only used when building LZO */
  37. #if defined(LZO_HAVE_CONFIG_H)
  38. #  include <config.h>
  39. #endif
  40.  
  41. /* LZO requires a conforming <limits.h> */
  42. #include <limits.h>
  43. #if !defined(CHAR_BIT) || (CHAR_BIT != 8)
  44. #  error invalid CHAR_BIT
  45. #endif
  46. #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
  47. #  error check your compiler installation
  48. #endif
  49.  
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53.  
  54.  
  55. /***********************************************************************
  56. // architecture defines
  57. ************************************************************************/
  58.  
  59. #if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
  60. #  define __LZO_WIN
  61. #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
  62. #  define __LZO_WIN
  63. #elif defined(__NT__) || defined(__WINDOWS_386__)
  64. #  define __LZO_WIN
  65. #elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
  66. #  define __LZO_DOS
  67. #endif
  68.  
  69. #if (UINT_MAX < 0xffffffffL)
  70. #  if defined(__LZO_WIN)
  71. #    define __LZO_WIN16
  72. #  elif defined(__LZO_DOS)
  73. #    define __LZO_DOS16
  74. #  elif defined(__TOS__)
  75. #    define __LZO_TOS16
  76. #  else
  77. #    error 16 bit target not supported
  78. #  endif
  79. #endif
  80.  
  81. #if !defined(__LZO_i386)
  82. #  if defined(__LZO_DOS) || defined(__LZO_WIN16)
  83. #    define __LZO_i386
  84. #  elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
  85. #    define __LZO_i386
  86. #  endif
  87. #endif
  88.  
  89.  
  90. /***********************************************************************
  91. // integral and pointer types
  92. ************************************************************************/
  93.  
  94. /* Integral types with 32 bits or more */
  95. #if !defined(LZO_UINT32_MAX)
  96. #  if (UINT_MAX >= 0xffffffffL)
  97.      typedef unsigned int       lzo_uint32;
  98.      typedef int                lzo_int32;
  99. #    define LZO_UINT32_MAX      UINT_MAX
  100. #  elif (ULONG_MAX >= 0xffffffffL)
  101.      typedef unsigned long      lzo_uint32;
  102.      typedef long               lzo_int32;
  103. #    define LZO_UINT32_MAX      ULONG_MAX
  104. #  else
  105. #    error lzo_uint32
  106. #  endif
  107. #endif
  108.  
  109. /* lzo_uint is used like size_t */
  110. #if !defined(LZO_UINT_MAX)
  111. #  if (UINT_MAX >= 0xffffffffL)
  112.      typedef unsigned int       lzo_uint;
  113.      typedef int                lzo_int;
  114. #    define LZO_UINT_MAX        UINT_MAX
  115. #  elif (ULONG_MAX >= 0xffffffffL)
  116.      typedef unsigned long      lzo_uint;
  117.      typedef long               lzo_int;
  118. #    define LZO_UINT_MAX        ULONG_MAX
  119. #  else
  120. #    error lzo_uint
  121. #  endif
  122. #endif
  123.  
  124.  
  125. /* Memory model that allows to access memory at offsets of lzo_uint.
  126.  * `Huge' pointers (16 bit DOS/Windows) are somewhat slow, but they
  127.  * work fine and I really don't care about 16 bit compiler
  128.  * optimizations nowadays.
  129.  */
  130. #if !defined(__LZO_MMODEL)
  131. #  if (LZO_UINT_MAX <= UINT_MAX)
  132. #    define __LZO_MMODEL
  133. #  elif defined(__LZO_DOS16) || defined(__LZO_WIN16)
  134. #    define __LZO_MMODEL        __huge
  135. #    define LZO_999_UNSUPPORTED
  136. #  elif defined(__LZO_TOS16)
  137. #    define __LZO_MMODEL
  138. #  else
  139. #    error __LZO_MMODEL
  140. #  endif
  141. #endif
  142.  
  143. /* no typedef here because of const-pointer issues */
  144. #define lzo_byte                unsigned char __LZO_MMODEL
  145. #define lzo_bytep               unsigned char __LZO_MMODEL *
  146. #define lzo_voidp               void __LZO_MMODEL *
  147. #define lzo_shortp              short __LZO_MMODEL *
  148. #define lzo_ushortp             unsigned short __LZO_MMODEL *
  149. #define lzo_uint32p             lzo_uint32 __LZO_MMODEL *
  150. #define lzo_int32p              lzo_int32 __LZO_MMODEL *
  151. #define lzo_uintp               lzo_uint __LZO_MMODEL *
  152. #define lzo_intp                lzo_int __LZO_MMODEL *
  153. #define lzo_voidpp              lzo_voidp __LZO_MMODEL *
  154. #define lzo_bytepp              lzo_bytep __LZO_MMODEL *
  155. #define lzo_charp               char __LZO_MMODEL *
  156.  
  157. /* improve code readability */
  158. typedef int lzo_bool;
  159.  
  160.  
  161. /***********************************************************************
  162. // function types
  163. ************************************************************************/
  164.  
  165. /* linkage */
  166. #if !defined(__LZO_EXTERN_C)
  167. #  ifdef __cplusplus
  168. #    define __LZO_EXTERN_C      extern "C"
  169. #  else
  170. #    define __LZO_EXTERN_C      extern
  171. #  endif
  172. #endif
  173.  
  174. /* calling conventions */
  175. #if !defined(__LZO_ENTRY)
  176. #  if defined(__LZO_DOS16) || defined(__LZO_WIN16)
  177. #    define __LZO_ENTRY         __far __cdecl
  178. #  elif defined(__LZO_i386) && defined(_MSC_VER)
  179. #    define __LZO_ENTRY         __cdecl
  180. #  elif defined(__LZO_i386) && defined(__WATCOMC__)
  181. #    define __LZO_ENTRY         __near __cdecl
  182. #  else
  183. #    define __LZO_ENTRY
  184. #  endif
  185. #endif
  186.  
  187. /* DLL export information */
  188. #if !defined(__LZO_EXPORT1)
  189. #  define __LZO_EXPORT1
  190. #endif
  191. #if !defined(__LZO_EXPORT2)
  192. #  define __LZO_EXPORT2
  193. #endif
  194.  
  195. #if !defined(LZO_PUBLIC)
  196. #  define LZO_PUBLIC(_rettype)  __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY
  197. #endif
  198. #if !defined(LZO_EXTERN)
  199. #  define LZO_EXTERN(_rettype)  __LZO_EXTERN_C LZO_PUBLIC(_rettype)
  200. #endif
  201. #if !defined(LZO_PRIVATE)
  202. #  define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY
  203. #endif
  204.  
  205.  
  206. typedef int
  207. (__LZO_ENTRY *lzo_compress_t)   ( const lzo_byte *src, lzo_uint  src_len,
  208.                                         lzo_byte *dst, lzo_uint *dst_len,
  209.                                         lzo_voidp wrkmem );
  210.  
  211. typedef int
  212. (__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint  src_len,
  213.                                         lzo_byte *dst, lzo_uint *dst_len,
  214.                                         lzo_voidp wrkmem );
  215.  
  216. typedef int
  217. (__LZO_ENTRY *lzo_optimize_t)   (       lzo_byte *src, lzo_uint  src_len,
  218.                                         lzo_byte *dst, lzo_uint *dst_len,
  219.                                         lzo_voidp wrkmem );
  220.  
  221.  
  222. /* a progress indicator callback function */
  223. typedef void
  224. (__LZO_ENTRY *lzo_progress_callback_t)(lzo_uint,lzo_uint);
  225.  
  226.  
  227. /***********************************************************************
  228. // error codes and prototypes
  229. ************************************************************************/
  230.  
  231. /* Error codes for the compression/decompression functions. Negative
  232.  * values are errors, positive values will be used for special but
  233.  * normal events.
  234.  */
  235. #define LZO_E_OK                    0
  236. #define LZO_E_ERROR                 (-1)
  237. #define LZO_E_OUT_OF_MEMORY         (-2)    /* not used right now */
  238. #define LZO_E_NOT_COMPRESSIBLE      (-3)    /* not used right now */
  239. #define LZO_E_INPUT_OVERRUN         (-4)
  240. #define LZO_E_OUTPUT_OVERRUN        (-5)
  241. #define LZO_E_LOOKBEHIND_OVERRUN    (-6)
  242. #define LZO_E_EOF_NOT_FOUND         (-7)
  243. #define LZO_E_INPUT_NOT_CONSUMED    (-8)
  244.  
  245.  
  246. /* lzo_init() should be the first function you call.
  247.  * Check the return code !
  248.  *
  249.  * lzo_init() is a macro to allow checking that the library and the
  250.  * compiler's view of various types are consistent.
  251.  */
  252. #define lzo_init() __lzo_init(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
  253.     (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\
  254.     (int)sizeof(lzo_voidp),(int)sizeof(lzo_compress_t))
  255. LZO_EXTERN(int) __lzo_init(unsigned,int,int,int,int,int,int,int);
  256.  
  257. /* version functions (useful for shared libraries) */
  258. LZO_EXTERN(unsigned) lzo_version(void);
  259. LZO_EXTERN(const char *) lzo_version_string(void);
  260. LZO_EXTERN(const char *) lzo_version_date(void);
  261. LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
  262. LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
  263.  
  264. /* string functions */
  265. LZO_EXTERN(int)
  266. lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len);
  267. LZO_EXTERN(lzo_voidp)
  268. lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
  269. LZO_EXTERN(lzo_voidp)
  270. lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
  271. LZO_EXTERN(lzo_voidp)
  272. lzo_memset(lzo_voidp _s, int _c, lzo_uint _len);
  273.  
  274. /* checksum functions */
  275. LZO_EXTERN(lzo_uint32)
  276. lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len);
  277. LZO_EXTERN(lzo_uint32)
  278. lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len);
  279.  
  280. /* misc. */
  281. LZO_EXTERN(lzo_bool) lzo_assert(int _expr);
  282. LZO_EXTERN(int) _lzo_config_check(void);
  283.  
  284. /* align a char pointer on a boundary that is a multiple of `size' */
  285. LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
  286. #define LZO_ALIGN(_ptr,_size) \
  287.     ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size)))
  288.  
  289.  
  290. #ifdef __cplusplus
  291. } /* extern "C" */
  292. #endif
  293.  
  294. #endif /* already included */
  295.  
  296.