kmadej_fast_excel_fork 0.2.2
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.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +28 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +70 -0
- data/Makefile +14 -0
- data/README.md +95 -0
- data/Rakefile +24 -0
- data/appveyor.yml +25 -0
- data/benchmarks/1k_rows.rb +59 -0
- data/benchmarks/20k_rows.rb +26 -0
- data/benchmarks/init.rb +59 -0
- data/benchmarks/memory.rb +49 -0
- data/examples/example.rb +42 -0
- data/examples/example_align.rb +23 -0
- data/examples/example_chart.rb +21 -0
- data/examples/example_colors.rb +37 -0
- data/examples/example_formula.rb +18 -0
- data/examples/example_image.rb +13 -0
- data/examples/example_styles.rb +27 -0
- data/examples/logo.png +0 -0
- data/extconf.rb +0 -0
- data/fast_excel.gemspec +20 -0
- data/lib/fast_excel.rb +600 -0
- data/lib/fast_excel/binding.rb +2819 -0
- data/lib/fast_excel/binding/chart.rb +2666 -0
- data/lib/fast_excel/binding/format.rb +1177 -0
- data/lib/fast_excel/binding/workbook.rb +338 -0
- data/lib/fast_excel/binding/worksheet.rb +1555 -0
- data/libxlsxwriter/.gitignore +49 -0
- data/libxlsxwriter/.indent.pro +125 -0
- data/libxlsxwriter/.travis.yml +25 -0
- data/libxlsxwriter/CONTRIBUTING.md +226 -0
- data/libxlsxwriter/Changes.txt +557 -0
- data/libxlsxwriter/LICENSE.txt +89 -0
- data/libxlsxwriter/Makefile +156 -0
- data/libxlsxwriter/Readme.md +78 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +30 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter.modulemap +7 -0
- data/libxlsxwriter/include/xlsxwriter.h +23 -0
- data/libxlsxwriter/include/xlsxwriter/app.h +79 -0
- data/libxlsxwriter/include/xlsxwriter/chart.h +3476 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +372 -0
- data/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
- data/libxlsxwriter/include/xlsxwriter/core.h +51 -0
- data/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
- data/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
- data/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
- data/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
- data/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
- data/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
- data/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +214 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
- data/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
- data/libxlsxwriter/include/xlsxwriter/workbook.h +757 -0
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
- data/libxlsxwriter/lib/.gitignore +0 -0
- data/libxlsxwriter/libxlsxwriter.podspec +47 -0
- data/libxlsxwriter/src/Makefile +130 -0
- data/libxlsxwriter/src/app.c +443 -0
- data/libxlsxwriter/src/chart.c +6346 -0
- data/libxlsxwriter/src/content_types.c +345 -0
- data/libxlsxwriter/src/core.c +293 -0
- data/libxlsxwriter/src/custom.c +224 -0
- data/libxlsxwriter/src/drawing.c +746 -0
- data/libxlsxwriter/src/format.c +729 -0
- data/libxlsxwriter/src/hash_table.c +223 -0
- data/libxlsxwriter/src/packager.c +948 -0
- data/libxlsxwriter/src/relationships.c +245 -0
- data/libxlsxwriter/src/shared_strings.c +266 -0
- data/libxlsxwriter/src/styles.c +1088 -0
- data/libxlsxwriter/src/theme.c +348 -0
- data/libxlsxwriter/src/utility.c +515 -0
- data/libxlsxwriter/src/workbook.c +1930 -0
- data/libxlsxwriter/src/worksheet.c +5022 -0
- data/libxlsxwriter/src/xmlwriter.c +355 -0
- data/libxlsxwriter/third_party/minizip/Makefile +44 -0
- data/libxlsxwriter/third_party/minizip/Makefile.am +45 -0
- data/libxlsxwriter/third_party/minizip/Makefile.orig +25 -0
- data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +6 -0
- data/libxlsxwriter/third_party/minizip/MiniZip64_info.txt +74 -0
- data/libxlsxwriter/third_party/minizip/README.txt +5 -0
- data/libxlsxwriter/third_party/minizip/configure.ac +32 -0
- data/libxlsxwriter/third_party/minizip/crypt.h +131 -0
- data/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
- data/libxlsxwriter/third_party/minizip/ioapi.h +208 -0
- data/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
- data/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
- data/libxlsxwriter/third_party/minizip/make_vms.com +25 -0
- data/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
- data/libxlsxwriter/third_party/minizip/miniunzip.1 +63 -0
- data/libxlsxwriter/third_party/minizip/minizip.1 +46 -0
- data/libxlsxwriter/third_party/minizip/minizip.c +520 -0
- data/libxlsxwriter/third_party/minizip/minizip.pc.in +12 -0
- data/libxlsxwriter/third_party/minizip/mztools.c +291 -0
- data/libxlsxwriter/third_party/minizip/mztools.h +37 -0
- data/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
- data/libxlsxwriter/third_party/minizip/unzip.h +437 -0
- data/libxlsxwriter/third_party/minizip/zip.c +2007 -0
- data/libxlsxwriter/third_party/minizip/zip.h +367 -0
- data/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
- data/libxlsxwriter/version.txt +1 -0
- data/test/date_test.rb +22 -0
- data/test/default_format_test.rb +19 -0
- data/test/format_test.rb +171 -0
- data/test/test_helper.rb +52 -0
- data/test/tmpfile_test.rb +23 -0
- data/test/worksheet_test.rb +86 -0
- metadata +182 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson
|
|
2
|
+
|
|
3
|
+
Introduction
|
|
4
|
+
---------------------
|
|
5
|
+
MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html )
|
|
6
|
+
|
|
7
|
+
When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0.
|
|
8
|
+
All possible work was done for compatibility.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Background
|
|
12
|
+
---------------------
|
|
13
|
+
When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64
|
|
14
|
+
support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ )
|
|
15
|
+
|
|
16
|
+
That was used as a starting point. And after that ZIP64 support was added to zip.c
|
|
17
|
+
some refactoring and code cleanup was also done.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Changed from MiniZip 1.0 to MiniZip 1.1
|
|
21
|
+
---------------------------------------
|
|
22
|
+
* Added ZIP64 support for unzip ( by Even Rouault )
|
|
23
|
+
* Added ZIP64 support for zip ( by Mathias Svensson )
|
|
24
|
+
* Reverted some changed that Even Rouault did.
|
|
25
|
+
* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users.
|
|
26
|
+
* Added unzip patch for BZIP Compression method (patch create by Daniel Borca)
|
|
27
|
+
* Added BZIP Compress method for zip
|
|
28
|
+
* Did some refactoring and code cleanup
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Credits
|
|
32
|
+
|
|
33
|
+
Gilles Vollant - Original MiniZip author
|
|
34
|
+
Even Rouault - ZIP64 unzip Support
|
|
35
|
+
Daniel Borca - BZip Compression method support in unzip
|
|
36
|
+
Mathias Svensson - ZIP64 zip support
|
|
37
|
+
Mathias Svensson - BZip Compression method support in zip
|
|
38
|
+
|
|
39
|
+
Resources
|
|
40
|
+
|
|
41
|
+
ZipLayout http://result42.com/projects/ZipFileLayout
|
|
42
|
+
Command line tool for Windows that shows the layout and information of the headers in a zip archive.
|
|
43
|
+
Used when debugging and validating the creation of zip files using MiniZip64
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
ZIP App Note http://www.pkware.com/documents/casestudies/APPNOTE.TXT
|
|
47
|
+
Zip File specification
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Notes.
|
|
51
|
+
* To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined.
|
|
52
|
+
|
|
53
|
+
License
|
|
54
|
+
----------------------------------------------------------
|
|
55
|
+
Condition of use and distribution are the same than zlib :
|
|
56
|
+
|
|
57
|
+
This software is provided 'as-is', without any express or implied
|
|
58
|
+
warranty. In no event will the authors be held liable for any damages
|
|
59
|
+
arising from the use of this software.
|
|
60
|
+
|
|
61
|
+
Permission is granted to anyone to use this software for any purpose,
|
|
62
|
+
including commercial applications, and to alter it and redistribute it
|
|
63
|
+
freely, subject to the following restrictions:
|
|
64
|
+
|
|
65
|
+
1. The origin of this software must not be misrepresented; you must not
|
|
66
|
+
claim that you wrote the original software. If you use this software
|
|
67
|
+
in a product, an acknowledgment in the product documentation would be
|
|
68
|
+
appreciated but is not required.
|
|
69
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
|
70
|
+
misrepresented as being the original software.
|
|
71
|
+
3. This notice may not be removed or altered from any source distribution.
|
|
72
|
+
|
|
73
|
+
----------------------------------------------------------
|
|
74
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# -*- Autoconf -*-
|
|
2
|
+
# Process this file with autoconf to produce a configure script.
|
|
3
|
+
|
|
4
|
+
AC_INIT([minizip], [1.2.8], [bugzilla.redhat.com])
|
|
5
|
+
AC_CONFIG_SRCDIR([minizip.c])
|
|
6
|
+
AM_INIT_AUTOMAKE([foreign])
|
|
7
|
+
LT_INIT
|
|
8
|
+
|
|
9
|
+
AC_MSG_CHECKING([whether to build example programs])
|
|
10
|
+
AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs]))
|
|
11
|
+
AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes])
|
|
12
|
+
if test "$enable_demos" = yes
|
|
13
|
+
then
|
|
14
|
+
AC_MSG_RESULT([yes])
|
|
15
|
+
else
|
|
16
|
+
AC_MSG_RESULT([no])
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
case "${host}" in
|
|
20
|
+
*-mingw* | mingw*)
|
|
21
|
+
WIN32="yes"
|
|
22
|
+
;;
|
|
23
|
+
*)
|
|
24
|
+
;;
|
|
25
|
+
esac
|
|
26
|
+
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
AC_SUBST([HAVE_UNISTD_H], [0])
|
|
30
|
+
AC_CHECK_HEADER([unistd.h], [HAVE_UNISTD_H=1], [])
|
|
31
|
+
AC_CONFIG_FILES([Makefile minizip.pc])
|
|
32
|
+
AC_OUTPUT
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Version 1.01e, February 12th, 2005
|
|
5
|
+
|
|
6
|
+
Copyright (C) 1998-2005 Gilles Vollant
|
|
7
|
+
|
|
8
|
+
This code is a modified version of crypting code in Infozip distribution
|
|
9
|
+
|
|
10
|
+
The encryption/decryption parts of this source code (as opposed to the
|
|
11
|
+
non-echoing password parts) were originally written in Europe. The
|
|
12
|
+
whole source package can be freely distributed, including from the USA.
|
|
13
|
+
(Prior to January 2000, re-export from the US was a violation of US law.)
|
|
14
|
+
|
|
15
|
+
This encryption code is a direct transcription of the algorithm from
|
|
16
|
+
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
|
17
|
+
file (appnote.txt) is distributed with the PKZIP program (even in the
|
|
18
|
+
version without encryption capabilities).
|
|
19
|
+
|
|
20
|
+
If you don't need crypting in your application, just define symbols
|
|
21
|
+
NOCRYPT and NOUNCRYPT.
|
|
22
|
+
|
|
23
|
+
This code support the "Traditional PKWARE Encryption".
|
|
24
|
+
|
|
25
|
+
The new AES encryption added on Zip format by Winzip (see the page
|
|
26
|
+
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
|
27
|
+
Encryption is not supported.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
|
31
|
+
|
|
32
|
+
/***********************************************************************
|
|
33
|
+
* Return the next byte in the pseudo-random sequence
|
|
34
|
+
*/
|
|
35
|
+
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
|
36
|
+
{
|
|
37
|
+
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
|
38
|
+
* unpredictable manner on 16-bit systems; not a problem
|
|
39
|
+
* with any known compiler so far, though */
|
|
40
|
+
|
|
41
|
+
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
|
42
|
+
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/***********************************************************************
|
|
46
|
+
* Update the encryption keys with the next byte of plain text
|
|
47
|
+
*/
|
|
48
|
+
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
|
|
49
|
+
{
|
|
50
|
+
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
|
51
|
+
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
|
52
|
+
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
|
53
|
+
{
|
|
54
|
+
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
|
55
|
+
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
|
56
|
+
}
|
|
57
|
+
return c;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
/***********************************************************************
|
|
62
|
+
* Initialize the encryption keys and the random header according to
|
|
63
|
+
* the given password.
|
|
64
|
+
*/
|
|
65
|
+
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
|
|
66
|
+
{
|
|
67
|
+
*(pkeys+0) = 305419896L;
|
|
68
|
+
*(pkeys+1) = 591751049L;
|
|
69
|
+
*(pkeys+2) = 878082192L;
|
|
70
|
+
while (*passwd != '\0') {
|
|
71
|
+
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
|
|
72
|
+
passwd++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#define zdecode(pkeys,pcrc_32_tab,c) \
|
|
77
|
+
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
|
78
|
+
|
|
79
|
+
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
|
80
|
+
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
|
81
|
+
|
|
82
|
+
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
|
83
|
+
|
|
84
|
+
#define RAND_HEAD_LEN 12
|
|
85
|
+
/* "last resort" source for second part of crypt seed pattern */
|
|
86
|
+
# ifndef ZCR_SEED2
|
|
87
|
+
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
|
88
|
+
# endif
|
|
89
|
+
|
|
90
|
+
static int crypthead(const char* passwd, /* password string */
|
|
91
|
+
unsigned char* buf, /* where to write header */
|
|
92
|
+
int bufSize,
|
|
93
|
+
unsigned long* pkeys,
|
|
94
|
+
const z_crc_t* pcrc_32_tab,
|
|
95
|
+
unsigned long crcForCrypting)
|
|
96
|
+
{
|
|
97
|
+
int n; /* index in random header */
|
|
98
|
+
int t; /* temporary */
|
|
99
|
+
int c; /* random byte */
|
|
100
|
+
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
|
101
|
+
static unsigned calls = 0; /* ensure different random header each time */
|
|
102
|
+
|
|
103
|
+
if (bufSize<RAND_HEAD_LEN)
|
|
104
|
+
return 0;
|
|
105
|
+
|
|
106
|
+
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
|
107
|
+
* output of rand() to get less predictability, since rand() is
|
|
108
|
+
* often poorly implemented.
|
|
109
|
+
*/
|
|
110
|
+
if (++calls == 1)
|
|
111
|
+
{
|
|
112
|
+
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
|
113
|
+
}
|
|
114
|
+
init_keys(passwd, pkeys, pcrc_32_tab);
|
|
115
|
+
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
|
116
|
+
{
|
|
117
|
+
c = (rand() >> 7) & 0xff;
|
|
118
|
+
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
|
119
|
+
}
|
|
120
|
+
/* Encrypt random header (last two bytes is high word of crc) */
|
|
121
|
+
init_keys(passwd, pkeys, pcrc_32_tab);
|
|
122
|
+
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
|
123
|
+
{
|
|
124
|
+
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
|
125
|
+
}
|
|
126
|
+
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
|
127
|
+
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
|
128
|
+
return n;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#endif
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
|
2
|
+
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
|
3
|
+
|
|
4
|
+
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
|
5
|
+
|
|
6
|
+
Modifications for Zip64 support
|
|
7
|
+
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
|
8
|
+
|
|
9
|
+
For more info read MiniZip_info.txt
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS)))
|
|
14
|
+
#define _CRT_SECURE_NO_WARNINGS
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
|
18
|
+
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
|
19
|
+
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
|
20
|
+
#define FTELLO_FUNC(stream) ftello(stream)
|
|
21
|
+
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
|
|
22
|
+
#else
|
|
23
|
+
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
|
|
24
|
+
#define FTELLO_FUNC(stream) ftello64(stream)
|
|
25
|
+
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
#include "ioapi.h"
|
|
30
|
+
|
|
31
|
+
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
|
|
32
|
+
{
|
|
33
|
+
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
|
34
|
+
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
|
|
35
|
+
else
|
|
36
|
+
{
|
|
37
|
+
return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
|
|
42
|
+
{
|
|
43
|
+
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
|
44
|
+
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
|
|
45
|
+
else
|
|
46
|
+
{
|
|
47
|
+
uLong offsetTruncated = (uLong)offset;
|
|
48
|
+
if (offsetTruncated != offset)
|
|
49
|
+
return -1;
|
|
50
|
+
else
|
|
51
|
+
return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
|
|
56
|
+
{
|
|
57
|
+
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
|
58
|
+
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
|
59
|
+
else
|
|
60
|
+
{
|
|
61
|
+
uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
|
62
|
+
if ((tell_uLong) == MAXU32)
|
|
63
|
+
return (ZPOS64_T)-1;
|
|
64
|
+
else
|
|
65
|
+
return tell_uLong;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
|
|
70
|
+
{
|
|
71
|
+
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
|
|
72
|
+
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
|
|
73
|
+
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
|
74
|
+
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
|
75
|
+
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
|
76
|
+
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
|
|
77
|
+
p_filefunc64_32->zfile_func64.zseek64_file = NULL;
|
|
78
|
+
p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
|
|
79
|
+
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
|
80
|
+
p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
|
|
81
|
+
p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
|
|
82
|
+
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
|
|
88
|
+
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
|
89
|
+
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
|
|
90
|
+
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
|
|
91
|
+
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
|
92
|
+
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
|
|
93
|
+
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
|
94
|
+
|
|
95
|
+
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
|
96
|
+
{
|
|
97
|
+
FILE* file = NULL;
|
|
98
|
+
const char* mode_fopen = NULL;
|
|
99
|
+
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
|
100
|
+
mode_fopen = "rb";
|
|
101
|
+
else
|
|
102
|
+
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
|
103
|
+
mode_fopen = "r+b";
|
|
104
|
+
else
|
|
105
|
+
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
|
106
|
+
mode_fopen = "wb";
|
|
107
|
+
|
|
108
|
+
if ((filename!=NULL) && (mode_fopen != NULL))
|
|
109
|
+
file = fopen(filename, mode_fopen);
|
|
110
|
+
return file;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
|
114
|
+
{
|
|
115
|
+
FILE* file = NULL;
|
|
116
|
+
const char* mode_fopen = NULL;
|
|
117
|
+
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
|
118
|
+
mode_fopen = "rb";
|
|
119
|
+
else
|
|
120
|
+
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
|
121
|
+
mode_fopen = "r+b";
|
|
122
|
+
else
|
|
123
|
+
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
|
124
|
+
mode_fopen = "wb";
|
|
125
|
+
|
|
126
|
+
if ((filename!=NULL) && (mode_fopen != NULL))
|
|
127
|
+
file = FOPEN_FUNC((const char*)filename, mode_fopen);
|
|
128
|
+
return file;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
|
133
|
+
{
|
|
134
|
+
uLong ret;
|
|
135
|
+
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
|
136
|
+
return ret;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
|
140
|
+
{
|
|
141
|
+
uLong ret;
|
|
142
|
+
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
|
143
|
+
return ret;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
|
147
|
+
{
|
|
148
|
+
long ret;
|
|
149
|
+
ret = ftell((FILE *)stream);
|
|
150
|
+
return ret;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
|
155
|
+
{
|
|
156
|
+
ZPOS64_T ret;
|
|
157
|
+
ret = FTELLO_FUNC((FILE *)stream);
|
|
158
|
+
return ret;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
|
|
162
|
+
{
|
|
163
|
+
int fseek_origin=0;
|
|
164
|
+
long ret;
|
|
165
|
+
switch (origin)
|
|
166
|
+
{
|
|
167
|
+
case ZLIB_FILEFUNC_SEEK_CUR :
|
|
168
|
+
fseek_origin = SEEK_CUR;
|
|
169
|
+
break;
|
|
170
|
+
case ZLIB_FILEFUNC_SEEK_END :
|
|
171
|
+
fseek_origin = SEEK_END;
|
|
172
|
+
break;
|
|
173
|
+
case ZLIB_FILEFUNC_SEEK_SET :
|
|
174
|
+
fseek_origin = SEEK_SET;
|
|
175
|
+
break;
|
|
176
|
+
default: return -1;
|
|
177
|
+
}
|
|
178
|
+
ret = 0;
|
|
179
|
+
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
|
|
180
|
+
ret = -1;
|
|
181
|
+
return ret;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
|
|
185
|
+
{
|
|
186
|
+
int fseek_origin=0;
|
|
187
|
+
long ret;
|
|
188
|
+
switch (origin)
|
|
189
|
+
{
|
|
190
|
+
case ZLIB_FILEFUNC_SEEK_CUR :
|
|
191
|
+
fseek_origin = SEEK_CUR;
|
|
192
|
+
break;
|
|
193
|
+
case ZLIB_FILEFUNC_SEEK_END :
|
|
194
|
+
fseek_origin = SEEK_END;
|
|
195
|
+
break;
|
|
196
|
+
case ZLIB_FILEFUNC_SEEK_SET :
|
|
197
|
+
fseek_origin = SEEK_SET;
|
|
198
|
+
break;
|
|
199
|
+
default: return -1;
|
|
200
|
+
}
|
|
201
|
+
ret = 0;
|
|
202
|
+
|
|
203
|
+
if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
|
|
204
|
+
ret = -1;
|
|
205
|
+
|
|
206
|
+
return ret;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
|
211
|
+
{
|
|
212
|
+
int ret;
|
|
213
|
+
ret = fclose((FILE *)stream);
|
|
214
|
+
return ret;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
|
218
|
+
{
|
|
219
|
+
int ret;
|
|
220
|
+
ret = ferror((FILE *)stream);
|
|
221
|
+
return ret;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
void fill_fopen_filefunc (pzlib_filefunc_def)
|
|
225
|
+
zlib_filefunc_def* pzlib_filefunc_def;
|
|
226
|
+
{
|
|
227
|
+
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
|
228
|
+
pzlib_filefunc_def->zread_file = fread_file_func;
|
|
229
|
+
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
|
230
|
+
pzlib_filefunc_def->ztell_file = ftell_file_func;
|
|
231
|
+
pzlib_filefunc_def->zseek_file = fseek_file_func;
|
|
232
|
+
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
|
233
|
+
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
|
234
|
+
pzlib_filefunc_def->opaque = NULL;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
|
|
238
|
+
{
|
|
239
|
+
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
|
|
240
|
+
pzlib_filefunc_def->zread_file = fread_file_func;
|
|
241
|
+
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
|
242
|
+
pzlib_filefunc_def->ztell64_file = ftell64_file_func;
|
|
243
|
+
pzlib_filefunc_def->zseek64_file = fseek64_file_func;
|
|
244
|
+
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
|
245
|
+
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
|
246
|
+
pzlib_filefunc_def->opaque = NULL;
|
|
247
|
+
}
|