package core:compress/gzip
⌘K
Ctrl+K
or
/
Overview
A small GZIP unpacker.
This package is deprecated, use core:compress/deflate as the example below does.
Example:
package compress_gzip_example
import "core:compress"
import "core:compress/deflate"
import "core:fmt"
import "core:os"
// Small GZIP file with fextra, fname and fcomment present.
@private
TEST: []u8 = {
0x1f, 0x8b, 0x08, 0x1c, 0xcb, 0x3b, 0x3a, 0x5a,
0x02, 0x03, 0x07, 0x00, 0x61, 0x62, 0x03, 0x00,
0x63, 0x64, 0x65, 0x66, 0x69, 0x6c, 0x65, 0x6e,
0x61, 0x6d, 0x65, 0x00, 0x54, 0x68, 0x69, 0x73,
0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x63, 0x6f,
0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x2b, 0x48,
0xac, 0xcc, 0xc9, 0x4f, 0x4c, 0x01, 0x00, 0x15,
0x6a, 0x2c, 0x42, 0x07, 0x00, 0x00, 0x00,
}
main :: proc() {
// Set up output buffer.
buf: [dynamic]byte
defer delete(buf)
stdout :: proc(s: string) {
os.write_string(os.stdout, s)
}
stderr :: proc(s: string) {
os.write_string(os.stderr, s)
}
if len(os.args) < 2 {
stderr("No input file specified.\n")
err := deflate.inflate_gzip(&buf, TEST)
if err == nil {
stdout("Displaying test vector: \"")
stdout(string(buf[:]))
stdout("\"\n")
} else {
fmt.printf("deflate.inflate_gzip returned %v\n", err)
}
delete(buf)
os.exit(0)
}
for file in os.args[1:] {
clear(&buf)
err: deflate.Error
if file == "-" {
// Read from stdin
ctx := compress.init_context(os.to_stream(os.stdin), &buf)
defer compress.destroy_context(&ctx)
err = deflate.inflate_gzip(&ctx)
} else {
data, read_err := os.read_entire_file(file, context.allocator)
defer delete(data)
if read_err != nil {
stderr("File not found: ")
stderr(file)
stderr("\n")
os.exit(1)
}
err = deflate.inflate_gzip(&buf, data)
}
if err != nil {
stderr("GZIP returned an error.\n")
os.exit(2)
}
stdout(string(buf[:]))
}
}
An implementation of the GZIP wrapper over the Deflate algorith.
Deprecated, folded into core:compress/deflate.
Index
Constants (2)
Variables (0)
This section is empty.
Procedures (3)
Procedure Groups (1)
Types
Compression ¶
Compression :: compress_deflate.Gzip_Compression
Compression_Flags ¶
Compression_Flags :: compress_deflate.Gzip_Compression_Flags
E_Deflate ¶
E_Deflate :: compress.Deflate_Error
E_GZIP ¶
E_GZIP :: compress.GZIP_Error
E_General ¶
E_General :: compress.General_Error
E_ZLIB ¶
E_ZLIB :: compress.ZLIB_Error
Error ¶
Error :: compress.Error
Related Procedures With Returns
- load_from_bytes
- load_from_context
- load_from_file
- load (procedure groups)
Header ¶
Header :: compress_deflate.Gzip_Header
Header_Flag ¶
Header_Flag :: compress_deflate.Gzip_Header_Flag
Header_Flags ¶
Header_Flags :: compress_deflate.Gzip_Header_Flags
Magic ¶
Magic :: compress_deflate.Gzip_Magic
Constants
GZIP_MAX_PAYLOAD_SIZE ¶
GZIP_MAX_PAYLOAD_SIZE: i64 : deflate.GZIP_MAX_PAYLOAD_SIZE
Variables
This section is empty.
Procedures
load_from_bytes ¶
Deprecated. Use
deflate.inflate_gzip from core:compress/deflate@(deprecated="Use `deflate.inflate_gzip` from `core:compress/deflate`") load_from_bytes :: proc( data: []u8, output: ^bytes.Buffer, known_gzip_size: int = -1, expected_output_size: int = -1, allocator := context.allocator, ) -> (err: compress.Error) {…}
load_from_context ¶
Deprecated. Use
deflate.inflate_gzip from core:compress/deflate@(deprecated="Use `deflate.inflate_gzip` from `core:compress/deflate`") load_from_context :: proc( z: ^compress.Context, known_gzip_size: int = -1, allocator := context.allocator, ) -> (err: compress.Error) {…}
load_from_file ¶
Deprecated. Use
[os.read_entire_file](/core/os/#read_entire_file) and deflate.inflate_gzip from core:compress/deflate@(deprecated="Use `os.read_entire_file` and `deflate.inflate_gzip` from `core:compress/deflate`") load_from_file :: proc( filename: string, output: ^bytes.Buffer, expected_output_size: int = -1, allocator := context.allocator, ) -> (err: compress.Error) {…}
Procedure Groups
load ¶
load :: proc{ load_from_bytes, load_from_file, load_from_context, }
Source Files
Generation Information
Generated with odin version dev-2026-11 (vendor "odin") Windows_amd64 @ 2026-11-10 03:07:04.374188700 +0000 UTC