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-zip/blob/main/src/zlibd.om # omega-zip omega-zip: ZIP archive reader in seeded Omega (store and deflate, CRC-32, fail-closed refusals) 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-zip / src / zlibd.om` 47 lines ยท 1071 bytes Raw Blame History 1 note ======== src/zlibd.om: the zlib wrapper (RFC 1950) and the raw DEFLATE tool ======== 2 note Header: CMF (CM = 8 deflate, CINFO <= 7, a window of at most 32 KiB) and FLG with 3 note (CMF * 256 + FLG) a multiple of 31 (RFC 1950 section 2.2). FDICT (a preset dictionary) is 4 note refused: this decoder has no way to be given one. After the last block the stream is 5 note byte-aligned and the Adler-32 of the output follows, most significant byte first (section 2.2, 6 note 8.2). Bytes after the trailer are not read. 7 8 text tzhdr "bad zlib header" 9 text tzdict "preset dictionary is not supported" 10 text tzsum "Adler-32 check failed" 11 12 fn rawrun to int 13 insrc 0 0 0 0 14 osink 1 OUTMAX 0 0 15 inflate 16 ret 0 17 end 18 19 fn zlibrun to int 20 insrc 0 0 0 0 21 osink 1 OUTMAX 0 2 22 a = inbyte 23 b = inbyte 24 if ne and a 15 8 25 fail 30 tzhdr 26 end 27 if gt shr a 4 7 28 fail 30 tzhdr 29 end 30 if ne rem or shl a 8 b 31 0 31 fail 30 tzhdr 32 end 33 if ne and b 32 0 34 fail 31 tzdict 35 end 36 inflate 37 put bitb 0 0 38 put bitn 0 0 39 s = ulong 0 40 for i ulong 4 41 s = or shl s 8 inbyte 42 end 43 if ne s or shl get adb 0 16 get ada 0 44 fail 32 tzsum 45 end 46 ret 0 47 end