source: trunk/gsdl3/packages/mg/lib/bitio_stdio.c@ 8694

Last change on this file since 8694 was 3745, checked in by mdewsnip, 21 years ago

Addition of MG package for search and retrieval

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 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 * $Id: bitio_stdio.c 3745 2003-02-20 21:20:24Z mdewsnip $
21 *
22 **************************************************************************/
23
24/*
25 $Log$
26 Revision 1.1 2003/02/20 21:14:16 mdewsnip
27 Addition of MG package for search and retrieval
28
29 Revision 1.1 1999/08/10 21:16:47 sjboddie
30 renamed mg-1.3d directory mg
31
32 Revision 1.1 1998/11/17 09:31:52 rjmcnab
33 *** empty log message ***
34
35 * Revision 1.1 1994/08/22 00:24:41 tes
36 * Initial placement under CVS.
37 *
38 */
39
40static char *RCSID = "$Id: bitio_stdio.c 3745 2003-02-20 21:20:24Z mdewsnip $";
41
42
43
44#include "sysfuncs.h"
45
46#include "bitio_m_stdio.h"
47#include "bitio_m.h"
48
49
50
51void
52BIO_Stdio_Encode_Start (FILE * f, stdio_bitio_state * bs)
53{
54 ENCODE_START (f)
55 ENCODE_PAUSE (*bs)
56}
57
58void
59BIO_Stdio_Encode_Done (stdio_bitio_state * bs)
60{
61 ENCODE_CONTINUE (*bs)
62 ENCODE_DONE
63}
64
65
66void
67BIO_Stdio_Decode_Start (FILE * f, stdio_bitio_state * bs)
68{
69 DECODE_START (f)
70 DECODE_PAUSE (*bs)
71}
72
73void
74BIO_Stdio_Encode_Bit (int bit, stdio_bitio_state * bs)
75{
76 ENCODE_CONTINUE (*bs)
77 ENCODE_BIT (bit);
78 ENCODE_PAUSE (*bs)
79}
80
81
82int
83BIO_Stdio_Decode_Bit (stdio_bitio_state * bs)
84{
85 register int val;
86 DECODE_CONTINUE (*bs)
87 val = DECODE_BIT;
88 DECODE_PAUSE (*bs)
89 return (val);
90}
91
92
93
94
95void
96BIO_Stdio_Unary_Encode (unsigned long val, stdio_bitio_state * bs,
97 unsigned long *bits)
98{
99 ENCODE_CONTINUE (*bs)
100 if (bits)
101 UNARY_ENCODE_L (val, *bits);
102 else
103 UNARY_ENCODE (val);
104 ENCODE_PAUSE (*bs)
105}
106
107
108unsigned long
109BIO_Stdio_Unary_Decode (stdio_bitio_state * bs,
110 unsigned long *bits)
111{
112 register unsigned long val;
113 DECODE_CONTINUE (*bs)
114 if (bits)
115 UNARY_DECODE_L (val, *bits);
116 else
117 UNARY_DECODE (val);
118 DECODE_PAUSE (*bs)
119 return (val);
120}
121
122
123
124
125
126
127
128void
129BIO_Stdio_Binary_Encode (unsigned long val, unsigned long b,
130 stdio_bitio_state * bs, unsigned long *bits)
131{
132 ENCODE_CONTINUE (*bs)
133 if (bits)
134 BINARY_ENCODE_L (val, b, *bits);
135 else
136 BINARY_ENCODE (val, b);
137 ENCODE_PAUSE (*bs)
138}
139
140
141unsigned long
142BIO_Stdio_Binary_Decode (unsigned long b, stdio_bitio_state * bs,
143 unsigned long *bits)
144{
145 register unsigned long val;
146 DECODE_CONTINUE (*bs)
147 if (bits)
148 BINARY_DECODE_L (val, b, *bits);
149 else
150 BINARY_DECODE (val, b);
151 DECODE_PAUSE (*bs)
152 return (val);
153}
154
155
156
157
158
159
160
161void
162BIO_Stdio_Gamma_Encode (unsigned long val, stdio_bitio_state * bs,
163 unsigned long *bits)
164{
165 ENCODE_CONTINUE (*bs)
166 if (bits)
167 GAMMA_ENCODE_L (val, *bits);
168 else
169 GAMMA_ENCODE (val);
170 ENCODE_PAUSE (*bs)
171}
172
173
174unsigned long
175BIO_Stdio_Gamma_Decode (stdio_bitio_state * bs,
176 unsigned long *bits)
177{
178 register unsigned long val;
179 DECODE_CONTINUE (*bs)
180 if (bits)
181 GAMMA_DECODE_L (val, *bits);
182 else
183 GAMMA_DECODE (val);
184 DECODE_PAUSE (*bs)
185 return (val);
186}
187
188
189
190
191void
192BIO_Stdio_Delta_Encode (unsigned long val, stdio_bitio_state * bs,
193 unsigned long *bits)
194{
195 ENCODE_CONTINUE (*bs)
196 if (bits)
197 DELTA_ENCODE_L (val, *bits);
198 else
199 DELTA_ENCODE (val);
200 ENCODE_PAUSE (*bs)
201}
202
203
204unsigned long
205BIO_Stdio_Delta_Decode (stdio_bitio_state * bs,
206 unsigned long *bits)
207{
208 register unsigned long val;
209 DECODE_CONTINUE (*bs)
210 if (bits)
211 DELTA_DECODE_L (val, *bits);
212 else
213 DELTA_DECODE (val);
214 DECODE_PAUSE (*bs)
215 return (val);
216}
217
218
219
220
221void
222BIO_Stdio_Elias_Encode (unsigned long val, unsigned long b, double s,
223 stdio_bitio_state * bs, unsigned long *bits)
224{
225 ENCODE_CONTINUE (*bs)
226 if (bits)
227 ELIAS_ENCODE_L (val, b, s, *bits);
228 else
229 ELIAS_ENCODE (val, b, s);
230 ENCODE_PAUSE (*bs)
231}
232
233
234unsigned long
235BIO_Stdio_Elias_Decode (unsigned long b, double s,
236 stdio_bitio_state * bs,
237 unsigned long *bits)
238{
239 register unsigned long val;
240 DECODE_CONTINUE (*bs)
241 if (bits)
242 ELIAS_DECODE_L (val, b, s, *bits);
243 else
244 ELIAS_DECODE (val, b, s);
245 DECODE_PAUSE (*bs)
246 return (val);
247}
248
249
250
251void
252BIO_Stdio_Bblock_Encode (unsigned long val, unsigned long b,
253 stdio_bitio_state * bs, unsigned long *bits)
254{
255 ENCODE_CONTINUE (*bs)
256 if (bits)
257 BBLOCK_ENCODE_L (val, b, *bits);
258 else
259 BBLOCK_ENCODE (val, b);
260 ENCODE_PAUSE (*bs)
261}
262
263
264unsigned long
265BIO_Stdio_Bblock_Decode (unsigned long b, stdio_bitio_state * bs,
266 unsigned long *bits)
267{
268 register unsigned long val;
269 DECODE_CONTINUE (*bs)
270 if (bits)
271 BBLOCK_DECODE_L (val, b, *bits);
272 else
273 BBLOCK_DECODE (val, b);
274 DECODE_PAUSE (*bs)
275 return (val);
276}
277
278void
279BIO_Stdio_Decode_Seek (unsigned long pos, stdio_bitio_state * bs)
280{
281 DECODE_CONTINUE (*bs)
282 DECODE_SEEK (pos);
283 DECODE_PAUSE (*bs)
284}
Note: See TracBrowser for help on using the repository browser.