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

Last change on this file since 23508 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: 4.7 KB
Line 
1/**************************************************************************
2 *
3 * bitio_stdio.c -- 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#include "sysfuncs.h"
23
24#include "bitio_m_stdio.h"
25#include "bitio_m.h"
26
27
28
29void
30BIO_Stdio_Encode_Start (FILE * f, stdio_bitio_state * bs)
31{
32 ENCODE_START (f)
33 ENCODE_PAUSE (*bs)
34}
35
36void
37BIO_Stdio_Encode_Done (stdio_bitio_state * bs)
38{
39 ENCODE_CONTINUE (*bs)
40 ENCODE_DONE
41}
42
43
44void
45BIO_Stdio_Decode_Start (FILE * f, stdio_bitio_state * bs)
46{
47 DECODE_START (f)
48 DECODE_PAUSE (*bs)
49}
50
51void
52BIO_Stdio_Encode_Bit (int bit, stdio_bitio_state * bs)
53{
54 ENCODE_CONTINUE (*bs)
55 ENCODE_BIT (bit);
56 ENCODE_PAUSE (*bs)
57}
58
59
60int
61BIO_Stdio_Decode_Bit (stdio_bitio_state * bs)
62{
63 register int val;
64 DECODE_CONTINUE (*bs)
65 val = DECODE_BIT;
66 DECODE_PAUSE (*bs)
67 return (val);
68}
69
70
71
72
73void
74BIO_Stdio_Unary_Encode (mg_u_long val, stdio_bitio_state * bs,
75 mg_u_long *bits)
76{
77 ENCODE_CONTINUE (*bs)
78 if (bits)
79 UNARY_ENCODE_L (val, *bits);
80 else
81 UNARY_ENCODE (val);
82 ENCODE_PAUSE (*bs)
83}
84
85
86mg_u_long
87BIO_Stdio_Unary_Decode (stdio_bitio_state * bs,
88 mg_u_long *bits)
89{
90 register mg_u_long val;
91 DECODE_CONTINUE (*bs)
92 if (bits)
93 UNARY_DECODE_L (val, *bits);
94 else
95 UNARY_DECODE (val);
96 DECODE_PAUSE (*bs)
97 return (val);
98}
99
100
101
102
103
104
105
106void
107BIO_Stdio_Binary_Encode (mg_u_long val, mg_u_long b,
108 stdio_bitio_state * bs, mg_u_long *bits)
109{
110 ENCODE_CONTINUE (*bs)
111 if (bits)
112 BINARY_ENCODE_L (val, b, *bits);
113 else
114 BINARY_ENCODE (val, b);
115 ENCODE_PAUSE (*bs)
116}
117
118
119mg_u_long
120BIO_Stdio_Binary_Decode (mg_u_long b, stdio_bitio_state * bs,
121 mg_u_long *bits)
122{
123 register mg_u_long val;
124 DECODE_CONTINUE (*bs)
125 if (bits)
126 BINARY_DECODE_L (val, b, *bits);
127 else
128 BINARY_DECODE (val, b);
129 DECODE_PAUSE (*bs)
130 return (val);
131}
132
133
134
135
136
137
138
139void
140BIO_Stdio_Gamma_Encode (mg_u_long val, stdio_bitio_state * bs,
141 mg_u_long *bits)
142{
143 ENCODE_CONTINUE (*bs)
144 if (bits)
145 GAMMA_ENCODE_L (val, *bits);
146 else
147 GAMMA_ENCODE (val);
148 ENCODE_PAUSE (*bs)
149}
150
151
152mg_u_long
153BIO_Stdio_Gamma_Decode (stdio_bitio_state * bs,
154 mg_u_long *bits)
155{
156 register mg_u_long val;
157 DECODE_CONTINUE (*bs)
158 if (bits)
159 GAMMA_DECODE_L (val, *bits);
160 else
161 GAMMA_DECODE (val);
162 DECODE_PAUSE (*bs)
163 return (val);
164}
165
166
167
168
169void
170BIO_Stdio_Delta_Encode (mg_u_long val, stdio_bitio_state * bs,
171 mg_u_long *bits)
172{
173 ENCODE_CONTINUE (*bs)
174 if (bits)
175 DELTA_ENCODE_L (val, *bits);
176 else
177 DELTA_ENCODE (val);
178 ENCODE_PAUSE (*bs)
179}
180
181
182mg_u_long
183BIO_Stdio_Delta_Decode (stdio_bitio_state * bs,
184 mg_u_long *bits)
185{
186 register mg_u_long val;
187 DECODE_CONTINUE (*bs)
188 if (bits)
189 DELTA_DECODE_L (val, *bits);
190 else
191 DELTA_DECODE (val);
192 DECODE_PAUSE (*bs)
193 return (val);
194}
195
196
197
198
199void
200BIO_Stdio_Elias_Encode (mg_u_long val, mg_u_long b, double s,
201 stdio_bitio_state * bs, mg_u_long *bits)
202{
203 ENCODE_CONTINUE (*bs)
204 if (bits)
205 ELIAS_ENCODE_L (val, b, s, *bits);
206 else
207 ELIAS_ENCODE (val, b, s);
208 ENCODE_PAUSE (*bs)
209}
210
211
212mg_u_long
213BIO_Stdio_Elias_Decode (mg_u_long b, double s,
214 stdio_bitio_state * bs,
215 mg_u_long *bits)
216{
217 register mg_u_long val;
218 DECODE_CONTINUE (*bs)
219 if (bits)
220 ELIAS_DECODE_L (val, b, s, *bits);
221 else
222 ELIAS_DECODE (val, b, s);
223 DECODE_PAUSE (*bs)
224 return (val);
225}
226
227
228
229void
230BIO_Stdio_Bblock_Encode (mg_u_long val, mg_u_long b,
231 stdio_bitio_state * bs, mg_u_long *bits)
232{
233 ENCODE_CONTINUE (*bs)
234 if (bits)
235 BBLOCK_ENCODE_L (val, b, *bits);
236 else
237 BBLOCK_ENCODE (val, b);
238 ENCODE_PAUSE (*bs)
239}
240
241
242mg_u_long
243BIO_Stdio_Bblock_Decode (mg_u_long b, stdio_bitio_state * bs,
244 mg_u_long *bits)
245{
246 register mg_u_long val;
247 DECODE_CONTINUE (*bs)
248 if (bits)
249 BBLOCK_DECODE_L (val, b, *bits);
250 else
251 BBLOCK_DECODE (val, b);
252 DECODE_PAUSE (*bs)
253 return (val);
254}
255
256void
257BIO_Stdio_Decode_Seek (mg_u_long pos, stdio_bitio_state * bs)
258{
259 DECODE_CONTINUE (*bs)
260 DECODE_SEEK (pos);
261 DECODE_PAUSE (*bs)
262}
Note: See TracBrowser for help on using the repository browser.