| [2] | 1 | /* zutil.c -- target dependent utility functions for the compression library
|
|---|
| 2 | * Copyright (C) 1995-2002 Jean-loup Gailly.
|
|---|
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /* @(#) $Id: zutil.c,v 1.1.26.1 2002/03/11 22:18:20 tromey Exp $ */
|
|---|
| 7 |
|
|---|
| 8 | #include "zutil.h"
|
|---|
| 9 |
|
|---|
| 10 | struct internal_state {int dummy;}; /* for buggy compilers */
|
|---|
| 11 |
|
|---|
| 12 | #ifndef STDC
|
|---|
| 13 | extern void exit OF((int));
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | const char *z_errmsg[10] = {
|
|---|
| 17 | "need dictionary", /* Z_NEED_DICT 2 */
|
|---|
| 18 | "stream end", /* Z_STREAM_END 1 */
|
|---|
| 19 | "", /* Z_OK 0 */
|
|---|
| 20 | "file error", /* Z_ERRNO (-1) */
|
|---|
| 21 | "stream error", /* Z_STREAM_ERROR (-2) */
|
|---|
| 22 | "data error", /* Z_DATA_ERROR (-3) */
|
|---|
| 23 | "insufficient memory", /* Z_MEM_ERROR (-4) */
|
|---|
| 24 | "buffer error", /* Z_BUF_ERROR (-5) */
|
|---|
| 25 | "incompatible version",/* Z_VERSION_ERROR (-6) */
|
|---|
| 26 | ""};
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 | const char * ZEXPORT zlibVersion()
|
|---|
| 30 | {
|
|---|
| 31 | return ZLIB_VERSION;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | #ifdef DEBUG
|
|---|
| 35 |
|
|---|
| 36 | # ifndef verbose
|
|---|
| 37 | # define verbose 0
|
|---|
| 38 | # endif
|
|---|
| 39 | int z_verbose = verbose;
|
|---|
| 40 |
|
|---|
| 41 | void z_error (m)
|
|---|
| 42 | char *m;
|
|---|
| 43 | {
|
|---|
| 44 | fprintf(stderr, "%s\n", m);
|
|---|
| 45 | exit(1);
|
|---|
| 46 | }
|
|---|
| 47 | #endif
|
|---|
| 48 |
|
|---|
| 49 | /* exported to allow conversion of error code to string for compress() and
|
|---|
| 50 | * uncompress()
|
|---|
| 51 | */
|
|---|
| 52 | const char * ZEXPORT zError(err)
|
|---|
| 53 | int err;
|
|---|
| 54 | {
|
|---|
| 55 | return ERR_MSG(err);
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | #ifndef HAVE_MEMCPY
|
|---|
| 60 |
|
|---|
| 61 | void zmemcpy(dest, source, len)
|
|---|
| 62 | Bytef* dest;
|
|---|
| 63 | const Bytef* source;
|
|---|
| 64 | uInt len;
|
|---|
| 65 | {
|
|---|
| 66 | if (len == 0) return;
|
|---|
| 67 | do {
|
|---|
| 68 | *dest++ = *source++; /* ??? to be unrolled */
|
|---|
| 69 | } while (--len != 0);
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | int zmemcmp(s1, s2, len)
|
|---|
| 73 | const Bytef* s1;
|
|---|
| 74 | const Bytef* s2;
|
|---|
| 75 | uInt len;
|
|---|
| 76 | {
|
|---|
| 77 | uInt j;
|
|---|
| 78 |
|
|---|
| 79 | for (j = 0; j < len; j++) {
|
|---|
| 80 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
|
|---|
| 81 | }
|
|---|
| 82 | return 0;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | void zmemzero(dest, len)
|
|---|
| 86 | Bytef* dest;
|
|---|
| 87 | uInt len;
|
|---|
| 88 | {
|
|---|
| 89 | if (len == 0) return;
|
|---|
| |
|---|