mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	Compare commits
	
		
			7 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 603164652d | ||
|  | 36c0a28fbb | ||
|  | fb98158e67 | ||
|  | 56fb6c2010 | ||
|  | 6b95156074 | ||
|  | 3172e9f7db | ||
|  | 9560a0a51d | 
							
								
								
									
										24
									
								
								example1.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								example1.c
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| // example1.c - Demonstrates miniz.c's compress() and uncompress() functions (same as zlib's). | ||||
| // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com | ||||
| // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c. | ||||
| #include "miniz.c" | ||||
|  | ||||
| typedef unsigned char uint8; | ||||
| @@ -24,13 +24,15 @@ int main(int argc, char *argv[]) | ||||
|   uLong uncomp_len = src_len; | ||||
|   uint8 *pCmp, *pUncomp; | ||||
|   uint total_succeeded = 0; | ||||
|   argc, argv; | ||||
|   (void)argc, (void)argv; | ||||
|  | ||||
|   printf("miniz.c version: %s\n", MZ_VERSION); | ||||
|  | ||||
|   do | ||||
|   { | ||||
|     // Allocate buffers to hold compressed and uncompressed data. | ||||
|     pCmp = (mz_uint8 *)malloc(cmp_len); | ||||
|     pUncomp = (mz_uint8 *)malloc(src_len); | ||||
|     pCmp = (mz_uint8 *)malloc((size_t)cmp_len); | ||||
|     pUncomp = (mz_uint8 *)malloc((size_t)src_len); | ||||
|     if ((!pCmp) || (!pUncomp)) | ||||
|     { | ||||
|       printf("Out of memory!\n"); | ||||
| @@ -47,7 +49,7 @@ int main(int argc, char *argv[]) | ||||
|       return EXIT_FAILURE; | ||||
|     } | ||||
|  | ||||
|     printf("Compressed from %u to %u bytes\n", src_len, cmp_len); | ||||
|     printf("Compressed from %u to %u bytes\n", (mz_uint32)src_len, (mz_uint32)cmp_len); | ||||
|  | ||||
|     if (step) | ||||
|     { | ||||
| @@ -59,11 +61,11 @@ int main(int argc, char *argv[]) | ||||
|         pCmp[i] ^= (rand() & 0xFF); | ||||
|       } | ||||
|     } | ||||
|      | ||||
|  | ||||
|     // Decompress. | ||||
|     cmp_status = uncompress(pUncomp, &uncomp_len, pCmp, cmp_len); | ||||
|     total_succeeded += (cmp_status == Z_OK); | ||||
|      | ||||
|  | ||||
|     if (step) | ||||
|     { | ||||
|       printf("Simple fuzzy test: step %u total_succeeded: %u\n", step, total_succeeded); | ||||
| @@ -78,10 +80,10 @@ int main(int argc, char *argv[]) | ||||
|         return EXIT_FAILURE; | ||||
|       } | ||||
|  | ||||
|       printf("Decompressed from %u to %u bytes\n", cmp_len, uncomp_len); | ||||
|       printf("Decompressed from %u to %u bytes\n", (mz_uint32)cmp_len, (mz_uint32)uncomp_len); | ||||
|  | ||||
|       // Ensure uncompress() returned the expected data. | ||||
|       if ((uncomp_len != src_len) || (memcmp(pUncomp, s_pStr, src_len))) | ||||
|       if ((uncomp_len != src_len) || (memcmp(pUncomp, s_pStr, (size_t)src_len))) | ||||
|       { | ||||
|         printf("Decompression failed!\n"); | ||||
|         free(pCmp); | ||||
| @@ -94,9 +96,9 @@ int main(int argc, char *argv[]) | ||||
|     free(pUncomp); | ||||
|  | ||||
|     step++; | ||||
|      | ||||
|  | ||||
|     // Keep on fuzzy testing if there's a non-empty command line. | ||||
|   } while (argc >= 2);   | ||||
|   } while (argc >= 2); | ||||
|  | ||||
|   printf("Success.\n"); | ||||
|   return EXIT_SUCCESS; | ||||
|   | ||||
							
								
								
									
										88
									
								
								example1.cbp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								example1.cbp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||||
| <CodeBlocks_project_file> | ||||
| 	<FileVersion major="1" minor="6" /> | ||||
| 	<Project> | ||||
| 		<Option title="example1" /> | ||||
| 		<Option pch_mode="2" /> | ||||
| 		<Option compiler="gcc" /> | ||||
| 		<Build> | ||||
| 			<Target title="Debug Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example1D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example1\Debug Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-g" /> | ||||
| 					<Add option="-O0" /> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Debug x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example1_x64D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example1\Debug x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O0" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 			<Target title="Release Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example1" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example1\Release Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-O3" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-s" /> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Release x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example1_x64" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example1\Release x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O3" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 		</Build> | ||||
| 		<Unit filename="example1.c"> | ||||
| 			<Option compilerVar="CC" /> | ||||
| 		</Unit> | ||||
| 		<Extensions> | ||||
| 			<code_completion /> | ||||
| 			<debugger /> | ||||
| 		</Extensions> | ||||
| 	</Project> | ||||
| </CodeBlocks_project_file> | ||||
| @@ -22,7 +22,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Debug|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| @@ -94,7 +94,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Debug|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| @@ -167,7 +167,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Release|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
| @@ -244,7 +244,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Release|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
|   | ||||
							
								
								
									
										70
									
								
								example2.c
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								example2.c
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| // example2.c - Simple demonstration of miniz.c's ZIP archive API's. | ||||
| // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com | ||||
| // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c. | ||||
| #include "miniz.c" | ||||
|  | ||||
| typedef unsigned char uint8; | ||||
| @@ -7,7 +7,7 @@ typedef unsigned short uint16; | ||||
| typedef unsigned int uint; | ||||
|  | ||||
| // The string to compress. | ||||
| static const char *s_pStr =  | ||||
| static const char *s_pStr = | ||||
| "MISSION CONTROL I wouldn't worry too much about the computer. First of all, there is still a chance that he is right, despite your tests, and" \ | ||||
| "if it should happen again, we suggest eliminating this possibility by allowing the unit to remain in place and seeing whether or not it" \ | ||||
| "actually fails. If the computer should turn out to be wrong, the situation is still not alarming. The type of obsessional error he may be" \ | ||||
| @@ -20,13 +20,15 @@ static const char *s_pComment = "This is a comment"; | ||||
|  | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
|   uint i; | ||||
|   mz_bool status; | ||||
|   size_t uncomp_size; | ||||
|   mz_zip_archive zip_archive;  | ||||
|   void *p; | ||||
|    uint i; | ||||
|    mz_bool status; | ||||
|    size_t uncomp_size; | ||||
|    mz_zip_archive zip_archive; | ||||
|    void *p; | ||||
|  | ||||
|   argc, argv; | ||||
|    printf("miniz.c version: %s\n", MZ_VERSION); | ||||
|  | ||||
|    (void)argc, (void)argv; | ||||
|  | ||||
|   // Append a bunch of text files to test.zip | ||||
|   for (i = 0; i < 50; i++) | ||||
| @@ -41,29 +43,29 @@ int main(int argc, char *argv[]) | ||||
|     } | ||||
|   } | ||||
|    | ||||
|   // Now try to open the archive. | ||||
|   memset(&zip_archive, 0, sizeof(zip_archive)); | ||||
|   status = mz_zip_reader_init_file(&zip_archive, "test.zip", 0); | ||||
|   if (!status) | ||||
|   { | ||||
|     printf("mz_zip_reader_init_file() failed!\n"); | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|  | ||||
|   // Get and print information about each file in the archive. | ||||
|   for (i = 0; i < mz_zip_reader_get_num_files(&zip_archive); i++) | ||||
|   { | ||||
|     mz_zip_archive_file_stat file_stat; | ||||
|     if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat)) | ||||
|     { | ||||
|       printf("mz_zip_reader_file_stat() failed!\n"); | ||||
|       mz_zip_reader_end(&zip_archive); | ||||
|    // Now try to open the archive. | ||||
|    memset(&zip_archive, 0, sizeof(zip_archive)); | ||||
|    status = mz_zip_reader_init_file(&zip_archive, "test.zip", 0); | ||||
|    if (!status) | ||||
|    { | ||||
|       printf("mz_zip_reader_init_file() failed!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|     } | ||||
|    } | ||||
|  | ||||
|    // Get and print information about each file in the archive. | ||||
|    for (i = 0; i < mz_zip_reader_get_num_files(&zip_archive); i++) | ||||
|    { | ||||
|       mz_zip_archive_file_stat file_stat; | ||||
|       if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat)) | ||||
|       { | ||||
|          printf("mz_zip_reader_file_stat() failed!\n"); | ||||
|          mz_zip_reader_end(&zip_archive); | ||||
|          return EXIT_FAILURE; | ||||
|       } | ||||
|  | ||||
|       printf("Filename: \"%s\", Comment: \"%s\", Uncompressed size: %u, Compressed size: %u\n", file_stat.m_filename, file_stat.m_comment, (uint)file_stat.m_uncomp_size, (uint)file_stat.m_comp_size); | ||||
|    } | ||||
|  | ||||
|     printf("Filename: \"%s\", Comment: \"%s\", Uncompressed size: %u, Compressed size: %u\n", file_stat.m_filename, file_stat.m_comment, (uint)file_stat.m_uncomp_size, (uint)file_stat.m_comp_size); | ||||
|   } | ||||
|    | ||||
|   // Try to extract 0.txt to the heap. | ||||
|   p = mz_zip_reader_extract_file_to_heap(&zip_archive, "0.txt", &uncomp_size, 0); | ||||
|   if (!p) | ||||
| @@ -84,10 +86,10 @@ int main(int argc, char *argv[]) | ||||
|  | ||||
|   printf("Successfully extracted file \"0.txt\", size %u\n", (uint)uncomp_size); | ||||
|  | ||||
|   // We're done. | ||||
|   free(p); | ||||
|   mz_zip_reader_end(&zip_archive); | ||||
|    // We're done. | ||||
|    free(p); | ||||
|    mz_zip_reader_end(&zip_archive); | ||||
|  | ||||
|   printf("Success.\n"); | ||||
|   return EXIT_SUCCESS; | ||||
|    printf("Success.\n"); | ||||
|    return EXIT_SUCCESS; | ||||
| } | ||||
|   | ||||
							
								
								
									
										88
									
								
								example2.cbp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								example2.cbp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||||
