source: trunk/indexers/mg/lib/bitio_stdio.h@ 13654

Last change on this file since 13654 was 13654, checked in by kjdon, 17 years ago

tidied up the top comments, removed Ids, and old log messages

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/**************************************************************************
2 *
3 * bitio_stdio.h -- Functions for bitio to a file
4 * Copyright (C) 1994 Neil Sharman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 **************************************************************************
21 *
22 * This file contains function definitions for doing bitwise input and output
23 * of number on a FILE*. With these function you cannot mix reads and writes
24 * on the FILE, or multiple writes, at the same time and guarantee them to
25 * work, also you cannot seek to a point and do a write. The decode function
26 * can detect when you run off the end of the file and will produce an
27 * approate error message.
28 *
29 *
30 **************************************************************************/
31
32#ifndef H_BITIO_STDIO
33#define H_BITIO_STDIO
34
35
36typedef struct stdio_bitio_state
37 {
38 FILE *File;
39 unsigned char Buff;
40 unsigned char Btg;
41 }
42stdio_bitio_state;
43
44
45/* NOTE : All bytes are filled high bit first */
46
47
48void BIO_Stdio_Encode_Start (FILE * f, stdio_bitio_state * bs);
49void BIO_Stdio_Encode_Done (stdio_bitio_state * bs);
50
51
52
53void BIO_Stdio_Decode_Start (FILE * f, stdio_bitio_state * bs);
54
55
56
57void BIO_Stdio_Encode_Bit (int bit, stdio_bitio_state * bs);
58int BIO_Stdio_Decode_Bit (stdio_bitio_state * bs);
59
60
61void BIO_Stdio_Unary_Encode (unsigned long val, stdio_bitio_state * bs,
62 unsigned long *bits);
63unsigned long BIO_Stdio_Unary_Decode (stdio_bitio_state * bs,
64 unsigned long *bits);
65
66
67
68void BIO_Stdio_Binary_Encode (unsigned long val, unsigned long b,
69 stdio_bitio_state * bs, unsigned long *bits);
70unsigned long BIO_Stdio_Binary_Decode (unsigned long b, stdio_bitio_state * bs,
71 unsigned long *bits);
72
73
74
75void BIO_Stdio_Gamma_Encode (unsigned long val, stdio_bitio_state * bs,
76 unsigned long *bits);
77unsigned long BIO_Stdio_Gamma_Decode (stdio_bitio_state * bs,
78 unsigned long *bits);
79
80
81
82void BIO_Stdio_Delta_Encode (unsigned long val, stdio_bitio_state * bs,
83 unsigned long *bits);
84unsigned long BIO_Stdio_Delta_Decode (stdio_bitio_state * bs,
85 unsigned long *bits);
86
87
88
89void BIO_Stdio_Elias_Encode (unsigned long val, unsigned long b, double s,
90 stdio_bitio_state * bs, unsigned long *bits);
91unsigned long BIO_Stdio_Elias_Decode (unsigned long b, double s,
92 stdio_bitio_state * bs,
93 unsigned long *bits);
94
95
96void BIO_Stdio_Bblock_Encode (unsigned long val, unsigned long b,
97 stdio_bitio_state * bs, unsigned long *bits);
98unsigned long BIO_Stdio_Bblock_Decode (unsigned long b, stdio_bitio_state * bs,
99 unsigned long *bits);
100
101
102void BIO_Stdio_Decode_Seek (unsigned long pos, stdio_bitio_state * bs);
103
104#endif
Note: See TracBrowser for help on using the repository browser.