summaryrefslogtreecommitdiffstats
path: root/depends/lzma/include
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-09-26 02:58:09 +0200
committerPetr Mrázek <peterix@gmail.com>2013-09-26 02:59:56 +0200
commit2c8dc0b855c38c5204d398ad306fa9cf43be1ada (patch)
tree59429d658012a3df0e548e1a5f08100fb2930fc0 /depends/lzma/include
parentaf234f35029de8c46aefecd8b9345b30ae1c51b0 (diff)
downloadMultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.tar
MultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.tar.gz
MultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.tar.lz
MultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.tar.xz
MultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.zip
Compression algo dependencies, still need hackery...
Diffstat (limited to 'depends/lzma/include')
-rw-r--r--depends/lzma/include/common.h118
-rw-r--r--depends/lzma/include/compress.h77
-rw-r--r--depends/lzma/include/decompress.h58
-rw-r--r--depends/lzma/include/simple.h37
4 files changed, 290 insertions, 0 deletions
diff --git a/depends/lzma/include/common.h b/depends/lzma/include/common.h
new file mode 100644
index 00000000..f02bdb4d
--- /dev/null
+++ b/depends/lzma/include/common.h
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ *
+ * easylzma/common.h - definitions common to both compression and
+ * decompression
+ */
+
+#pragma once
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* msft dll export gunk. To build a DLL on windows, you
+ * must define WIN32, EASYLZMA_SHARED, and EASYLZMA_BUILD. To use a
+ * DLL, you must define EASYLZMA_SHARED and WIN32 */
+#if defined(WIN32) && defined(EASYLZMA_SHARED)
+#ifdef EASYLZMA_BUILD
+#define EASYLZMA_API __declspec(dllexport)
+#else
+#define EASYLZMA_API __declspec(dllimport)
+#endif
+#else
+#define EASYLZMA_API
+#endif
+
+/** error codes */
+
+/** no error */
+#define ELZMA_E_OK 0
+/** bad parameters passed to an ELZMA function */
+#define ELZMA_E_BAD_PARAMS 10
+/** could not initialize the encode with configured parameters. */
+#define ELZMA_E_ENCODING_PROPERTIES_ERROR 11
+/** an error occured during compression (XXX: be more specific) */
+#define ELZMA_E_COMPRESS_ERROR 12
+/** currently unsupported lzma file format was specified*/
+#define ELZMA_E_UNSUPPORTED_FORMAT 13
+/** an error occured when reading input */
+#define ELZMA_E_INPUT_ERROR 14
+/** an error occured when writing output */
+#define ELZMA_E_OUTPUT_ERROR 15
+/** LZMA header couldn't be parsed */
+#define ELZMA_E_CORRUPT_HEADER 16
+/** an error occured during decompression (XXX: be more specific) */
+#define ELZMA_E_DECOMPRESS_ERROR 17
+/** the input stream returns EOF before the decompression could complete */
+#define ELZMA_E_INSUFFICIENT_INPUT 18
+/** for formats which have an emebedded crc, this error would indicated that
+ * what came out was not what went in, i.e. data corruption */
+#define ELZMA_E_CRC32_MISMATCH 19
+/** for formats which have an emebedded uncompressed content length,
+ * this error indicates that the amount we read was not what we expected */
+#define ELZMA_E_SIZE_MISMATCH 20
+
+/** Supported file formats */
+typedef enum
+{
+ ELZMA_lzip, /**< the lzip format which includes a magic number and
+ * CRC check */
+ ELZMA_lzma /**< the LZMA-Alone format, originally designed by
+ * Igor Pavlov and in widespread use due to lzmautils,
+ * lacking both aforementioned features of lzip */
+ /* XXX: future, potentially ,
+ ELZMA_xz
+ */
+} elzma_file_format;
+
+/**
+ * A callback invoked during elzma_[de]compress_run when the [de]compression
+ * process has generated [de]compressed output.
+ *
+ * the size parameter indicates how much data is in buf to be written.
+ * it is required that the write callback consume all data, and a return
+ * value not equal to input size indicates and error.
+ */
+typedef size_t (*elzma_write_callback)(void *ctx, const void *buf, size_t size);
+
+/**
+ * A callback invoked during elzma_[de]compress_run when the [de]compression
+ * process requires more [un]compressed input.
+ *
+ * the size parameter is an in/out argument. on input it indicates
+ * the buffer size. on output it indicates the amount of data read into
+ * buf. when *size is zero on output it indicates EOF.
+ *
+ * \returns the read callback should return nonzero on failure.
+ */
+typedef int (*elzma_read_callback)(void *ctx, void *buf, size_t *size);
+
+/**
+ * A callback invoked during elzma_[de]compress_run to report progress
+ * on the [de]compression.
+ *
+ * \returns the read callback should return nonzero on failure.
+ */
+typedef void (*elzma_progress_callback)(void *ctx, size_t complete, size_t total);
+
+/** pointer to a malloc function, supporting client overriding memory
+ * allocation routines */
+typedef void *(*elzma_malloc)(void *ctx, unsigned int sz);
+
+/** pointer to a free function, supporting client overriding memory
+ * allocation routines */
+typedef void (*elzma_free)(void *ctx, void *ptr);
+
+#ifdef __cplusplus
+}
+;
+#endif
diff --git a/depends/lzma/include/compress.h b/depends/lzma/include/compress.h
new file mode 100644
index 00000000..46c81d75
--- /dev/null
+++ b/depends/lzma/include/compress.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ *
+ * compress.h - the API for LZMA compression using easylzma
+ */
+
+#pragma once
+
+#include "common.h"
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** suggested default values */
+#define ELZMA_LC_DEFAULT 3
+#define ELZMA_LP_DEFAULT 0
+#define ELZMA_PB_DEFAULT 2
+#define ELZMA_DICT_SIZE_DEFAULT_MAX (1 << 24)
+
+/** an opaque handle to an lzma compressor */
+typedef struct _elzma_compress_handle *elzma_compress_handle;
+
+/**
+ * Allocate a handle to an LZMA compressor object.
+ */
+elzma_compress_handle EASYLZMA_API elzma_compress_alloc();
+
+/**
+ * set allocation routines (optional, if not called malloc & free will
+ * be used)
+ */
+void EASYLZMA_API
+elzma_compress_set_allocation_callbacks(elzma_compress_handle hand, elzma_malloc mallocFunc,
+ void *mallocFuncContext, elzma_free freeFunc,
+ void *freeFuncContext);
+
+/**
+ * Free all data associated with an LZMA compressor object.
+ */
+void EASYLZMA_API elzma_compress_free(elzma_compress_handle *hand);
+
+/**
+ * Set configuration paramters for a compression run. If not called,
+ * reasonable defaults will be used.
+ */
+int EASYLZMA_API elzma_compress_config(elzma_compress_handle hand, unsigned char lc,
+ unsigned char lp, unsigned char pb, unsigned char level,
+ unsigned int dictionarySize, elzma_file_format format,
+ unsigned long long uncompressedSize);
+
+/**
+ * Run compression
+ */
+int EASYLZMA_API
+elzma_compress_run(elzma_compress_handle hand, elzma_read_callback inputStream,
+ void *inputContext, elzma_write_callback outputStream, void *outputContext,
+ elzma_progress_callback progressCallback, void *progressContext);
+
+/**
+ * a heuristic utility routine to guess a dictionary size that gets near
+ * optimal compression while reducing memory usage.
+ * accepts a size in bytes, returns a proposed dictionary size
+ */
+unsigned int EASYLZMA_API elzma_get_dict_size(unsigned long long size);
+
+#ifdef __cplusplus
+}
+;
+#endif
diff --git a/depends/lzma/include/decompress.h b/depends/lzma/include/decompress.h
new file mode 100644
index 00000000..cb10b2ba
--- /dev/null
+++ b/depends/lzma/include/decompress.h
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ *
+ * easylzma/decompress.h - The API for LZMA decompression using easylzma
+ */
+
+#pragma once
+
+#include "include/common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** an opaque handle to an lzma decompressor */
+typedef struct _elzma_decompress_handle *elzma_decompress_handle;
+
+/**
+ * Allocate a handle to an LZMA decompressor object.
+ */
+elzma_decompress_handle EASYLZMA_API elzma_decompress_alloc();
+
+/**
+ * set allocation routines (optional, if not called malloc & free will
+ * be used)
+ */
+void EASYLZMA_API
+elzma_decompress_set_allocation_callbacks(elzma_decompress_handle hand, elzma_malloc mallocFunc,
+ void *mallocFuncContext, elzma_free freeFunc,
+ void *freeFuncContext);
+
+/**
+ * Free all data associated with an LZMA decompressor object.
+ */
+void EASYLZMA_API elzma_decompress_free(elzma_decompress_handle *hand);
+
+/**
+ * Perform decompression
+ *
+ * XXX: should the library automatically detect format by reading stream?
+ * currently it's based on data external to stream (such as extension
+ * or convention)
+ */
+int EASYLZMA_API elzma_decompress_run(elzma_decompress_handle hand,
+ elzma_read_callback inputStream, void *inputContext,
+ elzma_write_callback outputStream, void *outputContext,
+ elzma_file_format format);
+
+#ifdef __cplusplus
+}
+;
+#endif
diff --git a/depends/lzma/include/simple.h b/depends/lzma/include/simple.h
new file mode 100644
index 00000000..83f7b2d2
--- /dev/null
+++ b/depends/lzma/include/simple.h
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * simple.h - a wrapper around easylzma to compress/decompress to memory
+ */
+
+#pragma once
+
+#include "include/common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "include/compress.h"
+#include "include/decompress.h"
+
+/* compress a chunk of memory and return a dynamically allocated buffer
+ * if successful. return value is an easylzma error code */
+int EASYLZMA_API simpleCompress(elzma_file_format format, const unsigned char *inData,
+ size_t inLen, unsigned char **outData, size_t *outLen);
+
+/* decompress a chunk of memory and return a dynamically allocated buffer
+ * if successful. return value is an easylzma error code */
+int EASYLZMA_API simpleDecompress(elzma_file_format format, const unsigned char *inData,
+ size_t inLen, unsigned char **outData, size_t *outLen);
+
+#ifdef __cplusplus
+}
+;
+#endif \ No newline at end of file