| <CodeBlocks_project_file> | ||||
| 	<FileVersion major="1" minor="6" /> | ||||
| 	<Project> | ||||
| 		<Option title="example2" /> | ||||
| 		<Option pch_mode="2" /> | ||||
| 		<Option compiler="gcc" /> | ||||
| 		<Build> | ||||
| 			<Target title="Debug Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example2D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example2\Debug Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-g" /> | ||||
| 					<Add option="-O0" /> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Debug x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example2_x64D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example2\Debug x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O0" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 			<Target title="Release Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example2" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example2\Release Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-O3" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-s" /> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Release x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example2_x64" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example2\Release x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O3" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 		</Build> | ||||
| 		<Unit filename="example2.c"> | ||||
| 			<Option compilerVar="CC" /> | ||||
| 		</Unit> | ||||
| 		<Extensions> | ||||
| 			<code_completion /> | ||||
| 			<debugger /> | ||||
| 		</Extensions> | ||||
| 	</Project> | ||||
| </CodeBlocks_project_file> | ||||
| @@ -22,7 +22,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Debug|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| @@ -94,7 +94,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Debug|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| @@ -167,7 +167,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Release|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
| @@ -244,7 +244,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Release|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
|   | ||||
							
								
								
									
										102
									
								
								example3.c
									
									
									
									
									
								
							
							
						
						
									
										102
									
								
								example3.c
									
									
									
									
									
								
							| @@ -1,7 +1,8 @@ | ||||
