summaryrefslogtreecommitdiff
path: root/Build/source/libs/zziplib/zziplib-src/zzip/lib.h
blob: b09a13028299c41d93e5f5357e68920fa2b91016 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Author: 
 *      Guido Draheim <guidod@gmx.de>
 *      Tomi Ollila <Tomi.Ollila@iki.fi>
 *
 * Copyright (c) Guido Draheim, use under copyleft (LGPL,MPL)
 *
 * This is the private header containing definitions that are not
 * use by a libzzip user application. Writing an extension lib that
 * uses libzzip will still want to include this. The extension
 * write should make way to have the ISO C9X integer types defined.
 */
#ifndef _ZZIP_LIB_H /* zzip.h */
#define _ZZIP_LIB_H

#include <zzip/zzip.h>
#include <zzip/plugin.h>
#include <zzip/stdint.h>
#include <zzip/zzip32.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * this structure cannot be wildly enlarged... (see zzip-zip.c)
 */
struct zzip_dir_hdr
{
    uint32_t    d_usize;        /* uncompressed size */
    uint32_t    d_csize;        /* compressed size */
    uint32_t    d_crc32;        /* the adler32-checksum */
    uint32_t    d_off;          /* offset of file in zipfile */
    uint16_t    d_reclen;       /* next dir_hdr structure offset */
    uint16_t    d_namlen;       /* explicit namelen of d_name */
    uint8_t     d_compr;        /* the compression type, 0 = store, 8 = inflate */
    char        d_name[1];      /* the actual name of the entry, may contain DIRSEPs */
};
#define _ZZIP_DIRENT_HAVE_D_NAMLEN
#define _ZZIP_DIRENT_HAVE_D_OFF
#define _ZZIP_DIRENT_HAVE_D_RECLEN

/*
 * you shall not use this struct anywhere else than in zziplib sources.
 */
struct zzip_dir
{
    int fd;
    int errcode; /* zzip_error_t */
    long refcount;
    struct { /* reduce a lot of alloc/deallocations by caching these: */
	int * volatile locked;
        struct zzip_file * volatile fp;  
        char * volatile buf32k; 
    } cache;
    struct zzip_dir_hdr * hdr0;  /* zfi; */
    struct zzip_dir_hdr * hdr;   /* zdp; directory pointer, for dirent stuff */
    struct zzip_file * currentfp; /* last fp used... */
    struct zzip_dirent dirent;
    void*  realdir;               /* e.g. DIR* from posix dirent.h */
    char*  realname;
    zzip_strings_t* fileext;      /* list of fileext to test for */
    zzip_plugin_io_t io;          /* vtable for io routines */
}; 

#define ZZIP_32K 32768

/* try to open a zip-basename with default_fileext */
int      __zzip_try_open (zzip_char_t* filename, int filemode,
                          zzip_strings_t* ext, zzip_plugin_io_t io);

ZZIP_DIR * 
zzip_dir_fdopen(int fd, zzip_error_t * errcode_p);

ZZIP_DIR* 
zzip_dir_fdopen_ext_io(int fd, zzip_error_t * errorcode_p,
                       zzip_strings_t* ext, const zzip_plugin_io_t io);

ZZIP_DIR* /*deprecated*/
zzip_dir_alloc_ext_io (zzip_strings_t* ext, const zzip_plugin_io_t io);

#ifdef __cplusplus
}
#endif
#endif /* _ZZIP_H */