~ubuntu-branches/ubuntu/wily/opencollada/wily-proposed

« back to all changes in this revision

Viewing changes to Externals/zziplib/include/zzip/zzip.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Author: 
 
3
 *      Guido Draheim <guidod@gmx.de>
 
4
 *      Tomi Ollila <Tomi.Ollila@iki.fi>
 
5
 *
 
6
 *      Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim
 
7
 *          All rights reserved, 
 
8
 *          usage allowed under the restrictions of the
 
9
 *          Lesser GNU General Public License 
 
10
 *          or alternatively the restrictions 
 
11
 *          of the Mozilla Public License 1.1
 
12
 *
 
13
 * if you see "unknown symbol" errors, check first that `-I ..` is part of
 
14
 * your compiler options - a special hint to VC/IDE users who tend to make up
 
15
 * their own workspace files. All includes look like #include <zzip|*.h>, so
 
16
 * you need to add an include path to the dir containing (!!) the ./zzip/ dir
 
17
 */
 
18
 
 
19
#ifndef _ZZIP_ZZIP_H /* zziplib.h */
 
20
#define _ZZIP_ZZIP_H
 
21
 
 
22
#include <zzip/types.h>
 
23
 
 
24
#ifdef __cplusplus
 
25
extern "C" {
 
26
#endif
 
27
 
 
28
/* the zzip_error_t is also used to pass back ZLIB errors... */
 
29
#define ZZIP_ERROR -4096
 
30
 
 
31
typedef enum 
 
32
{
 
33
    ZZIP_NO_ERROR = 0,  /* no error, may be used if user sets it. */
 
34
    ZZIP_OUTOFMEM =      ZZIP_ERROR-20, /* out of memory */
 
35
    ZZIP_DIR_OPEN =      ZZIP_ERROR-21, /* failed to open zipfile, see errno for details */
 
36
    ZZIP_DIR_STAT =      ZZIP_ERROR-22, /* failed to fstat zipfile, see errno for details */
 
37
    ZZIP_DIR_SEEK =      ZZIP_ERROR-23, /* failed to lseek zipfile, see errno for details */
 
38
    ZZIP_DIR_READ =      ZZIP_ERROR-24, /* failed to read zipfile, see errno for details */
 
39
    ZZIP_DIR_TOO_SHORT = ZZIP_ERROR-25,
 
40
    ZZIP_DIR_EDH_MISSING = ZZIP_ERROR-26,
 
41
    ZZIP_DIRSIZE =       ZZIP_ERROR-27,
 
42
    ZZIP_ENOENT =        ZZIP_ERROR-28,
 
43
    ZZIP_UNSUPP_COMPR =  ZZIP_ERROR-29,
 
44
    ZZIP_CORRUPTED =     ZZIP_ERROR-31,
 
45
    ZZIP_UNDEF =         ZZIP_ERROR-32,
 
46
    ZZIP_DIR_LARGEFILE = ZZIP_ERROR-33
 
47
} zzip_error_t;
 
48
 
 
49
/*
 
50
 * zzip_open flags.
 
51
 */
 
52
#define ZZIP_CASEINSENSITIVE    O_APPEND /* do not use anymore. use CASLESS */
 
53
#define ZZIP_IGNOREPATH         O_TRUNC  /* do not use anymore. use NOPATHS */
 
54
#define ZZIP_EXTRAFLAGS         (ZZIP_CASEINSENSITIVE|ZZIP_IGNOREPATH)
 
55
 
 
56
/* zzip_open_ext_io o_modes flags : new style. use these from now on! */
 
57
#define ZZIP_CASELESS           (1<<12) /* ignore filename case inside zips */
 
58
#define ZZIP_NOPATHS            (1<<13) /* ignore subdir paths, just filename*/
 
59
#define ZZIP_PREFERZIP          (1<<14) /* try first zipped file, then real*/
 
60
#define ZZIP_ONLYZIP            (1<<16) /* try _only_ zipped file, skip real*/
 
61
#define ZZIP_FACTORY            (1<<17) /* old file handle is not closed */
 
62
#define ZZIP_ALLOWREAL          (1<<18) /* real files use default_io (magic) */
 
63
#define ZZIP_THREADED           (1<<19) /* try to be safe for multithreading */
 
64
 
 
65
/*
 
66
 * zzip largefile renames
 
67
 */
 
68
#ifdef ZZIP_LARGEFILE_RENAME
 
69
#define zzip_telldir zzip_telldir64
 
70
#define zzip_seekdir zzip_seekdir64
 
71
#endif
 
72
 
 
73
/*
 
74
 * zzip typedefs
 
75
 */
 
76
/* zzip_strings_t ext[] = { ".zip", ".jar", ".pk3", 0 } */
 
77
typedef  char _zzip_const * _zzip_const zzip_strings_t;
 
78
typedef  char _zzip_const       zzip_char_t;
 
79
typedef struct zzip_dir         ZZIP_DIR;
 
80
typedef struct zzip_file        ZZIP_FILE;
 
81
typedef struct zzip_dirent      ZZIP_DIRENT;
 
82
typedef struct zzip_dirent      ZZIP_STAT;
 
83
 
 
84
struct zzip_dirent
 
85
{
 
86
    int         d_compr;        /* compression method */
 
87
    int         d_csize;        /* compressed size */
 
88
    int         st_size;        /* file size / decompressed size */
 
89
    char *      d_name;         /* file name / strdupped name */
 
90
};
 
91
 
 
92
/*
 
93
 * Getting error strings 
 
94
 * zzip/err.c
 
95
 */
 
96
_zzip_export    /* error in _opendir : */
 
97
zzip_char_t*    zzip_strerror(int errcode); 
 
98
_zzip_export    /* error in other functions : */
 
99
zzip_char_t*    zzip_strerror_of(ZZIP_DIR * dir); 
 
100
_zzip_export    /* error mapped to errno.h defines : */
 
101
int             zzip_errno(int errcode); 
 
102
 
 
103
 
 
104
/*
 
105
 * Functions to grab information from ZZIP_DIR/ZZIP_FILE structure 
 
106
 * (if ever needed)
 
107
 * zzip/info.c
 
108
 */
 
109
_zzip_export
 
110
int             zzip_error(ZZIP_DIR * dir);
 
111
_zzip_export
 
112
void            zzip_seterror(ZZIP_DIR * dir, int errcode);
 
113
_zzip_export
 
114
zzip_char_t*    zzip_compr_str(int compr);
 
115
 
 
116
_zzip_export
 
117
ZZIP_DIR *      zzip_dirhandle(ZZIP_FILE * fp);
 
118
_zzip_export
 
119
int             zzip_dirfd(ZZIP_DIR * dir);
 
120
_zzip_export
 
121
int             zzip_dir_real(ZZIP_DIR * dir);
 
122
_zzip_export
 
123
int             zzip_file_real(ZZIP_FILE * fp);
 
124
_zzip_export
 
125
void*           zzip_realdir(ZZIP_DIR * dir);
 
126
_zzip_export
 
127
int             zzip_realfd(ZZIP_FILE * fp);
 
128
 
 
129
/*
 
130
 * zip handle management
 
131
 * zzip/zip.c
 
132
 */
 
133
_zzip_export
 
134
ZZIP_DIR *      zzip_dir_alloc(zzip_strings_t* fileext);
 
135
_zzip_export
 
136
int             zzip_dir_free(ZZIP_DIR *);
 
137
 
 
138
/*
 
139
 * Opening/closing a zip archive
 
140
 * zzip-zip.c
 
141
 */
 
142
_zzip_export
 
143
ZZIP_DIR *      zzip_dir_fdopen(int fd, zzip_error_t * errcode_p);
 
144
_zzip_export
 
145
ZZIP_DIR *      zzip_dir_open(zzip_char_t* filename, zzip_error_t * errcode_p);
 
146
_zzip_export
 
147
int             zzip_dir_close(ZZIP_DIR * dir);
 
148
_zzip_export
 
149
int             zzip_dir_read(ZZIP_DIR * dir, ZZIP_DIRENT * dirent);
 
150
 
 
151
 
 
152
/*
 
153
 * Scanning files in zip archive
 
154
 * zzip/dir.c
 
155
 * zzip/zip.c
 
156
 */
 
157
_zzip_export
 
158
ZZIP_DIR *      zzip_opendir(zzip_char_t* filename);
 
159
_zzip_export
 
160
int             zzip_closedir(ZZIP_DIR * dir);
 
161
_zzip_export
 
162
ZZIP_DIRENT *   zzip_readdir(ZZIP_DIR * dir);
 
163
_zzip_export
 
164
void            zzip_rewinddir(ZZIP_DIR * dir);
 
165
_zzip_export
 
166
zzip_off_t      zzip_telldir(ZZIP_DIR * dir);
 
167
_zzip_export
 
168
void            zzip_seekdir(ZZIP_DIR * dir, zzip_off_t offset);
 
169
 
 
170
/*
 
171
 * 'opening', 'closing' and reading invidual files in zip archive.
 
172
 * zzip/file.c
 
173
 */
 
174
_zzip_export
 
175
ZZIP_FILE *     zzip_file_open(ZZIP_DIR * dir, zzip_char_t* name, int flags);
 
176
_zzip_export
 
177
int             zzip_file_close(ZZIP_FILE * fp);
 
178
_zzip_export
 
179
zzip_ssize_t    zzip_file_read(ZZIP_FILE * fp, void* buf, zzip_size_t len);
 
180
 
 
181
_zzip_export
 
182
ZZIP_FILE *     zzip_open(zzip_char_t* name, int flags);
 
183
_zzip_export
 
184
int             zzip_close(ZZIP_FILE * fp);
 
185
_zzip_export
 
186
zzip_ssize_t    zzip_read(ZZIP_FILE * fp, void * buf, zzip_size_t len);
 
187
 
 
188
/*
 
189
 * the stdc variant to open/read/close files. - Take note of the freopen()
 
190
 * call as it may reuse an existing preparsed copy of a zip central directory
 
191
 */
 
192
_zzip_export
 
193
ZZIP_FILE*      zzip_freopen(zzip_char_t* name, zzip_char_t* mode, ZZIP_FILE*);
 
194
_zzip_export
 
195
ZZIP_FILE*      zzip_fopen(zzip_char_t* name, zzip_char_t* mode);
 
196
_zzip_export
 
197
zzip_size_t     zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, 
 
198
                           ZZIP_FILE * file);
 
