Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "pcl/surface/3rdparty/opennurbs/zutil.h"
00009
00010 #ifndef NO_DUMMY_DECL
00011 struct internal_state {int dummy;};
00012 #endif
00013
00014 const char * const z_errmsg[10] = {
00015 "need dictionary",
00016 "stream end",
00017 "",
00018 "file error",
00019 "stream error",
00020 "data error",
00021 "insufficient memory",
00022 "buffer error",
00023 "incompatible version",
00024 ""};
00025
00026
00027 const char * ZEXPORT zlibVersion()
00028 {
00029 return ZLIB_VERSION;
00030 }
00031
00032 uLong ZEXPORT zlibCompileFlags()
00033 {
00034 uLong flags;
00035
00036 flags = 0;
00037 switch (sizeof(uInt)) {
00038 case 2: break;
00039 case 4: flags += 1; break;
00040 case 8: flags += 2; break;
00041 default: flags += 3;
00042 }
00043 switch (sizeof(uLong)) {
00044 case 2: break;
00045 case 4: flags += 1 << 2; break;
00046 case 8: flags += 2 << 2; break;
00047 default: flags += 3 << 2;
00048 }
00049 switch (sizeof(voidpf)) {
00050 case 2: break;
00051 case 4: flags += 1 << 4; break;
00052 case 8: flags += 2 << 4; break;
00053 default: flags += 3 << 4;
00054 }
00055 switch (sizeof(z_off_t)) {
00056 case 2: break;
00057 case 4: flags += 1 << 6; break;
00058 case 8: flags += 2 << 6; break;
00059 default: flags += 3 << 6;
00060 }
00061 #ifdef DEBUG
00062 flags += 1 << 8;
00063 #endif
00064 #if defined(ASMV) || defined(ASMINF)
00065 flags += 1 << 9;
00066 #endif
00067 #ifdef ZLIB_WINAPI
00068 flags += 1 << 10;
00069 #endif
00070 #ifdef BUILDFIXED
00071 flags += 1 << 12;
00072 #endif
00073 #ifdef DYNAMIC_CRC_TABLE
00074 flags += 1 << 13;
00075 #endif
00076 #ifdef NO_GZCOMPRESS
00077 flags += 1L << 16;
00078 #endif
00079 #ifdef NO_GZIP
00080 flags += 1L << 17;
00081 #endif
00082 #ifdef PKZIP_BUG_WORKAROUND
00083 flags += 1L << 20;
00084 #endif
00085 #ifdef FASTEST
00086 flags += 1L << 21;
00087 #endif
00088 #ifdef STDC
00089 # ifdef NO_vsnprintf
00090 flags += 1L << 25;
00091 # ifdef HAS_vsprintf_void
00092 flags += 1L << 26;
00093 # endif
00094 # else
00095 # ifdef HAS_vsnprintf_void
00096 flags += 1L << 26;
00097 # endif
00098 # endif
00099 #else
00100 flags += 1L << 24;
00101 # ifdef NO_snprintf
00102 flags += 1L << 25;
00103 # ifdef HAS_sprintf_void
00104 flags += 1L << 26;
00105 # endif
00106 # else
00107 # ifdef HAS_snprintf_void
00108 flags += 1L << 26;
00109 # endif
00110 # endif
00111 #endif
00112 return flags;
00113 }
00114
00115 #ifdef DEBUG
00116
00117 # ifndef verbose
00118 # define verbose 0
00119 # endif
00120 int z_verbose = verbose;
00121
00122 void z_error (m)
00123 char *m;
00124 {
00125 fprintf(stderr, "%s\n", m);
00126 exit(1);
00127 }
00128 #endif
00129
00130
00131
00132
00133 const char * ZEXPORT zError(err)
00134 int err;
00135 {
00136 return ERR_MSG(err);
00137 }
00138
00139 #if defined(_WIN32_WCE)
00140
00141
00142
00143
00144 int errno = 0;
00145 #endif
00146
00147 #ifndef HAVE_MEMCPY
00148
00149 void zmemcpy(dest, source, len)
00150 Bytef* dest;
00151 const Bytef* source;
00152 uInt len;
00153 {
00154 if (len == 0) return;
00155 do {
00156 *dest++ = *source++;
00157 } while (--len != 0);
00158 }
00159
00160 int zmemcmp(s1, s2, len)
00161 const Bytef* s1;
00162 const Bytef* s2;
00163 uInt len;
00164 {
00165 uInt j;
00166
00167 for (j = 0; j < len; j++) {
00168 if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
00169 }
00170 return 0;
00171 }
00172
00173 void zmemzero(dest, len)
00174 Bytef* dest;
00175 uInt len;
00176 {
00177 if (len == 0) return;
00178 do {
00179 *dest++ = 0;
00180 } while (--len != 0);
00181 }
00182 #endif
00183
00184
00185 #ifdef SYS16BIT
00186
00187 #ifdef __TURBOC__
00188
00189
00190 # define MY_ZCALLOC
00191
00192
00193
00194
00195
00196
00197
00198 #define MAX_PTR 10
00199
00200
00201 local int next_ptr = 0;
00202
00203 typedef struct ptr_table_s {
00204 voidpf org_ptr;
00205 voidpf new_ptr;
00206 } ptr_table;
00207
00208 local ptr_table table[MAX_PTR];
00209
00210
00211
00212
00213
00214
00215
00216 voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
00217 {
00218 voidpf buf = opaque;
00219 ulg bsize = (ulg)items*size;
00220
00221
00222
00223
00224 if (bsize < 65520L) {
00225 buf = farmalloc(bsize);
00226 if (*(ush*)&buf != 0) return buf;
00227 } else {
00228 buf = farmalloc(bsize + 16L);
00229 }
00230 if (buf == 0 || next_ptr >= MAX_PTR) return 0;
00231 table[next_ptr].org_ptr = buf;
00232
00233
00234 *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
00235 *(ush*)&buf = 0;
00236 table[next_ptr++].new_ptr = buf;
00237 return buf;
00238 }
00239
00240 void zcfree (voidpf opaque, voidpf ptr)
00241 {
00242 int n;
00243 if (*(ush*)&ptr != 0) {
00244 farfree(ptr);
00245 return;
00246 }
00247
00248 for (n = 0; n < next_ptr; n++) {
00249 if (ptr != table[n].new_ptr) continue;
00250
00251 farfree(table[n].org_ptr);
00252 while (++n < next_ptr) {
00253 table[n-1] = table[n];
00254 }
00255 next_ptr--;
00256 return;
00257 }
00258 ptr = opaque;
00259 Assert(0, "zcfree: ptr not found");
00260 }
00261
00262 #endif
00263
00264
00265 #ifdef M_I86
00266
00267
00268 # define MY_ZCALLOC
00269
00270 #if (!defined(_MSC_VER) || (_MSC_VER <= 600))
00271 # define _halloc halloc
00272 # define _hfree hfree
00273 #endif
00274
00275 voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
00276 {
00277 if (opaque) opaque = 0;
00278 return _halloc((int)items, size);
00279 }
00280
00281 void zcfree (voidpf opaque, voidpf ptr)
00282 {
00283 if (opaque) opaque = 0;
00284 _hfree(ptr);
00285 }
00286
00287 #endif
00288
00289 #endif
00290
00291
00292 #ifndef MY_ZCALLOC
00293
00294 #ifndef STDC
00295 extern voidp malloc OF((uInt size));
00296 extern voidp calloc OF((uInt items, uInt size));
00297 extern void free OF((voidpf ptr));
00298 #endif
00299
00300 voidpf zcalloc (opaque, items, size)
00301 voidpf opaque;
00302 unsigned items;
00303 unsigned size;
00304 {
00305 if (opaque) items += size - size;
00306 return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
00307 (voidpf)calloc(items, size);
00308 }
00309
00310 void zcfree (opaque, ptr)
00311 voidpf opaque;
00312 voidpf ptr;
00313 {
00314 free(ptr);
00315 if (opaque) return;
00316 }
00317
00318 #endif