2 Generic object-oriented reading/writing.
4 Part of the swftools package.
6 Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24 #ifndef __rfxswf_bitio_h__
25 #define __rfxswf_bitio_h__
27 #define READER_TYPE_FILE 1
28 #define READER_TYPE_MEM 2
29 #define READER_TYPE_ZLIB_U 3
30 #define READER_TYPE_ZLIB_C 4
31 #define READER_TYPE_ZLIB READER_TYPE_ZLIB_U
32 #define READER_TYPE_NULL 5
34 #define WRITER_TYPE_FILE 1
35 #define WRITER_TYPE_MEM 2
36 #define WRITER_TYPE_ZLIB_C 3
37 #define WRITER_TYPE_ZLIB_U 4
38 #define WRITER_TYPE_NULL 5
39 #define WRITER_TYPE_GROWING_MEM 6
40 #define WRITER_TYPE_ZLIB WRITER_TYPE_ZLIB_C
44 int (*read)(struct reader_t*, void*data, int len);
45 void (*dealloc)(struct reader_t*);
56 int (*write)(struct writer_t*, void*data, int len);
57 void (*finish)(struct writer_t*);
66 void reader_resetbits(struct reader_t*r);
67 unsigned int reader_readbit(struct reader_t*r);
68 unsigned int reader_readbits(struct reader_t*r, int num);
70 void writer_resetbits(struct writer_t*w);
71 void writer_writebit(struct writer_t*w, int bit);
72 void writer_writebits(struct writer_t*w, unsigned int data, int bits);
74 /* standard readers / writers */
76 void reader_init_filereader(struct reader_t*r, int handle);
77 void reader_init_zlibinflate(struct reader_t*r, struct reader_t*input);
78 void reader_init_memreader(struct reader_t*r, void*data, int length);
79 void reader_init_nullreader(struct reader_t*r);
81 void writer_init_filewriter(struct writer_t*w, int handle);
82 void writer_init_filewriter2(struct writer_t*w, char*filename);
83 void writer_init_zlibdeflate(struct writer_t*w, struct writer_t*output);
84 void writer_init_memwriter(struct writer_t*r, void*data, int length);
85 void writer_init_nullwriter(struct writer_t*w);
87 void writer_init_growingmemwriter(struct writer_t*r);
88 void* writer_growmemwrite_getmem(struct writer_t*w);
90 #endif //__rfxswf_bitio_h__