VirtualBox

source: vbox/trunk/include/iprt/zip.h@ 3630

Last change on this file since 3630 was 3630, checked in by vboxsync, 17 years ago

iprt_hdr_h -> _iprt_hdr_h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
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 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef ___iprt_zip_h
22#define ___iprt_zip_h
23
24#include <iprt/cdefs.h>
25#include <iprt/types.h>
26
27
28__BEGIN_DECLS
29
30/** @defgroup grp_rt_zip RTZip - Compression
31 * @ingroup grp_rt
32 * @{
33 */
34
35
36
37/**
38 * Callback function for consuming compressed data during compression.
39 *
40 * @returns iprt status code.
41 * @param pvUser User argument.
42 * @param pvBuf Compressed data.
43 * @param cbBuf Size of the compressed data.
44 */
45typedef DECLCALLBACK(int) FNRTZIPOUT(void *pvUser, const void *pvBuf, size_t cbBuf);
46/** Pointer to FNRTZIPOUT() function. */
47typedef FNRTZIPOUT *PFNRTZIPOUT;
48
49/**
50 * Callback function for supplying compressed data during decompression.
51 *
52 * @returns iprt status code.
53 * @param pvUser User argument.
54 * @param pvBuf Where to store the compressed data.
55 * @param cbBuf Size of the buffer.
56 * @param pcbBuf Number of bytes actually stored in the buffer.
57 */
58typedef DECLCALLBACK(int) FNRTZIPIN(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbBuf);
59/** Pointer to FNRTZIPIN() function. */
60typedef FNRTZIPIN *PFNRTZIPIN;
61
62/**
63 * Compression type.
64 * (Be careful with these they are stored in files!)
65 */
66typedef enum RTZIPTYPE
67{
68 /** Invalid. */
69 RTZIPTYPE_INVALID = 0,
70 /** Choose best fitting one. */
71 RTZIPTYPE_AUTO,
72 /** Store the data. */
73 RTZIPTYPE_STORE,
74 /** Zlib compression the data. */
75 RTZIPTYPE_ZLIB,
76 /** BZlib compress. */
77 RTZIPTYPE_BZLIB,
78 /** libLZF compress. */
79 RTZIPTYPE_LZF
80} RTZIPTYPE;
81
82/**
83 * Compression level.
84 */
85typedef enum RTZIPLEVEL
86{
87 /** Store, don't compress. */
88 RTZIPLEVEL_STORE = 0,
89 /** Fast compression. */
90 RTZIPLEVEL_FAST,
91 /** Default compression. */
92 RTZIPLEVEL_DEFAULT,
93 /** Maximal compression. */
94 RTZIPLEVEL_MAX
95} RTZIPLEVEL;
96
97
98/**
99 * Create a compressor instance.
100 *
101 * @returns iprt status code.
102 * @param ppZip Where to store the instance handle.
103 * @param pvUser User argument which will be passed on to pfnOut and pfnIn.
104 * @param pfnOut Callback for consuming output of compression.
105 * @param enmType Type of compressor to create.
106 * @param enmLevel Compression level.
107 */
108RTDECL(int) RTZipCompCreate(PRTZIPCOMP *ppZip, void *pvUser, PFNRTZIPOUT pfnOut, RTZIPTYPE enmType, RTZIPLEVEL enmLevel);
109
110/**
111 * Compresses a chunk of memory.
112 *
113 * @returns iprt status code.
114 * @param pZip The compressor instance.
115 * @param pvBuf Pointer to buffer containing the bits to compress.
116 * @param cbBuf Number of bytes to compress.
117 */
118RTDECL(int) RTZipCompress(PRTZIPCOMP pZip, const void *pvBuf, size_t cbBuf);
119
120/**
121 * Finishes the compression.
122 * This will flush all data and terminate the compression data stream.
123 *
124 * @returns iprt status code.
125 * @param pZip The compressor instance.
126 */
127RTDECL(int) RTZipCompFinish(PRTZIPCOMP pZip);
128
129/**
130 * Destroys the compressor instance.
131 *
132 * @returns iprt status code.
133 * @param pZip The compressor instance.
134 */
135RTDECL(int) RTZipCompDestroy(PRTZIPCOMP pZip);
136
137
138/**
139 * Create a decompressor instance.
140 *
141 * @returns iprt status code.
142 * @param ppZip Where to store the instance handle.
143 * @param pvUser User argument which will be passed on to pfnOut and pfnIn.
144 * @param pfnIn Callback for producing input for decompression.
145 */
146RTDECL(int) RTZipDecompCreate(PRTZIPDECOMP *ppZip, void *pvUser, PFNRTZIPIN pfnIn);
147
148/**
149 * Decompresses a chunk of memory.
150 *
151 * @returns iprt status code.
152 * @param pZip The decompressor instance.
153 * @param pvBuf Where to store the decompressed data.
154 * @param cbBuf Number of bytes to produce. If pcbWritten is set
155 * any number of bytes up to cbBuf might be returned.
156 * @param pcbWritten Number of bytes actually written to the buffer. If NULL
157 * cbBuf number of bytes must be written.
158 */
159RTDECL(int) RTZipDecompress(PRTZIPDECOMP pZip, void *pvBuf, size_t cbBuf, size_t *pcbWritten);
160
161/**
162 * Destroys the decompressor instance.
163 *
164 * @returns iprt status code.
165 * @param pZip The decompressor instance.
166 */
167RTDECL(int) RTZipDecompDestroy(PRTZIPDECOMP pZip);
168
169
170/** @} */
171
172__END_DECLS
173
174#endif
175
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette