Skip to content

A collection of functions for making writing to a bitstream eaisier; written in C under a BSD license

Notifications You must be signed in to change notification settings

willemt/bitstream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How does it work?

See bitstream.h for documentation.

See bitstream in action: https://github.com/willemt/peer-wire-protocol/blob/master/pwp_connection.c

Check out quick example:

char* bits[100];

bitstream_init(bits, 100);

/* write 0x5 as a byte to the stream. Move pointer by 1 byte */
bitstream_write_ubyte(&b, 0x5);

/* write out an 32bit unsigned int to the stream. Move pointer by 4 bytes */
bitstream_write_uint32(&b, 0xFF00FF00);

/* write out 1 bit. Record that we've "moved" forward one bit */
unsigned int bit_offset = 0;
bitstream_write_bit_from_bitoffset(&b, 1, &bit_offset);

/* write out 31 bits of a uint32. Move pointer 4 bytes forward */
bitstream_write_uint32_from_bitoffset(&b, 0xFF00FF00, 31, &bit_offset);

Building

$make

About

A collection of functions for making writing to a bitstream eaisier; written in C under a BSD license

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published