1 /* zutil.h -- internal interface and configuration of the compression library
2 * Copyright (C) 1995-1998 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h
6 /* WARNING: this file should *not* be used by applications. It is
7 part of the implementation of the compression library and is
8 subject to change. Applications should only use zlib.h.
11 /* @(#) $Id: zutil.h,v 1.1 2000/01/01 03:32:23 davem Exp $ */
16 #include <linux/zlib.h>
17 #include <linux/string.h>
18 #include <linux/kernel.h>
20 typedef unsigned char uch
;
21 typedef unsigned short ush
;
22 typedef unsigned long ulg
;
24 /* common constants */
26 #define STORED_BLOCK 0
27 #define STATIC_TREES 1
29 /* The three kinds of block type */
33 /* The minimum and maximum match lengths */
35 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
37 /* target dependencies */
42 # define OS_CODE 0x03 /* assume Unix */
47 typedef uLong (*check_func
) (uLong check
, const Byte
*buf
,
51 /* checksum functions */
53 #define BASE 65521L /* largest prime smaller than 65536 */
55 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
57 #define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
58 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
59 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
60 #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
61 #define DO16(buf) DO8(buf,0); DO8(buf,8);
63 /* ========================================================================= */
65 Update a running Adler-32 checksum with the bytes buf[0..len-1] and
66 return the updated checksum. If buf is NULL, this function returns
67 the required initial value for the checksum.
68 An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
69 much faster. Usage example:
71 uLong adler = adler32(0L, NULL, 0);
73 while (read_buffer(buffer, length) != EOF) {
74 adler = adler32(adler, buffer, length);
76 if (adler != original_adler) error();
78 static inline uLong
zlib_adler32(uLong adler
,
82 unsigned long s1
= adler
& 0xffff;
83 unsigned long s2
= (adler
>> 16) & 0xffff;
86 if (buf
== NULL
) return 1L;
89 k
= len
< NMAX
? len
: NMAX
;
103 return (s2
<< 16) | s1
;
106 #endif /* _Z_UTIL_H */
This page took 0.033624 seconds and 5 git commands to generate.