aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/api/lzma/container.h
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-08-28 22:53:15 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-08-28 22:53:15 +0300
commit3b34851de1eaf358cf9268922fa0eeed8278d680 (patch)
tree7bab212af647541df64227a8d350d17a2e789f6b /src/liblzma/api/lzma/container.h
parentFix test_filter_flags to match the new restriction of lc+lp. (diff)
downloadxz-3b34851de1eaf358cf9268922fa0eeed8278d680.tar.xz
Sort of garbage collection commit. :-| Many things are still
broken. API has changed a lot and it will still change a little more here and there. The command line tool doesn't have all the required changes to reflect the API changes, so it's easy to get "internal error" or trigger assertions.
Diffstat (limited to '')
-rw-r--r--src/liblzma/api/lzma/container.h252
1 files changed, 252 insertions, 0 deletions
diff --git a/src/liblzma/api/lzma/container.h b/src/liblzma/api/lzma/container.h
new file mode 100644
index 00000000..27014856
--- /dev/null
+++ b/src/liblzma/api/lzma/container.h
@@ -0,0 +1,252 @@
+/**
+ * \file lzma/FIXME.h
+ * \brief File formats
+ *
+ * \author Copyright (C) 1999-2008 Igor Pavlov
+ * \author Copyright (C) 2007-2008 Lasse Collin
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+
+#ifndef LZMA_H_INTERNAL
+# error Never include this file directly. Use <lzma.h> instead.
+#endif
+
+
+/************
+ * Encoding *
+ ************/
+
+/**
+ * \brief Compression level names for lzma_easy_* functions
+ *
+ * At the moment, all the compression levels support LZMA_SYNC_FLUSH.
+ * In future there may be levels that don't support LZMA_SYNC_FLUSH.
+ * However, the LZMA_SYNC_FLUSH support won't be removed from the
+ * existing compression levels.
+ *
+ * \note If liblzma is built without encoder support, or with some
+ * filters disabled, some of the compression levels may be
+ * unsupported. In that case, the initialization functions
+ * will return LZMA_HEADER_ERROR.
+ */
+typedef enum {
+ LZMA_EASY_COPY = 0,
+ /**<
+ * No compression; the data is just wrapped into .lzma
+ * container.
+ */
+
+ LZMA_EASY_LZMA2_1 = 1,
+ /**<
+ * LZMA2 filter with fast compression (fast in terms of LZMA2).
+ * If you are interested in the exact options used, see
+ * lzma_preset_lzma[0]. Note that the exact options may
+ * change between liblzma versions.
+ *
+ * At the moment, the command line tool uses these settings
+ * when `lzma -1' is used. In future, the command line tool
+ * may default to some more complex way to determine the
+ * settings used e.g. the type of files being compressed.
+ *
+ * LZMA_EASY_LZMA_2 is equivalent to lzma_preset_lzma[1]
+ * and so on.
+ */
+
+ LZMA_EASY_LZMA_2 = 2,
+ LZMA_EASY_LZMA_3 = 3,
+ LZMA_EASY_LZMA_4 = 4,
+ LZMA_EASY_LZMA_5 = 5,
+ LZMA_EASY_LZMA_6 = 6,
+ LZMA_EASY_LZMA_7 = 7,
+ LZMA_EASY_LZMA_8 = 8,
+ LZMA_EASY_LZMA_9 = 9,
+} lzma_easy_level;
+
+
+/**
+ * \brief Default compression level
+ *
+ * Data Blocks contain the actual compressed data. It's not straightforward
+ * to recommend a default level, because in some cases keeping the resource
+ * usage relatively low is more important that getting the maximum
+ * compression ratio.
+ */
+#define LZMA_EASY_DEFAULT LZMA_EASY_LZMA2_7
+
+
+/**
+ * \brief Calculates rough memory requirements of a compression level
+ *
+ * This function is a wrapper for lzma_memory_usage(), which is declared
+ * in filter.h.
+ *
+ * \return Approximate memory usage of the encoder with the given
+ * compression level in mebibytes (value * 1024 * 1024 bytes).
+ * On error (e.g. compression level is not supported),
+ * UINT32_MAX is returned.
+ */
+extern uint32_t lzma_easy_memory_usage(lzma_easy_level level)
+ lzma_attr_pure;
+
+
+/**
+ * \brief Initializes .lzma Stream encoder
+ *
+ * This function is intended for those who just want to use the basic features
+ * if liblzma (that is, most developers out there). Lots of assumptions are
+ * made, which are correct or at least good enough for most situations.
+ *
+ * \param strm Pointer to lzma_stream that is at least initialized
+ * with LZMA_STREAM_INIT.
+ * \param level Compression level to use. This selects a set of
+ * compression settings from a list of compression
+ * presets.
+ *
+ * \return - LZMA_OK: Initialization succeeded. Use lzma_code() to
+ * encode your data.
+ * - LZMA_MEM_ERROR: Memory allocation failed. All memory
+ * previously allocated for *strm is now freed.
+ * - LZMA_HEADER_ERROR: The given compression level is not
+ * supported by this build of liblzma.
+ *
+ * If initialization succeeds, use lzma_code() to do the actual encoding.
+ * Valid values for `action' (the second argument of lzma_code()) are
+ * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future,
+ * there may be compression levels that don't support LZMA_SYNC_FLUSH.
+ */
+extern lzma_ret lzma_easy_encoder(lzma_stream *strm, lzma_easy_level level)
+ lzma_attr_warn_unused_result;
+
+
+/**
+ * \brief Initializes .lzma Stream encoder
+ *
+ * \param strm Pointer to properly prepared lzma_stream
+ * \param filters Array of filters. This must be terminated with
+ * filters[n].id = LZMA_VLI_VALUE_UNKNOWN. There must
+ * be 1-4 filters, but there are restrictions on how
+ * multiple filters can be combined. FIXME Tell where
+ * to find more information.
+ * \param check Type of the integrity check to calculate from
+ * uncompressed data.
+ *
+ * \return - LZMA_OK: Initialization was successful.
+ * - LZMA_MEM_ERROR
+ * - LZMA_HEADER_ERROR
+ * - LZMA_PROG_ERROR
+ */
+extern lzma_ret lzma_stream_encoder(lzma_stream *strm,
+ const lzma_filter *filters, lzma_check check)
+ lzma_attr_warn_unused_result;
+
+
+/**
+ * \brief Initializes LZMA_Alone (deprecated file format) encoder
+ *
+ * LZMA_Alone files have the suffix .lzma like the .lzma Stream files.
+ * LZMA_Alone format supports only one filter, the LZMA filter. There is
+ * no support for integrity checks like CRC32.
+ *
+ * Use this format if and only if you need to create files readable by
+ * legacy LZMA tools such as LZMA Utils 4.32.x.
+ *
+ * LZMA_Alone encoder doesn't support LZMA_SYNC_FLUSH or LZMA_FULL_FLUSH.
+ *
+ * \return - LZMA_OK
+ * - LZMA_MEM_ERROR
+ * - LZMA_PROG_ERROR
+ */
+extern lzma_ret lzma_alone_encoder(
+ lzma_stream *strm, const lzma_options_lzma *options)
+ lzma_attr_warn_unused_result;
+
+
+/************
+ * Decoding *
+ ************/
+
+/**
+ * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream
+ * being decoded has no integrity check. Note that when used with
+ * lzma_auto_decoder(), all LZMA_Alone files will cause trigger LZMA_NO_CHECK
+ * if LZMA_WARN_NO_CHECK is used.
+ */
+#define LZMA_WARN_NO_CHECK UINT32_C(0x01)
+
+
+/**
+ * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input
+ * stream has an integrity check, but the type of the integrity check is not
+ * supported by this liblzma version or build. Such files can still be
+ * decoded, but the integrity check cannot be verified.
+ */
+#define LZMA_WARN_UNSUPPORTED_CHECK UINT32_C(0x02)
+
+
+/**
+ * This flag makes lzma_code() return LZMA_READ_CHECK as soon as the type
+ * of the integrity check is known. The type can then be read with
+ * lzma_check_get().
+ */
+#define LZMA_TELL_CHECK UINT32_C(0x04)
+
+
+/**
+ * This flag makes lzma_code() decode concatenated .lzma files.
+ * FIXME Explain the changed API.
+ */
+#define LZMA_CONCATENATED UINT32_C(0x08)
+
+
+/**
+ * \brief Initializes decoder for .lzma Stream
+ *
+ * \param strm Pointer to propertily prepared lzma_stream
+ * \param memlimit Rough memory usage limit as bytes
+ *
+ * \return - LZMA_OK: Initialization was successful.
+ * - LZMA_MEM_ERROR: Cannot allocate memory.
+ */
+extern lzma_ret lzma_stream_decoder(
+ lzma_stream *strm, uint64_t memlimit, uint32_t flags)
+ lzma_attr_warn_unused_result;
+
+
+/**
+ * \brief Decode .lzma Streams and LZMA_Alone files with autodetection
+ *
+ * Autodetects between the .lzma Stream and LZMA_Alone formats, and
+ * calls lzma_stream_decoder_init() or lzma_alone_decoder_init() once
+ * the type of the file has been detected.
+ *
+ * \param strm Pointer to propertily prepared lzma_stream
+ * \param memlimit Rough memory usage limit as bytes
+ * \param flags Bitwise-or of flags, or zero for no flags.
+ *
+ * \return - LZMA_OK: Initialization was successful.
+ * - LZMA_MEM_ERROR: Cannot allocate memory.
+ */
+extern lzma_ret lzma_auto_decoder(
+ lzma_stream *strm, uint64_t memlimit, uint32_t flags)
+ lzma_attr_warn_unused_result;
+
+
+/**
+ * \brief Initializes decoder for LZMA_Alone file
+ *
+ * The LZMA_Alone decoder supports LZMA_SYNC_FLUSH. FIXME
+ *
+ * \return - LZMA_OK
+ * - LZMA_MEM_ERROR
+ */
+extern lzma_ret lzma_alone_decoder(lzma_stream *strm, uint64_t memlimit)
+ lzma_attr_warn_unused_result;