mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	v1.13 initial checkin
This commit is contained in:
		| @@ -24,7 +24,7 @@ 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); | ||||
|  | ||||
| @@ -49,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) | ||||
|     { | ||||
| @@ -80,7 +80,7 @@ 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, (size_t)src_len))) | ||||
|   | ||||
							
								
								
									
										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> | ||||
							
								
								
									
										78
									
								
								example2.c
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								example2.c
									
									
									
									
									
								
							| @@ -8,27 +8,27 @@ typedef unsigned int uint; | ||||
|  | ||||
| // The string to compress. | ||||
| 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" \ | ||||
|   "guilty of is not unknown among the latest generation of HAL 9000 computers. It has almost always revolved around a single detail, such as" \ | ||||
|   "the one you have described, and it has never interfered with the integrity or reliability of the computer's performance in other areas." \ | ||||
|   "No one is certain of the cause of this kind of malfunctioning. It may be over-programming, but it could also be any number of reasons. In any" \ | ||||
|   "event, it is somewhat analogous to human neurotic behavior. Does this answer your query?  Zero-five-three-Zero, MC, transmission concluded."; | ||||
| "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" \ | ||||
| "guilty of is not unknown among the latest generation of HAL 9000 computers. It has almost always revolved around a single detail, such as" \ | ||||
| "the one you have described, and it has never interfered with the integrity or reliability of the computer's performance in other areas." \ | ||||
| "No one is certain of the cause of this kind of malfunctioning. It may be over-programming, but it could also be any number of reasons. In any" \ | ||||
| "event, it is somewhat analogous to human neurotic behavior. Does this answer your query?  Zero-five-three-Zero, MC, transmission concluded."; | ||||
|  | ||||
| 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; | ||||
|  | ||||
|   printf("miniz.c version: %s\n", MZ_VERSION); | ||||
|    printf("miniz.c version: %s\n", MZ_VERSION); | ||||
|  | ||||
|   argc, argv; | ||||
|    (void)argc, (void)argv; | ||||
|  | ||||
|   // Append a bunch of text files to test.zip | ||||
|   for (i = 0; i < 50; i++) | ||||
| @@ -43,28 +43,28 @@ 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; | ||||
|     } | ||||
|    } | ||||
|  | ||||
|     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); | ||||
|   } | ||||
|    // 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); | ||||
|    } | ||||
|  | ||||
|   // Try to extract 0.txt to the heap. | ||||
|   p = mz_zip_reader_extract_file_to_heap(&zip_archive, "0.txt", &uncomp_size, 0); | ||||
| @@ -86,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> | ||||
							
								
								
									
										37
									
								
								example3.c
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								example3.c
									
									
									
									
									
								
							| @@ -2,6 +2,7 @@ | ||||
