summaryrefslogtreecommitdiff
path: root/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.h
blob: 96faa011a4af02114a2c20e8ca927501cbcf1592 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef _ZZIP_FSEEKO_H_
#define _ZZIP_FSEEKO_H_
/*
 * NOTE: this is part of libzzipfseeko (i.e. it is not libzzip). 
 *
 * simplified zip disk access using fseeko on a stdio FILE handle
 *
 * Author: 
 *      Guido Draheim <guidod@gmx.de>
 *
 * Copyright (c) Guido Draheim, use under copyleft (LGPL,MPL)
 */


#include <zzip/types.h>
#include <stdio.h>

#ifdef _ZZIP_ENTRY_STRUCT
#include <zlib.h>
#include <zzip/format.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct zzip_entry ZZIP_ENTRY;
typedef struct zzip_entry_file ZZIP_ENTRY_FILE;

typedef int (*zzip_strcmp_fn_t)(char*, char*);
typedef int (*zzip_fnmatch_fn_t)(char*, char*, int);

#ifndef zzip_entry_extern
#define zzip_entry_extern extern
#endif

zzip_entry_extern zzip_off_t
zzip_entry_data_offset(ZZIP_ENTRY* entry);

zzip__new__
zzip_entry_extern ZZIP_ENTRY*
zzip_entry_findfirst(FILE* file);

zzip__new__
zzip_entry_extern ZZIP_ENTRY*
zzip_entry_findnext(ZZIP_ENTRY* _zzip_restrict entry);

#define zzip_entry_findlast      zzip_entry_free
#define zzip_entry_findlastfile  zzip_entry_free
#define zzip_entry_findlastmatch zzip_entry_free

zzip_entry_extern int
zzip_entry_free(ZZIP_ENTRY* entry);

zzip__new__
zzip_entry_extern char*
zzip_entry_strdup_name(ZZIP_ENTRY* entry);
zzip_entry_extern char*
zzip_entry_to_data(ZZIP_ENTRY* entry);

zzip__new__
zzip_entry_extern ZZIP_ENTRY*
zzip_entry_findfile(FILE* disk, char* filename, 
		    ZZIP_ENTRY* _zzip_restrict old,
		   zzip_strcmp_fn_t compare);
zzip__new__
zzip_entry_extern ZZIP_ENTRY*
zzip_entry_findmatch(FILE* disk, char* filespec, 
		     ZZIP_ENTRY* _zzip_restrict old,
		    zzip_fnmatch_fn_t compare, int flags);
zzip__new__
zzip_entry_extern ZZIP_ENTRY_FILE*
zzip_entry_fopen (ZZIP_ENTRY* entry, int takeover);

zzip__new__
zzip_entry_extern ZZIP_ENTRY_FILE*
zzip_entry_ffile (FILE* disk, char* filename);

zzip_entry_extern _zzip_size_t
zzip_entry_fread (void* ptr, _zzip_size_t size, _zzip_size_t nmemb,
		 ZZIP_ENTRY_FILE* file);
zzip_entry_extern int
zzip_entry_fclose (ZZIP_ENTRY_FILE* file);
int
zzip_entry_feof (ZZIP_ENTRY_FILE* file);

# ifdef _ZZIP_ENTRY_STRUCT
#  ifdef __cplusplus
#  define __zzip_entry_extends_zzip_disk_entry
struct zzip_entry : public struct zzip_disk_entry
{
    char*             _zzip_restrict tail;
    zzip_off_t                  tailalloc;   /* the allocated size of tail */
    FILE*                        diskfile;   /* a file reference */
    zzip_off_t                   disksize;   /* the size of the file */
    zzip_off_t                   headseek;   /* the offset within the file */
    zzip_off_t                   zz_usize;
    zzip_off_t                   zz_csize;   /* items scanned from header */
    zzip_off_t                   zz_offset;  /* or zip64 extension block */
    int                          zz_diskstart;
};
# define zzip_entry_d(_p) (_p)
#  else
struct zzip_entry /* : struct zzip_disk_entry */
{
    struct zzip_disk_entry           head;
    char*             _zzip_restrict tail;
    zzip_off_t                  tailalloc;   /* the allocated size of tail */
    FILE*                        diskfile;   /* a file reference */
    zzip_off_t                   disksize;   /* the size of the file */
    zzip_off_t                   headseek;   /* the offset within the file */
    zzip_off_t                   zz_usize;
    zzip_off_t                   zz_csize;   /* items scanned from header */
    zzip_off_t                   zz_offset;  /* or zip64 extension block */
    int                          zz_diskstart;
};
# define zzip_entry_d(_p) (&(_p)->head)
#  endif /* __cplusplus */
# endif /* _ZZIP_MEM_ENTRY_PRIVATE */

#ifdef _ZZIP_ENTRY_STRUCT
/* zzip_entry is-a zip_disk_entry => fetch.h */
#define zzip_entry_csize(__p)   ((zzip_size_t) \
        zzip_disk_entry_get_csize(zzip_entry_d(__p)))
#define zzip_entry_usize(__p)   ((zzip_size_t) \
        zzip_disk_entry_get_usize(zzip_entry_d(__p))) 
#define zzip_entry_compr(__p) ( \
        zzip_disk_entry_get_compr(zzip_entry_d(__p)))
#define zzip_entry_flags(__p) ( \
        zzip_disk_entry_get_flags(zzip_entry_d(__p)))
#define zzip_entry_namlen(__p)   ((zzip_size_t) \
        zzip_disk_entry_get_namlen(zzip_entry_d(__p)))
#define zzip_entry_extras(__p)   ((zzip_size_t) \
        zzip_disk_entry_get_extras(zzip_entry_d(__p)))
#define zzip_entry_comment(__p)   ((zzip_size_t) \
        zzip_disk_entry_get_comment(zzip_entry_d(__p)))
#define zzip_entry_diskstart(__p) ((int) \
        zzip_disk_entry_get_diskstart(zzip_entry_d(__p)))
#define zzip_entry_filetype(__p) ((int) \
        zzip_disk_entry_get_filetype(zzip_entry_d(__p)))
#define zzip_entry_filemode(__p) ((int) \
        zzip_disk_entry_get_filemode(zzip_entry_d(__p)))
#define zzip_entry_fileoffset(__p) ((zzip_off_t) \
        zzip_disk_entry_get_offset(zzip_entry_d(__p)))
#define zzip_entry_sizeof_tail(__p) ((zzip_size_t) \
        zzip_disk_entry_sizeof_tails(zzip_entry_d(__p)))
#endif

#ifdef __cplusplus
extern "C" {
}
#endif
#endif