v1.13 initial checkin

This commit is contained in:
richgel99@gmail.com
2012-05-20 04:01:37 +00:00
parent 6b95156074
commit 56fb6c2010
18 changed files with 3046 additions and 133 deletions

View File

@@ -2,6 +2,7 @@
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
#include "tinfl.c"
#include <stdio.h>
#include <limits.h>
typedef unsigned char uint8;
typedef unsigned short uint16;
@@ -22,7 +23,8 @@ int main(int argc, char *argv[])
uint infile_size, outfile_size;
size_t in_buf_size;
uint8 *pCmp_data;
long file_loc;
if (argc != 3)
{
printf("Usage: example4 infile outfile\n");
@@ -38,12 +40,21 @@ int main(int argc, char *argv[])
printf("Failed opening input file!\n");
return EXIT_FAILURE;
}
// Determine input file's size.
fseek(pInfile, 0, SEEK_END);
infile_size = ftell(pInfile);
file_loc = ftell(pInfile);
fseek(pInfile, 0, SEEK_SET);
if ((file_loc < 0) || (file_loc > INT_MAX))
{
// This is not a limitation of miniz or tinfl, but this example.
printf("File is too large to be processed by this example.\n");
return EXIT_FAILURE;
}
infile_size = (uint)file_loc;
pCmp_data = (uint8 *)malloc(infile_size);
if (!pCmp_data)
{
@@ -65,7 +76,7 @@ int main(int argc, char *argv[])
}
printf("Input file size: %u\n", infile_size);
in_buf_size = infile_size;
status = tinfl_decompress_mem_to_callback(pCmp_data, &in_buf_size, tinfl_put_buf_func, pOutfile, TINFL_FLAG_PARSE_ZLIB_HEADER);
if (!status)