| // example3.c - Demonstrates how to use miniz.c's deflate() and inflate() functions for simple file compression. | ||||
| // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com | ||||
| // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c. | ||||
| // For simplicity, this example is limited to files smaller than 4GB, but this is not a limitation of miniz.c. | ||||
| #include "miniz.c" | ||||
| #include <limits.h> | ||||
|  | ||||
| typedef unsigned char uint8; | ||||
| typedef unsigned short uint16; | ||||
| @@ -19,33 +20,96 @@ int main(int argc, char *argv[]) | ||||
|   const char *pMode; | ||||
|   FILE *pInfile, *pOutfile; | ||||
|   uint infile_size; | ||||
|   int level = Z_BEST_COMPRESSION; | ||||
|   z_stream stream; | ||||
|    | ||||
|   if (argc != 4) | ||||
|   int p = 1; | ||||
|   const char *pSrc_filename; | ||||
|   const char *pDst_filename; | ||||
|   long file_loc; | ||||
|  | ||||
|   printf("miniz.c version: %s\n", MZ_VERSION); | ||||
|  | ||||
|   if (argc < 4) | ||||
|   { | ||||
|     printf("Usage: example3 [c/d] infile outfile\n"); | ||||
|     printf("Usage: example3 [options] [mode:c or d] infile outfile\n"); | ||||
|     printf("\nModes:\n"); | ||||
|     printf("c - Compresses file infile to a zlib stream in file outfile\n"); | ||||
|     printf("d - Decompress zlib stream in file infile to file outfile\n"); | ||||
|     printf("\nOptions:\n"); | ||||
|     printf("-l[0-10] - Compression level, higher values are slower.\n"); | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|  | ||||
|   pMode = argv[1]; | ||||
|    | ||||
|   while ((p < argc) && (argv[p][0] == '-')) | ||||
|   { | ||||
|     switch (argv[p][1]) | ||||
|     { | ||||
|       case 'l': | ||||
|       { | ||||
|         level = atoi(&argv[1][2]); | ||||
|         if ((level < 0) || (level > 10)) | ||||
|         { | ||||
|           printf("Invalid level!\n"); | ||||
|           return EXIT_FAILURE; | ||||
|         } | ||||
|         break; | ||||
|       } | ||||
|       default: | ||||
|       { | ||||
|         printf("Invalid option: %s\n", argv[p]); | ||||
|         return EXIT_FAILURE; | ||||
|       } | ||||
|     } | ||||
|     p++; | ||||
|   } | ||||
|  | ||||
|   if ((argc - p) < 3) | ||||
|   { | ||||
|     printf("Must specify mode, input filename, and output filename after options!\n"); | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|   else if ((argc - p) > 3) | ||||
|   { | ||||
|     printf("Too many filenames!\n"); | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|  | ||||
|   pMode = argv[p++]; | ||||
|   if (!strchr("cCdD", pMode[0])) | ||||
|   { | ||||
|     printf("Invalid mode!\n"); | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|  | ||||
|   pSrc_filename = argv[p++]; | ||||
|   pDst_filename = argv[p++]; | ||||
|  | ||||
|   printf("Mode: %c, Level: %u\nInput File: \"%s\"\nOutput File: \"%s\"\n", pMode[0], level, pSrc_filename, pDst_filename); | ||||
|  | ||||
|   // Open input file. | ||||
|   pInfile = fopen(argv[2], "rb"); | ||||
|   pInfile = fopen(pSrc_filename, "rb"); | ||||
|   if (!pInfile) | ||||
|   { | ||||
|     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; | ||||
|  | ||||
|   // Open output file. | ||||
|   pOutfile = fopen(argv[3], "wb"); | ||||
|   pOutfile = fopen(pDst_filename, "wb"); | ||||
|   if (!pOutfile) | ||||
|   { | ||||
|     printf("Failed opening output file!\n"); | ||||
| @@ -53,7 +117,7 @@ int main(int argc, char *argv[]) | ||||
|   } | ||||
|  | ||||
|   printf("Input file size: %u\n", infile_size); | ||||
|    | ||||
|  | ||||
|   // Init the z_stream | ||||
|   memset(&stream, 0, sizeof(stream)); | ||||
|   stream.next_in = s_inbuf; | ||||
| @@ -66,7 +130,7 @@ int main(int argc, char *argv[]) | ||||
|     // Compression. | ||||
|     uint infile_remaining = infile_size; | ||||
|  | ||||
|     if (deflateInit(&stream, Z_BEST_COMPRESSION) != Z_OK) | ||||
|     if (deflateInit(&stream, level) != Z_OK) | ||||
|     { | ||||
|       printf("deflateInit() failed!\n"); | ||||
|       return EXIT_FAILURE; | ||||
| @@ -79,18 +143,18 @@ int main(int argc, char *argv[]) | ||||
|       { | ||||
|         // Input buffer is empty, so read more bytes from input file. | ||||
|         uint n = my_min(BUF_SIZE, infile_remaining); | ||||
|                  | ||||
|  | ||||
|         if (fread(s_inbuf, 1, n, pInfile) != n) | ||||
|         { | ||||
|           printf("Failed reading from input file!\n"); | ||||
|           return EXIT_FAILURE; | ||||
|         } | ||||
|          | ||||
|  | ||||
|         stream.next_in = s_inbuf; | ||||
|         stream.avail_in = n; | ||||
|          | ||||
|  | ||||
|         infile_remaining -= n; | ||||
|         printf("Input bytes remaining: %u\n", infile_remaining); | ||||
|         //printf("Input bytes remaining: %u\n", infile_remaining); | ||||
|       } | ||||
|  | ||||
|       status = deflate(&stream, infile_remaining ? Z_NO_FLUSH : Z_FINISH); | ||||
| @@ -182,7 +246,7 @@ int main(int argc, char *argv[]) | ||||
|     { | ||||
|       printf("inflateEnd() failed!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|     }       | ||||
|     } | ||||
|   } | ||||
|   else | ||||
|   { | ||||
| @@ -197,8 +261,8 @@ int main(int argc, char *argv[]) | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|  | ||||
|   printf("Total input bytes: %u\n", stream.total_in); | ||||
|   printf("Total output bytes: %u\n", stream.total_out); | ||||
|   printf("Total input bytes: %u\n", (mz_uint32)stream.total_in); | ||||
|   printf("Total output bytes: %u\n", (mz_uint32)stream.total_out); | ||||
|   printf("Success.\n"); | ||||
|   return EXIT_SUCCESS; | ||||
| } | ||||
|   | ||||
							
								
								
									
										88
									
								
								example3.cbp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								example3.cbp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||||
| <CodeBlocks_project_file> | ||||
| 	<FileVersion major="1" minor="6" /> | ||||
| 	<Project> | ||||
| 		<Option title="example3" /> | ||||
| 		<Option pch_mode="2" /> | ||||
| 		<Option compiler="gcc" /> | ||||
| 		<Build> | ||||
| 			<Target title="Debug Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example3D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example3\Debug Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-O0" /> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-g" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Debug x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example3_x64D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example3\Debug x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O0" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 			<Target title="Release Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example3" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example3\Release Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O3" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-s" /> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Release x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example3_x64" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example3\Release x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O3" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 		</Build> | ||||
| 		<Unit filename="example3.c"> | ||||
| 			<Option compilerVar="CC" /> | ||||
| 		</Unit> | ||||
| 		<Extensions> | ||||
| 			<code_completion /> | ||||
| 			<debugger /> | ||||
| 		</Extensions> | ||||
| 	</Project> | ||||
| </CodeBlocks_project_file> | ||||
| @@ -22,7 +22,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Debug|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| @@ -94,7 +94,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Debug|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| @@ -167,7 +167,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Release|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
| @@ -244,7 +244,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Release|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
|   | ||||
							
								
								
									
										21
									
								
								example4.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								example4.c
									
									
									
									
									
								
							| @@ -1,7 +1,8 @@ | ||||
| // example4.c - Uses tinfl.c to decompress a zlib stream in memory to an output file | ||||
| // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com | ||||
| // 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) | ||||
|   | ||||
							
								
								
									
										88
									
								
								example4.cbp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								example4.cbp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||||
| <CodeBlocks_project_file> | ||||
| 	<FileVersion major="1" minor="6" /> | ||||
| 	<Project> | ||||
| 		<Option title="example4" /> | ||||
| 		<Option pch_mode="2" /> | ||||
| 		<Option compiler="gcc" /> | ||||
| 		<Build> | ||||
| 			<Target title="Debug Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example4D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example4\Debug Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-O0" /> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-g" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Debug x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example4_x64D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example4\Debug x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O0" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 			<Target title="Release Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example4" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example4\Release Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O3" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-s" /> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Release x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example4_x64" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example4\Release x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O3" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 		</Build> | ||||
| 		<Unit filename="example4.c"> | ||||
| 			<Option compilerVar="CC" /> | ||||
| 		</Unit> | ||||
| 		<Extensions> | ||||
| 			<code_completion /> | ||||
| 			<debugger /> | ||||
| 		</Extensions> | ||||
| 	</Project> | ||||
| </CodeBlocks_project_file> | ||||
| @@ -22,7 +22,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Debug|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| @@ -94,7 +94,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Debug|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| @@ -167,7 +167,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Release|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
| @@ -244,7 +244,7 @@ | ||||
| 		<Configuration | ||||
| 			Name="Release|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
|   | ||||
							
								
								
									
										327
									
								
								example5.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										327
									
								
								example5.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,327 @@ | ||||
| // example5.c - Demonstrates how to use miniz.c's low-level tdefl_compress() and tinfl_inflate() API's for simple file to file compression/decompression. | ||||
| // The low-level API's are the fastest, make no use of dynamic memory allocation, and are the most flexible functions exposed by miniz.c. | ||||
| // Public domain, April 11 2012, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c. | ||||
| // For simplicity, this example is limited to files smaller than 4GB, but this is not a limitation of miniz.c. | ||||
|  | ||||
| // Purposely disable a whole bunch of stuff this low-level example doesn't use. | ||||
| #define MINIZ_NO_STDIO | ||||
| #define MINIZ_NO_ARCHIVE_APIS | ||||
| #define MINIZ_NO_TIME | ||||
| #define MINIZ_NO_ZLIB_APIS | ||||
| #define MINIZ_NO_MALLOC | ||||
| #include "miniz.c" | ||||
|  | ||||
| // Now include stdio.h because this test uses fopen(), etc. (but we still don't want miniz.c's stdio stuff, for testing). | ||||
| #include <stdio.h> | ||||
| #include <limits.h> | ||||
|  | ||||
| typedef unsigned char uint8; | ||||
| typedef unsigned short uint16; | ||||
| typedef unsigned int uint; | ||||
|  | ||||
| #define my_max(a,b) (((a) > (b)) ? (a) : (b)) | ||||
| #define my_min(a,b) (((a) < (b)) ? (a) : (b)) | ||||
|  | ||||
| // IN_BUF_SIZE is the size of the file read buffer. | ||||
| // IN_BUF_SIZE must be >= 1 | ||||
| #define IN_BUF_SIZE (1024*512) | ||||
| static uint8 s_inbuf[IN_BUF_SIZE]; | ||||
|  | ||||
| // COMP_OUT_BUF_SIZE is the size of the output buffer used during compression. | ||||
| // COMP_OUT_BUF_SIZE must be >= 1 and <= OUT_BUF_SIZE | ||||
| #define COMP_OUT_BUF_SIZE (1024*512) | ||||
|  | ||||
| // OUT_BUF_SIZE is the size of the output buffer used during decompression. | ||||
| // OUT_BUF_SIZE must be a power of 2 >= TINFL_LZ_DICT_SIZE (because the low-level decompressor not only writes, but reads from the output buffer as it decompresses) | ||||
| //#define OUT_BUF_SIZE (TINFL_LZ_DICT_SIZE) | ||||
| #define OUT_BUF_SIZE (1024*512) | ||||
| static uint8 s_outbuf[OUT_BUF_SIZE]; | ||||
|  | ||||
| // tdefl_compressor contains all the state needed by the low-level compressor so it's a pretty big struct (~300k). | ||||
| // This example makes it a global vs. putting it on the stack, of course in real-world usage you'll probably malloc() or new it. | ||||
| tdefl_compressor g_deflator; | ||||
|  | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
|    const char *pMode; | ||||
|    FILE *pInfile, *pOutfile; | ||||
|    uint infile_size; | ||||
|    int level = 9; | ||||
|    int p = 1; | ||||
|    const char *pSrc_filename; | ||||
|    const char *pDst_filename; | ||||
|    const void *next_in = s_inbuf; | ||||
|    size_t avail_in = 0; | ||||
|    void *next_out = s_outbuf; | ||||
|    size_t avail_out = OUT_BUF_SIZE; | ||||
|    size_t total_in = 0, total_out = 0; | ||||
|    long file_loc; | ||||
|  | ||||
|    assert(COMP_OUT_BUF_SIZE <= OUT_BUF_SIZE); | ||||
|  | ||||
|    printf("miniz.c example5 (demonstrates tinfl/tdefl)\n"); | ||||
|  | ||||
|    if (argc < 4) | ||||
|    { | ||||
|       printf("File to file compression/decompression using the low-level tinfl/tdefl API's.\n"); | ||||
|       printf("Usage: example5 [options] [mode:c or d] infile outfile\n"); | ||||
|       printf("\nModes:\n"); | ||||
|       printf("c - Compresses file infile to a zlib stream in file outfile\n"); | ||||
|       printf("d - Decompress zlib stream in file infile to file outfile\n"); | ||||
|       printf("\nOptions:\n"); | ||||
|       printf("-l[0-10] - Compression level, higher values are slower, 0 is none.\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    while ((p < argc) && (argv[p][0] == '-')) | ||||
|    { | ||||
|       switch (argv[p][1]) | ||||
|       { | ||||
|          case 'l': | ||||
|          { | ||||
|             level = atoi(&argv[1][2]); | ||||
|             if ((level < 0) || (level > 10)) | ||||
|             { | ||||
|                printf("Invalid level!\n"); | ||||
|                return EXIT_FAILURE; | ||||
|             } | ||||
|             break; | ||||
|          } | ||||
|          default: | ||||
|          { | ||||
|             printf("Invalid option: %s\n", argv[p]); | ||||
|             return EXIT_FAILURE; | ||||
|          } | ||||
|       } | ||||
|       p++; | ||||
|    } | ||||
|  | ||||
|    if ((argc - p) < 3) | ||||
|    { | ||||
|       printf("Must specify mode, input filename, and output filename after options!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|    else if ((argc - p) > 3) | ||||
|    { | ||||
|       printf("Too many filenames!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    pMode = argv[p++]; | ||||
|    if (!strchr("cCdD", pMode[0])) | ||||
|    { | ||||
|       printf("Invalid mode!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    pSrc_filename = argv[p++]; | ||||
|    pDst_filename = argv[p++]; | ||||
|  | ||||
|    printf("Mode: %c, Level: %u\nInput File: \"%s\"\nOutput File: \"%s\"\n", pMode[0], level, pSrc_filename, pDst_filename); | ||||
|  | ||||
|    // Open input file. | ||||
|    pInfile = fopen(pSrc_filename, "rb"); | ||||
|    if (!pInfile) | ||||
|    { | ||||
|       printf("Failed opening input file!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    // Determine input file's size. | ||||
|    fseek(pInfile, 0, SEEK_END); | ||||
|    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; | ||||
|  | ||||
|    // Open output file. | ||||
|    pOutfile = fopen(pDst_filename, "wb"); | ||||
|    if (!pOutfile) | ||||
|    { | ||||
|       printf("Failed opening output file!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    printf("Input file size: %u\n", infile_size); | ||||
|  | ||||
|    if ((pMode[0] == 'c') || (pMode[0] == 'C')) | ||||
|    { | ||||
|       // The number of dictionary probes to use at each compression level (0-10). 0=implies fastest/minimal possible probing. | ||||
|       static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32,  16, 32, 128, 256,  512, 768, 1500 }; | ||||
|  | ||||
|       tdefl_status status; | ||||
|       uint infile_remaining = infile_size; | ||||
|  | ||||
|       // create tdefl() compatible flags (we have to compose the low-level flags ourselves, or use tdefl_create_comp_flags_from_zip_params() but that means MINIZ_NO_ZLIB_APIS can't be defined). | ||||
|       mz_uint comp_flags = TDEFL_WRITE_ZLIB_HEADER | s_tdefl_num_probes[MZ_MIN(10, level)] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0); | ||||
|       if (!level) | ||||
|          comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS; | ||||
|  | ||||
|       // Initialize the low-level compressor. | ||||
|       status = tdefl_init(&g_deflator, NULL, NULL, comp_flags); | ||||
|       if (status != TDEFL_STATUS_OKAY) | ||||
|       { | ||||
|          printf("tdefl_init() failed!\n"); | ||||
|          return EXIT_FAILURE; | ||||
|       } | ||||
|  | ||||
|       avail_out = COMP_OUT_BUF_SIZE; | ||||
|  | ||||
|       // Compression. | ||||
|       for ( ; ; ) | ||||
|       { | ||||
|          size_t in_bytes, out_bytes; | ||||
|  | ||||
|          if (!avail_in) | ||||
|          { | ||||
|             // Input buffer is empty, so read more bytes from input file. | ||||
|             uint n = my_min(IN_BUF_SIZE, infile_remaining); | ||||
|  | ||||
|             if (fread(s_inbuf, 1, n, pInfile) != n) | ||||
|             { | ||||
|                printf("Failed reading from input file!\n"); | ||||
|                return EXIT_FAILURE; | ||||
|             } | ||||
|  | ||||
|             next_in = s_inbuf; | ||||
|             avail_in = n; | ||||
|  | ||||
|             infile_remaining -= n; | ||||
|             //printf("Input bytes remaining: %u\n", infile_remaining); | ||||
|          } | ||||
|  | ||||
|          in_bytes = avail_in; | ||||
|          out_bytes = avail_out; | ||||
|          // Compress as much of the input as possible (or all of it) to the output buffer. | ||||
|          status = tdefl_compress(&g_deflator, next_in, &in_bytes, next_out, &out_bytes, infile_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); | ||||
|  | ||||
|          next_in = (const char *)next_in + in_bytes; | ||||
|          avail_in -= in_bytes; | ||||
|          total_in += in_bytes; | ||||
|  | ||||
|          next_out = (char *)next_out + out_bytes; | ||||
|          avail_out -= out_bytes; | ||||
|          total_out += out_bytes; | ||||
|  | ||||
|          if ((status != TDEFL_STATUS_OKAY) || (!avail_out)) | ||||
|          { | ||||
|             // Output buffer is full, or compression is done or failed, so write buffer to output file. | ||||
|             uint n = COMP_OUT_BUF_SIZE - (uint)avail_out; | ||||
|             if (fwrite(s_outbuf, 1, n, pOutfile) != n) | ||||
|             { | ||||
|                printf("Failed writing to output file!\n"); | ||||
|                return EXIT_FAILURE; | ||||
|             } | ||||
|             next_out = s_outbuf; | ||||
|             avail_out = COMP_OUT_BUF_SIZE; | ||||
|          } | ||||
|  | ||||
|          if (status == TDEFL_STATUS_DONE) | ||||
|          { | ||||
|             // Compression completed successfully. | ||||
|             break; | ||||
|          } | ||||
|          else if (status != TDEFL_STATUS_OKAY) | ||||
|          { | ||||
|             // Compression somehow failed. | ||||
|             printf("tdefl_compress() failed with status %i!\n", status); | ||||
|             return EXIT_FAILURE; | ||||
|          } | ||||
|       } | ||||
|    } | ||||
|    else if ((pMode[0] == 'd') || (pMode[0] == 'D')) | ||||
|    { | ||||
|       // Decompression. | ||||
|       uint infile_remaining = infile_size; | ||||
|  | ||||
|       tinfl_decompressor inflator; | ||||
|       tinfl_init(&inflator); | ||||
|  | ||||
|       for ( ; ; ) | ||||
|       { | ||||
|          size_t in_bytes, out_bytes; | ||||
|          tinfl_status status; | ||||
|          if (!avail_in) | ||||
|          { | ||||
|             // Input buffer is empty, so read more bytes from input file. | ||||
|             uint n = my_min(IN_BUF_SIZE, infile_remaining); | ||||
|  | ||||
|             if (fread(s_inbuf, 1, n, pInfile) != n) | ||||
|             { | ||||
|                printf("Failed reading from input file!\n"); | ||||
|                return EXIT_FAILURE; | ||||
|             } | ||||
|  | ||||
|             next_in = s_inbuf; | ||||
|             avail_in = n; | ||||
|  | ||||
|             infile_remaining -= n; | ||||
|          } | ||||
|  | ||||
|          in_bytes = avail_in; | ||||
|          out_bytes = avail_out; | ||||
|          status = tinfl_decompress(&inflator, (const mz_uint8 *)next_in, &in_bytes, s_outbuf, (mz_uint8 *)next_out, &out_bytes, (infile_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0) | TINFL_FLAG_PARSE_ZLIB_HEADER); | ||||
|  | ||||
|          avail_in -= in_bytes; | ||||
|          next_in = (const mz_uint8 *)next_in + in_bytes; | ||||
|          total_in += in_bytes; | ||||
|  | ||||
|          avail_out -= out_bytes; | ||||
|          next_out = (mz_uint8 *)next_out + out_bytes; | ||||
|          total_out += out_bytes; | ||||
|  | ||||
|          if ((status <= TINFL_STATUS_DONE) || (!avail_out)) | ||||
|          { | ||||
|             // Output buffer is full, or decompression is done, so write buffer to output file. | ||||
|             uint n = OUT_BUF_SIZE - (uint)avail_out; | ||||
|             if (fwrite(s_outbuf, 1, n, pOutfile) != n) | ||||
|             { | ||||
|                printf("Failed writing to output file!\n"); | ||||
|                return EXIT_FAILURE; | ||||
|             } | ||||
|             next_out = s_outbuf; | ||||
|             avail_out = OUT_BUF_SIZE; | ||||
|          } | ||||
|  | ||||
|          // If status is <= TINFL_STATUS_DONE then either decompression is done or something went wrong. | ||||
|          if (status <= TINFL_STATUS_DONE) | ||||
|          { | ||||
|             if (status == TINFL_STATUS_DONE) | ||||
|             { | ||||
|                // Decompression completed successfully. | ||||
|                break; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                // Decompression failed. | ||||
|                printf("tinfl_decompress() failed with status %i!\n", status); | ||||
|                return EXIT_FAILURE; | ||||
|             } | ||||
|          } | ||||
|       } | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       printf("Invalid mode!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    fclose(pInfile); | ||||
|    if (EOF == fclose(pOutfile)) | ||||
|    { | ||||
|       printf("Failed writing to output file!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    printf("Total input bytes: %u\n", (mz_uint32)total_in); | ||||
|    printf("Total output bytes: %u\n", (mz_uint32)total_out); | ||||
|    printf("Success.\n"); | ||||
|    return EXIT_SUCCESS; | ||||
| } | ||||
							
								
								
									
										88
									
								
								example5.cbp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								example5.cbp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||||
| <CodeBlocks_project_file> | ||||
| 	<FileVersion major="1" minor="6" /> | ||||
| 	<Project> | ||||
| 		<Option title="example5" /> | ||||
| 		<Option pch_mode="2" /> | ||||
| 		<Option compiler="gcc" /> | ||||
| 		<Build> | ||||
| 			<Target title="Debug Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example5D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example5\Debug Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-O0" /> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-g" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Debug x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example5_x64D" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example5\Debug x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-D_DEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O0" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 			<Target title="Release Win32"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example5" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example5\Release Win32_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-m32" /> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O3" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-s" /> | ||||
| 					<Add option="-m32" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 			<Target title="Release x64"> | ||||
| 				<Option output="$(SolutionDir)bin_mingw\example5_x64" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option working_dir="$(SolutionDir)bin_mingw" /> | ||||
| 				<Option object_output="example5\Release x64_Win32" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-DWIN32" /> | ||||
| 					<Add option="-DNDEBUG" /> | ||||
| 					<Add option="-D_CONSOLE" /> | ||||
| 					<Add option="-D_CRT_SECURE_NO_WARNINGS" /> | ||||
| 					<Add option="-Wall" /> | ||||
| 					<Add option="-O3" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 		</Build> | ||||
| 		<Unit filename="example5.c"> | ||||
| 			<Option compilerVar="CC" /> | ||||
| 		</Unit> | ||||
| 		<Extensions> | ||||
| 			<code_completion /> | ||||
| 			<debugger /> | ||||
| 		</Extensions> | ||||
| 	</Project> | ||||
| </CodeBlocks_project_file> | ||||
							
								
								
									
										346
									
								
								example5.vcproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										346
									
								
								example5.vcproj
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,346 @@ | ||||
| <?xml version="1.0" encoding="Windows-1252"?> | ||||
| <VisualStudioProject | ||||
| 	ProjectType="Visual C++" | ||||
| 	Version="9.00" | ||||
| 	Name="example5" | ||||
| 	ProjectGUID="{AE293522-92D8-4B60-95C7-B4AEE10A303F}" | ||||
| 	RootNamespace="example5" | ||||
| 	Keyword="Win32Proj" | ||||
| 	TargetFrameworkVersion="196613" | ||||
| 	> | ||||
| 	<Platforms> | ||||
| 		<Platform | ||||
| 			Name="Win32" | ||||
| 		/> | ||||
| 		<Platform | ||||
| 			Name="x64" | ||||
| 		/> | ||||
| 	</Platforms> | ||||
| 	<ToolFiles> | ||||
| 	</ToolFiles> | ||||
| 	<Configurations> | ||||
| 		<Configuration | ||||
| 			Name="Debug|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| 			<Tool | ||||
| 				Name="VCPreBuildEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCustomBuildTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXMLDataGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCWebServiceProxyGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCMIDLTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCLCompilerTool" | ||||
| 				Optimization="0" | ||||
| 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" | ||||
| 				MinimalRebuild="true" | ||||
| 				BasicRuntimeChecks="3" | ||||
| 				RuntimeLibrary="1" | ||||
| 				UsePrecompiledHeader="0" | ||||
| 				WarningLevel="4" | ||||
| 				DebugInformationFormat="4" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManagedResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPreLinkEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCLinkerTool" | ||||
| 				OutputFile="$(OutDir)\$(ProjectName)D.exe" | ||||
| 				LinkIncremental="2" | ||||
| 				GenerateDebugInformation="true" | ||||
| 				SubSystem="1" | ||||
| 				TargetMachine="1" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCALinkTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManifestTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXDCMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCBscMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCFxCopTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCAppVerifierTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPostBuildEventTool" | ||||
| 			/> | ||||
| 		</Configuration> | ||||
| 		<Configuration | ||||
| 			Name="Debug|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| 			<Tool | ||||
| 				Name="VCPreBuildEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCustomBuildTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXMLDataGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCWebServiceProxyGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCMIDLTool" | ||||
| 				TargetEnvironment="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCLCompilerTool" | ||||
| 				Optimization="0" | ||||
| 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" | ||||
| 				MinimalRebuild="true" | ||||
| 				BasicRuntimeChecks="3" | ||||
| 				RuntimeLibrary="1" | ||||
| 				UsePrecompiledHeader="0" | ||||
| 				WarningLevel="4" | ||||
| 				DebugInformationFormat="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManagedResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPreLinkEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCLinkerTool" | ||||
| 				OutputFile="$(OutDir)\$(ProjectName)_x64D.exe" | ||||
| 				LinkIncremental="2" | ||||
| 				GenerateDebugInformation="true" | ||||
| 				SubSystem="1" | ||||
| 				TargetMachine="17" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCALinkTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManifestTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXDCMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCBscMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCFxCopTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCAppVerifierTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPostBuildEventTool" | ||||
| 			/> | ||||
| 		</Configuration> | ||||
| 		<Configuration | ||||
| 			Name="Release|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
| 			> | ||||
| 			<Tool | ||||
| 				Name="VCPreBuildEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCustomBuildTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXMLDataGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCWebServiceProxyGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCMIDLTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCLCompilerTool" | ||||
| 				Optimization="3" | ||||
| 				InlineFunctionExpansion="2" | ||||
| 				EnableIntrinsicFunctions="true" | ||||
| 				FavorSizeOrSpeed="1" | ||||
| 				OmitFramePointers="true" | ||||
| 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" | ||||
| 				RuntimeLibrary="0" | ||||
| 				EnableFunctionLevelLinking="true" | ||||
| 				UsePrecompiledHeader="0" | ||||
| 				WarningLevel="4" | ||||
| 				DebugInformationFormat="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManagedResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPreLinkEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCLinkerTool" | ||||
| 				LinkIncremental="1" | ||||
| 				GenerateDebugInformation="true" | ||||
| 				SubSystem="1" | ||||
| 				OptimizeReferences="2" | ||||
| 				EnableCOMDATFolding="2" | ||||
| 				TargetMachine="1" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCALinkTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManifestTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXDCMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCBscMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCFxCopTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCAppVerifierTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPostBuildEventTool" | ||||
| 			/> | ||||
| 		</Configuration> | ||||
| 		<Configuration | ||||
| 			Name="Release|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
| 			> | ||||
| 			<Tool | ||||
| 				Name="VCPreBuildEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCustomBuildTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXMLDataGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCWebServiceProxyGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCMIDLTool" | ||||
| 				TargetEnvironment="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCLCompilerTool" | ||||
| 				Optimization="3" | ||||
| 				InlineFunctionExpansion="2" | ||||
| 				EnableIntrinsicFunctions="true" | ||||
| 				FavorSizeOrSpeed="1" | ||||
| 				OmitFramePointers="true" | ||||
| 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" | ||||
| 				RuntimeLibrary="0" | ||||
| 				EnableFunctionLevelLinking="true" | ||||
| 				UsePrecompiledHeader="0" | ||||
| 				WarningLevel="4" | ||||
| 				DebugInformationFormat="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManagedResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPreLinkEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCLinkerTool" | ||||
| 				OutputFile="$(OutDir)\$(ProjectName)_x64.exe" | ||||
| 				LinkIncremental="1" | ||||
| 				GenerateDebugInformation="true" | ||||
| 				SubSystem="1" | ||||
| 				OptimizeReferences="2" | ||||
| 				EnableCOMDATFolding="2" | ||||
| 				TargetMachine="17" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCALinkTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManifestTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXDCMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCBscMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCFxCopTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCAppVerifierTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPostBuildEventTool" | ||||
| 			/> | ||||
| 		</Configuration> | ||||
| 	</Configurations> | ||||
| 	<References> | ||||
| 	</References> | ||||
| 	<Files> | ||||
| 		<Filter | ||||
| 			Name="Source Files" | ||||
| 			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" | ||||
| 			UniqueIdentifier="{4FD737F1-C7A5-4376-A066-2A32D752A31F}" | ||||
| 			> | ||||
| 			<File | ||||
| 				RelativePath=".\example5.c" | ||||
| 				> | ||||
| 			</File> | ||||
| 		</Filter> | ||||
| 		<Filter | ||||
| 			Name="Resource Files" | ||||
| 			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" | ||||
| 			UniqueIdentifier="{17DA6AB6-F800-4c08-8B7A-83BB121AAC02}" | ||||
| 			> | ||||
| 		</Filter> | ||||
| 	</Files> | ||||
| 	<Globals> | ||||
| 	</Globals> | ||||
| </VisualStudioProject> | ||||
							
								
								
									
										20
									
								
								examples.sln
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								examples.sln
									
									
									
									
									
								
							| @@ -9,6 +9,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example3", "example3.vcproj | ||||
| EndProject | ||||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example4", "example4.vcproj", "{AE293522-92D8-4B60-95C7-C3AEE10A303F}" | ||||
| EndProject | ||||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example5", "example5.vcproj", "{AE293522-92D8-4B60-95C7-B4AEE10A303F}" | ||||
| EndProject | ||||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniz_tester", "miniz_tester.vcproj", "{AE293522-92D9-1B60-95C7-B4AEE10A303F}" | ||||
| EndProject | ||||
| Global | ||||
| 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
| 		Debug|Win32 = Debug|Win32 | ||||
| @@ -49,6 +53,22 @@ Global | ||||
| 		{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.Build.0 = Release|Win32 | ||||
| 		{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.ActiveCfg = Release|x64 | ||||
| 		{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.Build.0 = Release|x64 | ||||
| 		{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32 | ||||
| 		{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32 | ||||
| 		{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64 | ||||
| 		{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|x64.Build.0 = Debug|x64 | ||||
| 		{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32 | ||||
| 		{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|Win32.Build.0 = Release|Win32 | ||||
| 		{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|x64.ActiveCfg = Release|x64 | ||||
| 		{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|x64.Build.0 = Release|x64 | ||||
| 		{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32 | ||||
| 		{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32 | ||||
| 		{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64 | ||||
| 		{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|x64.Build.0 = Debug|x64 | ||||
| 		{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32 | ||||
| 		{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|Win32.Build.0 = Release|Win32 | ||||
| 		{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|x64.ActiveCfg = Release|x64 | ||||
| 		{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|x64.Build.0 = Release|x64 | ||||
| 	EndGlobalSection | ||||
| 	GlobalSection(SolutionProperties) = preSolution | ||||
| 		HideSolutionNode = FALSE | ||||
|   | ||||
							
								
								
									
										10
									
								
								examples.workspace
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								examples.workspace
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||||
| <CodeBlocks_workspace_file> | ||||
| 	<Workspace title="Workspace"> | ||||
| 		<Project filename="example1.cbp" /> | ||||
| 		<Project filename="example2.cbp" active="1" /> | ||||
| 		<Project filename="example3.cbp" /> | ||||
| 		<Project filename="example4.cbp" /> | ||||
| 		<Project filename="example5.cbp" /> | ||||
| 	</Workspace> | ||||
| </CodeBlocks_workspace_file> | ||||
							
								
								
									
										1804
									
								
								miniz_tester.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1804
									
								
								miniz_tester.cpp
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										358
									
								
								miniz_tester.vcproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										358
									
								
								miniz_tester.vcproj
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,358 @@ | ||||
| <?xml version="1.0" encoding="Windows-1252"?> | ||||
| <VisualStudioProject | ||||
| 	ProjectType="Visual C++" | ||||
| 	Version="9.00" | ||||
| 	Name="miniz_tester" | ||||
| 	ProjectGUID="{AE293522-92D9-1B60-95C7-B4AEE10A303F}" | ||||
| 	RootNamespace="miniz_tester" | ||||
| 	Keyword="Win32Proj" | ||||
| 	TargetFrameworkVersion="196613" | ||||
| 	> | ||||
| 	<Platforms> | ||||
| 		<Platform | ||||
| 			Name="Win32" | ||||
| 		/> | ||||
| 		<Platform | ||||
| 			Name="x64" | ||||
| 		/> | ||||
| 	</Platforms> | ||||
| 	<ToolFiles> | ||||
| 	</ToolFiles> | ||||
| 	<Configurations> | ||||
| 		<Configuration | ||||
| 			Name="Debug|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| 			<Tool | ||||
| 				Name="VCPreBuildEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCustomBuildTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXMLDataGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCWebServiceProxyGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCMIDLTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCLCompilerTool" | ||||
| 				Optimization="0" | ||||
| 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" | ||||
| 				MinimalRebuild="true" | ||||
| 				BasicRuntimeChecks="3" | ||||
| 				RuntimeLibrary="1" | ||||
| 				UsePrecompiledHeader="0" | ||||
| 				WarningLevel="4" | ||||
| 				DebugInformationFormat="4" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManagedResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPreLinkEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCLinkerTool" | ||||
| 				OutputFile="$(OutDir)\$(ProjectName)D.exe" | ||||
| 				LinkIncremental="2" | ||||
| 				GenerateDebugInformation="true" | ||||
| 				SubSystem="1" | ||||
| 				TargetMachine="1" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCALinkTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManifestTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXDCMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCBscMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCFxCopTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCAppVerifierTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPostBuildEventTool" | ||||
| 			/> | ||||
| 		</Configuration> | ||||
| 		<Configuration | ||||
| 			Name="Debug|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			> | ||||
| 			<Tool | ||||
| 				Name="VCPreBuildEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCustomBuildTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXMLDataGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCWebServiceProxyGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCMIDLTool" | ||||
| 				TargetEnvironment="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCLCompilerTool" | ||||
| 				Optimization="0" | ||||
| 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" | ||||
| 				MinimalRebuild="true" | ||||
| 				BasicRuntimeChecks="3" | ||||
| 				RuntimeLibrary="1" | ||||
| 				UsePrecompiledHeader="0" | ||||
| 				WarningLevel="4" | ||||
| 				DebugInformationFormat="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManagedResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPreLinkEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCLinkerTool" | ||||
| 				OutputFile="$(OutDir)\$(ProjectName)_x64D.exe" | ||||
| 				LinkIncremental="2" | ||||
| 				GenerateDebugInformation="true" | ||||
| 				SubSystem="1" | ||||
| 				TargetMachine="17" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCALinkTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManifestTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXDCMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCBscMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCFxCopTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCAppVerifierTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPostBuildEventTool" | ||||
| 			/> | ||||
| 		</Configuration> | ||||
| 		<Configuration | ||||
| 			Name="Release|Win32" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
| 			> | ||||
| 			<Tool | ||||
| 				Name="VCPreBuildEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCustomBuildTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXMLDataGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCWebServiceProxyGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCMIDLTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCLCompilerTool" | ||||
| 				Optimization="3" | ||||
| 				InlineFunctionExpansion="2" | ||||
| 				EnableIntrinsicFunctions="true" | ||||
| 				FavorSizeOrSpeed="1" | ||||
| 				OmitFramePointers="true" | ||||
| 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" | ||||
| 				RuntimeLibrary="0" | ||||
| 				EnableFunctionLevelLinking="true" | ||||
| 				UsePrecompiledHeader="0" | ||||
| 				WarningLevel="4" | ||||
| 				DebugInformationFormat="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManagedResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPreLinkEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCLinkerTool" | ||||
| 				LinkIncremental="1" | ||||
| 				GenerateDebugInformation="true" | ||||
| 				SubSystem="1" | ||||
| 				OptimizeReferences="2" | ||||
| 				EnableCOMDATFolding="2" | ||||
| 				TargetMachine="1" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCALinkTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManifestTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXDCMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCBscMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCFxCopTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCAppVerifierTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPostBuildEventTool" | ||||
| 			/> | ||||
| 		</Configuration> | ||||
| 		<Configuration | ||||
| 			Name="Release|x64" | ||||
| 			OutputDirectory="$(SolutionDir)bin" | ||||
| 			IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)" | ||||
| 			ConfigurationType="1" | ||||
| 			CharacterSet="1" | ||||
| 			WholeProgramOptimization="1" | ||||
| 			> | ||||
| 			<Tool | ||||
| 				Name="VCPreBuildEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCustomBuildTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXMLDataGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCWebServiceProxyGeneratorTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCMIDLTool" | ||||
| 				TargetEnvironment="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCCLCompilerTool" | ||||
| 				Optimization="3" | ||||
| 				InlineFunctionExpansion="2" | ||||
| 				EnableIntrinsicFunctions="true" | ||||
| 				FavorSizeOrSpeed="1" | ||||
| 				OmitFramePointers="true" | ||||
| 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" | ||||
| 				RuntimeLibrary="0" | ||||
| 				EnableFunctionLevelLinking="true" | ||||
| 				UsePrecompiledHeader="0" | ||||
| 				WarningLevel="4" | ||||
| 				DebugInformationFormat="3" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManagedResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCResourceCompilerTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPreLinkEventTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCLinkerTool" | ||||
| 				OutputFile="$(OutDir)\$(ProjectName)_x64.exe" | ||||
| 				LinkIncremental="1" | ||||
| 				GenerateDebugInformation="true" | ||||
| 				SubSystem="1" | ||||
| 				OptimizeReferences="2" | ||||
| 				EnableCOMDATFolding="2" | ||||
| 				TargetMachine="17" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCALinkTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCManifestTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCXDCMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCBscMakeTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCFxCopTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCAppVerifierTool" | ||||
| 			/> | ||||
| 			<Tool | ||||
| 				Name="VCPostBuildEventTool" | ||||
| 			/> | ||||
| 		</Configuration> | ||||
| 	</Configurations> | ||||
| 	<References> | ||||
| 	</References> | ||||
| 	<Files> | ||||
| 		<Filter | ||||
| 			Name="Source Files" | ||||
| 			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" | ||||
| 			UniqueIdentifier="{4FD737F1-C7A5-4376-A066-2A32D752A31F}" | ||||
| 			> | ||||
| 			<File | ||||
| 				RelativePath=".\miniz.c" | ||||
| 				> | ||||
| 			</File> | ||||
| 			<File | ||||
| 				RelativePath=".\miniz_tester.cpp" | ||||
| 				> | ||||
| 			</File> | ||||
| 			<File | ||||
| 				RelativePath=".\timer.cpp" | ||||
| 				> | ||||
| 			</File> | ||||
| 			<File | ||||
| 				RelativePath=".\timer.h" | ||||
| 				> | ||||
| 			</File> | ||||
| 		</Filter> | ||||
| 		<Filter | ||||
| 			Name="Resource Files" | ||||
| 			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" | ||||
| 			UniqueIdentifier="{17DA6AB6-F800-4c08-8B7A-83BB121AAC02}" | ||||
| 			> | ||||
| 		</Filter> | ||||
| 	</Files> | ||||
| 	<Globals> | ||||
| 	</Globals> | ||||
| </VisualStudioProject> | ||||
							
								
								
									
										152
									
								
								timer.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								timer.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,152 @@ | ||||
| // File: timer.cpp - Simple high-precision timer class. Supports Win32, X360, and POSIX/Linux | ||||
| #include <stdlib.h> | ||||
| #include <stdio.h> | ||||
| #include <assert.h> | ||||
| #include <time.h> | ||||
|  | ||||
| #include "timer.h" | ||||
|  | ||||
| #if defined(WIN32) | ||||
| #include <windows.h> | ||||
| #elif defined(_XBOX) | ||||
| #include <xtl.h> | ||||
| #endif | ||||
|  | ||||
| unsigned long long timer::g_init_ticks; | ||||
| unsigned long long timer::g_freq; | ||||
| double timer::g_inv_freq; | ||||
|  | ||||
| #if defined(WIN32) || defined(_XBOX) | ||||
| inline void query_counter(timer_ticks *pTicks) | ||||
| { | ||||
|    QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(pTicks)); | ||||
| } | ||||
| inline void query_counter_frequency(timer_ticks *pTicks) | ||||
| { | ||||
|    QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(pTicks)); | ||||
| } | ||||
| #elif defined(__GNUC__) | ||||
| #include <sys/timex.h> | ||||
| inline void query_counter(timer_ticks *pTicks) | ||||
| { | ||||
|    struct timeval cur_time; | ||||
|    gettimeofday(&cur_time, NULL); | ||||
|    *pTicks = static_cast<unsigned long long>(cur_time.tv_sec)*1000000ULL + static_cast<unsigned long long>(cur_time.tv_usec); | ||||
| } | ||||
| inline void query_counter_frequency(timer_ticks *pTicks) | ||||
| { | ||||
|    *pTicks = 1000000; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| timer::timer() : | ||||
|    m_start_time(0), | ||||
|    m_stop_time(0), | ||||
|    m_started(false), | ||||
|    m_stopped(false) | ||||
| { | ||||
|    if (!g_inv_freq) | ||||
|       init(); | ||||
| } | ||||
|  | ||||
| timer::timer(timer_ticks start_ticks) | ||||
| { | ||||
|    if (!g_inv_freq) | ||||
|       init(); | ||||
|  | ||||
|    m_start_time = start_ticks; | ||||
|  | ||||
|    m_started = true; | ||||
|    m_stopped = false; | ||||
| } | ||||
|  | ||||
| void timer::start(timer_ticks start_ticks) | ||||
| { | ||||
|    m_start_time = start_ticks; | ||||
|  | ||||
|    m_started = true; | ||||
|    m_stopped = false; | ||||
| } | ||||
|  | ||||
| void timer::start() | ||||
| { | ||||
|    query_counter(&m_start_time); | ||||
|  | ||||
|    m_started = true; | ||||
|    m_stopped = false; | ||||
| } | ||||
|  | ||||
| void timer::stop() | ||||
| { | ||||
|    assert(m_started); | ||||
|  | ||||
|    query_counter(&m_stop_time); | ||||
|  | ||||
|    m_stopped = true; | ||||
| } | ||||
|  | ||||
| double timer::get_elapsed_secs() const | ||||
| { | ||||
|    assert(m_started); | ||||
|    if (!m_started) | ||||
|       return 0; | ||||
|  | ||||
|    timer_ticks stop_time = m_stop_time; | ||||
|    if (!m_stopped) | ||||
|       query_counter(&stop_time); | ||||
|  | ||||
|    timer_ticks delta = stop_time - m_start_time; | ||||
|    return delta * g_inv_freq; | ||||
| } | ||||
|  | ||||
| timer_ticks timer::get_elapsed_us() const | ||||
| { | ||||
|    assert(m_started); | ||||
|    if (!m_started) | ||||
|       return 0; | ||||
|  | ||||
|    timer_ticks stop_time = m_stop_time; | ||||
|    if (!m_stopped) | ||||
|       query_counter(&stop_time); | ||||
|  | ||||
|    timer_ticks delta = stop_time - m_start_time; | ||||
|    return (delta * 1000000ULL + (g_freq >> 1U)) / g_freq; | ||||
| } | ||||
|  | ||||
| void timer::init() | ||||
| { | ||||
|    if (!g_inv_freq) | ||||
|    { | ||||
|       query_counter_frequency(&g_freq); | ||||
|       g_inv_freq = 1.0f / g_freq; | ||||
|  | ||||
|       query_counter(&g_init_ticks); | ||||
|    } | ||||
| } | ||||
|  | ||||
| timer_ticks timer::get_init_ticks() | ||||
| { | ||||
|    if (!g_inv_freq) | ||||
|       init(); | ||||
|  | ||||
|    return g_init_ticks; | ||||
| } | ||||
|  | ||||
| timer_ticks timer::get_ticks() | ||||
| { | ||||
|    if (!g_inv_freq) | ||||
|       init(); | ||||
|  | ||||
|    timer_ticks ticks; | ||||
|    query_counter(&ticks); | ||||
|    return ticks - g_init_ticks; | ||||
| } | ||||
|  | ||||
| double timer::ticks_to_secs(timer_ticks ticks) | ||||
| { | ||||
|    if (!g_inv_freq) | ||||
|       init(); | ||||
|  | ||||
|    return ticks * g_inv_freq; | ||||
| } | ||||
|  | ||||
							
								
								
									
										40
									
								
								timer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								timer.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| // File: timer.h | ||||
| #pragma once | ||||
|  | ||||
| typedef unsigned long long timer_ticks; | ||||
|  | ||||
| class timer | ||||
| { | ||||
| public: | ||||
|    timer(); | ||||
|    timer(timer_ticks start_ticks); | ||||
|  | ||||
|    void start(); | ||||
|    void start(timer_ticks start_ticks); | ||||
|  | ||||
|    void stop(); | ||||
|  | ||||
|    double get_elapsed_secs() const; | ||||
|    inline double get_elapsed_ms() const { return get_elapsed_secs() * 1000.0f; } | ||||
|    timer_ticks get_elapsed_us() const; | ||||
|  | ||||
|    static void init(); | ||||
|    static inline timer_ticks get_ticks_per_sec() { return g_freq; } | ||||
|    static timer_ticks get_init_ticks(); | ||||
|    static timer_ticks get_ticks(); | ||||
|    static double ticks_to_secs(timer_ticks ticks); | ||||
|    static inline double ticks_to_ms(timer_ticks ticks) { return ticks_to_secs(ticks) * 1000.0f; } | ||||
|    static inline double get_secs() { return ticks_to_secs(get_ticks()); } | ||||
|    static inline double get_ms() { return ticks_to_ms(get_ticks()); } | ||||
|  | ||||
| private: | ||||
|    static timer_ticks g_init_ticks; | ||||
|    static timer_ticks g_freq; | ||||
|    static double g_inv_freq; | ||||
|  | ||||
|    timer_ticks m_start_time; | ||||
|    timer_ticks m_stop_time; | ||||
|  | ||||
|    bool m_started : 1; | ||||
|    bool m_stopped : 1; | ||||
| }; | ||||
							
								
								
									
										54
									
								
								tinfl.c
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								tinfl.c
									
									
									
									
									
								
							| @@ -1,5 +1,6 @@ | ||||
| /* tinfl.c v1.09 - public domain inflate with zlib header parsing/adler32 checking (inflate-only subset of miniz.c) | ||||
|    Rich Geldreich <richgel99@gmail.com>, last updated May 15, 2011 | ||||
| /* tinfl.c v1.11 - public domain inflate with zlib header parsing/adler32 checking (inflate-only subset of miniz.c) | ||||
|    See "unlicense" statement at the end of this file. | ||||
|    Rich Geldreich <richgel99@gmail.com>, last updated May 20, 2011 | ||||
|    Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt | ||||
|  | ||||
|    The entire decompressor coroutine is implemented in tinfl_decompress(). The other functions are optional high-level helpers. | ||||
| @@ -9,11 +10,11 @@ | ||||
|  | ||||
| #include <stdlib.h> | ||||
|  | ||||
| typedef unsigned char mz_uint8;  | ||||
| typedef signed short mz_int16;  | ||||
| typedef unsigned short mz_uint16;  | ||||
| typedef unsigned int mz_uint32;  | ||||
| typedef unsigned int mz_uint;  | ||||
| typedef unsigned char mz_uint8; | ||||
| typedef signed short mz_int16; | ||||
| typedef unsigned short mz_uint16; | ||||
| typedef unsigned int mz_uint32; | ||||
| typedef unsigned int mz_uint; | ||||
| typedef unsigned long long mz_uint64; | ||||
|  | ||||
| #if defined(_M_IX86) || defined(_M_X64) | ||||
| @@ -29,9 +30,17 @@ typedef unsigned long long mz_uint64; | ||||
| #endif | ||||
|  | ||||
| // Works around MSVC's spammy "warning C4127: conditional expression is constant" message. | ||||
| #define MZ_MACRO_END while (0, 0) | ||||
| #ifdef _MSC_VER | ||||
|   #define MZ_MACRO_END while (0, 0) | ||||
| #else | ||||
|   #define MZ_MACRO_END while (0) | ||||
| #endif | ||||
|  | ||||
| // Decompression flags. | ||||
| // Decompression flags used by tinfl_decompress(). | ||||
| // TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. | ||||
| // TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. | ||||
| // TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). | ||||
| // TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. | ||||
| enum | ||||
| { | ||||
|   TINFL_FLAG_PARSE_ZLIB_HEADER = 1, | ||||
| @@ -554,3 +563,30 @@ int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, | ||||
| } | ||||
|  | ||||
| #endif // #ifndef TINFL_HEADER_FILE_ONLY | ||||
|  | ||||
| /* | ||||
|   This is free and unencumbered software released into the public domain. | ||||
|  | ||||
|   Anyone is free to copy, modify, publish, use, compile, sell, or | ||||
|   distribute this software, either in source code form or as a compiled | ||||
|   binary, for any purpose, commercial or non-commercial, and by any | ||||
|   means. | ||||
|  | ||||
|   In jurisdictions that recognize copyright laws, the author or authors | ||||
|   of this software dedicate any and all copyright interest in the | ||||
|   software to the public domain. We make this dedication for the benefit | ||||
|   of the public at large and to the detriment of our heirs and | ||||
|   successors. We intend this dedication to be an overt act of | ||||
|   relinquishment in perpetuity of all present and future rights to this | ||||
|   software under copyright law. | ||||
|  | ||||
|   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
|   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
|   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||||
|   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||||
|   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||||
|   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||||
|   OTHER DEALINGS IN THE SOFTWARE. | ||||
|  | ||||
|   For more information, please refer to <http://unlicense.org/> | ||||
| */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user