source: main/tags/2.20/gsdl/packages/mg/lib/bitio_stdio.c@ 23214

Last change on this file since 23214 was 439, checked in by sjboddie, 25 years ago

renamed mg-1.3d directory mg

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