| 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 <netpbm/pm.h> |
| 36 |
|
| 37 |
#ifdef __cplusplus |
| 38 |
extern "C" { |
| 39 |
#endif |
| 40 |
#if 0 |
| 41 |
} /* to fake out automatic code indenters */ |
| 42 |
#endif |
| 43 |
|
| 44 |
typedef struct bitstream *BITSTREAM; |
| 45 |
|
| 46 |
struct bitstream * |
| 47 |
pm_bitinit(FILE * const f, const char * const mode); |
| 48 |
|
| 49 |
/* |
| 50 |
* pm_bitfini() - deallocate the given BITSTREAM. |
| 51 |
* |
| 52 |
* You must call this after you are done with the BITSTREAM. |
| 53 |
* |
| 54 |
* It may flush some bits left in the buffer. |
| 55 |
* |
| 56 |
* Returns the number of bytes written, -1 on error. |
| 57 |
*/ |
| 58 |
|
| 59 |
int |
| 60 |
pm_bitfini(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 |
int |
| 69 |
pm_bitread(BITSTREAM b, |
| 70 |
unsigned long nbits, |
| 71 |
unsigned long * val); |
| 72 |
|
| 73 |
/* |
| 74 |
* pm_bitwrite() - write the low nbits of val to the given file. |
| 75 |
* |
| 76 |
* The last pm_bitwrite() must be followed by a call to pm_bitflush(). |
| 77 |
* |
| 78 |
* Returns the number of bytes written, -1 on error. |
| 79 |
*/ |
| 80 |
|
| 81 |
int |
| 82 |
pm_bitwrite(BITSTREAM b, |
| 83 |
unsigned long nbits, |
| 84 |
unsigned long val); |
| 85 |
|
| 86 |
#ifdef __cplusplus |
| 87 |
} |
| 88 |
#endif |
| 89 |
#endif |