home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netpbma.zip / ppm / bitio.h < prev    next >
C/C++ Source or Header  |  1993-10-04  |  2KB  |  81 lines

  1. /*\
  2.  * $Id: bitio.h,v 1.4 1992/11/24 19:37:02 dws Exp dws $
  3.  *
  4.  * bitio.h - bitstream I/O
  5.  *
  6.  * Works for (sizeof(unsigned long)-1)*8 bits.
  7.  *
  8.  * Copyright (C) 1992 by David W. Sanderson.
  9.  * 
  10.  * Permission to use, copy, modify, and distribute this software and its
  11.  * documentation for any purpose and without fee is hereby granted,
  12.  * provided that the above copyright notice appear in all copies and
  13.  * that both that copyright notice and this permission notice appear
  14.  * in supporting documentation.  This software is provided "as is"
  15.  * without express or implied warranty.
  16.  *
  17.  * $Log: bitio.h,v $
  18.  * Revision 1.4  1992/11/24  19:37:02  dws
  19.  * Added copyright
  20.  *
  21.  * Revision 1.3  1992/11/17  03:37:59  dws
  22.  * updated comment
  23.  *
  24.  * Revision 1.2  1992/11/10  23:10:22  dws
  25.  * Generalized to handle more than one bitstream at a time.
  26.  *
  27.  * Revision 1.1  1992/11/10  18:33:51  dws
  28.  * Initial revision
  29.  *
  30. \*/
  31.  
  32. #ifndef _BITIO_H_
  33. #define _BITIO_H_
  34.  
  35. #include "pbmplus.h"
  36.  
  37. typedef struct bitstream    *BITSTREAM;
  38.  
  39. /*
  40.  * pm_bitinit() - allocate and return a BITSTREAM for the given FILE*.
  41.  *
  42.  * mode must be one of "r" or "w", according to whether you will be
  43.  * reading from or writing to the BITSTREAM.
  44.  *
  45.  * Returns 0 on error.
  46.  */
  47.  
  48. extern BITSTREAM pm_bitinit ARGS((FILE *f, char *mode));
  49.  
  50. /*
  51.  * pm_bitfini() - deallocate the given BITSTREAM.
  52.  *
  53.  * You must call this after you are done with the BITSTREAM.
  54.  * 
  55.  * It may flush some bits left in the buffer.
  56.  *
  57.  * Returns the number of bytes written, -1 on error.
  58.  */
  59.  
  60. extern int pm_bitfini ARGS((BITSTREAM b));
  61.  
  62. /*
  63.  * pm_bitread() - read the next nbits into *val from the given file.
  64.  * 
  65.  * Returns the number of bytes read, -1 on error.
  66.  */
  67.  
  68. extern int pm_bitread ARGS((BITSTREAM b, unsigned long nbits, unsigned long *val));
  69.  
  70. /*
  71.  * pm_bitwrite() - write the low nbits of val to the given file.
  72.  * 
  73.  * The last pm_bitwrite() must be followed by a call to pm_bitflush().
  74.  * 
  75.  * Returns the number of bytes written, -1 on error.
  76.  */
  77.  
  78. extern int pm_bitwrite ARGS((BITSTREAM b, unsigned long nbits, unsigned long val));
  79.  
  80. #endif /* _BITIO_H_ */
  81.