source: gsdl/trunk/trunk/mg/lib/bitio_random.h@ 16583

Last change on this file since 16583 was 16583, checked in by davidb, 16 years ago

Undoing change commited in r16582

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/**************************************************************************
2 *
3 * bitio_random.h -- Functions for bitio to a file (random access)
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 numbers on an array of chars. These routines are slower than the ones
24 * in "mem" files. but with these routines you can mix reads and writes, or
25 * multiple writes, on the array of chars at the same time and guarantee
26 * them to work, also you can seek to a point and do a write. The decode and
27 * encode functions cannot detect when the end off the character is reached
28 * and just continue processing.
29 *
30 * Modified:
31 * - long long seek and tell ops
32 * (1999-08-03 Tim Bell <[email protected]>)
33 **************************************************************************/
34
35#ifndef H_BITIO_RANDOM
36#define H_BITIO_RANDOM
37
38#include "longlong.h"
39
40
41typedef struct random_bitio_state
42 {
43 FILE *File;
44 unsigned char *Buf;
45 unsigned long Base;
46 unsigned long Used;
47 unsigned long pos;
48 unsigned long len;
49 unsigned long sft;
50 }
51random_bitio_state;
52
53
54/* NOTE : All bytes are filled high bit first */
55
56
57void BIO_Random_Start (FILE * f, unsigned long len,
58 random_bitio_state * bs);
59void BIO_Random_Done (random_bitio_state * bs);
60
61
62
63void BIO_Random_Decode_Start (void *buf, unsigned long pos,
64 random_bitio_state * bs);
65
66void BIO_Random_Encode_Bit (int bit, random_bitio_state * bs);
67
68int BIO_Random_Decode_Bit (random_bitio_state * bs);
69
70
71void BIO_Random_Unary_Encode (unsigned long val, random_bitio_state * bs,
72 unsigned long *bits);
73unsigned long BIO_Random_Unary_Decode (random_bitio_state * bs,
74 unsigned long *bits);
75
76
77
78void BIO_Random_Binary_Encode (unsigned long val, unsigned long b,
79 random_bitio_state * bs, unsigned long *bits);
80unsigned long BIO_Random_Binary_Decode (unsigned long b, random_bitio_state * bs,
81 unsigned long *bits);
82
83
84
85void BIO_Random_Gamma_Encode (unsigned long val, random_bitio_state * bs,
86 unsigned long *bits);
87unsigned long BIO_Random_Gamma_Decode (random_bitio_state * bs,
88 unsigned long *bits);
89
90
91
92void BIO_Random_Delta_Encode (unsigned long val, random_bitio_state * bs,
93 unsigned long *bits);
94unsigned long BIO_Random_Delta_Decode (random_bitio_state * bs,
95 unsigned long *bits);
96
97
98void BIO_Random_Elias_Encode (unsigned long val, unsigned long b, double s,
99 random_bitio_state * bs, unsigned long *bits);
100unsigned long BIO_Random_Elias_Decode (unsigned long b, double s,
101 random_bitio_state * bs,
102 unsigned long *bits);
103
104
105void BIO_Random_Bblock_Encode (unsigned long val, unsigned long b,
106 random_bitio_state * bs, unsigned long *bits);
107unsigned long BIO_Random_Bblock_Decode (unsigned long b,
108 random_bitio_state * bs,
109 unsigned long *bits);
110
111
112void BIO_Random_Seek (unsigned long pos, random_bitio_state * bs);
113
114void BIO_Random_Flush (random_bitio_state * bs);
115
116unsigned long BIO_Random_Tell (random_bitio_state * bs);
117
118#ifdef USE_LONG_LONG
119
120void BIO_Random_Seek_LL (mg_ullong pos, random_bitio_state * bs);
121mg_ullong BIO_Random_Tell_LL (random_bitio_state * bs);
122
123#endif /* USE_LONG_LONG */
124
125#endif
Note: See TracBrowser for help on using the repository browser.