cordova-plugin-mserviceinterface-2.0 1.0.21 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +28 -28
- package/plugin.xml +153 -153
- package/src/android/CallbackProgressDialog.java +53 -53
- package/src/android/FileProvider.java +7 -7
- package/src/android/backgroundNotification.java +120 -120
- package/src/android/doubleogradle.gradle +5 -5
- package/src/android/mInterface.java +2087 -2066
- package/src/android/mInterfaceReceiver.java +59 -59
- package/src/android/mInterfaceService.java +749 -749
- package/src/android/mInterfaceUtil.java +1686 -1688
- package/src/android/res/xml/network_security_config.xml +8 -8
- package/src/android/res/xml/opener_paths.xml +16 -16
- package/src/ios/InternetConnection.h +64 -64
- package/src/ios/InternetConnection.m +242 -242
- package/src/ios/SSZipArchive.h +146 -146
- package/src/ios/SSZipArchive.m +1180 -1180
- package/src/ios/SSZipCommon.h +66 -66
- package/src/ios/UICKeyChainStore.h +64 -64
- package/src/ios/UICKeyChainStore.m +434 -434
- package/src/ios/XMLConverter.h +61 -61
- package/src/ios/XMLConverter.m +243 -243
- package/src/ios/ZipArchive.h +19 -19
- package/src/ios/aes/aes.h +270 -270
- package/src/ios/aes/aes_ni.c +687 -687
- package/src/ios/aes/aes_ni.h +59 -59
- package/src/ios/aes/aescrypt.c +301 -301
- package/src/ios/aes/aeskey.c +554 -554
- package/src/ios/aes/aesopt.h +776 -776
- package/src/ios/aes/aestab.c +418 -418
- package/src/ios/aes/aestab.h +173 -173
- package/src/ios/aes/brg_endian.h +127 -127
- package/src/ios/aes/brg_types.h +191 -191
- package/src/ios/aes/fileenc.c +145 -145
- package/src/ios/aes/fileenc.h +121 -121
- package/src/ios/aes/hmac.c +209 -209
- package/src/ios/aes/hmac.h +119 -119
- package/src/ios/aes/prng.c +155 -155
- package/src/ios/aes/prng.h +82 -82
- package/src/ios/aes/pwd2key.c +181 -181
- package/src/ios/aes/pwd2key.h +45 -45
- package/src/ios/aes/sha1.c +283 -283
- package/src/ios/aes/sha1.h +72 -72
- package/src/ios/mInterface.h +2 -0
- package/src/ios/mInterface.m +18 -1
- package/src/ios/minizip/crypt.c +146 -146
- package/src/ios/minizip/crypt.h +66 -66
- package/src/ios/minizip/ioapi.c +353 -353
- package/src/ios/minizip/ioapi.h +154 -154
- package/src/ios/minizip/ioapi_buf.c +452 -452
- package/src/ios/minizip/ioapi_buf.h +52 -52
- package/src/ios/minizip/ioapi_mem.c +167 -167
- package/src/ios/minizip/ioapi_mem.h +52 -52
- package/src/ios/minizip/minishared.c +292 -292
- package/src/ios/minizip/minishared.h +50 -50
- package/src/ios/minizip/unzip.c +2007 -2007
- package/src/ios/minizip/unzip.h +254 -254
- package/src/ios/minizip/zip.c +2007 -2007
- package/src/ios/minizip/zip.h +215 -215
- package/www/mInterface.js +3 -3
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
/* ioapi_buf.h -- IO base function header for compress/uncompress .zip
|
|
2
|
-
files using zlib + zip or unzip API
|
|
3
|
-
|
|
4
|
-
This version of ioapi is designed to buffer IO.
|
|
5
|
-
|
|
6
|
-
Copyright (C) 2012-2017 Nathan Moinvaziri
|
|
7
|
-
https://github.com/nmoinvaz/minizip
|
|
8
|
-
|
|
9
|
-
This program is distributed under the terms of the same license as zlib.
|
|
10
|
-
See the accompanying LICENSE file for the full text of the license.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
#ifndef _IOAPI_BUF_H
|
|
14
|
-
#define _IOAPI_BUF_H
|
|
15
|
-
|
|
16
|
-
#include <stdio.h>
|
|
17
|
-
#include <stdlib.h>
|
|
18
|
-
#include <string.h>
|
|
19
|
-
|
|
20
|
-
#include "zlib.h"
|
|
21
|
-
#include "ioapi.h"
|
|
22
|
-
|
|
23
|
-
#ifdef __cplusplus
|
|
24
|
-
extern "C" {
|
|
25
|
-
#endif
|
|
26
|
-
|
|
27
|
-
voidpf ZCALLBACK fopen_buf_func(voidpf opaque, const char* filename, int mode);
|
|
28
|
-
voidpf ZCALLBACK fopen64_buf_func(voidpf opaque, const void* filename, int mode);
|
|
29
|
-
voidpf ZCALLBACK fopendisk_buf_func(voidpf opaque, voidpf stream_cd, uint32_t number_disk, int mode);
|
|
30
|
-
voidpf ZCALLBACK fopendisk64_buf_func(voidpf opaque, voidpf stream_cd, uint32_t number_disk, int mode);
|
|
31
|
-
uint32_t ZCALLBACK fread_buf_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
|
|
32
|
-
uint32_t ZCALLBACK fwrite_buf_func(voidpf opaque, voidpf stream, const void* buf, uint32_t size);
|
|
33
|
-
long ZCALLBACK ftell_buf_func(voidpf opaque, voidpf stream);
|
|
34
|
-
uint64_t ZCALLBACK ftell64_buf_func(voidpf opaque, voidpf stream);
|
|
35
|
-
long ZCALLBACK fseek_buf_func(voidpf opaque, voidpf stream, uint32_t offset, int origin);
|
|
36
|
-
long ZCALLBACK fseek64_buf_func(voidpf opaque, voidpf stream, uint64_t offset, int origin);
|
|
37
|
-
int ZCALLBACK fclose_buf_func(voidpf opaque,voidpf stream);
|
|
38
|
-
int ZCALLBACK ferror_buf_func(voidpf opaque,voidpf stream);
|
|
39
|
-
|
|
40
|
-
typedef struct ourbuffer_s {
|
|
41
|
-
zlib_filefunc_def filefunc;
|
|
42
|
-
zlib_filefunc64_def filefunc64;
|
|
43
|
-
} ourbuffer_t;
|
|
44
|
-
|
|
45
|
-
void fill_buffer_filefunc(zlib_filefunc_def* pzlib_filefunc_def, ourbuffer_t *ourbuf);
|
|
46
|
-
void fill_buffer_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def, ourbuffer_t *ourbuf);
|
|
47
|
-
|
|
48
|
-
#ifdef __cplusplus
|
|
49
|
-
}
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
#endif
|
|
1
|
+
/* ioapi_buf.h -- IO base function header for compress/uncompress .zip
|
|
2
|
+
files using zlib + zip or unzip API
|
|
3
|
+
|
|
4
|
+
This version of ioapi is designed to buffer IO.
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2012-2017 Nathan Moinvaziri
|
|
7
|
+
https://github.com/nmoinvaz/minizip
|
|
8
|
+
|
|
9
|
+
This program is distributed under the terms of the same license as zlib.
|
|
10
|
+
See the accompanying LICENSE file for the full text of the license.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#ifndef _IOAPI_BUF_H
|
|
14
|
+
#define _IOAPI_BUF_H
|
|
15
|
+
|
|
16
|
+
#include <stdio.h>
|
|
17
|
+
#include <stdlib.h>
|
|
18
|
+
#include <string.h>
|
|
19
|
+
|
|
20
|
+
#include "zlib.h"
|
|
21
|
+
#include "ioapi.h"
|
|
22
|
+
|
|
23
|
+
#ifdef __cplusplus
|
|
24
|
+
extern "C" {
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
voidpf ZCALLBACK fopen_buf_func(voidpf opaque, const char* filename, int mode);
|
|
28
|
+
voidpf ZCALLBACK fopen64_buf_func(voidpf opaque, const void* filename, int mode);
|
|
29
|
+
voidpf ZCALLBACK fopendisk_buf_func(voidpf opaque, voidpf stream_cd, uint32_t number_disk, int mode);
|
|
30
|
+
voidpf ZCALLBACK fopendisk64_buf_func(voidpf opaque, voidpf stream_cd, uint32_t number_disk, int mode);
|
|
31
|
+
uint32_t ZCALLBACK fread_buf_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
|
|
32
|
+
uint32_t ZCALLBACK fwrite_buf_func(voidpf opaque, voidpf stream, const void* buf, uint32_t size);
|
|
33
|
+
long ZCALLBACK ftell_buf_func(voidpf opaque, voidpf stream);
|
|
34
|
+
uint64_t ZCALLBACK ftell64_buf_func(voidpf opaque, voidpf stream);
|
|
35
|
+
long ZCALLBACK fseek_buf_func(voidpf opaque, voidpf stream, uint32_t offset, int origin);
|
|
36
|
+
long ZCALLBACK fseek64_buf_func(voidpf opaque, voidpf stream, uint64_t offset, int origin);
|
|
37
|
+
int ZCALLBACK fclose_buf_func(voidpf opaque,voidpf stream);
|
|
38
|
+
int ZCALLBACK ferror_buf_func(voidpf opaque,voidpf stream);
|
|
39
|
+
|
|
40
|
+
typedef struct ourbuffer_s {
|
|
41
|
+
zlib_filefunc_def filefunc;
|
|
42
|
+
zlib_filefunc64_def filefunc64;
|
|
43
|
+
} ourbuffer_t;
|
|
44
|
+
|
|
45
|
+
void fill_buffer_filefunc(zlib_filefunc_def* pzlib_filefunc_def, ourbuffer_t *ourbuf);
|
|
46
|
+
void fill_buffer_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def, ourbuffer_t *ourbuf);
|
|
47
|
+
|
|
48
|
+
#ifdef __cplusplus
|
|
49
|
+
}
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
#endif
|
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
/* ioapi_mem.c -- IO base function header for compress/uncompress .zip
|
|
2
|
-
files using zlib + zip or unzip API
|
|
3
|
-
|
|
4
|
-
This version of ioapi is designed to access memory rather than files.
|
|
5
|
-
We do use a region of memory to put data in to and take it out of. We do
|
|
6
|
-
not have auto-extending buffers and do not inform anyone else that the
|
|
7
|
-
data has been written. It is really intended for accessing a zip archive
|
|
8
|
-
embedded in an application such that I can write an installer with no
|
|
9
|
-
external files. Creation of archives has not been attempted, although
|
|
10
|
-
parts of the framework are present.
|
|
11
|
-
|
|
12
|
-
Based on Unzip ioapi.c version 0.22, May 19th, 2003
|
|
13
|
-
|
|
14
|
-
Copyright (C) 2012-2017 Nathan Moinvaziri
|
|
15
|
-
https://github.com/nmoinvaz/minizip
|
|
16
|
-
Copyright (C) 2003 Justin Fletcher
|
|
17
|
-
Copyright (C) 1998-2003 Gilles Vollant
|
|
18
|
-
http://www.winimage.com/zLibDll/minizip.html
|
|
19
|
-
|
|
20
|
-
This file is under the same license as the Unzip tool it is distributed
|
|
21
|
-
with.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
#include <stdio.h>
|
|
26
|
-
#include <stdlib.h>
|
|
27
|
-
#include <string.h>
|
|
28
|
-
|
|
29
|
-
#include "zlib.h"
|
|
30
|
-
#include "ioapi.h"
|
|
31
|
-
|
|
32
|
-
#include "ioapi_mem.h"
|
|
33
|
-
|
|
34
|
-
#ifndef IOMEM_BUFFERSIZE
|
|
35
|
-
# define IOMEM_BUFFERSIZE (UINT16_MAX)
|
|
36
|
-
#endif
|
|
37
|
-
|
|
38
|
-
voidpf ZCALLBACK fopen_mem_func(voidpf opaque, ZIP_UNUSED const char *filename, int mode)
|
|
39
|
-
{
|
|
40
|
-
ourmemory_t *mem = (ourmemory_t *)opaque;
|
|
41
|
-
if (mem == NULL)
|
|
42
|
-
return NULL; /* Mem structure passed in was null */
|
|
43
|
-
|
|
44
|
-
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
|
45
|
-
{
|
|
46
|
-
if (mem->grow)
|
|
47
|
-
{
|
|
48
|
-
mem->size = IOMEM_BUFFERSIZE;
|
|
49
|
-
mem->base = (char *)malloc(mem->size);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
mem->limit = 0; /* When writing we start with 0 bytes written */
|
|
53
|
-
}
|
|
54
|
-
else
|
|
55
|
-
mem->limit = mem->size;
|
|
56
|
-
|
|
57
|
-
mem->cur_offset = 0;
|
|
58
|
-
|
|
59
|
-
return mem;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
voidpf ZCALLBACK fopendisk_mem_func(ZIP_UNUSED voidpf opaque, ZIP_UNUSED voidpf stream, ZIP_UNUSED uint32_t number_disk, ZIP_UNUSED int mode)
|
|
63
|
-
{
|
|
64
|
-
/* Not used */
|
|
65
|
-
return NULL;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
uint32_t ZCALLBACK fread_mem_func(ZIP_UNUSED voidpf opaque, voidpf stream, void *buf, uint32_t size)
|
|
69
|
-
{
|
|
70
|
-
ourmemory_t *mem = (ourmemory_t *)stream;
|
|
71
|
-
|
|
72
|
-
if (size > mem->size - mem->cur_offset)
|
|
73
|
-
size = mem->size - mem->cur_offset;
|
|
74
|
-
|
|
75
|
-
memcpy(buf, mem->base + mem->cur_offset, size);
|
|
76
|
-
mem->cur_offset += size;
|
|
77
|
-
|
|
78
|
-
return size;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
uint32_t ZCALLBACK fwrite_mem_func(ZIP_UNUSED voidpf opaque, voidpf stream, const void *buf, uint32_t size)
|
|
82
|
-
{
|
|
83
|
-
ourmemory_t *mem = (ourmemory_t *)stream;
|
|
84
|
-
uint32_t newmemsize = 0;
|
|
85
|
-
char *newbase = NULL;
|
|
86
|
-
|
|
87
|
-
if (size > mem->size - mem->cur_offset)
|
|
88
|
-
{
|
|
89
|
-
if (mem->grow)
|
|
90
|
-
{
|
|
91
|
-
newmemsize = mem->size;
|
|
92
|
-
if (size < IOMEM_BUFFERSIZE)
|
|
93
|
-
newmemsize += IOMEM_BUFFERSIZE;
|
|
94
|
-
else
|
|
95
|
-
newmemsize += size;
|
|
96
|
-
newbase = (char *)malloc(newmemsize);
|
|
97
|
-
memcpy(newbase, mem->base, mem->size);
|
|
98
|
-
free(mem->base);
|
|
99
|
-
mem->base = newbase;
|
|
100
|
-
mem->size = newmemsize;
|
|
101
|
-
}
|
|
102
|
-
else
|
|
103
|
-
size = mem->size - mem->cur_offset;
|
|
104
|
-
}
|
|
105
|
-
memcpy(mem->base + mem->cur_offset, buf, size);
|
|
106
|
-
mem->cur_offset += size;
|
|
107
|
-
if (mem->cur_offset > mem->limit)
|
|
108
|
-
mem->limit = mem->cur_offset;
|
|
109
|
-
|
|
110
|
-
return size;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
long ZCALLBACK ftell_mem_func(ZIP_UNUSED voidpf opaque, voidpf stream)
|
|
114
|
-
{
|
|
115
|
-
ourmemory_t *mem = (ourmemory_t *)stream;
|
|
116
|
-
return mem->cur_offset;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
long ZCALLBACK fseek_mem_func(ZIP_UNUSED voidpf opaque, voidpf stream, uint32_t offset, int origin)
|
|
120
|
-
{
|
|
121
|
-
ourmemory_t *mem = (ourmemory_t *)stream;
|
|
122
|
-
uint32_t new_pos = 0;
|
|
123
|
-
switch (origin)
|
|
124
|
-
{
|
|
125
|
-
case ZLIB_FILEFUNC_SEEK_CUR:
|
|
126
|
-
new_pos = mem->cur_offset + offset;
|
|
127
|
-
break;
|
|
128
|
-
case ZLIB_FILEFUNC_SEEK_END:
|
|
129
|
-
new_pos = mem->limit + offset;
|
|
130
|
-
break;
|
|
131
|
-
case ZLIB_FILEFUNC_SEEK_SET:
|
|
132
|
-
new_pos = offset;
|
|
133
|
-
break;
|
|
134
|
-
default:
|
|
135
|
-
return -1;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (new_pos > mem->size)
|
|
139
|
-
return 1; /* Failed to seek that far */
|
|
140
|
-
mem->cur_offset = new_pos;
|
|
141
|
-
return 0;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
int ZCALLBACK fclose_mem_func(ZIP_UNUSED voidpf opaque, ZIP_UNUSED voidpf stream)
|
|
145
|
-
{
|
|
146
|
-
/* Even with grow = 1, caller must always free() memory */
|
|
147
|
-
return 0;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
int ZCALLBACK ferror_mem_func(ZIP_UNUSED voidpf opaque, ZIP_UNUSED voidpf stream)
|
|
151
|
-
{
|
|
152
|
-
/* We never return errors */
|
|
153
|
-
return 0;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def, ourmemory_t *ourmem)
|
|
157
|
-
{
|
|
158
|
-
pzlib_filefunc_def->zopen_file = fopen_mem_func;
|
|
159
|
-
pzlib_filefunc_def->zopendisk_file = fopendisk_mem_func;
|
|
160
|
-
pzlib_filefunc_def->zread_file = fread_mem_func;
|
|
161
|
-
pzlib_filefunc_def->zwrite_file = fwrite_mem_func;
|
|
162
|
-
pzlib_filefunc_def->ztell_file = ftell_mem_func;
|
|
163
|
-
pzlib_filefunc_def->zseek_file = fseek_mem_func;
|
|
164
|
-
pzlib_filefunc_def->zclose_file = fclose_mem_func;
|
|
165
|
-
pzlib_filefunc_def->zerror_file = ferror_mem_func;
|
|
166
|
-
pzlib_filefunc_def->opaque = ourmem;
|
|
167
|
-
}
|
|
1
|
+
/* ioapi_mem.c -- IO base function header for compress/uncompress .zip
|
|
2
|
+
files using zlib + zip or unzip API
|
|
3
|
+
|
|
4
|
+
This version of ioapi is designed to access memory rather than files.
|
|
5
|
+
We do use a region of memory to put data in to and take it out of. We do
|
|
6
|
+
not have auto-extending buffers and do not inform anyone else that the
|
|
7
|
+
data has been written. It is really intended for accessing a zip archive
|
|
8
|
+
embedded in an application such that I can write an installer with no
|
|
9
|
+
external files. Creation of archives has not been attempted, although
|
|
10
|
+
parts of the framework are present.
|
|
11
|
+
|
|
12
|
+
Based on Unzip ioapi.c version 0.22, May 19th, 2003
|
|
13
|
+
|
|
14
|
+
Copyright (C) 2012-2017 Nathan Moinvaziri
|
|
15
|
+
https://github.com/nmoinvaz/minizip
|
|
16
|
+
Copyright (C) 2003 Justin Fletcher
|
|
17
|
+
Copyright (C) 1998-2003 Gilles Vollant
|
|
18
|
+
http://www.winimage.com/zLibDll/minizip.html
|
|
19
|
+
|
|
20
|
+
This file is under the same license as the Unzip tool it is distributed
|
|
21
|
+
with.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#include <stdio.h>
|
|
26
|
+
#include <stdlib.h>
|
|
27
|
+
#include <string.h>
|
|
28
|
+
|
|
29
|
+
#include "zlib.h"
|
|
30
|
+
#include "ioapi.h"
|
|
31
|
+
|
|
32
|
+
#include "ioapi_mem.h"
|
|
33
|
+
|
|
34
|
+
#ifndef IOMEM_BUFFERSIZE
|
|
35
|
+
# define IOMEM_BUFFERSIZE (UINT16_MAX)
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
voidpf ZCALLBACK fopen_mem_func(voidpf opaque, ZIP_UNUSED const char *filename, int mode)
|
|
39
|
+
{
|
|
40
|
+
ourmemory_t *mem = (ourmemory_t *)opaque;
|
|
41
|
+
if (mem == NULL)
|
|
42
|
+
return NULL; /* Mem structure passed in was null */
|
|
43
|
+
|
|
44
|
+
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
|
45
|
+
{
|
|
46
|
+
if (mem->grow)
|
|
47
|
+
{
|
|
48
|
+
mem->size = IOMEM_BUFFERSIZE;
|
|
49
|
+
mem->base = (char *)malloc(mem->size);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
mem->limit = 0; /* When writing we start with 0 bytes written */
|
|
53
|
+
}
|
|
54
|
+
else
|
|
55
|
+
mem->limit = mem->size;
|
|
56
|
+
|
|
57
|
+
mem->cur_offset = 0;
|
|
58
|
+
|
|
59
|
+
return mem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
voidpf ZCALLBACK fopendisk_mem_func(ZIP_UNUSED voidpf opaque, ZIP_UNUSED voidpf stream, ZIP_UNUSED uint32_t number_disk, ZIP_UNUSED int mode)
|
|
63
|
+
{
|
|
64
|
+
/* Not used */
|
|
65
|
+
return NULL;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
uint32_t ZCALLBACK fread_mem_func(ZIP_UNUSED voidpf opaque, voidpf stream, void *buf, uint32_t size)
|
|
69
|
+
{
|
|
70
|
+
ourmemory_t *mem = (ourmemory_t *)stream;
|
|
71
|
+
|
|
72
|
+
if (size > mem->size - mem->cur_offset)
|
|
73
|
+
size = mem->size - mem->cur_offset;
|
|
74
|
+
|
|
75
|
+
memcpy(buf, mem->base + mem->cur_offset, size);
|
|
76
|
+
mem->cur_offset += size;
|
|
77
|
+
|
|
78
|
+
return size;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
uint32_t ZCALLBACK fwrite_mem_func(ZIP_UNUSED voidpf opaque, voidpf stream, const void *buf, uint32_t size)
|
|
82
|
+
{
|
|
83
|
+
ourmemory_t *mem = (ourmemory_t *)stream;
|
|
84
|
+
uint32_t newmemsize = 0;
|
|
85
|
+
char *newbase = NULL;
|
|
86
|
+
|
|
87
|
+
if (size > mem->size - mem->cur_offset)
|
|
88
|
+
{
|
|
89
|
+
if (mem->grow)
|
|
90
|
+
{
|
|
91
|
+
newmemsize = mem->size;
|
|
92
|
+
if (size < IOMEM_BUFFERSIZE)
|
|
93
|
+
newmemsize += IOMEM_BUFFERSIZE;
|
|
94
|
+
else
|
|
95
|
+
newmemsize += size;
|
|
96
|
+
newbase = (char *)malloc(newmemsize);
|
|
97
|
+
memcpy(newbase, mem->base, mem->size);
|
|
98
|
+
free(mem->base);
|
|
99
|
+
mem->base = newbase;
|
|
100
|
+
mem->size = newmemsize;
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
size = mem->size - mem->cur_offset;
|
|
104
|
+
}
|
|
105
|
+
memcpy(mem->base + mem->cur_offset, buf, size);
|
|
106
|
+
mem->cur_offset += size;
|
|
107
|
+
if (mem->cur_offset > mem->limit)
|
|
108
|
+
mem->limit = mem->cur_offset;
|
|
109
|
+
|
|
110
|
+
return size;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
long ZCALLBACK ftell_mem_func(ZIP_UNUSED voidpf opaque, voidpf stream)
|
|
114
|
+
{
|
|
115
|
+
ourmemory_t *mem = (ourmemory_t *)stream;
|
|
116
|
+
return mem->cur_offset;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
long ZCALLBACK fseek_mem_func(ZIP_UNUSED voidpf opaque, voidpf stream, uint32_t offset, int origin)
|
|
120
|
+
{
|
|
121
|
+
ourmemory_t *mem = (ourmemory_t *)stream;
|
|
122
|
+
uint32_t new_pos = 0;
|
|
123
|
+
switch (origin)
|
|
124
|
+
{
|
|
125
|
+
case ZLIB_FILEFUNC_SEEK_CUR:
|
|
126
|
+
new_pos = mem->cur_offset + offset;
|
|
127
|
+
break;
|
|
128
|
+
case ZLIB_FILEFUNC_SEEK_END:
|
|
129
|
+
new_pos = mem->limit + offset;
|
|
130
|
+
break;
|
|
131
|
+
case ZLIB_FILEFUNC_SEEK_SET:
|
|
132
|
+
new_pos = offset;
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
return -1;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (new_pos > mem->size)
|
|
139
|
+
return 1; /* Failed to seek that far */
|
|
140
|
+
mem->cur_offset = new_pos;
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
int ZCALLBACK fclose_mem_func(ZIP_UNUSED voidpf opaque, ZIP_UNUSED voidpf stream)
|
|
145
|
+
{
|
|
146
|
+
/* Even with grow = 1, caller must always free() memory */
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
int ZCALLBACK ferror_mem_func(ZIP_UNUSED voidpf opaque, ZIP_UNUSED voidpf stream)
|
|
151
|
+
{
|
|
152
|
+
/* We never return errors */
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def, ourmemory_t *ourmem)
|
|
157
|
+
{
|
|
158
|
+
pzlib_filefunc_def->zopen_file = fopen_mem_func;
|
|
159
|
+
pzlib_filefunc_def->zopendisk_file = fopendisk_mem_func;
|
|
160
|
+
pzlib_filefunc_def->zread_file = fread_mem_func;
|
|
161
|
+
pzlib_filefunc_def->zwrite_file = fwrite_mem_func;
|
|
162
|
+
pzlib_filefunc_def->ztell_file = ftell_mem_func;
|
|
163
|
+
pzlib_filefunc_def->zseek_file = fseek_mem_func;
|
|
164
|
+
pzlib_filefunc_def->zclose_file = fclose_mem_func;
|
|
165
|
+
pzlib_filefunc_def->zerror_file = ferror_mem_func;
|
|
166
|
+
pzlib_filefunc_def->opaque = ourmem;
|
|
167
|
+
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
/* ioapi_mem.h -- IO base function header for compress/uncompress .zip
|
|
2
|
-
files using zlib + zip or unzip API
|
|
3
|
-
|
|
4
|
-
This version of ioapi is designed to access memory rather than files.
|
|
5
|
-
We do use a region of memory to put data in to and take it out of.
|
|
6
|
-
|
|
7
|
-
Copyright (C) 2012-2017 Nathan Moinvaziri (https://github.com/nmoinvaz/minizip)
|
|
8
|
-
(C) 2003 Justin Fletcher
|
|
9
|
-
(C) 1998-2003 Gilles Vollant
|
|
10
|
-
|
|
11
|
-
This program is distributed under the terms of the same license as zlib.
|
|
12
|
-
See the accompanying LICENSE file for the full text of the license.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
#ifndef _IOAPI_MEM_H
|
|
16
|
-
#define _IOAPI_MEM_H
|
|
17
|
-
|
|
18
|
-
#include <stdio.h>
|
|
19
|
-
#include <stdlib.h>
|
|
20
|
-
#include <string.h>
|
|
21
|
-
|
|
22
|
-
#include "zlib.h"
|
|
23
|
-
#include "ioapi.h"
|
|
24
|
-
|
|
25
|
-
#ifdef __cplusplus
|
|
26
|
-
extern "C" {
|
|
27
|
-
#endif
|
|
28
|
-
|
|
29
|
-
voidpf ZCALLBACK fopen_mem_func(voidpf opaque, const char* filename, int mode);
|
|
30
|
-
voidpf ZCALLBACK fopendisk_mem_func(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
|
|
31
|
-
uint32_t ZCALLBACK fread_mem_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
|
|
32
|
-
uint32_t ZCALLBACK fwrite_mem_func(voidpf opaque, voidpf stream, const void* buf, uint32_t size);
|
|
33
|
-
long ZCALLBACK ftell_mem_func(voidpf opaque, voidpf stream);
|
|
34
|
-
long ZCALLBACK fseek_mem_func(voidpf opaque, voidpf stream, uint32_t offset, int origin);
|
|
35
|
-
int ZCALLBACK fclose_mem_func(voidpf opaque, voidpf stream);
|
|
36
|
-
int ZCALLBACK ferror_mem_func(voidpf opaque, voidpf stream);
|
|
37
|
-
|
|
38
|
-
typedef struct ourmemory_s {
|
|
39
|
-
char *base; /* Base of the region of memory we're using */
|
|
40
|
-
uint32_t size; /* Size of the region of memory we're using */
|
|
41
|
-
uint32_t limit; /* Furthest we've written */
|
|
42
|
-
uint32_t cur_offset; /* Current offset in the area */
|
|
43
|
-
int grow; /* Growable memory buffer */
|
|
44
|
-
} ourmemory_t;
|
|
45
|
-
|
|
46
|
-
void fill_memory_filefunc(zlib_filefunc_def* pzlib_filefunc_def, ourmemory_t *ourmem);
|
|
47
|
-
|
|
48
|
-
#ifdef __cplusplus
|
|
49
|
-
}
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
#endif
|
|
1
|
+
/* ioapi_mem.h -- IO base function header for compress/uncompress .zip
|
|
2
|
+
files using zlib + zip or unzip API
|
|
3
|
+
|
|
4
|
+
This version of ioapi is designed to access memory rather than files.
|
|
5
|
+
We do use a region of memory to put data in to and take it out of.
|
|
6
|
+
|
|
7
|
+
Copyright (C) 2012-2017 Nathan Moinvaziri (https://github.com/nmoinvaz/minizip)
|
|
8
|
+
(C) 2003 Justin Fletcher
|
|
9
|
+
(C) 1998-2003 Gilles Vollant
|
|
10
|
+
|
|
11
|
+
This program is distributed under the terms of the same license as zlib.
|
|
12
|
+
See the accompanying LICENSE file for the full text of the license.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
#ifndef _IOAPI_MEM_H
|
|
16
|
+
#define _IOAPI_MEM_H
|
|
17
|
+
|
|
18
|
+
#include <stdio.h>
|
|
19
|
+
#include <stdlib.h>
|
|
20
|
+
#include <string.h>
|
|
21
|
+
|
|
22
|
+
#include "zlib.h"
|
|
23
|
+
#include "ioapi.h"
|
|
24
|
+
|
|
25
|
+
#ifdef __cplusplus
|
|
26
|
+
extern "C" {
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
voidpf ZCALLBACK fopen_mem_func(voidpf opaque, const char* filename, int mode);
|
|
30
|
+
voidpf ZCALLBACK fopendisk_mem_func(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
|
|
31
|
+
uint32_t ZCALLBACK fread_mem_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
|
|
32
|
+
uint32_t ZCALLBACK fwrite_mem_func(voidpf opaque, voidpf stream, const void* buf, uint32_t size);
|
|
33
|
+
long ZCALLBACK ftell_mem_func(voidpf opaque, voidpf stream);
|
|
34
|
+
long ZCALLBACK fseek_mem_func(voidpf opaque, voidpf stream, uint32_t offset, int origin);
|
|
35
|
+
int ZCALLBACK fclose_mem_func(voidpf opaque, voidpf stream);
|
|
36
|
+
int ZCALLBACK ferror_mem_func(voidpf opaque, voidpf stream);
|
|
37
|
+
|
|
38
|
+
typedef struct ourmemory_s {
|
|
39
|
+
char *base; /* Base of the region of memory we're using */
|
|
40
|
+
uint32_t size; /* Size of the region of memory we're using */
|
|
41
|
+
uint32_t limit; /* Furthest we've written */
|
|
42
|
+
uint32_t cur_offset; /* Current offset in the area */
|
|
43
|
+
int grow; /* Growable memory buffer */
|
|
44
|
+
} ourmemory_t;
|
|
45
|
+
|
|
46
|
+
void fill_memory_filefunc(zlib_filefunc_def* pzlib_filefunc_def, ourmemory_t *ourmem);
|
|
47
|
+
|
|
48
|
+
#ifdef __cplusplus
|
|
49
|
+
}
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
#endif
|