aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/delta
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/liblzma/delta/Makefile.am34
-rw-r--r--src/liblzma/delta/delta_common.c (renamed from src/liblzma/common/delta_common.c)2
-rw-r--r--src/liblzma/delta/delta_common.h (renamed from src/liblzma/common/delta_common.h)0
-rw-r--r--src/liblzma/delta/delta_decoder.c (renamed from src/liblzma/common/delta_decoder.c)21
-rw-r--r--src/liblzma/delta/delta_decoder.h (renamed from src/liblzma/common/delta_decoder.h)4
-rw-r--r--src/liblzma/delta/delta_encoder.c (renamed from src/liblzma/common/delta_encoder.c)21
-rw-r--r--src/liblzma/delta/delta_encoder.h (renamed from src/liblzma/common/delta_encoder.h)2
7 files changed, 83 insertions, 1 deletions
diff --git a/src/liblzma/delta/Makefile.am b/src/liblzma/delta/Makefile.am
new file mode 100644
index 00000000..fc09f5b8
--- /dev/null
+++ b/src/liblzma/delta/Makefile.am
@@ -0,0 +1,34 @@
+##
+## Copyright (C) 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.
+##
+
+noinst_LTLIBRARIES = libdelta.la
+libdelta_la_CPPFLAGS = \
+ -I@top_srcdir@/src/liblzma/api \
+ -I@top_srcdir@/src/liblzma/common
+
+libdelta_la_SOURCES = \
+ delta_common.c \
+ delta_common.h
+
+if COND_ENCODER_DELTA
+libdelta_la_SOURCES += \
+ delta_encoder.c \
+ delta_encoder.h
+endif
+
+if COND_DECODER_DELTA
+libdelta_la_SOURCES += \
+ delta_decoder.c \
+ delta_decoder.h
+endif
diff --git a/src/liblzma/common/delta_common.c b/src/liblzma/delta/delta_common.c
index acd31e14..d40e0c7f 100644
--- a/src/liblzma/common/delta_common.c
+++ b/src/liblzma/delta/delta_common.c
@@ -23,7 +23,7 @@
static void
delta_coder_end(lzma_coder *coder, lzma_allocator *allocator)
{
- lzma_next_coder_end(&coder->next, allocator);
+ lzma_next_end(&coder->next, allocator);
lzma_free(coder, allocator);
return;
}
diff --git a/src/liblzma/common/delta_common.h b/src/liblzma/delta/delta_common.h
index 1d58899d..1d58899d 100644
--- a/src/liblzma/common/delta_common.h
+++ b/src/liblzma/delta/delta_common.h
diff --git a/src/liblzma/common/delta_decoder.c b/src/liblzma/delta/delta_decoder.c
index 8f5a4cbf..ee22ba02 100644
--- a/src/liblzma/common/delta_decoder.c
+++ b/src/liblzma/delta/delta_decoder.c
@@ -59,3 +59,24 @@ lzma_delta_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
{
return lzma_delta_coder_init(next, allocator, filters, &delta_decode);
}
+
+
+extern lzma_ret
+lzma_delta_props_decode(void **options, lzma_allocator *allocator,
+ const uint8_t *props, size_t props_size)
+{
+ if (props_size != 1)
+ return LZMA_HEADER_ERROR;
+
+ lzma_options_delta *opt
+ = lzma_alloc(sizeof(lzma_options_delta), allocator);
+ if (opt == NULL)
+ return LZMA_MEM_ERROR;
+
+ opt->type = LZMA_DELTA_TYPE_BYTE;
+ opt->distance = props[0] + 1;
+
+ *options = opt;
+
+ return LZMA_OK;
+}
diff --git a/src/liblzma/common/delta_decoder.h b/src/liblzma/delta/delta_decoder.h
index bef9f58a..84852bf3 100644
--- a/src/liblzma/common/delta_decoder.h
+++ b/src/liblzma/delta/delta_decoder.h
@@ -25,4 +25,8 @@
extern lzma_ret lzma_delta_decoder_init(lzma_next_coder *next,
lzma_allocator *allocator, const lzma_filter_info *filters);
+extern lzma_ret lzma_delta_props_decode(
+ void **options, lzma_allocator *allocator,
+ const uint8_t *props, size_t props_size);
+
#endif
diff --git a/src/liblzma/common/delta_encoder.c b/src/liblzma/delta/delta_encoder.c
index a8bb9341..d8f40287 100644
--- a/src/liblzma/common/delta_encoder.c
+++ b/src/liblzma/delta/delta_encoder.c
@@ -96,3 +96,24 @@ lzma_delta_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
{
return lzma_delta_coder_init(next, allocator, filters, &delta_encode);
}
+
+
+extern lzma_ret
+lzma_delta_props_encode(const void *options, uint8_t *out)
+{
+ if (options == NULL)
+ return LZMA_PROG_ERROR;
+
+ const lzma_options_delta *opt = options;
+
+ // It's possible that newer liblzma versions will support larger
+ // distance values.
+ if (opt->type != LZMA_DELTA_TYPE_BYTE
+ || opt->distance < LZMA_DELTA_DISTANCE_MIN
+ || opt->distance > LZMA_DELTA_DISTANCE_MAX)
+ return LZMA_HEADER_ERROR;
+
+ out[0] = opt->distance - LZMA_DELTA_DISTANCE_MIN;
+
+ return LZMA_OK;
+}
diff --git a/src/liblzma/common/delta_encoder.h b/src/liblzma/delta/delta_encoder.h
index c669458d..b8b29c61 100644
--- a/src/liblzma/common/delta_encoder.h
+++ b/src/liblzma/delta/delta_encoder.h
@@ -25,4 +25,6 @@
extern lzma_ret lzma_delta_encoder_init(lzma_next_coder *next,
lzma_allocator *allocator, const lzma_filter_info *filters);
+extern lzma_ret lzma_delta_props_encode(const void *options, uint8_t *out);
+
#endif