/* @(#) $Id$ */
#include "zutil.h"
+#include <stdint.h>
-#define local static
-
-static uLong adler32_combine_ (uLong adler1, uLong adler2, z_off64_t len2);
+static uint32_t adler32_combine_ (uint32_t adler1, uint32_t adler2, z_off64_t len2);
#define BASE 65521 /* largest prime smaller than 65536 */
#define NMAX 5552
(thank you to John Reiser for pointing this out) */
# define CHOP(a) \
do { \
- unsigned long tmp = a >> 16; \
- a &= 0xffffUL; \
+ uint32_t tmp = a >> 16; \
+ a &= 0xffff; \
a += (tmp << 4) - tmp; \
} while (0)
# define MOD28(a) \
#endif
/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
+uint32_t ZEXPORT adler32(adler, buf, len)
+ uint32_t adler;
const Byte *buf;
uInt len;
{
- unsigned long sum2;
+ uint32_t sum2;
unsigned n;
/* split Adler-32 into component sums */
}
/* ========================================================================= */
-static uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
+static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2)
{
- unsigned long sum1;
- unsigned long sum2;
+ uint32_t sum1;
+ uint32_t sum2;
unsigned rem;
/* for negative len, return invalid adler32 as a clue for debugging */
if (len2 < 0)
- return 0xffffffffUL;
+ return 0xffffffff;
/* the derivation of this formula is left as an exercise for the reader */
MOD63(len2); /* assumes len2 >= 0 */
}
/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
+uint32_t ZEXPORT adler32_combine(adler1, adler2, len2)
+ uint32_t adler1;
+ uint32_t adler2;
z_off_t len2;
{
return adler32_combine_(adler1, adler2, len2);
}
-uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
+uint32_t ZEXPORT adler32_combine64(adler1, adler2, len2)
+ uint32_t adler1;
+ uint32_t adler2;
z_off64_t len2;
{
return adler32_combine_(adler1, adler2, len2);
void *opaque; /* private data object passed to zalloc and zfree */
int data_type; /* best guess about the data type: binary or text */
- uLong adler; /* adler32 value of the uncompressed data */
+ uint32_t adler; /* adler32 value of the uncompressed data */
uLong reserved; /* reserved for future use */
} z_stream;
library.
*/
-ZEXTERN uLong ZEXPORT adler32 (uLong adler, const Byte *buf, uInt len);
+ZEXTERN uint32_t ZEXPORT adler32 (uint32_t adler, const Byte *buf, uInt len);
/*
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
return the updated checksum. If buf is Z_NULL, this function returns the
Usage example:
- uLong adler = adler32(0L, Z_NULL, 0);
+ uint32_t adler = adler32(0L, Z_NULL, 0);
while (read_buffer(buffer, length) != EOF) {
adler = adler32(adler, buffer, length);
*/
/*
-ZEXTERN uLong ZEXPORT adler32_combine (uLong adler1, uLong adler2,
+ZEXTERN uint32_t ZEXPORT adler32_combine (uint32_t adler1, uint32_t adler2,
z_off_t len2);
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
ZEXTERN z_off64_t ZEXPORT gzseek64 (gzFile, z_off64_t, int);
ZEXTERN z_off64_t ZEXPORT gztell64 (gzFile);
ZEXTERN z_off64_t ZEXPORT gzoffset64 (gzFile);
- ZEXTERN uLong ZEXPORT adler32_combine64 (uLong, uLong, z_off64_t);
+ ZEXTERN uint32_t ZEXPORT adler32_combine64 (uint32_t, uint32_t, z_off64_t);
ZEXTERN uint32_t ZEXPORT crc32_combine64 (uint32_t, uint32_t, z_off64_t);
#endif
ZEXTERN z_off_t ZEXPORT gzseek64 (gzFile, z_off_t, int);
ZEXTERN z_off_t ZEXPORT gztell64 (gzFile);
ZEXTERN z_off_t ZEXPORT gzoffset64 (gzFile);
- ZEXTERN uLong ZEXPORT adler32_combine64 (uLong, uLong, z_off_t);
+ ZEXTERN uint32_t ZEXPORT adler32_combine64 (uint32_t, uint32_t, z_off_t);
ZEXTERN uint32_t ZEXPORT crc32_combine64 (uint32_t, uint32_t, z_off_t);
# endif
#else
ZEXTERN z_off_t ZEXPORT gzseek (gzFile, z_off_t, int);
ZEXTERN z_off_t ZEXPORT gztell (gzFile);
ZEXTERN z_off_t ZEXPORT gzoffset (gzFile);
- ZEXTERN uLong ZEXPORT adler32_combine (uLong, uLong, z_off_t);
+ ZEXTERN uint32_t ZEXPORT adler32_combine (uint32_t, uint32_t, z_off_t);
ZEXTERN uint32_t ZEXPORT crc32_combine (uint32_t, uint32_t, z_off_t);
#endif