Bitfile  0.9.2
Bit stream file I/O library
Data Structures | Typedefs | Enumerations | Functions
bitfile.c File Reference

Bit file stream library implementation. More...

#include <stdlib.h>
#include <errno.h>
#include "bitfile.h"
Include dependency graph for bitfile.c:

Data Structures

struct  bit_file_t
 This is an complete definition for the type containing data needed to correctly manipulate a bit file. More...
 
struct  endian_test_t
 This is a union used when testing for endianess. More...
 

Typedefs

typedef int(* num_func_t) (bit_file_t *, void *, const unsigned int, const size_t)
 This type to points to the kind of functions that put/get bits from/to numerical data types (short, int, long, ...) More...
 

Enumerations

enum  endian_t { BF_UNKNOWN_ENDIAN, BF_LITTLE_ENDIAN, BF_BIG_ENDIAN }
 This is an enumeration of the types of endianess handled by this library (big endian and little endian). More...
 

Functions

bit_file_tBitFileOpen (const char *fileName, const BF_MODES mode)
 This function opens a bit file for reading, writing, or appending. More...
 
bit_file_tMakeBitFile (FILE *stream, const BF_MODES mode)
 This function naively wraps a standard file in a bit_file_t structure. More...
 
int BitFileClose (bit_file_t *stream)
 This function closes a bit file and frees all associated data. More...
 
FILE * BitFileToFILE (bit_file_t *stream)
 This function flushes and frees the bitfile structure, returning a pointer to a stdio file corresponding to the bitfile. More...
 
int BitFileByteAlign (bit_file_t *stream)
 This function aligns the bitfile to the nearest byte. More...
 
int BitFileFlushOutput (bit_file_t *stream, const unsigned char onesFill)
 This function flushes an output bit buffer. More...
 
int BitFileGetChar (bit_file_t *stream)
 This function returns the next byte from the file passed as a parameter. More...
 
int BitFilePutChar (const int c, bit_file_t *stream)
 This function writes the byte passed as a parameter to the file passed a parameter. More...
 
int BitFileGetBit (bit_file_t *stream)
 This function returns the next bit from the file passed as a parameter. More...
 
int BitFilePutBit (const int c, bit_file_t *stream)
 This function writes the bit passed as a parameter to the file passed a parameter. More...
 
int BitFileGetBits (bit_file_t *stream, void *bits, const unsigned int count)
 This function reads the specified number of bits from the file passed as a parameter. More...
 
int BitFilePutBits (bit_file_t *stream, void *bits, const unsigned int count)
 This function writes the specified number of bits from the memory location passed as a parameter to the file passed as a parameter. More...
 
int BitFileGetBitsNum (bit_file_t *stream, void *bits, const unsigned int count, const size_t size)
 This function provides a machine independent layer that allows a single function call to stuff an arbitrary number of bits into an integer type variable. More...
 
int BitFilePutBitsNum (bit_file_t *stream, void *bits, const unsigned int count, const size_t size)
 This function provides a machine independent layer that allows a single function call to write an arbitrary number of bits from an integer type variable into a file. More...
 

Detailed Description

Bit file stream library implementation.

Author
Michael Dipperstein (mdipp.nosp@m.erst.nosp@m.ein@g.nosp@m.mail.nosp@m..com)
Date
January 9, 2004

This file implements a simple library of I/O functions for files that contain data in sizes that aren't integral bytes. An attempt was made to make the functions in this library analogous to functions provided to manipulate byte streams. The functions contained in this library were created with compression algorithms in mind, but may be suited to other applications.

This file is part of the bit file library.
License
The bitfile library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
The bitfile library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.