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