Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-pdf/blob/main/vendor/omega-zip/src/crc32.om # omega-pdf Omega PDF: read and write PDF files in Omega Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-pdf / vendor / omega-zip / src / crc32.om` 46 lines ยท 1035 bytes Raw Blame History 1 note ======== src/crc32.om: CRC-32 (ISO 3309 / ITU-T V.42, the zip and gzip CRC) ======== 2 note Reflected polynomial 0xEDB88320 (`3988292384`), register preset to all ones, result inverted, 3 note as specified in the zip application note section 4.4.7 and RFC 1952 section 8. 4 note crcinit builds the 256-entry table the usual way: entry n is n shifted right 8 times, 5 note XORing the polynomial whenever the bit shifted out is 1. 6 7 fn crcinit to void 8 for n uint 256 9 c = n 10 for k uint 8 11 if eq and c 1 1 12 c = xor `3988292384` shr c 1 13 else 14 c = shr c 1 15 end 16 end 17 put crctab n c 18 end 19 end 20 21 note crcrun: CRC-32 of all of stdin, printed as 8 lowercase hex digits and a newline. 22 note At most 2^40 input bytes (`33554432` reads of 32 KiB); more is refused with code 22. 23 fn crcrun to int 24 put crcv 0 `4294967295` 25 n = ulong 0 26 while true bound `33554433` 27 r = read 0 win 0 WSIZE 28 if lt r 0 29 fail 3 tread 30 ret 3 31 end 32 if eq r 0 33 c = xor get crcv 0 `4294967295` 34 sayhex ulong c 8 35 say tnl 36 ret 0 37 end 38 crcwin ulong r 39 n = add n 1 40 if ge n `33554432` 41 fail 22 tbig 42 ret 22 43 end 44 end 45 ret 22 46 end