altEngine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
junzip.h
Go to the documentation of this file.
1
6
#ifndef __JUNZIP_H
7
#define __JUNZIP_H
8
9
#define Z_ERRNO 1
10
#define Z_OK 0
11
12
13
#ifdef __cplusplus
14
extern
"C"
{
15
#endif
/* __cplusplus */
16
17
#include "
deflate_tinfl.h
"
18
#include <stdint.h>
19
20
typedef
struct
21
{
22
char
*
file
;
23
unsigned
char
*
data
;
24
int
size
;
25
}
userdata_t
;
26
27
// If you don't have stdint.h, the following two lines should work for most 32/64 bit systems
28
// typedef unsigned int uint32_t;
29
// typedef unsigned short uint16_t;
30
31
typedef
struct
JZFile
JZFile
;
32
33
struct
JZFile
{
34
size_t(*
read
)(
JZFile
*file,
void
*buf,
size_t
size);
35
size_t(*
tell
)(
JZFile
*file);
36
int(*
seek
)(
JZFile
*file,
size_t
offset,
int
whence);
37
int(*
error
)(
JZFile
*file);
38
void(*
close
)(
JZFile
*file);
39
};
40
41
JZFile
*
42
jzfile_from_stdio_file
(FILE *fp);
43
#pragma pack(push)
44
#pragma pack(1)
45
typedef
struct
{
46
uint32_t
signature
;
47
uint16_t
versionNeededToExtract
;
// unsupported
48
uint16_t
generalPurposeBitFlag
;
// unsupported
49
uint16_t
compressionMethod
;
50
uint16_t
lastModFileTime
;
51
uint16_t
lastModFileDate
;
52
uint32_t
crc32
;
53
uint32_t
compressedSize
;
54
uint32_t
uncompressedSize
;
55
uint16_t
fileNameLength
;
56
uint16_t
extraFieldLength
;
// unsupported
57
}
JZLocalFileHeader
;
58
59
typedef
struct
{
60
uint32_t
signature
;
61
uint16_t
versionMadeBy
;
// unsupported
62
uint16_t
versionNeededToExtract
;
// unsupported
63
uint16_t
generalPurposeBitFlag
;
// unsupported
64
uint16_t
compressionMethod
;
65
uint16_t
lastModFileTime
;
66
uint16_t
lastModFileDate
;
67
uint32_t
crc32
;
68
uint32_t
compressedSize
;
69
uint32_t
uncompressedSize
;
70
uint16_t
fileNameLength
;
71
uint16_t
extraFieldLength
;
// unsupported
72
uint16_t
fileCommentLength
;
// unsupported
73
uint16_t
diskNumberStart
;
// unsupported
74
uint16_t
internalFileAttributes
;
// unsupported
75
uint32_t
externalFileAttributes
;
// unsupported
76
uint32_t
relativeOffsetOflocalHeader
;
77
}
JZGlobalFileHeader
;
78
79
typedef
struct
{
80
uint16_t
compressionMethod
;
81
uint16_t
lastModFileTime
;
82
uint16_t
lastModFileDate
;
83
uint32_t
crc32
;
84
uint32_t
compressedSize
;
85
uint32_t
uncompressedSize
;
86
uint32_t
offset
;
87
}
JZFileHeader
;
88
89
typedef
struct
{
90
uint32_t
signature
;
// 0x06054b50
91
uint16_t
diskNumber
;
// unsupported
92
uint16_t
centralDirectoryDiskNumber
;
// unsupported
93
uint16_t
numEntriesThisDisk
;
// unsupported
94
uint16_t
numEntries
;
95
uint32_t
centralDirectorySize
;
96
uint32_t
centralDirectoryOffset
;
97
uint16_t
zipCommentLength
;
98
// Followed by .ZIP file comment (variable size)
99
}
JZEndRecord
;
100
#pragma pack(pop)
101
102
// Callback prototype for central and local file record reading functions
103
typedef
int(*
JZRecordCallback
)(
JZFile
*zip,
int
index,
JZFileHeader
*header,
104
char
*filename,
void
*user_data);
105
106
#define JZ_BUFFER_SIZE 65536
107
108
// Read ZIP file end record. Will move within file.
109
int
jzReadEndRecord
(
JZFile
*zip,
JZEndRecord
*endRecord);
110
111
// Read ZIP file global directory. Will move within file.
112
// Callback is called for each record, until callback returns zero
113
int
jzReadCentralDirectory
(
JZFile
*zip,
JZEndRecord
*endRecord,
114
JZRecordCallback
callback,
void
*user_data);
115
116
// Read local ZIP file header. Silent on errors so optimistic reading possible.
117
int
jzReadLocalFileHeader
(
JZFile
*zip,
JZFileHeader
*header,
118
char
*filename,
int
len);
119
120
// Read data from file stream, described by header, to preallocated buffer
121
// Return value is zlib coded, e.g. Z_OK, or error code
122
int
jzReadData
(
JZFile
*zip,
JZFileHeader
*header,
void
*buffer);
123
124
#ifdef __cplusplus
125
};
126
#endif
/* __cplusplus */
127
128
#endif
Generated on Tue Nov 21 2017 19:18:54 for altEngine by
1.8.2