diff options
Diffstat (limited to 'depends')
61 files changed, 4329 insertions, 8600 deletions
diff --git a/depends/lzma/CMakeLists.txt b/depends/lzma/CMakeLists.txt deleted file mode 100644 index 4df2b762..00000000 --- a/depends/lzma/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -PROJECT(lzma) - -IF (WIN32) - ADD_DEFINITIONS(-DWIN32) -ENDIF (WIN32) - -SET(SRCS -# original code by Igor Pavlov -# Lzma version 4.63 -# Minified ~_~ -pavlov/7zCrc.c -pavlov/7zCrc.h -pavlov/LzFind.c -pavlov/LzFind.h -pavlov/LzHash.h -pavlov/LzmaDec.c -pavlov/LzmaDec.h -pavlov/LzmaEnc.c -pavlov/LzmaEnc.h -pavlov/LzmaLib.c -pavlov/LzmaLib.h -pavlov/Types.h - -# Public headers -include/common.h -include/compress.h -include/decompress.h -include/simple.h - -# Wrapper by Lloyd Hilaiel (lloyd@hilaiel.com) -wrapper/common_internal.c -wrapper/common_internal.h -wrapper/compress.c -wrapper/decompress.c -wrapper/simple.c -wrapper/lzip_header.c -wrapper/lzip_header.h -wrapper/lzma_header.c -wrapper/lzma_header.h -) - -# an include directory to allow easylzma implementation to find public -# headers -INCLUDE_DIRECTORIES(include) -ADD_LIBRARY(lzma STATIC ${SRCS}) - -# lzma compress/decompress tool -ADD_EXECUTABLE(elzma elzma.c) -TARGET_LINK_LIBRARIES(elzma lzma) -# a simple test... -ADD_EXECUTABLE(easylzma_test easylzma_test.c) -TARGET_LINK_LIBRARIES(easylzma_test lzma) diff --git a/depends/lzma/LICENSE.txt b/depends/lzma/LICENSE.txt deleted file mode 100644 index a8a34e6a..00000000 --- a/depends/lzma/LICENSE.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Written in 2009 by Lloyd Hilaiel -# Butchered in 2013 by Petr Mrazek -# -# License -# -# All the cruft you find here is public domain. You don't have to credit -# anyone to use this code, but my personal request is that you mention -# Igor Pavlov for his hard, high quality work. -# diff --git a/depends/lzma/easylzma_test.c b/depends/lzma/easylzma_test.c deleted file mode 100644 index 69858728..00000000 --- a/depends/lzma/easylzma_test.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Written in 2009 by Lloyd Hilaiel - * - * License - * - * All the cruft you find here is public domain. You don't have to credit - * anyone to use this code, but my personal request is that you mention - * Igor Pavlov for his hard, high quality work. - * - * Various compiled-in tests for the easylzma library which excercise - * API correctness and handling of corrupt data. - */ - -#include "simple.h" - -#include <stdio.h> -#include <string.h> - -static const char *sampleData = - "Overview\n" - "\n" - "Easylzma is a C library and command line tools for LZMA compression and \n" - "decompression. It uses a Igor Pavlov's reference implementation and SDK\n" - "written in C.\n" - "\n" - "License\n" - "\n" - "All the cruft you find here is public domain. You don't have to credit\n" - "anyone to use this code, but my personal request is that you mention\n" - "Igor Pavlov for his hard, high quality work.\n" - "\n" - "Project Goals\n" - "\n" - "1. A tiny C wrapper and portable build system around a subset of\n" - " Igor Pavlov's public domain LZMA compression and decompression\n" - " implementation.\n" - "2. A tiny and straighforward API\n" - "3. Support for multiple different prominent LZMA file formats (see section on\n" - " file formats below)\n" - "4. easy to build and use everywhere (doze and nix alike)\n" - "5. public domain licensing through and through. (hats off to Igor)\n" - "\n" - "Current State:\n" - "\n" - "THIS IS A WORK IN PROGRESS. The code here should be considered pre-alpha,\n" - "and this should only be used by tinkerers or hackers at this point. Once\n" - "feature completion is attained this message will be updated. See the\n" - "TODO file distributed with the source for remaining work to be done.\n" - "\n" - "Platforms Supported\n" - "\n" - "0.0.2 has been successfully compiled and run basic round trip testing\n" - "on the following platforms & compilers:\n" - "\n" - " * win32 - visual studio 2005\n" - " * osx - 10.4 & 10.5 (intel)\n" - " * netbsd ppc - 4.0.1 with gcc 4.1.2\n" - " (NOTE: memory allocation errors when dict size is default)\n" - " * freebsd 6.1 - amd64 gcc 3.4.4\n" - "\n" - "Features\n" - "\n" - "XXX: write me (and the code)\n" - "\n" - "Usage\n" - "\n" - "XXX: write me (and the code)\n" - "\n" - "The Saga of LZMA File Formats, and a couple cents.\n" - "\n" - "As far as I can tell, there are at least four different ways to put LZMA\n" - "compressed data in a stream:\n" - "\n" - "1. The LZMA-Alone format, which consists of a 13 byte header including\n" - " compression properties, dictionary size, and the uncompressed size of\n" - " the file, followed by compressed data. This format has some support\n" - " in Igor Pavlov's reference implementation and is in widespread use, as\n" - " it's supported by lzmautils: http://tukaani.org/lzma/\n" - "\n" - " The canonical (afaict) implementation of this format (lzmautis) is\n" - " BSD licensed.\n" - "\n" - "2. The lzip format (http://www.nongnu.org/lzip/lzip.html) - which\n" - " includes a CRC footer and leading \"magic number\". The former\n" - " affords data integrity gaurantees, while the latter simplifies\n" - " heuristic determination of file format. This format looks to have\n" - " reasonably widespread usage, though not quite as significant as\n" - " LZMA-Alone.\n" - "\n" - " The only implementation of this format I can find (lzip) is GPL licensed.\n" - "\n" - "3. the xz format ( http://tukaani.org/xz/xz-file-format.txt ) which is\n" - " a more complex representation that includes CRC support and a magic\n" - " number. This format is to be supported by the next iteration of\n" - " XZ Utils which is currently in beta. The source may be obtained\n" - " here: git://ctrl.tukaani.org/xz.git\n" - "\n" - " This format will address some criticisms to the LZMA-Alone format and\n" - " was developed collaboratively by Lasse Collin (the current maintainer\n" - " of XZ utils) and Igor Pavlov (the author of 7zip and the refrence\n" - " implementation of LZMA).\n" - "\n" - " The xz format will employ LZMA2 which consists of extensions on top\n" - " of LZMA, in the xz utils maintainer's words:\n" - "\n" - " \"The primary compression algorithm in .xz is currently LZMA2, which\n" - " is an extension on top of the orignal LZMA to fix a few practical\n" - " issues, like adding support for flushing the encoder (equivalent\n" - " to zlib's Z_SYNC_FLUSH), which isn't possible with the original\n" - " LZMA.\"\n" - "\n" - " Again, maintainers words, regarding licensing:\n" - "\n" - " \"XZ Utils currently contains a zlib-like compression library and a \n" - " gzip-like command line tool. It's currently under LGPLv2.1+ but I will \n" - " put it into the public domain before the first stable release.\"\n" - "\n" - "4. The 7zip disk format which can contain multiple files possibly stored in\n" - " LZMA compressed format.\n" - "\n" - "Given the state of things, the goal of this project is to develop something\n" - "based on the existing formats, and quickly leverage code generated by the XZ\n" - "Utils project, or simply kill this thing if that project produces something\n" - "that's easy to embed and has a clean API at a similar level of abstraction\n" - "as easylzma.\n" - "\n" - "lloyd - sometime in oh nine.\n"; - -/* a test that we can round trip compress/decompress data using LZMA or LZIP - * formats */ -static int roundTripTest(elzma_file_format format) -{ - int rc; - unsigned char *compressed; - unsigned char *decompressed; - size_t sz; - - rc = simpleCompress(format, (unsigned char *)sampleData, strlen(sampleData), &compressed, - &sz); - - if (rc != ELZMA_E_OK) - return rc; - - /* gross assurance that compression is actually compressing */ - if (sz > strlen(sampleData)) - { - free(compressed); - return 1; - } - - rc = simpleDecompress(format, compressed, sz, &decompressed, &sz); - - free(compressed); - - if (rc != ELZMA_E_OK) - return rc; - - if (sz != strlen(sampleData) || 0 != memcmp(decompressed, sampleData, sz)) - { - free(decompressed); - return 1; - } - - return ELZMA_E_OK; -} - -/* "correct" lzip generated from the lzip program */ -/*|LZIP...3.?..????|*/ -/*|....?e2~........|*/ -static unsigned char correctLzip[] = { - 0x4c, 0x5a, 0x49, 0x50, 0x01, 0x0c, 0x00, 0x33, 0x1b, 0xec, 0x15, 0x07, 0xff, 0xff, - 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0xa8, 0x65, 0x32, 0x7e, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -/* "correct" lzip generated from lzma utils */ -static unsigned char correctLzma[] = {0x5d, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x33, 0x1b, 0xec, 0x14, 0x00, 0x00, 0x00}; - -/* lzip with a bad CRC */ -static unsigned char corruptCRC[] = { - 0x4c, 0x5a, 0x49, 0x50, 0x01, 0x0c, 0x00, 0x33, 0x1b, 0xec, 0x15, 0x07, 0xff, 0xff, - 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0xa8, 0x65, 0x31, 0x7e, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -/* lzip with a bad uncompressed size */ -static unsigned char corruptSize[] = { - 0x4c, 0x5a, 0x49, 0x50, 0x01, 0x0c, 0x00, 0x33, 0x1b, 0xec, 0x15, 0x07, 0xff, 0xff, - 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0xa8, 0x65, 0x32, 0x7e, 0x04, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -/* lzma with a bad uncompressed size */ -static unsigned char corruptSizeLzma[] = {0x5d, 0x00, 0x00, 0x80, 0x00, 0x04, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x33, 0x1b, 0xec, 0x14, 0x00, 0x00, 0x00}; - -/* lzma with a bad uncompressed size */ -static unsigned char corruptSizeLzma2[] = {0x5d, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x33, 0x1b, 0xec, 0x14, 0x00, 0x00, 0x00}; - -/* tests */ -static struct -{ - const char *testName; /* the name of the test */ - int expectedCode; /* the expected output of the test */ - elzma_file_format format; - unsigned char *data; /* input data */ - unsigned int dataSize; -} tests[] = { - {"correct lzip", ELZMA_E_OK, ELZMA_lzip, correctLzip, sizeof(correctLzip)}, - {"lzip as lzma", ELZMA_E_DECOMPRESS_ERROR, ELZMA_lzma, correctLzip, sizeof(correctLzip)}, - {"correct lzma", ELZMA_E_OK, ELZMA_lzma, correctLzma, sizeof(correctLzma)}, - {"lzma as lzip", ELZMA_E_CORRUPT_HEADER, ELZMA_lzip, correctLzma, sizeof(correctLzma)}, - {"corrupt crc", ELZMA_E_CRC32_MISMATCH, ELZMA_lzip, corruptCRC, sizeof(corruptCRC)}, - {"bad lzip size", ELZMA_E_SIZE_MISMATCH, ELZMA_lzip, corruptSize, sizeof(corruptSize)}, - {"bad lzma size", ELZMA_E_INSUFFICIENT_INPUT, ELZMA_lzma, - corruptSizeLzma, sizeof(corruptSizeLzma)}, - {"bad lzma size 2", ELZMA_E_SIZE_MISMATCH, ELZMA_lzma, - corruptSizeLzma2, sizeof(corruptSizeLzma2)}}; - -int main(void) -{ - unsigned int i; - unsigned int testsPassed = 0; - unsigned int testsRun = 0; - - int rc = 0; - - printf("round trip lzma test: "); - fflush(stdout); - testsRun++; - if (ELZMA_E_OK != (rc = roundTripTest(ELZMA_lzma))) - { - printf("fail! (%d)\n", rc); - } - else - { - testsPassed++; - printf("ok\n"); - } - - printf("round trip lzip test: "); - fflush(stdout); - testsRun++; - if (ELZMA_E_OK != (rc = roundTripTest(ELZMA_lzip))) - { - printf("fail (%d)!\n", rc); - } - else - { - testsPassed++; - printf("ok\n"); - } - - /* now run through the tests table */ - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) - { - unsigned char *decompressed = NULL; - size_t sz = 0; - - printf("%s test: ", tests[i].testName); - rc = simpleDecompress(tests[i].format, tests[i].data, tests[i].dataSize, &decompressed, - &sz); - - testsRun++; - if (rc != tests[i].expectedCode) - { - printf("fail - got %d - expected %d\n", rc, tests[i].expectedCode); - } - else - { - testsPassed++; - printf("ok\n"); - free(decompressed); - } - } - - printf("\n%d/%d tests passed\n", testsPassed, testsRun); - - return (testsPassed == testsRun) ? 0 : 1; -} diff --git a/depends/lzma/elzma.c b/depends/lzma/elzma.c deleted file mode 100644 index f715a7b2..00000000 --- a/depends/lzma/elzma.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * Written in 2009 by Lloyd Hilaiel - * - * License - * - * All the cruft you find here is public domain. You don't have to credit - * anyone to use this code, but my personal request is that you mention - * Igor Pavlov for his hard, high quality work. - * - * command line elzma tool for lzma compression - * - * At time of writing, the primary purpose of this tool is to test the - * easylzma library. - * - * TODO: - * - stdin/stdout support - * - multiple file support - * - much more - */ - -#include "include/compress.h" -#include "include/decompress.h" - -#include <stdio.h> -#include <string.h> -#include <assert.h> - -#ifdef WIN32 -#include <stdio.h> -#define unlink _unlink -#else -#include <unistd.h> -#endif - -int deleteFile(const char *path) -{ - return unlink(path); -} - -/* a utility to open a pair of files */ -/* XXX: respect overwrite flag */ -static int openFiles(const char *ifname, FILE **inFile, const char *ofname, FILE **outFile, - int overwrite) -{ - *inFile = fopen(ifname, "rb"); - if (*inFile == NULL) - { - fprintf(stderr, "couldn't open '%s' for reading\n", ifname); - return 1; - } - - *outFile = fopen(ofname, "wb"); - if (*outFile == NULL) - { - fprintf(stderr, "couldn't open '%s' for writing\n", ofname); - return 1; - } - - return 0; -} - -#define ELZMA_COMPRESS_USAGE \ - "Compress files using the LZMA algorithm (in place by default).\n" \ - "\n" \ - "Usage: elzma [options] [file]\n" \ - " -1 .. -9 compression level, -1 is fast, -9 is best (default 5)\n" \ - " -f, --force overwrite output files if they exist\n" \ - " -h, --help output this message and exit\n" \ - " -k, --keep don't delete input files\n" \ - " --lzip compress to lzip disk format (.lz extension)\n" \ - " --lzma compress to LZMA-Alone disk format (.lzma extension)\n" \ - " -v, --verbose output verbose status information while compressing\n" \ - " -z, --compress compress files (default when invoking elzma program)\n" \ - " -d, --decompress decompress files (default when invoking unelzma program)\n" \ - "\n" \ - "Advanced Options:\n" \ - " -s --set-max-dict (advanced) specify maximum dictionary size in bytes\n" - -/* parse arguments populating output parameters, return nonzero on failure */ -static int parseCompressArgs(int argc, char **argv, unsigned char *level, char **fname, - unsigned int *maxDictSize, unsigned int *verbose, - unsigned int *keep, unsigned int *overwrite, - elzma_file_format *format) -{ - int i; - - if (argc < 2) - return 1; - - for (i = 1; i < argc; i++) - { - if (argv[i][0] == '-') - { - char *val = NULL; - char *arg = &(argv[i][1]); - if (arg[0] == '-') - arg++; - - /* now see what argument this is */ - if (!strcmp(arg, "h") || !strcmp(arg, "help")) - { - return 1; - } - else if (!strcmp(arg, "s") || !strcmp(arg, "set-max-dict")) - { - unsigned int j = 0; - val = argv[++i]; - - /* validate argument is numeric */ - for (j = 0; j < strlen(val); j++) - { - if (val[j] < '0' || val[j] > '9') - return 1; - } - - *maxDictSize = strtoul(val, (char **)NULL, 10); - - /* don't allow dictionary sizes less than 8k */ - if (*maxDictSize < (1 < 13)) - *maxDictSize = 1 < 13; - else - { - /* make sure dict size is compatible with lzip, - * this will effectively collapse it to a close power - * of 2 */ - *maxDictSize = elzma_get_dict_size(*maxDictSize); - } - } - else if (!strcmp(arg, "v") || !strcmp(arg, "verbose")) - { - *verbose = 1; - } - else if (!strcmp(arg, "f") || !strcmp(arg, "force")) - { - *overwrite = 1; - } - else if (!strcmp(arg, "k") || !strcmp(arg, "keep")) - { - *keep = 1; - } - else if (strlen(arg) == 1 && arg[0] >= '1' && arg[0] <= '9') - { - *level = arg[0] - '0'; - } - else if (!strcmp(arg, "lzma")) - { - *format = ELZMA_lzma; - } - else if (!strcmp(arg, "lzip")) - { - *format = ELZMA_lzip; - } - else if (!strcmp(arg, "z") || !strcmp(arg, "d") || !strcmp(arg, "compress") || - !strcmp(arg, "decompress")) - { - /* noop */ - } - else - { - return 1; - } - } - else - { - *fname = argv[i]; - break; - } - } - - /* proper number of arguments? */ - if (i != argc - 1 || *fname == NULL) - return 1; - - return 0; -} - -/* callbacks for streamed input and output */ -static size_t elzmaWriteFunc(void *ctx, const void *buf, size_t size) -{ - size_t wt; - FILE *f = (FILE *)ctx; - assert(f != NULL); - - wt = fwrite(buf, 1, size, f); - - return wt; -} - -static int elzmaReadFunc(void *ctx, void *buf, size_t *size) -{ - FILE *f = (FILE *)ctx; - assert(f != NULL); - *size = fread(buf, 1, *size, f); - - return 0; -} - -static void printProgressHeader(void) -{ - printf("|0%% 50%% 100%%|\n"); -} - -static void endProgress(int pCtx) -{ - while (pCtx++ < 64) - { |
