libopc
zip.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, Florian Reuter
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions
7  are met:
8 
9  * Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15  * Neither the name of Florian Reuter nor the names of its contributors
16  may be used to endorse or promote products derived from this
17  software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30  OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
36 #include <opc/config.h>
37 #include <opc/file.h>
38 #include <opc/container.h>
39 
40 #ifndef OPC_ZIP_H
41 #define OPC_ZIP_H
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
50  #define OPC_DEFAULT_GROWTH_HINT 512
51 
56  typedef struct OPC_ZIP_STRUCT opcZip;
57 
63 
69 
73  typedef struct OPC_ZIP_SEGMENT_INFO_STRUCT {
74  xmlChar name[OPC_MAX_PATH];
75  opc_uint32_t name_len;
76  opc_uint32_t segment_number;
77  opc_bool_t last_segment;
78  opc_bool_t rels_segment;
79  opc_uint32_t header_size;
80  opc_uint32_t min_header_size;
81  opc_uint32_t trailing_bytes;
82  opc_uint32_t compressed_size;
83  opc_uint32_t uncompressed_size;
84  opc_uint16_t bit_flag;
85  opc_uint32_t data_crc;
86  opc_uint16_t compression_method;
87  opc_ofs_t stream_ofs;
88  opc_uint16_t growth_hint;
90 
94  typedef int opcZipLoaderOpenCallback(void *iocontext);
98  typedef int opcZipLoaderSkipCallback(void *iocontext);
102  typedef int opcZipLoaderReadCallback(void *iocontext, char *buffer, int len);
106  typedef int opcZipLoaderCloseCallback(void *iocontext);
107 
112 
119  opc_error_t opcZipLoader(opcIO_t *io, void *userctx, opcZipLoaderSegmentCallback_t *segmentCallback);
120 
125 
130  void opcZipClose(opcZip *zip, opcZipSegmentReleaseCallback* releaseCallback);
131 
136 
142 
147 
154  opc_uint32_t opcZipLoadSegment(opcZip *zip, const xmlChar *partName, opc_bool_t rels_segment, opcZipSegmentInfo_t *info);
155 
161  const xmlChar *partName,
162  opc_bool_t relsSegment,
163  opc_uint32_t segment_size,
164  opc_uint32_t growth_hint,
165  opc_uint16_t compression_method,
166  opc_uint16_t bit_flag);
167 
174 
179 
185 
186 
193  opc_uint32_t *segment_id,
194  const xmlChar *partName,
195  opc_bool_t relsSegment,
196  opc_uint32_t segment_size,
197  opc_uint32_t growth_hint,
198  opc_uint16_t compression_method,
199  opc_uint16_t bit_flag);
200 
207 
213 
219 
233 
239 
243  opc_error_t opcZipGetSegmentInfo(opcZip *zip, opc_uint32_t segment_id, const xmlChar **name, opc_bool_t *rels_segment, opc_uint32_t *crc);
244 
249  opc_bool_t opcZipSegmentDelete(opcZip *zip, opc_uint32_t *first_segment, opc_uint32_t *last_segment, opcZipSegmentReleaseCallback* releaseCallback);
250 
251 #ifdef __cplusplus
252 } /* extern "C" */
253 #endif
254 
255 #endif /* OPC_ZIP_H */
opc_uint32_t opcZipGetFirstSegmentId(opcZip *zip)
Definition: zip.c:1450
opc_bool_t opcZipSegmentDelete(opcZip *zip, opc_uint32_t *first_segment, opc_uint32_t *last_segment, opcZipSegmentReleaseCallback *releaseCallback)
Definition: zip.c:1482
opc_uint32_t opcZipReadInputStream(opcZip *zip, opcZipInputStream *stream, opc_uint8_t *buf, opc_uint32_t buf_len)
Definition: zip.c:962
opc_uint32_t opcZipCreateSegment(opcZip *zip, const xmlChar *partName, opc_bool_t relsSegment, opc_uint32_t segment_size, opc_uint32_t growth_hint, opc_uint16_t compression_method, opc_uint16_t bit_flag)
Definition: zip.c:1024
opc_uint32_t opcZipGetNextSegmentId(opcZip *zip, opc_uint32_t segment_id)
Definition: zip.c:1456
puint16_t opc_uint16_t
Definition: config.h:97
Definition: zip.h:73
puint8_t opc_uint8_t
Definition: config.h:91
pbool_t opc_bool_t
Definition: config.h:79
Definition: internal.h:90
Definition: internal.h:76
#define OPC_MAX_PATH
Definition: config.h:143
opcZipOutputStream * opcZipCreateOutputStream(opcZip *zip, opc_uint32_t *segment_id, const xmlChar *partName, opc_bool_t relsSegment, opc_uint32_t segment_size, opc_uint32_t growth_hint, opc_uint16_t compression_method, opc_uint16_t bit_flag)
Definition: zip.c:1257
opc_error_t( opcZipSegmentReleaseCallback)(opcZip *zip, opc_uint32_t segment_id)
Definition: zip.h:124
opc_error_t opcZipGC(opcZip *zip)
Definition: zip.c:1049
struct OPC_ZIP_SEGMENT_INFO_STRUCT opcZipSegmentInfo_t
puint32_t opc_uint32_t
Definition: config.h:103
int opcZipLoaderOpenCallback(void *iocontext)
Definition: zip.h:94
Definition: internal.h:102
opc_error_t opcZipCloseInputStream(opcZip *zip, opcZipInputStream *stream)
Definition: zip.c:950
opc_error_t opcZipLoader(opcIO_t *io, void *userctx, opcZipLoaderSegmentCallback_t *segmentCallback)
Definition: zip.c:879
opc_error_t opcZipCommit(opcZip *zip, opc_bool_t trim)
Definition: zip.c:1202
enum OPC_ERROR_ENUM opc_error_t
opc_error_t opcZipGetSegmentInfo(opcZip *zip, opc_uint32_t segment_id, const xmlChar **name, opc_bool_t *rels_segment, opc_uint32_t *crc)
Definition: zip.c:1467
pofs_t opc_ofs_t
Definition: config.h:85
opc_error_t( opcZipLoaderSegmentCallback_t)(void *iocontext, void *userctx, opcZipSegmentInfo_t *info, opcZipLoaderOpenCallback *open, opcZipLoaderReadCallback *read, opcZipLoaderCloseCallback *close, opcZipLoaderSkipCallback *skip)
Definition: zip.h:111
opcZip * opcZipCreate(opcIO_t *io)
Definition: zip.c:158
int opcZipLoaderCloseCallback(void *iocontext)
Definition: zip.h:106
int opcZipLoaderSkipCallback(void *iocontext)
Definition: zip.h:98
opc_uint32_t opcZipWriteOutputStream(opcZip *zip, opcZipOutputStream *stream, const opc_uint8_t *buf, opc_uint32_t buf_len)
Definition: zip.c:1440
void opcZipClose(opcZip *zip, opcZipSegmentReleaseCallback *releaseCallback)
Definition: zip.c:169
opc_error_t opcZipCloseOutputStream(opcZip *zip, opcZipOutputStream *stream, opc_uint32_t *segment_id)
Definition: zip.c:1426
Definition: file.h:153
int opcZipLoaderReadCallback(void *iocontext, char *buffer, int len)
Definition: zip.h:102
opcZipOutputStream * opcZipOpenOutputStream(opcZip *zip, opc_uint32_t *segment_id)
Definition: zip.c:1214
opc_uint32_t opcZipLoadSegment(opcZip *zip, const xmlChar *partName, opc_bool_t rels_segment, opcZipSegmentInfo_t *info)
Definition: zip.c:1007
opcZipInputStream * opcZipOpenInputStream(opcZip *zip, opc_uint32_t segment_id)
Definition: zip.c:930