mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Calculate the zlib checksum.
This commit is contained in:
1 parent
62935c41d7
commit
1c75edb32e
8 files changed
+174
-46
No files matched your search
@@ -24,6 +24,7 @@ pub error "bad distance"
|
||||
pub error "bad distance code count"
|
||||
pub error "bad flate block"
|
||||
pub error "bad literal/length code count"
|
||||
pub error "checksum mismatch"
|
||||
pub error "inconsistent stored block length"
|
||||
pub error "internal error: inconsistent Huffman decoder state"
|
||||
pub error "internal error: inconsistent n_bits"
|
||||
|
||||
@@ -37,16 +37,18 @@ pub func zlib_decoder.decode?(dst writer1, src reader1)() {
|
||||
if (x % 31) != 0 {
|
||||
return error "invalid zlib parity check"
|
||||
}
|
||||
var checksum u32
|
||||
while true {
|
||||
var z status = try this.dec.decode?(dst:in.dst, src:in.src)
|
||||
// TODO: calculate the checksum.
|
||||
checksum = this.adler.update(x:in.dst.slice())
|
||||
if z.is_ok() {
|
||||
break
|
||||
}
|
||||
return z
|
||||
}
|
||||
var checksum u32 = in.src.read_u32be?()
|
||||
// TODO: verify the checksum.
|
||||
if checksum != in.src.read_u32be?() {
|
||||
return error "checksum mismatch"
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: drop the '?' but still generate puffs_flate_adler_initialize?
|
||||
|
||||
Reference in new issue
Block a user