1 | /** @file
|
---|
2 | * innotek Portable Runtime - Compression.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef ___iprt_zip_h
|
---|
18 | #define ___iprt_zip_h
|
---|
19 |
|
---|
20 | #include <iprt/cdefs.h>
|
---|
21 | #include <iprt/types.h>
|
---|
22 |
|
---|
23 |
|
---|
24 | __BEGIN_DECLS
|
---|
25 |
|
---|
26 | /** @defgroup grp_rt_zip RTZip - Compression
|
---|
27 | * @ingroup grp_rt
|
---|
28 | * @{
|
---|
29 | */
|
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Callback function for consuming compressed data during compression.
|
---|
35 | *
|
---|
36 | * @returns iprt status code.
|
---|
37 | * @param pvUser User argument.
|
---|
38 | * @param pvBuf Compressed data.
|
---|
39 | * @param cbBuf Size of the compressed data.
|
---|
40 | */
|
---|
41 | typedef DECLCALLBACK(int) FNRTZIPOUT(void *pvUser, const void *pvBuf, size_t cbBuf);
|
---|
42 | /** Pointer to FNRTZIPOUT() function. */
|
---|
43 | typedef FNRTZIPOUT *PFNRTZIPOUT;
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Callback function for supplying compressed data during decompression.
|
---|
47 | *
|
---|
48 | * @returns iprt status code.
|
---|
49 | * @param pvUser User argument.
|
---|
50 | * @param pvBuf Where to store the compressed data.
|
---|
51 | * @param cbBuf Size of the buffer.
|
---|
52 | * @param pcbBuf Number of bytes actually stored in the buffer.
|
---|
53 | */
|
---|
54 | typedef DECLCALLBACK(int) FNRTZIPIN(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbBuf);
|
---|
55 | /** Pointer to FNRTZIPIN() function. */
|
---|
56 | typedef FNRTZIPIN *PFNRTZIPIN;
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Compression type.
|
---|
60 | * (Be careful with these they are stored in files!)
|
---|
61 | */
|
---|
62 | typedef enum RTZIPTYPE
|
---|
63 | {
|
---|
64 | /** Invalid. */
|
---|
65 | RTZIPTYPE_INVALID = 0,
|
---|
66 | /** Choose best fitting one. */
|
---|
67 | RTZIPTYPE_AUTO,
|
---|
68 | /** Store the data. */
|
---|
69 | RTZIPTYPE_STORE,
|
---|
70 | /** Zlib compression the data. */
|
---|
71 | RTZIPTYPE_ZLIB,
|
---|
72 | /** BZlib compress. */
|
---|
73 | RTZIPTYPE_BZLIB,
|
---|
74 | /** libLZF compress. */
|
---|
75 | RTZIPTYPE_LZF
|
---|
76 | } RTZIPTYPE;
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Compression level.
|
---|
80 | */
|
---|
81 | typedef enum RTZIPLEVEL
|
---|
82 | {
|
---|
83 | /** Store, don't compress. */
|
---|
84 | RTZIPLEVEL_STORE = 0,
|
---|
85 | /** Fast compression. */
|
---|
86 | RTZIPLEVEL_FAST,
|
---|
87 | /** Default compression. */
|
---|
88 | RTZIPLEVEL_DEFAULT,
|
---|
89 | /** Maximal compression. */
|
---|
90 | RTZIPLEVEL_MAX
|
---|
91 | } RTZIPLEVEL;
|
---|
92 |
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * Create a compressor instance.
|
---|
96 | *
|
---|
97 | * @returns iprt status code.
|
---|
98 | * @param ppZip Where to store the instance handle.
|
---|
99 | * @param pvUser User argument which will be passed on to pfnOut and pfnIn.
|
---|
100 | * @param pfnOut Callback for consuming output of compression.
|
---|
101 | * @param enmType Type of compressor to create.
|
---|
102 | * @param enmLevel Compression level.
|
---|
103 | */
|
---|
104 | RTDECL(int) RTZipCompCreate(PRTZIPCOMP *ppZip, void *pvUser, PFNRTZIPOUT pfnOut, RTZIPTYPE enmType, RTZIPLEVEL enmLevel);
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Compresses a chunk of memory.
|
---|
108 | *
|
---|
109 | * @returns iprt status code.
|
---|
110 | * @param pZip The compressor instance.
|
---|
111 | * @param pvBuf Pointer to buffer containing the bits to compress.
|
---|
112 | * @param cbBuf Number of bytes to compress.
|
---|
113 | */
|
---|
114 | RTDECL(int) RTZipCompress(PRTZIPCOMP pZip, const void *pvBuf, size_t cbBuf);
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * Finishes the compression.
|
---|
118 | * This will flush all data and terminate the compression data stream.
|
---|
119 | *
|
---|
120 | * @returns iprt status code.
|
---|
121 | * @param pZip The compressor instance.
|
---|
122 | */
|
---|
123 | RTDECL(int) RTZipCompFinish(PRTZIPCOMP pZip);
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * Destroys the compressor instance.
|
---|
127 | *
|
---|
128 | * @returns iprt status code.
|
---|
129 | * @param pZip The compressor instance.
|
---|
130 | */
|
---|
131 | RTDECL(int) RTZipCompDestroy(PRTZIPCOMP pZip);
|
---|
132 |
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Create a decompressor instance.
|
---|
136 | *
|
---|
137 | * @returns iprt status code.
|
---|
138 | * @param ppZip Where to store the instance handle.
|
---|
139 | * @param pvUser User argument which will be passed on to pfnOut and pfnIn.
|
---|
140 | * @param pfnIn Callback for producing input for decompression.
|
---|
141 | */
|
---|
142 | RTDECL(int) RTZipDecompCreate(PRTZIPDECOMP *ppZip, void *pvUser, PFNRTZIPIN pfnIn);
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * Decompresses a chunk of memory.
|
---|
146 | *
|
---|
147 | * @returns iprt status code.
|
---|
148 | * @param pZip The decompressor instance.
|
---|
149 | * @param pvBuf Where to store the decompressed data.
|
---|
150 | * @param cbBuf Number of bytes to produce. If pcbWritten is set
|
---|
151 | * any number of bytes up to cbBuf might be returned.
|
---|
152 | * @param pcbWritten Number of bytes actually written to the buffer. If NULL
|
---|
153 | * cbBuf number of bytes must be written.
|
---|
154 | */
|
---|
155 | RTDECL(int) RTZipDecompress(PRTZIPDECOMP pZip, void *pvBuf, size_t cbBuf, size_t *pcbWritten);
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * Destroys the decompressor instance.
|
---|
159 | *
|
---|
160 | * @returns iprt status code.
|
---|
161 | * @param pZip The decompressor instance.
|
---|
162 | */
|
---|
163 | RTDECL(int) RTZipDecompDestroy(PRTZIPDECOMP pZip);
|
---|
164 |
|
---|
165 |
|
---|
166 | /** @} */
|
---|
167 |
|
---|
168 | __END_DECLS
|
---|
169 |
|
---|
170 | #endif
|
---|
171 |
|
---|