summaryrefslogtreecommitdiff
path: root/adler32.c
diff options
context:
space:
mode:
Diffstat (limited to 'adler32.c')
-rw-r--r--adler32.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/adler32.c b/adler32.c
index 624a169..94f1021 100644
--- a/adler32.c
+++ b/adler32.c
@@ -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/* ========================================================================= */
77uLong 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}