Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
26 | pmbaty | 1 | /* uclconf.h -- configuration for the UCL data compression library |
2 | |||
3 | This file is part of the UCL data compression library. |
||
4 | |||
5 | Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer |
||
6 | Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer |
||
7 | Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer |
||
8 | Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer |
||
9 | Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer |
||
10 | Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer |
||
11 | Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer |
||
12 | Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer |
||
13 | Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer |
||
14 | All Rights Reserved. |
||
15 | |||
16 | The UCL library is free software; you can redistribute it and/or |
||
17 | modify it under the terms of the GNU General Public License as |
||
18 | published by the Free Software Foundation; either version 2 of |
||
19 | the License, or (at your option) any later version. |
||
20 | |||
21 | The UCL library is distributed in the hope that it will be useful, |
||
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
24 | GNU General Public License for more details. |
||
25 | |||
26 | You should have received a copy of the GNU General Public License |
||
27 | along with the UCL library; see the file COPYING. |
||
28 | If not, write to the Free Software Foundation, Inc., |
||
29 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
30 | |||
31 | Markus F.X.J. Oberhumer |
||
32 | <markus@oberhumer.com> |
||
33 | http://www.oberhumer.com/opensource/ucl/ |
||
34 | */ |
||
35 | |||
36 | |||
37 | #ifndef __UCLCONF_H_INCLUDED |
||
38 | #define __UCLCONF_H_INCLUDED |
||
39 | |||
40 | #define UCL_VERSION 0x010300L |
||
41 | #define UCL_VERSION_STRING "1.03" |
||
42 | #define UCL_VERSION_DATE "Jul 20 2004" |
||
43 | |||
44 | /* internal Autoconf configuration file - only used when building UCL */ |
||
45 | #if defined(UCL_HAVE_CONFIG_H) |
||
46 | # include <config.h> |
||
47 | #endif |
||
48 | #include <limits.h> |
||
49 | |||
50 | #ifdef __cplusplus |
||
51 | extern "C" { |
||
52 | #endif |
||
53 | |||
54 | |||
55 | /*********************************************************************** |
||
56 | // UCL requires a conforming <limits.h> |
||
57 | ************************************************************************/ |
||
58 | |||
59 | #if !defined(CHAR_BIT) || (CHAR_BIT != 8) |
||
60 | # error "invalid CHAR_BIT" |
||
61 | #endif |
||
62 | #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) |
||
63 | # error "check your compiler installation" |
||
64 | #endif |
||
65 | #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) |
||
66 | # error "your limits.h macros are broken" |
||
67 | #endif |
||
68 | |||
69 | /* workaround a compiler bug under hpux 10.20 */ |
||
70 | #define UCL_0xffffL 65535ul |
||
71 | #define UCL_0xffffffffL 4294967295ul |
||
72 | |||
73 | #if !defined(UCL_UINT32_C) |
||
74 | # if (UINT_MAX < UCL_0xffffffffL) |
||
75 | # define UCL_UINT32_C(c) c ## UL |
||
76 | # else |
||
77 | # define UCL_UINT32_C(c) ((c) + 0U) |
||
78 | # endif |
||
79 | #endif |
||
80 | |||
81 | |||
82 | /*********************************************************************** |
||
83 | // architecture defines |
||
84 | ************************************************************************/ |
||
85 | |||
86 | #if (defined(__CYGWIN__) || defined(__CYGWIN32__)) && defined(__GNUC__) |
||
87 | # define UCL_OS_CYGWIN 1 |
||
88 | #elif defined(__EMX__) && defined(__GNUC__) |
||
89 | # define UCL_OS_EMX 1 |
||
90 | #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) |
||
91 | # define UCL_OS_DOS32 1 |
||
92 | #elif defined(__BORLANDC__) && defined(__DPMI16__) |
||
93 | # define UCL_OS_DOS16 1 |
||
94 | #elif defined(__ZTC__) && defined(DOS386) |
||
95 | # define UCL_OS_DOS32 1 |
||
96 | #elif defined(__OS2__) || defined(__OS2V2__) |
||
97 | # if (UINT_MAX == UCL_0xffffL) |
||
98 | # define UCL_OS_OS216 1 |
||
99 | # elif (UINT_MAX == UCL_0xffffffffL) |
||
100 | # define UCL_OS_OS2 1 |
||
101 | # else |
||
102 | # error "check your limits.h header" |
||
103 | # endif |
||
104 | #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) |
||
105 | # define UCL_OS_WIN64 1 |
||
106 | #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) |
||
107 | # define UCL_OS_WIN32 1 |
||
108 | #elif defined(__MWERKS__) && defined(__INTEL__) |
||
109 | # define UCL_OS_WIN32 1 |
||
110 | #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) |
||
111 | # if (UINT_MAX == UCL_0xffffL) |
||
112 | # define UCL_OS_WIN16 1 |
||
113 | # elif (UINT_MAX == UCL_0xffffffffL) |
||
114 | # define UCL_OS_WIN32 1 |
||
115 | # else |
||
116 | # error "check your limits.h header" |
||
117 | # endif |
||
118 | #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) |
||
119 | # if (UINT_MAX == UCL_0xffffL) |
||
120 | # define UCL_OS_DOS16 1 |
||
121 | # elif (UINT_MAX == UCL_0xffffffffL) |
||
122 | # define UCL_OS_DOS32 1 |
||
123 | # else |
||
124 | # error "check your limits.h header" |
||
125 | # endif |
||
126 | #elif defined(__WATCOMC__) |
||
127 | # if defined(__NT__) && (UINT_MAX == UCL_0xffffL) |
||
128 | /* wcl: NT host defaults to DOS target */ |
||
129 | # define UCL_OS_DOS16 1 |
||
130 | # elif defined(__NT__) && (__WATCOMC__ < 1100) |
||
131 | /* wcl386: Watcom C 11 defines _WIN32 */ |
||
132 | # define UCL_OS_WIN32 1 |
||
133 | # else |
||
134 | # error "please specify a target using the -bt compiler option" |
||
135 | # endif |
||
136 | #elif defined(__palmos__) |
||
137 | # if (UINT_MAX == UCL_0xffffL) |
||
138 | # define UCL_OS_PALMOS 1 |
||
139 | # else |
||
140 | # error "check your limits.h header" |
||
141 | # endif |
||
142 | #elif defined(__TOS__) || defined(__atarist__) |
||
143 | # define UCL_OS_TOS 1 |
||
144 | #elif defined(macintosh) |
||
145 | # define UCL_OS_MACCLASSIC 1 |
||
146 | #elif defined(__VMS) |
||
147 | # define UCL_OS_VMS 1 |
||
148 | #else |
||
149 | # define UCL_OS_POSIX 1 |
||
150 | #endif |
||
151 | |||
152 | /* memory checkers */ |
||
153 | #if !defined(__UCL_CHECKER) |
||
154 | # if defined(__BOUNDS_CHECKING_ON) |
||
155 | # define __UCL_CHECKER 1 |
||
156 | # elif defined(__CHECKER__) |
||
157 | # define __UCL_CHECKER 1 |
||
158 | # elif defined(__INSURE__) |
||
159 | # define __UCL_CHECKER 1 |
||
160 | # elif defined(__PURIFY__) |
||
161 | # define __UCL_CHECKER 1 |
||
162 | # endif |
||
163 | #endif |
||
164 | |||
165 | /* fix ancient compiler versions */ |
||
166 | #if (UINT_MAX == UCL_0xffffL) |
||
167 | #if (defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)) || (defined(MSDOS) && defined(_MSC_VER) && (_MSC_VER < 700)) |
||
168 | # if !defined(__cdecl) |
||
169 | # define __cdecl cdecl |
||
170 | # endif |
||
171 | # if !defined(__far) |
||
172 | # define __far far |
||
173 | # endif |
||
174 | # if !defined(__huge) |
||
175 | # define __huge huge |
||
176 | # endif |
||
177 | # if !defined(__near) |
||
178 | # define __near near |
||
179 | # endif |
||
180 | #endif |
||
181 | #endif |
||
182 | |||
183 | |||
184 | /*********************************************************************** |
||
185 | // integral and pointer types |
||
186 | ************************************************************************/ |
||
187 | |||
188 | /* Integral types with 32 bits or more */ |
||
189 | #if !defined(UCL_UINT32_MAX) |
||
190 | # if (UINT_MAX >= UCL_0xffffffffL) |
||
191 | typedef unsigned int ucl_uint32; |
||
192 | typedef int ucl_int32; |
||
193 | # define UCL_UINT32_MAX UINT_MAX |
||
194 | # define UCL_INT32_MAX INT_MAX |
||
195 | # define UCL_INT32_MIN INT_MIN |
||
196 | # elif (ULONG_MAX >= UCL_0xffffffffL) |
||
197 | typedef unsigned long ucl_uint32; |
||
198 | typedef long ucl_int32; |
||
199 | # define UCL_UINT32_MAX ULONG_MAX |
||
200 | # define UCL_INT32_MAX LONG_MAX |
||
201 | # define UCL_INT32_MIN LONG_MIN |
||
202 | # else |
||
203 | # error "ucl_uint32" |
||
204 | # endif |
||
205 | #endif |
||
206 | |||
207 | /* ucl_uint is used like size_t */ |
||
208 | #if !defined(UCL_UINT_MAX) |
||
209 | # if (UINT_MAX >= UCL_0xffffffffL) |
||
210 | typedef unsigned int ucl_uint; |
||
211 | typedef int ucl_int; |
||
212 | # define UCL_UINT_MAX UINT_MAX |
||
213 | # define UCL_INT_MAX INT_MAX |
||
214 | # define UCL_INT_MIN INT_MIN |
||
215 | # elif (ULONG_MAX >= UCL_0xffffffffL) |
||
216 | typedef unsigned long ucl_uint; |
||
217 | typedef long ucl_int; |
||
218 | # define UCL_UINT_MAX ULONG_MAX |
||
219 | # define UCL_INT_MAX LONG_MAX |
||
220 | # define UCL_INT_MIN LONG_MIN |
||
221 | # else |
||
222 | # error "ucl_uint" |
||
223 | # endif |
||
224 | #endif |
||
225 | |||
226 | /* Memory model that allows to access memory at offsets of ucl_uint. */ |
||
227 | #if !defined(__UCL_MMODEL) |
||
228 | # if (UCL_UINT_MAX <= UINT_MAX) |
||
229 | # define __UCL_MMODEL |
||
230 | # elif defined(UCL_OS_DOS16) || defined(UCL_OS_OS216) || defined(UCL_OS_WIN16) |
||
231 | # define __UCL_MMODEL_HUGE 1 |
||
232 | # define __UCL_MMODEL __huge |
||
233 | # define ucl_uintptr_t unsigned long |
||
234 | # else |
||
235 | # define __UCL_MMODEL |
||
236 | # endif |
||
237 | #endif |
||
238 | |||
239 | /* no typedef here because of const-pointer issues */ |
||
240 | #define ucl_bytep unsigned char __UCL_MMODEL * |
||
241 | #define ucl_charp char __UCL_MMODEL * |
||
242 | #define ucl_voidp void __UCL_MMODEL * |
||
243 | #define ucl_shortp short __UCL_MMODEL * |
||
244 | #define ucl_ushortp unsigned short __UCL_MMODEL * |
||
245 | #define ucl_uint32p ucl_uint32 __UCL_MMODEL * |
||
246 | #define ucl_int32p ucl_int32 __UCL_MMODEL * |
||
247 | #define ucl_uintp ucl_uint __UCL_MMODEL * |
||
248 | #define ucl_intp ucl_int __UCL_MMODEL * |
||
249 | #define ucl_voidpp ucl_voidp __UCL_MMODEL * |
||
250 | #define ucl_bytepp ucl_bytep __UCL_MMODEL * |
||
251 | /* deprecated - use `ucl_bytep' instead of `ucl_byte *' */ |
||
252 | #define ucl_byte unsigned char __UCL_MMODEL |
||
253 | |||
254 | typedef int ucl_bool; |
||
255 | |||
256 | |||
257 | /*********************************************************************** |
||
258 | // function types |
||
259 | ************************************************************************/ |
||
260 | |||
261 | /* name mangling */ |
||
262 | #if !defined(__UCL_EXTERN_C) |
||
263 | # ifdef __cplusplus |
||
264 | # define __UCL_EXTERN_C extern "C" |
||
265 | # else |
||
266 | # define __UCL_EXTERN_C extern |
||
267 | # endif |
||
268 | #endif |
||
269 | |||
270 | /* calling convention */ |
||
271 | #if !defined(__UCL_CDECL) |
||
272 | # if defined(__GNUC__) || defined(__HIGHC__) || defined(__NDPC__) |
||
273 | # define __UCL_CDECL |
||
274 | # elif defined(UCL_OS_DOS16) || defined(UCL_OS_OS216) || defined(UCL_OS_WIN16) |
||
275 | # define __UCL_CDECL __far __cdecl |
||
276 | # elif defined(UCL_OS_DOS32) || defined(UCL_OS_OS2) || defined(UCL_OS_WIN32) || defined(UCL_OS_WIN64) |
||
277 | # define __UCL_CDECL __cdecl |
||
278 | # else |
||
279 | # define __UCL_CDECL |
||
280 | # endif |
||
281 | #endif |
||
282 | |||
283 | /* DLL export information */ |
||
284 | #if !defined(__UCL_EXPORT1) |
||
285 | # define __UCL_EXPORT1 |
||
286 | #endif |
||
287 | #if !defined(__UCL_EXPORT2) |
||
288 | # define __UCL_EXPORT2 |
||
289 | #endif |
||
290 | |||
291 | /* __cdecl calling convention for public C and assembly functions */ |
||
292 | #if !defined(UCL_PUBLIC) |
||
293 | # define UCL_PUBLIC(_rettype) __UCL_EXPORT1 _rettype __UCL_EXPORT2 __UCL_CDECL |
||
294 | #endif |
||
295 | #if !defined(UCL_EXTERN) |
||
296 | # define UCL_EXTERN(_rettype) __UCL_EXTERN_C UCL_PUBLIC(_rettype) |
||
297 | #endif |
||
298 | #if !defined(UCL_PRIVATE) |
||
299 | # define UCL_PRIVATE(_rettype) static _rettype __UCL_CDECL |
||
300 | #endif |
||
301 | |||
302 | /* C++ exception specification for extern "C" function types */ |
||
303 | #if !defined(__cplusplus) |
||
304 | # undef UCL_NOTHROW |
||
305 | # define UCL_NOTHROW |
||
306 | #elif !defined(UCL_NOTHROW) |
||
307 | # define UCL_NOTHROW |
||
308 | #endif |
||
309 | |||
310 | /* function types */ |
||
311 | typedef int |
||
312 | (__UCL_CDECL *ucl_compress_t) ( const ucl_bytep src, ucl_uint src_len, |
||
313 | ucl_bytep dst, ucl_uintp dst_len, |
||
314 | ucl_voidp wrkmem ); |
||
315 | |||
316 | typedef int |
||
317 | (__UCL_CDECL *ucl_decompress_t) ( const ucl_bytep src, ucl_uint src_len, |
||
318 | ucl_bytep dst, ucl_uintp dst_len, |
||
319 | ucl_voidp wrkmem ); |
||
320 | |||
321 | typedef int |
||
322 | (__UCL_CDECL *ucl_optimize_t) ( ucl_bytep src, ucl_uint src_len, |
||
323 | ucl_bytep dst, ucl_uintp dst_len, |
||
324 | ucl_voidp wrkmem ); |
||
325 | |||
326 | typedef int |
||
327 | (__UCL_CDECL *ucl_compress_dict_t)(const ucl_bytep src, ucl_uint src_len, |
||
328 | ucl_bytep dst, ucl_uintp dst_len, |
||
329 | ucl_voidp wrkmem, |
||
330 | const ucl_bytep dict, ucl_uint dict_len ); |
||
331 | |||
332 | typedef int |
||
333 | (__UCL_CDECL *ucl_decompress_dict_t)(const ucl_bytep src, ucl_uint src_len, |
||
334 | ucl_bytep dst, ucl_uintp dst_len, |
||
335 | ucl_voidp wrkmem, |
||
336 | const ucl_bytep dict, ucl_uint dict_len ); |
||
337 | |||
338 | /* a progress indicator callback function */ |
||
339 | typedef struct |
||
340 | { |
||
341 | void (__UCL_CDECL *callback) (ucl_uint, ucl_uint, int, ucl_voidp); |
||
342 | ucl_voidp user; |
||
343 | } |
||
344 | ucl_progress_callback_t; |
||
345 | #define ucl_progress_callback_p ucl_progress_callback_t __UCL_MMODEL * |
||
346 | |||
347 | |||
348 | /*********************************************************************** |
||
349 | // error codes and prototypes |
||
350 | ************************************************************************/ |
||
351 | |||
352 | /* Error codes for the compression/decompression functions. Negative |
||
353 | * values are errors, positive values will be used for special but |
||
354 | * normal events. |
||
355 | */ |
||
356 | #define UCL_E_OK 0 |
||
357 | #define UCL_E_ERROR (-1) |
||
358 | #define UCL_E_INVALID_ARGUMENT (-2) |
||
359 | #define UCL_E_OUT_OF_MEMORY (-3) |
||
360 | /* compression errors */ |
||
361 | #define UCL_E_NOT_COMPRESSIBLE (-101) |
||
362 | /* decompression errors */ |
||
363 | #define UCL_E_INPUT_OVERRUN (-201) |
||
364 | #define UCL_E_OUTPUT_OVERRUN (-202) |
||
365 | #define UCL_E_LOOKBEHIND_OVERRUN (-203) |
||
366 | #define UCL_E_EOF_NOT_FOUND (-204) |
||
367 | #define UCL_E_INPUT_NOT_CONSUMED (-205) |
||
368 | #define UCL_E_OVERLAP_OVERRUN (-206) |
||
369 | |||
370 | |||
371 | /* ucl_init() should be the first function you call. |
||
372 | * Check the return code ! |
||
373 | * |
||
374 | * ucl_init() is a macro to allow checking that the library and the |
||
375 | * compiler's view of various types are consistent. |
||
376 | */ |
||
377 | #define ucl_init() __ucl_init2(UCL_VERSION,(int)sizeof(short),(int)sizeof(int),\ |
||
378 | (int)sizeof(long),(int)sizeof(ucl_uint32),(int)sizeof(ucl_uint),\ |
||
379 | (int)-1,(int)sizeof(char *),(int)sizeof(ucl_voidp),\ |
||
380 | (int)sizeof(ucl_compress_t)) |
||
381 | UCL_EXTERN(int) __ucl_init2(ucl_uint32,int,int,int,int,int,int,int,int,int); |
||
382 | |||
383 | /* version functions (useful for shared libraries) */ |
||
384 | UCL_EXTERN(ucl_uint32) ucl_version(void); |
||
385 | UCL_EXTERN(const char *) ucl_version_string(void); |
||
386 | UCL_EXTERN(const char *) ucl_version_date(void); |
||
387 | UCL_EXTERN(const ucl_charp) _ucl_version_string(void); |
||
388 | UCL_EXTERN(const ucl_charp) _ucl_version_date(void); |
||
389 | |||
390 | /* string functions */ |
||
391 | UCL_EXTERN(int) |
||
392 | ucl_memcmp(const ucl_voidp _s1, const ucl_voidp _s2, ucl_uint _len); |
||
393 | UCL_EXTERN(ucl_voidp) |
||
394 | ucl_memcpy(ucl_voidp _dest, const ucl_voidp _src, ucl_uint _len); |
||
395 | UCL_EXTERN(ucl_voidp) |
||
396 | ucl_memmove(ucl_voidp _dest, const ucl_voidp _src, ucl_uint _len); |
||
397 | UCL_EXTERN(ucl_voidp) |
||
398 | ucl_memset(ucl_voidp _s, int _c, ucl_uint _len); |
||
399 | |||
400 | /* checksum functions */ |
||
401 | UCL_EXTERN(ucl_uint32) |
||
402 | ucl_adler32(ucl_uint32 _adler, const ucl_bytep _buf, ucl_uint _len); |
||
403 | UCL_EXTERN(ucl_uint32) |
||
404 | ucl_crc32(ucl_uint32 _c, const ucl_bytep _buf, ucl_uint _len); |
||
405 | UCL_EXTERN(const ucl_uint32p) |
||
406 | ucl_get_crc32_table(void); |
||
407 | |||
408 | /* memory allocation hooks */ |
||
409 | typedef ucl_voidp (__UCL_CDECL *ucl_malloc_hook_t) (ucl_uint); |
||
410 | typedef void (__UCL_CDECL *ucl_free_hook_t) (ucl_voidp); |
||
411 | UCL_EXTERN(void) |
||
412 | ucl_set_malloc_hooks(ucl_malloc_hook_t, ucl_free_hook_t); |
||
413 | UCL_EXTERN(void) |
||
414 | ucl_get_malloc_hooks(ucl_malloc_hook_t*, ucl_free_hook_t*); |
||
415 | |||
416 | /* memory allocation functions */ |
||
417 | UCL_EXTERN(ucl_voidp) ucl_malloc(ucl_uint); |
||
418 | UCL_EXTERN(ucl_voidp) ucl_alloc(ucl_uint, ucl_uint); |
||
419 | UCL_EXTERN(void) ucl_free(ucl_voidp); |
||
420 | |||
421 | |||
422 | /* misc. */ |
||
423 | UCL_EXTERN(ucl_bool) ucl_assert(int _expr); |
||
424 | UCL_EXTERN(int) _ucl_config_check(void); |
||
425 | typedef union { ucl_bytep p; ucl_uint u; } __ucl_pu_u; |
||
426 | typedef union { ucl_bytep p; ucl_uint32 u32; } __ucl_pu32_u; |
||
427 | |||
428 | /* align a char pointer on a boundary that is a multiple of `size' */ |
||
429 | UCL_EXTERN(unsigned) __ucl_align_gap(const ucl_voidp _ptr, ucl_uint _size); |
||
430 | #define UCL_PTR_ALIGN_UP(_ptr,_size) \ |
||
431 | ((_ptr) + (ucl_uint) __ucl_align_gap((const ucl_voidp)(_ptr),(ucl_uint)(_size))) |
||
432 | |||
433 | |||
434 | #ifdef __cplusplus |
||
435 | } /* extern "C" */ |
||
436 | #endif |
||
437 | |||
438 | #endif /* already included */ |
||
439 |