source: main/branches/64_bit_Greenstone/greenstone2/common-src/indexers/mg/lib/bitio_stdio.h@ 25138

Last change on this file since 25138 was 23508, checked in by sjm84, 13 years ago

Committing 64 bit changes into the branch

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 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 (mg_u_long val, stdio_bitio_state * bs,
62 mg_u_long *bits);
63mg_u_long BIO_Stdio_Unary_Decode (stdio_bitio_state * bs,
64 mg_u_long *bits);
65
66
67
68void BIO_Stdio_Binary_Encode (mg_u_long val, mg_u_long b,
69 stdio_bitio_state * bs, mg_u_long *bits);
70mg_u_long BIO_Stdio_Binary_Decode (mg_u_long b, stdio_bitio_state * bs,
71 mg_u_long *bits);
72
73
74
75void BIO_Stdio_Gamma_Encode (mg_u_long val, stdio_bitio_state * bs,
76 mg_u_long *bits);
77mg_u_long BIO_Stdio_Gamma_Decode (stdio_bitio_state * bs,
78 mg_u_long *bits);
79
80
81
82void BIO_Stdio_Delta_Encode (mg_u_long val, stdio_bitio_state * bs,
83 mg_u_long *bits);
84mg_u_long BIO_Stdio_Delta_Decode (stdio_bitio_state * bs,
85 mg_u_long *bits);
86
87
88
89void BIO_Stdio_Elias_Encode (mg_u_long val, mg_u_long b, double s,
90 stdio_bitio_state * bs, mg_u_long *bits);
91mg_u_long BIO_Stdio_Elias_Decode (mg_u_long b, double s,
92 stdio_bitio_state * bs,
93 mg_u_long *bits);
94
95
96void BIO_Stdio_Bblock_Encode (mg_u_long val, mg_u_long b,
97 stdio_bitio_state * bs, mg_u_long *bits);
98mg_u_long BIO_Stdio_Bblock_Decode (mg_u_long b, stdio_bitio_state * bs,
99 mg_u_long *bits);
100
101
102void BIO_Stdio_Decode_Seek (mg_u_long pos, stdio_bitio_state * bs);
103
104#endif
Note: See TracBrowser for help on using the repository browser.