199
_zzip_export
 
200
int             zzip_fclose(ZZIP_FILE * fp);
 
201
 
 
202
/*
 
203
 *  seek and tell functions
 
204
 */
 
205
_zzip_export
 
206
int             zzip_rewind(ZZIP_FILE *fp);
 
207
_zzip_export
 
208
zzip_off_t      zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence);
 
209
_zzip_export
 
210
zzip_off_t      zzip_tell(ZZIP_FILE * fp);
 
211
 
 
212
/*
 
213
 * reading info of a single file 
 
214
 * zzip/stat.c
 
215
 */
 
216
_zzip_export
 
217
int             zzip_dir_stat(ZZIP_DIR * dir, zzip_char_t* name, 
 
218
                              ZZIP_STAT * zs, int flags);
 
219
_zzip_export
 
220
int             zzip_file_stat(ZZIP_FILE * fp, ZZIP_STAT * zs);
 
221
_zzip_export
 
222
int             zzip_fstat(ZZIP_FILE * fp, ZZIP_STAT * zs);
 
223
 
 
224
#ifdef ZZIP_LARGEFILE_RENAME
 
225
#define zzip_open_shared_io  zzip_open_shared_io64
 
226
#define zzip_open_ext_io     zzip_open_ext_io64
 
227
#define zzip_opendir_ext_io  zzip_opendir_ext_io64
 