| // 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; | ||||
| @@ -21,9 +22,10 @@ int main(int argc, char *argv[]) | ||||
|   uint infile_size; | ||||
|   int level = Z_BEST_COMPRESSION; | ||||
|   z_stream stream; | ||||
|   int n = 1; | ||||
|   int p = 1; | ||||
|   const char *pSrc_filename; | ||||
|   const char *pDst_filename; | ||||
|   long file_loc; | ||||
|  | ||||
|   printf("miniz.c version: %s\n", MZ_VERSION); | ||||
|  | ||||
| @@ -38,9 +40,9 @@ int main(int argc, char *argv[]) | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|  | ||||
|   while ((n < argc) && (argv[n][0] == '-')) | ||||
|   while ((p < argc) && (argv[p][0] == '-')) | ||||
|   { | ||||
|     switch (argv[n][1]) | ||||
|     switch (argv[p][1]) | ||||
|     { | ||||
|       case 'l': | ||||
|       { | ||||
| @@ -54,33 +56,33 @@ int main(int argc, char *argv[]) | ||||
|       } | ||||
|       default: | ||||
|       { | ||||
|         printf("Invalid option: %s\n", argv[n]); | ||||
|         printf("Invalid option: %s\n", argv[p]); | ||||
|         return EXIT_FAILURE; | ||||
|       } | ||||
|     } | ||||
|     n++; | ||||
|     p++; | ||||
|   } | ||||
|  | ||||
|   if ((argc - n) < 3) | ||||
|   if ((argc - p) < 3) | ||||
|   { | ||||
|     printf("Must specify mode, input filename, and output filename after options!\n"); | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|   else if ((argc - n) > 3) | ||||
|   else if ((argc - p) > 3) | ||||
|   { | ||||
|     printf("Too many filenames!\n"); | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|  | ||||
|   pMode = argv[n++]; | ||||
|   pMode = argv[p++]; | ||||
|   if (!strchr("cCdD", pMode[0])) | ||||
|   { | ||||
|     printf("Invalid mode!\n"); | ||||
|     return EXIT_FAILURE; | ||||
|   } | ||||
|  | ||||
|   pSrc_filename = argv[n++]; | ||||
|   pDst_filename = argv[n++]; | ||||
|   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); | ||||
|  | ||||
| @@ -94,9 +96,18 @@ int main(int argc, char *argv[]) | ||||
|  | ||||
|   // 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(pDst_filename, "wb"); | ||||
|   if (!pOutfile) | ||||
| @@ -250,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> | ||||
							
								
								
									
										13
									
								
								example4.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								example4.c
									
									
									
									
									
								
							| @@ -2,6 +2,7 @@ | ||||
| // Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c. | ||||
| #include "tinfl.c" | ||||
| #include <stdio.h> | ||||
| #include <limits.h> | ||||
|  | ||||
| typedef unsigned char uint8; | ||||
| typedef unsigned short uint16; | ||||
| @@ -22,6 +23,7 @@ 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) | ||||
|   { | ||||
| @@ -41,9 +43,18 @@ int main(int argc, char *argv[]) | ||||
|  | ||||
|   // 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) | ||||
|   { | ||||
|   | ||||
							
								
								
									
										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> | ||||
							
								
								
									
										70
									
								
								example5.c
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								example5.c
									
									
									
									
									
								
							| @@ -2,8 +2,19 @@ | ||||
| // 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; | ||||
| @@ -26,13 +37,17 @@ static uint8 s_inbuf[IN_BUF_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 = Z_BEST_COMPRESSION; | ||||
|    int n = 1; | ||||
|    int level = 9; | ||||
|    int p = 1; | ||||
|    const char *pSrc_filename; | ||||
|    const char *pDst_filename; | ||||
|    const void *next_in = s_inbuf; | ||||
| @@ -40,10 +55,11 @@ int main(int argc, char *argv[]) | ||||
|    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 version: %s\n", MZ_VERSION); | ||||
|    printf("miniz.c example5 (demonstrates tinfl/tdefl)\n"); | ||||
|  | ||||
|    if (argc < 4) | ||||
|    { | ||||
| @@ -57,9 +73,9 @@ int main(int argc, char *argv[]) | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    while ((n < argc) && (argv[n][0] == '-')) | ||||
|    while ((p < argc) && (argv[p][0] == '-')) | ||||
|    { | ||||
|       switch (argv[n][1]) | ||||
|       switch (argv[p][1]) | ||||
|       { | ||||
|          case 'l': | ||||
|          { | ||||
| @@ -73,33 +89,33 @@ int main(int argc, char *argv[]) | ||||
|          } | ||||
|          default: | ||||
|          { | ||||
|             printf("Invalid option: %s\n", argv[n]); | ||||
|             printf("Invalid option: %s\n", argv[p]); | ||||
|             return EXIT_FAILURE; | ||||
|          } | ||||
|       } | ||||
|       n++; | ||||
|       p++; | ||||
|    } | ||||
|  | ||||
|    if ((argc - n) < 3) | ||||
|    if ((argc - p) < 3) | ||||
|    { | ||||
|       printf("Must specify mode, input filename, and output filename after options!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|    else if ((argc - n) > 3) | ||||
|    else if ((argc - p) > 3) | ||||
|    { | ||||
|       printf("Too many filenames!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    pMode = argv[n++]; | ||||
|    pMode = argv[p++]; | ||||
|    if (!strchr("cCdD", pMode[0])) | ||||
|    { | ||||
|       printf("Invalid mode!\n"); | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    pSrc_filename = argv[n++]; | ||||
|    pDst_filename = argv[n++]; | ||||
|    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); | ||||
|  | ||||
| @@ -113,9 +129,18 @@ int main(int argc, char *argv[]) | ||||
|  | ||||
|    // 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(pDst_filename, "wb"); | ||||
|    if (!pOutfile) | ||||
| @@ -128,12 +153,19 @@ int main(int argc, char *argv[]) | ||||
|  | ||||
|    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; | ||||
|       uint comp_flags = tdefl_create_comp_flags_from_zip_params(level, MZ_DEFAULT_WINDOW_BITS, MZ_DEFAULT_STRATEGY) | TDEFL_WRITE_ZLIB_HEADER; | ||||
|  | ||||
|       // 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. | ||||
|       tdefl_compressor deflator; | ||||
|       tdefl_status status = tdefl_init(&deflator, NULL, NULL, comp_flags); | ||||
|       status = tdefl_init(&g_deflator, NULL, NULL, comp_flags); | ||||
|       if (status != TDEFL_STATUS_OKAY) | ||||
|       { | ||||
|          printf("tdefl_init() failed!\n"); | ||||
| @@ -168,7 +200,7 @@ int main(int argc, char *argv[]) | ||||
|          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(&deflator, next_in, &in_bytes, next_out, &out_bytes, infile_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); | ||||
|          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; | ||||
| @@ -288,8 +320,8 @@ int main(int argc, char *argv[]) | ||||
|       return EXIT_FAILURE; | ||||
|    } | ||||
|  | ||||
|    printf("Total input bytes: %u\n", total_in); | ||||
|    printf("Total output bytes: %u\n", total_out); | ||||
|    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> | ||||
							
								
								
									
										10
									
								
								examples.sln
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								examples.sln
									
									
									
									
									
								
							| @@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example4", "example4.vcproj | ||||
| 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 | ||||
| @@ -59,6 +61,14 @@ Global | ||||
| 		{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> | ||||
							
								
								
									
										81
									
								
								miniz.c
									
									
									
									
									
								
							
							
						
						
									
										81
									
								
								miniz.c
									
									
									
									
									
								
							| @@ -1,12 +1,22 @@ | ||||
| /* miniz.c v1.12 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing | ||||
| /* miniz.c v1.13 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing | ||||
|    See "unlicense" statement at the end of this file. | ||||
|    Rich Geldreich <richgel99@gmail.com>, last updated April 12, 2012 | ||||
|    Rich Geldreich <richgel99@gmail.com>, last updated May 19, 2012 | ||||
|    Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt | ||||
|  | ||||
|    Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define | ||||
|    MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros). | ||||
|  | ||||
|    * Change History | ||||
|      5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. | ||||
|        Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. | ||||
|        Eliminated a bunch of warnings when compiling with GCC 32-bit/64. | ||||
|        Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly | ||||
|        "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). | ||||
|        Created 32-bit and 64-bit Codeblocks projects/workspace. | ||||
|        Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. | ||||
|        Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. | ||||
|        Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) | ||||
|        Fix fell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). | ||||
|      4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's. | ||||
|       level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson <bruced@valvesoftware.com> for the feedback/bug report. | ||||
|      5/28/11 v1.11 - Added statement from unlicense.org | ||||
| @@ -179,7 +189,7 @@ extern "C" { | ||||
|  | ||||
| // ------------------- zlib-style API Definitions. | ||||
|  | ||||
| // For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. | ||||
| // For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! | ||||
| typedef unsigned long mz_ulong; | ||||
|  | ||||
| // Heap allocation callbacks. | ||||
| @@ -204,11 +214,11 @@ enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3 | ||||
|  | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
|  | ||||
| #define MZ_VERSION          "9.1.12" | ||||
| #define MZ_VERNUM           0x91C0 | ||||
| #define MZ_VERSION          "9.1.13" | ||||
| #define MZ_VERNUM           0x91D0 | ||||
| #define MZ_VER_MAJOR        9 | ||||
| #define MZ_VER_MINOR        1 | ||||
| #define MZ_VER_REVISION     12 | ||||
| #define MZ_VER_REVISION     13 | ||||
| #define MZ_VER_SUBREVISION  0 | ||||
|  | ||||
| // Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). | ||||
| @@ -430,7 +440,11 @@ typedef int mz_bool; | ||||
| #define MZ_TRUE (1) | ||||
|  | ||||
| // 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 | ||||
|  | ||||
| // ------------------- ZIP archive reading/writing | ||||
|  | ||||
| @@ -852,11 +866,14 @@ tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, siz | ||||
| tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); | ||||
| mz_uint32 tdefl_get_adler32(tdefl_compressor *d); | ||||
|  | ||||
| // Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't defined, because it uses some of its macros. | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
| // Create tdefl_compress() flags given zlib-style compression parameters. | ||||
| // level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) | ||||
| // window_bits may be -15 (raw deflate) or 15 (zlib) | ||||
| // strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED | ||||
| mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); | ||||
| #endif // #ifndef MINIZ_NO_ZLIB_APIS | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| @@ -879,7 +896,7 @@ typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1]; | ||||
|  | ||||
| #ifdef MINIZ_NO_MALLOC | ||||
|   #define MZ_MALLOC(x) NULL | ||||
|   #define MZ_FREE(x) x, ((void)0) | ||||
|   #define MZ_FREE(x) (void)x, ((void)0) | ||||
|   #define MZ_REALLOC(p, x) NULL | ||||
| #else | ||||
|   #define MZ_MALLOC(x) malloc(x) | ||||
| @@ -913,10 +930,6 @@ typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1]; | ||||
|  | ||||
| // ------------------- zlib-style API's | ||||
|  | ||||
| static void *def_alloc_func(void *opaque, size_t items, size_t size) { (void)opaque; return MZ_MALLOC(items * size); } | ||||
| static void def_free_func(void *opaque, void *address) { (void)opaque, MZ_FREE(address); } | ||||
| static void *def_realloc_func(void *opaque, void *address, size_t items, size_t size) { (void)opaque; return MZ_REALLOC(address, items * size); } | ||||
|  | ||||
| mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) | ||||
| { | ||||
|   mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); size_t block_len = buf_len % 5552; | ||||
| @@ -937,12 +950,18 @@ mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) | ||||
| { | ||||
|   static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, | ||||
|     0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c }; | ||||
|   mz_uint32 crcu32 = (mz_uint32)crc; | ||||
|   if (!ptr) return MZ_CRC32_INIT; | ||||
|   crc = ~crc; while (buf_len--) { mz_uint8 b = *ptr++; crc = (crc >> 4) ^ s_crc32[(crc & 0xF) ^ (b & 0xF)]; crc = (crc >> 4) ^ s_crc32[(crc & 0xF) ^ (b >> 4)]; } return ~crc; | ||||
|   crcu32 = ~crcu32; while (buf_len--) { mz_uint8 b = *ptr++; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; } | ||||
|   return ~crcu32; | ||||
| } | ||||
|  | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
|  | ||||
| static void *def_alloc_func(void *opaque, size_t items, size_t size) { (void)opaque, (void)items, (void)size; return MZ_MALLOC(items * size); } | ||||
| static void def_free_func(void *opaque, void *address) { (void)opaque, (void)address; MZ_FREE(address); } | ||||
| static void *def_realloc_func(void *opaque, void *address, size_t items, size_t size) { (void)opaque, (void)address, (void)items, (void)size; return MZ_REALLOC(address, items * size); } | ||||
|  | ||||
| const char *mz_version(void) | ||||
| { | ||||
|   return MZ_VERSION; | ||||
| @@ -1055,7 +1074,7 @@ int mz_deflateEnd(mz_streamp pStream) | ||||
|  | ||||
| mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) | ||||
| { | ||||
|   pStream; | ||||
|   (void)pStream; | ||||
|   // This is really over conservative. (And lame, but it's actually pretty tricky to compute a true upper bound given the way tdefl's blocking works.) | ||||
|   return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5); | ||||
| } | ||||
| @@ -2421,10 +2440,10 @@ static __forceinline void tdefl_record_match(tdefl_compressor *d, mz_uint match_ | ||||
|  | ||||
|   *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } | ||||
|  | ||||
|   s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[match_dist >> 8]; | ||||
|   s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; | ||||
|   d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; | ||||
|  | ||||
|   d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; | ||||
|   if (match_len >= TDEFL_MIN_MATCH_LEN) d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; | ||||
| } | ||||
|  | ||||
| static mz_bool tdefl_compress_normal(tdefl_compressor *d) | ||||
| @@ -2515,7 +2534,7 @@ static mz_bool tdefl_compress_normal(tdefl_compressor *d) | ||||
|       } | ||||
|     } | ||||
|     else if (!cur_match_dist) | ||||
|       tdefl_record_literal(d, d->m_dict[cur_pos]); | ||||
|       tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]); | ||||
|     else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128)) | ||||
|     { | ||||
|       tdefl_record_match(d, cur_match_len, cur_match_dist); | ||||
| @@ -2523,7 +2542,7 @@ static mz_bool tdefl_compress_normal(tdefl_compressor *d) | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|       d->m_saved_lit = d->m_dict[cur_pos]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; | ||||
|       d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; | ||||
|     } | ||||
|     // Move the lookahead forward by len_to_move bytes. | ||||
|     d->m_lookahead_pos += len_to_move; | ||||
| @@ -2705,6 +2724,7 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void | ||||
|   return out_buf.m_size; | ||||
| } | ||||
|  | ||||
| #ifndef MINIZ_NO_ZLIB_APIS | ||||
| static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32,  16, 32, 128, 256,  512, 768, 1500 }; | ||||
|  | ||||
| // level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). | ||||
| @@ -2721,6 +2741,7 @@ mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int | ||||
|  | ||||
|   return comp_flags; | ||||
| } | ||||
| #endif //MINIZ_NO_ZLIB_APIS | ||||
|  | ||||
| #ifdef _MSC_VER | ||||
| #pragma warning (push) | ||||
| @@ -3016,7 +3037,7 @@ static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *p | ||||
|  | ||||
| static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 flags) | ||||
| { | ||||
|   mz_uint i, n, cdir_size, num_this_disk, cdir_disk_index; | ||||
|   mz_uint cdir_size, num_this_disk, cdir_disk_index; | ||||
|   mz_uint64 cdir_ofs; | ||||
|   mz_int64 cur_file_ofs; | ||||
|   const mz_uint8 *p; | ||||
| @@ -3066,6 +3087,7 @@ static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 fl | ||||
|  | ||||
|   if (pZip->m_total_files) | ||||
|   { | ||||
|      mz_uint i, n; | ||||
|     // Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and another to hold the sorted indices. | ||||
|     if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) || | ||||
|         (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE)) || | ||||
| @@ -3438,7 +3460,11 @@ mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file | ||||
|   { | ||||
|     // Temporarily allocate a read buffer. | ||||
|     read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); | ||||
| #ifdef _MSC_VER | ||||
|     if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) | ||||
| #else | ||||
|     if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) | ||||
| #endif | ||||
|       return MZ_FALSE; | ||||
|     if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) | ||||
|       return MZ_FALSE; | ||||
| @@ -3514,7 +3540,11 @@ void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, si | ||||
|   uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); | ||||
|  | ||||
|   alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size; | ||||
| #ifdef _MSC_VER | ||||
|   if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) | ||||
| #else | ||||
|   if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) | ||||
| #endif | ||||
|     return NULL; | ||||
|   if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size))) | ||||
|     return NULL; | ||||
| @@ -3594,7 +3624,11 @@ mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_ind | ||||
|     // The file is stored or the caller has requested the compressed data. | ||||
|     if (pZip->m_pState->m_pMem) | ||||
|     { | ||||
| #ifdef _MSC_VER | ||||
|       if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) | ||||
| #else | ||||
|       if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) | ||||
| #endif | ||||
|         return MZ_FALSE; | ||||
|       if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size) | ||||
|         status = TINFL_STATUS_FAILED; | ||||
| @@ -3755,6 +3789,7 @@ mz_bool mz_zip_reader_end(mz_zip_archive *pZip) | ||||
|   return MZ_TRUE; | ||||
| } | ||||
|  | ||||
| #ifndef MINIZ_NO_STDIO | ||||
| mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags) | ||||
| { | ||||
|   int file_index = mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags); | ||||
| @@ -3762,6 +3797,7 @@ mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pAr | ||||
|     return MZ_FALSE; | ||||
|   return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags); | ||||
| } | ||||
| #endif | ||||
|  | ||||
| // ------------------- .ZIP archive writing | ||||
|  | ||||
| @@ -3807,7 +3843,11 @@ static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const vo | ||||
|   mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; | ||||
|   mz_zip_internal_state *pState = pZip->m_pState; | ||||
|   mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); | ||||
| #ifdef _MSC_VER | ||||
|   if ((!n) || ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) | ||||
| #else | ||||
|   if ((!n) || ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) | ||||
| #endif | ||||
|     return 0; | ||||
|   if (new_size > pState->m_mem_capacity) | ||||
|   { | ||||
| @@ -4641,7 +4681,8 @@ mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const | ||||
|   if ((!status) && (created_new_archive)) | ||||
|   { | ||||
|     // It's a new archive and something went wrong, so just delete it. | ||||
|     MZ_DELETE_FILE(pZip_filename); | ||||
|     int ignoredStatus = MZ_DELETE_FILE(pZip_filename); | ||||
|     (void)ignoredStatus; | ||||
|   } | ||||
|   return status; | ||||
| } | ||||
|   | ||||
							
								
								
									
										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; | ||||
| }; | ||||
							
								
								
									
										6
									
								
								tinfl.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								tinfl.c
									
									
									
									
									
								
							| @@ -30,7 +30,11 @@ 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 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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user