diff options
Diffstat (limited to 'adler32.c')
-rw-r--r-- | adler32.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* adler32.c -- compute the Adler-32 checksum of a data stream | 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream |
2 | * Copyright (C) 1995-2003 Mark Adler | 2 | * Copyright (C) 1995-2004 Mark Adler |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -72,3 +72,25 @@ uLong ZEXPORT adler32(adler, buf, len) | |||
72 | } | 72 | } |
73 | return (s2 << 16) | s1; | 73 | return (s2 << 16) | s1; |
74 | } | 74 | } |
75 | |||
76 | /* ========================================================================= */ | ||
77 | uLong ZEXPORT adler32_combine(adler1, adler2, len2) | ||
78 | uLong adler1; | ||
79 | uLong adler2; | ||
80 | uLong len2; | ||
81 | { | ||
82 | unsigned long s1; | ||
83 | unsigned long s2; | ||
84 | |||
85 | len2 %= BASE; | ||
86 | s1 = adler1 & 0xffff; | ||
87 | s2 = len2 * s1; | ||
88 | MOD(s2); | ||
89 | s1 += (adler2 & 0xffff) + BASE - 1; | ||
90 | s2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - len2; | ||
91 | if (s1 > BASE) s1 -= BASE; | ||
92 | if (s1 > BASE) s1 -= BASE; | ||
93 | if (s2 > (BASE << 1)) s2 -= (BASE << 1); | ||
94 | if (s2 > BASE) s2 -= BASE; | ||
95 | return (s2 << 16) | s1; | ||
96 | } | ||