228
#define zzip_dir_open_ext_io zzip_dir_open_ext_io64
 
229
#define zzip_plugin_io_t     zzip_plugin_io64_t
 
230
#endif
 
231
 
 
232
/*
 
233
 * all ext_io functions can be called with a default of ext/io == zero/zero
 
234
 * which will default to a ".zip" extension and posix io of the system.
 
235
 */
 
236
typedef union _zzip_plugin_io _zzip_const * zzip_plugin_io_t;
 
237
 
 
238
_zzip_export
 
239
ZZIP_FILE * zzip_open_shared_io(ZZIP_FILE* stream,
 
240
                                zzip_char_t* name, int o_flags, int o_modes,
 
241
                                zzip_strings_t* ext, zzip_plugin_io_t io);
 
242
 
 
243
_zzip_export
 
244
ZZIP_FILE * zzip_open_ext_io(zzip_char_t* name, int o_flags, int o_modes,
 
245
                             zzip_strings_t* ext, zzip_plugin_io_t io);
 
246
 
 
247
_zzip_export
 
248
ZZIP_DIR *  zzip_opendir_ext_io(zzip_char_t* name, int o_modes,
 
249
                                zzip_strings_t* ext, zzip_plugin_io_t io);
 
250
 
 
251
_zzip_export
 
252
ZZIP_DIR *  zzip_dir_open_ext_io(zzip_char_t* filename,
 
253
                                 zzip_error_t* errcode_p,
 
254
                                 zzip_strings_t* ext, zzip_plugin_io_t io);
 
255
 
 
256
/* zzip_file_open_ext_io => zzip_dir_open_ext_io + zzip_file_open */
 
257
 
 
258
#ifdef __cplusplus
 
259
};
 
260
#endif
 
261
 
 
262
#endif /* _ZZIPLIB_H */
 
263
 
 
264
/* 
 
265
 * Local variables:
 
266
 * c-file-style: "stroustrup"
 
267
 * End:
 
268
 */