LibBitbuf is a simple library written in C to write bit-a-bit or byte-a-byte to files and other streams.
LibBitbuf provides an easy to use interface, very similar to stdio, so that everyone should be able to start using it very quickly.
The code is written to be portable, however Libbitbuf only works on little endian architectures.
This is a very simple example:


int main(int argc,char**argv){
   bitbuf buf;
   FILE*fout,*fout2,*fin;
   unsigned long int res=100;
   unsigned char c=2;
  
   if((fout=fopen(argv[1],"wb"))==NULL) {perror("fopen");exit(3);}

   if(binit(&buf,64,fout,1)<0) {perror("binit");exit(7);}

   bytewrite(&buf,sizeof(unsigned long int),&res);
   bitwrite(&buf,2,c);

   bflush(&buf);

   fclose(fout);
}

For more informations read bitbuf.h.

libbitbuf 0.1 sources



Valid HTML 4.01 Transitional Valid CSS!

Slackware is a registered trademark of Slackware Linux, Inc. This project is not "Slackware Linux", nor is it affiliated with or endorsed by Slackware Inc. in any way.
Copyright 2006 - Stefano Stabellini, All Rights Reserved
 
 

 

STEFANO STABELLINI