fn computeChksum(header: Header) Chksums
Sum of all bytes in the header block. The chksum field is treated as if it were filled with spaces (ASCII 32).
header: Header
270 271 272 273 274 275 276 277 278
fn computeChksum(header: Header) Chksums { var cs: Chksums = .{ .signed = 0, .unsigned = 0 }; for (header.bytes, 0..) |v, i| { const b = if (148 <= i and i < 156) 32 else v; // Treating chksum bytes as spaces. cs.unsigned += b; cs.signed += @as(i8, @bitCast(b)); } return cs; }
Sum of all bytes in the header block. The chksum field is treated as if it were filled with spaces (ASCII 32).