aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-09-06 15:14:30 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-09-06 15:14:30 +0300
commit0a31ed9d5e3cde4feb094b66f3a8b2c074605d84 (patch)
tree571b741cc155767f3c5e0ee0a0a686995568b16a /src/liblzma/common
parentAdded support for raw encoding and decoding to the command (diff)
downloadxz-0a31ed9d5e3cde4feb094b66f3a8b2c074605d84.tar.xz
Some API cleanups
Diffstat (limited to 'src/liblzma/common')
-rw-r--r--src/liblzma/common/auto_decoder.c18
-rw-r--r--src/liblzma/common/common.c7
-rw-r--r--src/liblzma/common/common.h18
-rw-r--r--src/liblzma/common/easy.c2
-rw-r--r--src/liblzma/common/stream_decoder.c31
5 files changed, 42 insertions, 34 deletions
diff --git a/src/liblzma/common/auto_decoder.c b/src/liblzma/common/auto_decoder.c
index acfc3549..4272dadf 100644
--- a/src/liblzma/common/auto_decoder.c
+++ b/src/liblzma/common/auto_decoder.c
@@ -63,15 +63,15 @@ auto_decode(lzma_coder *coder, lzma_allocator *allocator,
return_if_error(lzma_alone_decoder_init(&coder->next,
allocator, coder->memlimit));
- // If the application wants a warning about missing
+ // If the application wants to know about missing
// integrity check or about the check in general, we
// need to handle it here, because LZMA_Alone decoder
// doesn't accept any flags.
- if (coder->flags & LZMA_WARN_NO_CHECK)
+ if (coder->flags & LZMA_TELL_NO_CHECK)
return LZMA_NO_CHECK;
- if (coder->flags & LZMA_TELL_CHECK)
- return LZMA_SEE_CHECK;
+ if (coder->flags & LZMA_TELL_ANY_CHECK)
+ return LZMA_GET_CHECK;
}
// Fall through
@@ -116,11 +116,11 @@ auto_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_check
-auto_decoder_see_check(const lzma_coder *coder)
+auto_decoder_get_check(const lzma_coder *coder)
{
- // It is LZMA_Alone if see_check is NULL.
- return coder->next.see_check == NULL ? LZMA_CHECK_NONE
- : coder->next.see_check(coder->next.coder);
+ // It is LZMA_Alone if get_check is NULL.
+ return coder->next.get_check == NULL ? LZMA_CHECK_NONE
+ : coder->next.get_check(coder->next.coder);
}
@@ -140,7 +140,7 @@ auto_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->code = &auto_decode;
next->end = &auto_decoder_end;
- next->see_check = &auto_decoder_see_check;
+ next->get_check = &auto_decoder_get_check;
next->coder->next = LZMA_NEXT_CODER_INIT;
}
diff --git a/src/liblzma/common/common.c b/src/liblzma/common/common.c
index feac9cbf..c5f5039d 100644
--- a/src/liblzma/common/common.c
+++ b/src/liblzma/common/common.c
@@ -296,3 +296,10 @@ lzma_end(lzma_stream *strm)
return;
}
+
+
+extern LZMA_API lzma_check
+lzma_get_check(const lzma_stream *strm)
+{
+ return strm->internal->next.get_check(strm->internal->next.coder);
+}
diff --git a/src/liblzma/common/common.h b/src/liblzma/common/common.h
index 81f2a9a4..bb999842 100644
--- a/src/liblzma/common/common.h
+++ b/src/liblzma/common/common.h
@@ -60,10 +60,10 @@
/// Supported flags that can be passed to lzma_stream_decoder()
/// or lzma_auto_decoder().
#define LZMA_SUPPORTED_FLAGS \
- (LZMA_WARN_NO_CHECK \
- | LZMA_WARN_UNSUPPORTED_CHECK \
- | LZMA_TELL_CHECK \
- | LZMA_CONCATENATED)
+ ( LZMA_TELL_NO_CHECK \
+ | LZMA_TELL_UNSUPPORTED_CHECK \
+ | LZMA_TELL_ANY_CHECK \
+ | LZMA_CONCATENATED )
///////////
@@ -134,10 +134,11 @@ struct lzma_next_coder_s {
/// Pointer to function to return the type of the integrity check.
/// Most coders won't support this.
- lzma_check (*see_check)(const lzma_coder *coder);
+ lzma_check (*get_check)(const lzma_coder *coder);
-// uint64_t (*memconfig)(
-// lzma_coder *coder, uint64_t memlimit, bool change);
+ /// Pointer to function to get and/or change the memory usage limit.
+ /// If memlimit == 0, the limit is not changed.
+ uint64_t (*memconfig)(lzma_coder *coder, uint64_t memlimit);
};
@@ -148,7 +149,8 @@ struct lzma_next_coder_s {
.init = (uintptr_t)(NULL), \
.code = NULL, \
.end = NULL, \
- .see_check = NULL, \
+ .get_check = NULL, \
+ .memconfig = NULL, \
}
diff --git a/src/liblzma/common/easy.c b/src/liblzma/common/easy.c
index ae0e4f74..6f6dc0fa 100644
--- a/src/liblzma/common/easy.c
+++ b/src/liblzma/common/easy.c
@@ -113,7 +113,7 @@ lzma_easy_encoder(lzma_stream *strm, lzma_easy_level level)
}
-extern LZMA_API uint32_t
+extern LZMA_API uint64_t
lzma_easy_memory_usage(lzma_easy_level level)
{
lzma_filter filters[5];
diff --git a/src/liblzma/common/stream_decoder.c b/src/liblzma/common/stream_decoder.c
index cf7af7ac..7d1df9cc 100644
--- a/src/liblzma/common/stream_decoder.c
+++ b/src/liblzma/common/stream_decoder.c
@@ -55,14 +55,14 @@ struct lzma_coder_s {
/// If true, LZMA_NO_CHECK is returned if the Stream has
/// no integrity check.
- bool warn_no_check;
+ bool tell_no_check;
/// If true, LZMA_UNSUPPORTED_CHECK is returned if the Stream has
/// an integrity check that isn't supported by this liblzma build.
- bool warn_unsupported_check;
+ bool tell_unsupported_check;
- /// If true, LZMA_SEE_CHECK is returned after decoding Stream Header.
- bool tell_check;
+ /// If true, LZMA_GET_CHECK is returned after decoding Stream Header.
+ bool tell_any_check;
/// If true, we will decode concatenated Streams that possibly have
/// Stream Padding between or after them. LZMA_STREAM_END is returned
@@ -141,17 +141,17 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
// Detect if there's no integrity check or if it is
// unsupported if those were requested by the application.
- if (coder->warn_no_check && coder->stream_flags.check
+ if (coder->tell_no_check && coder->stream_flags.check
== LZMA_CHECK_NONE)
return LZMA_NO_CHECK;
- if (coder->warn_unsupported_check
+ if (coder->tell_unsupported_check
&& !lzma_check_is_supported(
coder->stream_flags.check))
return LZMA_UNSUPPORTED_CHECK;
- if (coder->tell_check)
- return LZMA_SEE_CHECK;
+ if (coder->tell_any_check)
+ return LZMA_GET_CHECK;
}
// Fall through
@@ -366,7 +366,7 @@ stream_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_check
-stream_decoder_see_check(const lzma_coder *coder)
+stream_decoder_get_check(const lzma_coder *coder)
{
return coder->stream_flags.check;
}
@@ -388,19 +388,18 @@ lzma_stream_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->code = &stream_decode;
next->end = &stream_decoder_end;
- next->see_check = &stream_decoder_see_check;
+ next->get_check = &stream_decoder_get_check;
next->coder->block_decoder = LZMA_NEXT_CODER_INIT;
next->coder->index_hash = NULL;
}
next->coder->memlimit = memlimit;
- next->coder->warn_no_check = (flags & LZMA_WARN_NO_CHECK) != 0;
- next->coder->warn_unsupported_check
- = (flags & LZMA_WARN_UNSUPPORTED_CHECK) != 0;
- next->coder->tell_check = (flags & LZMA_TELL_CHECK) != 0;
- next->coder->concatenated
- = (flags & LZMA_CONCATENATED) != 0;
+ next->coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0;
+ next->coder->tell_unsupported_check
+ = (flags & LZMA_TELL_UNSUPPORTED_CHECK) != 0;
+ next->coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0;
+ next->coder->concatenated = (flags & LZMA_CONCATENATED) != 0;
return stream_decoder_reset(next->coder, allocator);
}