~/bend-docscommunity

gzip.bend relies on unsafe/foreign

raw source on the hub · import gralha-gzip-frame@0.1.0.0/gzip.bend as Gzip

gralha-gzip-frame: the RFC 1952 gzip container around gralha-deflate. is_gzip checks the magic, decode inflates a whole member (sized by its ISIZE trailer), header and trailer frame a stream that is written in pieces, and write compresses a whole packed buffer into an open file.

4 imports
import Base
import gralha-byte-words@0.1.0.0/words.bend as Words
import gralha-crc32@0.1.0.0/crc32.bend as Crc32
import gralha-deflate@0.1.0.0/deflate.bend as Deflate

Types

type Sk source · line 18 · raw

Type

past a NUL-terminated field from pos

Definitions

def pick source · line 10 · raw

@c:Bool -> @a:U32 -> @b:U32 -> U32

def sk_at source · line 21 · raw

@r:Pair(Array<U32>, U32) -> @+pos:U32 -> @+n:U32 -> Sk

def sk_loop source · line 25 · raw

@fuel:Nat -> @st:Sk -> @+n:U32 -> Sk

def sk_of source · line 37 · raw

@st:Sk -> Pair(Array<U32>, U32)

def skip_nul_go source · line 42 · raw

@a:Array<U32> -> @+pos:U32 -> @+n:U32 -> @on:Bool -> Pair(Array<U32>, U32)

def skip_nul source · line 49 · raw

@r:Pair(Array<U32>, U32) -> @+n:U32 -> @on:Bool -> Pair(Array<U32>, U32)

def skip_n source · line 54 · raw

@r:Pair(Array<U32>, U32) -> @+k:U32 -> @on:Bool -> Pair(Array<U32>, U32)

def skip_xlen source · line 58 · raw

@r:Pair(Array<U32>, U32) -> @+pos:U32 -> Pair(Array<U32>, U32)

def skip_extra_go source · line 62 · raw

@a:Array<U32> -> @+pos:U32 -> @on:Bool -> Pair(Array<U32>, U32)

def skip_extra source · line 69 · raw

@r:Pair(Array<U32>, U32) -> @on:Bool -> Pair(Array<U32>, U32)

def gz_body source · line 75 · raw

@r:Pair(Array<U32>, U32) -> @+n:U32 -> Pair(Array<U32>, U32)

the deflate stream's offset from the flags byte

def gz_start source · line 80 · raw

@r:Pair(Array<U32>, U32) -> @+n:U32 -> @+out_n:U32 -> Pair(Array<U32>, U32)

def gz_sized source · line 84 · raw

@r:Pair(Array<U32>, U32) -> @+n:U32 -> Pair(Array<U32>, U32)

def decode source · line 88 · raw

@a:Array<U32> -> @+n:U32 -> Pair(Array<U32>, U32)

def gz_magic source · line 92 · raw

@r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Bool)

the magic 1f 8b

def is_gzip source · line 96 · raw

@a:Array<U32> -> Pair(Array<U32>, Bool)

def decode_if source · line 99 · raw

@a:Array<U32> -> @+n:U32 -> @gz:Bool -> Pair(Array<U32>, U32)

def trailer source · line 111 · raw

@ob:0x365c60316ea66a6c80658fc03b4eeac5/words.Sink -> @+crc:U32 -> @+size:U32 -> 0x365c60316ea66a6c80658fc03b4eeac5/words.Sink

CRC32 and ISIZE (the size mod 2^32), each little-endian

def write_crc source · line 114 · raw

@r:Pair(Array<U32>, U32) -> @+path:String -> @file:File -> @+n:U32 -> @+level:U32 -> IO(File)

def write source · line 124 · raw

@+path:String -> @file:File -> @a:Array<U32> -> @+n:U32 -> @+level:U32 -> IO(File)

the n bytes of a, compressed at level (0-9) as one gzip member, written to file; a holds three spare zero words past n, as Words.read leaves it