VirtualBox

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

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

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 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 (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 */
50typedef DECLCALLBACK(int) FNRTZIPOUT(void *pvUser, const void *pvBuf, size_t cbBuf);
51/** Pointer to FNRTZIPOUT() function. */
52typedef 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 */
63typedef DECLCALLBACK(int) FNRTZIPIN(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbBuf);
64/** Pointer to FNRTZIPIN() function. */
65typedef FNRTZIPIN *PFNRTZIPIN;
66
67/**
68 * Compression type.
69 * (Be careful with these they are stored in files!)
70 */
71typedef 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 */
90typedef 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 */
113RTDECL(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 */
123RTDECL(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 */
132RTDECL(int) RTZipCompFinish(PRTZIPCOMP pZip);
133
134/**
135 * Destroys the compressor instance.
136 *
137 * @returns iprt status code.
138 * @param pZip The compressor instance.
139 */
140RTDECL(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 */
151RTDECL(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 */
164RTDECL(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 */
172RTDECL(int) RTZipDecompDestroy(PRTZIPDECOMP pZip);
173
174
175/** @} */
176
177__END_DECLS
178
179#endif
180
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