aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-07-01 05:12:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-01 05:12:28 +0200
commit45f66167fe96de219aac91d842f3e64d857340f6 (patch)
treec141f2aa8213089258125b370a7427bf14937aaf /include
parent620e863ba24fe9e0126d1540e89a531264021a77 (diff)
downloadbusybox-45f66167fe96de219aac91d842f3e64d857340f6.tar.gz
xz compression detection: avoid the need to seek
function old new delta unpack_unxz 12 67 +55 unpack_xz_stream 2357 2373 +16 xmalloc_read 197 199 +2 setup_unzip_on_fd 118 99 -19 rpm2cpio_main 222 203 -19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 73/-38) Total: 35 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'include')
-rw-r--r--include/unarchive.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/include/unarchive.h b/include/unarchive.h
index b4cf16082..3b8e1575a 100644
--- a/include/unarchive.h
+++ b/include/unarchive.h
@@ -7,16 +7,21 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
enum {
#if BB_BIG_ENDIAN
COMPRESS_MAGIC = 0x1f9d,
- GZIP_MAGIC = 0x1f8b,
- BZIP2_MAGIC = ('B'<<8) + 'Z',
- XZ_MAGIC1 = (0xfd<<8) + '7',
- XZ_MAGIC2 = ((((('z'<<8) + 'X')<<8) + 'Z')<<8) + 0,
+ GZIP_MAGIC = 0x1f8b,
+ BZIP2_MAGIC = 'B' * 256 + 'Z',
+ XZ_MAGIC1 = 0xfd * 256 + '7',
+ XZ_MAGIC2 = (('z' * 256 + 'X') * 256 + 'Z') * 256 + 0,
+ /* Different form: 32 bits, then 16 bits: */
+ XZ_MAGIC1a = ((0xfd * 256 + '7') * 256 + 'z') * 256 + 'X',
+ XZ_MAGIC2a = 'Z' * 256 + 0,
#else
COMPRESS_MAGIC = 0x9d1f,
- GZIP_MAGIC = 0x8b1f,
- BZIP2_MAGIC = ('Z'<<8) + 'B',
- XZ_MAGIC1 = ('7'<<8) + 0xfd,
- XZ_MAGIC2 = (((((0<<8) + 'Z')<<8) + 'X')<<8) + 'z',
+ GZIP_MAGIC = 0x8b1f,
+ BZIP2_MAGIC = 'Z' * 256 + 'B',
+ XZ_MAGIC1 = '7' * 256 + 0xfd,
+ XZ_MAGIC2 = ((0 * 256 + 'Z') * 256 + 'X') * 256 + 'z',
+ XZ_MAGIC1a = (('X' * 256 + 'z') * 256 + '7') * 256 + 0xfd,
+ XZ_MAGIC2a = 0 * 256 + 'Z',
#endif
};
@@ -196,7 +201,7 @@ typedef struct inflate_unzip_result {
} inflate_unzip_result;
IF_DESKTOP(long long) int inflate_unzip(inflate_unzip_result *res, off_t compr_size, int src_fd, int dst_fd) FAST_FUNC;
-/* xz unpacker takes .xz stream from offset 0 */
+/* xz unpacker takes .xz stream from offset 6 */
IF_DESKTOP(long long) int unpack_xz_stream(int src_fd, int dst_fd) FAST_FUNC;
/* lzma unpacker takes .lzma stream from offset 0 */
IF_DESKTOP(long long) int unpack_lzma_stream(int src_fd, int dst_fd) FAST_FUNC;