annotate src/console/Zlib_Inflater.h @ 3111:7c27b8612b7e

Show "Add CD" command on playlist "Add" menu (closes #41)
author John Lindgren <john.lindgren@tds.net>
date Sun, 03 May 2009 08:59:43 -0400
parents 986f098da058
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
1 // Simplifies use of zlib for deflating data
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
2
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
3 // File_Extractor 0.4.0
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
4 #ifndef ZLIB_INFLATER_H
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
5 #define ZLIB_INFLATER_H
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
6
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
7 #include "blargg_common.h"
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
8 #include "zlib.h"
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
9
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
10 class Zlib_Inflater {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
11 public:
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
12
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
13 // Data reader callback
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
14 typedef blargg_err_t (*callback_t)( void* user_data, void* out, long* count );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
15
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
16 // Begin inflation using specified mode and fill buffer using read callback.
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
17 // Default buffer is 16K and filled to 4K, or specify buf_size for custom
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
18 // buffer size and to read that much file data. Using mode_auto selects
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
19 // between mode_copy and mode_ungz by examining first two bytes of buffer.
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
20 enum mode_t { mode_copy, mode_ungz, mode_raw_deflate, mode_auto };
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
21 blargg_err_t begin( mode_t, callback_t, void* user_data, long buf_size = 0 );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
22
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
23 // True if begin() has been called with mode_ungz or mode_raw_deflate
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
24 bool deflated() const { return deflated_; }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
25
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
26 // Read/inflate at most *count_io bytes into out and set *count_io to actual
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
27 // number of bytes read (less than requested if end of deflated data is reached).
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
28 // Keeps buffer full with user-provided callback.
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
29 blargg_err_t read( void* out, long* count_io, callback_t, void* user_data );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
30
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
31 // End inflation and free memory
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
32 void end();
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
33
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
34 private:
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
35 // noncopyable
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
36 Zlib_Inflater( const Zlib_Inflater& );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
37 Zlib_Inflater& operator = ( const Zlib_Inflater& );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
38
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
39 public:
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
40 Zlib_Inflater();
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
41 ~Zlib_Inflater();
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
42 private:
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
43 z_stream_s zbuf;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
44 blargg_vector<unsigned char> buf;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
45 bool deflated_;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
46 };
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
47
986f098da058 [svn] - merge in blargg's changes
nenolod
parents:
diff changeset
48 #endif