• Stars
    star
    111
  • Rank 314,510 (Top 7 %)
  • Language
    C
  • License
    BSD 2-Clause "Sim...
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

mini_gzip - embeddable, minimal, in-memory GZIP API

mini_gzip - embeddable, minimal, in-memory GZIP API

Build Status

Embeddable, minimal GZIP functionality, with API designed to work from memory. Only supports decompression for now.

I wrote it when I needed a small piece of code to give me decompression in an embedded system I was working with, and I found out that most of the GZIP-related programs use POSIX FILE API, which made the examples not work for my case.

The mini_gzip is based on miniz library (https://code.google.com/p/miniz/), which provides an API for operating on data compressed according to deflate algorithm. Added is a layer which provides a container for the GZIP files and let me do some verification.

To build

Everything should be fairly self-contained, and built with:

make

How to use

The API operates on struct mini_gzip structures, which are containers for the memory with GZIPed data. You must call mini_gz_init() on the structure 1st for the rest of the API to work correctly. Next, you must call mini_gz_start(&gz, mem_in, size), where gz is the initialized container and with GZIPed data pointed by mem_in of the size of size. To unpack, you call mini_gz_unpack(&gz, mem_out, memsize), where the first argument is the initialized container, the second mem_out is a pointer to the output memory, and memsize is its lenght. It's important to have enough bytes in the output buffer for decompressed data.

To test

Simple test is provided:

make test

To test by yourself, you can do:

	wk:/w/repos/mini_gzip> ls -la miniz.o
	-rw-r--r--  1 wk  staff  114348 20 paź 09:46 miniz.o
	wk:/w/repos/mini_gzip> md5 miniz.o
	MD5 (miniz.o) = e6199aade2020b6040fa160baee47d68
	wk:/w/repos/mini_gzip> gzip miniz.o
	wk:/w/repos/mini_gzip> ls -la miniz.o.gz
	-rw-r--r--  1 wk  staff  44965 20 paź 09:46 miniz.o.gz
	wk:/w/repos/mini_gzip> ./mini_gzip miniz.o.gz miniz.o
	flag_c: 0 is_gzipped: 1
	in_fn: miniz.o.gz out_fn: miniz.o level 6
	--- testing decompression --
	out_len = 114348
	ret = 114348
	wk:/w/repos/mini_gzip> md5 miniz.o
	MD5 (miniz.o) = e6199aade2020b6040fa160baee47d68

References

After publishing mini_gzip on HackerNews, byuu (http://byuu.org/) mentioned he has much leaner implementation of GZIP:

Author

More Repositories

1

cpu60

Example of CPU simulation in software
C
156
star
2

lastpass-ssh

SSH key management with LastPass
Ruby
110
star
3

kmnsim

Koszek-Matyja Network Simulator. Specify network architecture in a simple configuration file and run network simulations.
C
59
star
4

ncurses_guide

NCurses Examples from the book "Programmer's Guide to NCurses" with improvements and fixes
C
53
star
5

synology

My Synology automation scripts. Making Synology NAS command line usable
Shell
53
star
6

book-real-world-haskell

Real World Haskell Source Code
Shell
50
star
7

flviz

FLVIz - Finite Automata Simulator written in QT/Graphviz
HTML
36
star
8

mini_printf

mini_printf - minimal, self-contained and verified printf()
C
34
star
9

cweb

The CWEB System of Structured Documentation
C
29
star
10

lastpass-ansible

Unlock Ansible Vault with LastPass
Ruby
23
star
11

yc_interview

YC Interview Questions
14
star
12

libxbf

Xilinx Bitstream Format Library. Easily read .bit files from C programs.
C
13
star
13

usbpush

USBpush program for "DNW" U-boot protocol support in FriendlyARM/QT2410/OrigenBoard boards
C
8
star
14

sensorama-ios

Sensorama for iOS
Objective-C
8
star
15

book-programming-ruby

Source Code for Programming Ruby (2nd edition)
Ruby
7
star
16

freebsd_netfpga

FreeBSD NetFPGA driver
C
5
star
17

macb

Mac and iOS build tool
Ruby
4
star
18

edu_valgrind

Valgrind HOWTO and Examples
Makefile
4
star
19

stay_offline

Stuff for iPad/iPhone reading/listening/watching offline
Ruby
3
star
20

me

Wojciech Koszek's home page and blog
HTML
3
star
21

ruby_packages

Ruby packages built for Ubuntu
Ruby
3
star
22

tools

Handy tools and useful scripts for the command line
Shell
3
star
23

geom_sunx86label

FreeBSD GEOM class for Solaris x86 disk labels
C
2
star
24

fxload

fxload from Linux Hotplug project
C
2
star
25

godaddycli

[BROKEN] Command Line Interface to GoDaddy.com based on PyGoDaddy Library
Python
2
star
26

cs193p

Stanford's CS193p Class Source Code
Objective-C
2
star
27

shroud

Shroud
C
1
star
28

netgear_recovery

Netgear Firmware Recovery via TFTP
1
star
29

uitestviewer

pytest result test viewer
1
star
30

msgr

msgr
Go
1
star
31

edu_objc

Objective C exercises to understand the semantics of some APIs.
Objective-C
1
star
32

unix_plugin

unix_plugin - skeleton for UNIX plugin mechanism
C
1
star
33

rmdups

Remove duplicate copies of files from your messy backup
Go
1
star
34

sentperm

SentPerm - sentence permutation program
C
1
star
35

sensorama-datapath

Sensorama Datapath
PHP
1
star
36

usb_relay

usb_relay - JS283 relay controller
C
1
star
37

travis_deploy

My Travis Deployment environment
Shell
1
star
38

printf_binary

printf_binary plugin for FreeBSD printf implementation
C
1
star
39

vmshow

VMshow - Virtual memory statistics tool based on FreeBSD's KVM API
C
1
star
40

libcla

Command Line Argument library for easier argument parsing and usage screen generation.
C
1
star
41

zimcat

cat for ZIM file format archives
Go
1
star
42

hardware

Wojciech's hardware bits and Verilog snippets.
Verilog
1
star
43

friends

Programs written for friends, mostly during out CS studies
C++
1
star
44

edu_ruby

Ruby Educational Examples. Result of my attempt to get better at Ruby. I studied from 3 books: Programming Ruby, Ruby Programming and Teach yourself Ruby in 21 days.
Ruby
1
star
45

puzzles

Various programming puzzles
C
1
star
46

drums

My repository related to my snare drum and drumset interests
Verilog
1
star
47

sensorama.org

Sensorama website: what you see on sensorama.org
HTML
1
star
48

rcd

RCD, IP address obfuscator, for some strange reason written in C.
Perl
1
star
49

sensorama

Sensorama: understanding sensor data
Java
1
star
50

unsaver

Screen Saver Killer for UNIX, written in Literate Programming
C
1
star