From 02807927e47b6efa8cd5e2bb3eeae8d2041ffb63 Mon Sep 17 00:00:00 2001
From: xgizzmo <xgizzmo@slackbuilds.org>
Date: Mon, 11 May 2009 22:00:51 -0400
Subject: [PATCH] Added XZ compression support.
Signed-off-by: xgizzmo <xgizzmo@slackbuilds.org>
---
edit/edit.c | 1 +
misc/mc.ext.in | 14 ++++++++++++++
src/util.c | 11 +++++++++++
src/util.h | 3 ++-
vfs/extfs/iso9660.in | 1 +
vfs/extfs/lslR.in | 1 +
vfs/extfs/mailfs.in | 3 +++
vfs/extfs/patchfs.in | 5 +++++
vfs/extfs/sfs.ini | 2 ++
9 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/edit/edit.c b/edit/edit.c
index 77f64ef..1becefb 100644
a
|
b
|
edit_load_file_fast (WEdit *edit, const char *filename) |
321 | 321 | static const struct edit_filters { |
322 | 322 | const char *read, *write, *extension; |
323 | 323 | } all_filters[] = { |
| 324 | { "xz -cd %s 2>&1", "xz > %s", ".xz" }, |
324 | 325 | { "lzma -cd %s 2>&1", "lzma > %s", ".lzma" }, |
325 | 326 | { "bzip2 -cd %s 2>&1", "bzip2 > %s", ".bz2" }, |
326 | 327 | { "gzip -cd %s 2>&1", "gzip > %s", ".gz" }, |
diff --git a/misc/mc.ext.in b/misc/mc.ext.in
index 6cef6bd..86fc7ff 100644
a
|
b
|
regex/\.t(ar\.lzma|lz)$ |
124 | 124 | Open=%cd %p#utar |
125 | 125 | View=%view{ascii} lzma -dc %f 2>/dev/null | tar tvvf - |
126 | 126 | |
| 127 | # .tar.xz, .txz |
| 128 | regex/\.t(ar\.xz|xz)$ |
| 129 | Open=%cd %p#utar |
| 130 | View=%view{ascii} xz -dc %f 2>/dev/null | tar tvvf - |
| 131 | |
127 | 132 | # .tar.F - used in QNX |
128 | 133 | regex/\.tar\.F$ |
129 | 134 | # Open=%cd %p#utar |
… |
… |
regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lzma$ |
320 | 325 | Open=case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more} |
321 | 326 | View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac |
322 | 327 | |
| 328 | regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$ |
| 329 | Open=case %d/%f in */log/*|*/logs/*) xz -dc %f ;; *) xz -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more} |
| 330 | View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) xz -dc %f ;; *) xz -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac |
| 331 | |
323 | 332 | |
324 | 333 | ### Images ### |
325 | 334 | |
… |
… |
regex/\.lzma$ |
601 | 610 | Open=lzma -dc %f | %var{PAGER:more} |
602 | 611 | View=%view{ascii} lzma -dc %f 2>/dev/null |
603 | 612 | |
| 613 | # xz |
| 614 | regex/\.xz$ |
| 615 | Open=xz -dc %f | %var{PAGER:more} |
| 616 | View=%view{ascii} xz -dc %f 2>/dev/null |
| 617 | |
604 | 618 | |
605 | 619 | ### Default ### |
606 | 620 | |
diff --git a/src/util.c b/src/util.c
index b4b6e14..2a84a78 100644
a
|
b
|
get_compression_type (int fd) |
875 | 875 | } |
876 | 876 | } |
877 | 877 | |
| 878 | /* XZ compression magic */ |
| 879 | if (magic[0] == 0xFD |
| 880 | && magic[1] == 0x37 && magic[2] == 0x7A && magic[3] == 0x58) { |
| 881 | if (mc_read (fd, (char *) magic + 4, 2) == 2) { |
| 882 | if (magic[4] == 0x5A && magic[5] == 0x00) { |
| 883 | return COMPRESSION_XZ; |
| 884 | } |
| 885 | } |
| 886 | } |
| 887 | |
878 | 888 | return 0; |
879 | 889 | } |
880 | 890 | |
… |
… |
decompress_extension (int type) |
886 | 896 | case COMPRESSION_BZIP: return "#ubz"; |
887 | 897 | case COMPRESSION_BZIP2: return "#ubz2"; |
888 | 898 | case COMPRESSION_LZMA: return "#ulzma"; |
| 899 | case COMPRESSION_XZ: return "#uxz"; |
889 | 900 | } |
890 | 901 | /* Should never reach this place */ |
891 | 902 | fprintf (stderr, "Fatal: decompress_extension called with an unknown argument\n"); |
diff --git a/src/util.h b/src/util.h
index 557d70b..76c72e9 100644
a
|
b
|
enum compression_type { |
183 | 183 | COMPRESSION_GZIP, |
184 | 184 | COMPRESSION_BZIP, |
185 | 185 | COMPRESSION_BZIP2, |
186 | | COMPRESSION_LZMA |
| 186 | COMPRESSION_LZMA, |
| 187 | COMPRESSION_XZ |
187 | 188 | }; |
188 | 189 | |
189 | 190 | /* Looks for ``magic'' bytes at the start of the VFS file to guess the |
diff --git a/vfs/extfs/iso9660.in b/vfs/extfs/iso9660.in
index ad58e74..7b2ba70 100644
a
|
b
|
mcisofs_list () { |
30 | 30 | # left as a reminder to implement compressed image support =) |
31 | 31 | case "$1" in |
32 | 32 | *.lzma) MYCAT="lzma -dc";; |
| 33 | *.xz) MYCAT="xz -dc";; |
33 | 34 | *.bz2) MYCAT="bzip2 -dc";; |
34 | 35 | *.gz) MYCAT="gzip -dc";; |
35 | 36 | *.z) MYCAT="gzip -dc";; |
diff --git a/vfs/extfs/lslR.in b/vfs/extfs/lslR.in
index 67f5edb..2bc2bd0 100644
a
|
b
|
AWK=@AWK@ |
13 | 13 | mclslRfs_list () { |
14 | 14 | case "$1" in |
15 | 15 | *.lzma) MYCAT="lzma -dc";; |
| 16 | *.xz) MYCAT="xz -dc";; |
16 | 17 | *.bz2) MYCAT="bzip2 -dc";; |
17 | 18 | *.gz) MYCAT="gzip -dc";; |
18 | 19 | *.z) MYCAT="gzip -dc";; |
diff --git a/vfs/extfs/mailfs.in b/vfs/extfs/mailfs.in
index 91cf3d7..bb372e3 100644
a
|
b
|
use bytes; |
8 | 8 | $zcat="zcat"; # gunzip to stdout |
9 | 9 | $bzcat="bzip2 -dc"; # bunzip2 to stdout |
10 | 10 | $lzcat="lzma -dc"; # unlzma to stdout |
| 11 | $xzcat="xz -dc"; # unxz to stdout |
11 | 12 | $file="file"; # "file" command |
12 | 13 | $TZ='GMT'; # default timezone (for Date module) |
13 | 14 | |
… |
… |
if (/gzip/) { |
185 | 186 | exit 1 unless (open IN, "$bzcat $mbox_qname|"); |
186 | 187 | } elsif (/lzma/) { |
187 | 188 | exit 1 unless (open IN, "$lzcat $mbox_qname|"); |
| 189 | } elsif (/xz/) { |
| 190 | exit 1 unless (open IN, "$xzcat $mbox_qname|"); |
188 | 191 | } else { |
189 | 192 | exit 1 unless (open IN, "<$mbox_name"); |
190 | 193 | } |
diff --git a/vfs/extfs/patchfs.in b/vfs/extfs/patchfs.in
index 62a6d0d..7c6b468 100644
a
|
b
|
use File::Temp 'tempfile'; |
13 | 13 | |
14 | 14 | # standard binaries |
15 | 15 | my $lzma = 'lzma'; |
| 16 | my $xz = 'xz'; |
16 | 17 | my $bzip = 'bzip2'; |
17 | 18 | my $gzip = 'gzip'; |
18 | 19 | my $fileutil = 'file'; |
… |
… |
sub myin |
73 | 74 | $_=`$fileutil $qfname`; |
74 | 75 | if (/lzma/) { |
75 | 76 | return "$lzma -dc $qfname"; |
| 77 | } elsif (/xz/) { |
| 78 | return "$xz -dc $qfname"; |
76 | 79 | } elsif (/bzip/) { |
77 | 80 | return "$bzip -dc $qfname"; |
78 | 81 | } elsif (/gzip/) { |
… |
… |
sub myout |
91 | 94 | $_=`$fileutil $qfname`; |
92 | 95 | if (/lzma/) { |
93 | 96 | return "$lzma -c $sep $qfname"; |
| 97 | } elsif (/xz/) { |
| 98 | return "$xz -c $sep $qfname"; |
94 | 99 | } elsif (/bzip/) { |
95 | 100 | return "$bzip -c $sep $qfname"; |
96 | 101 | } elsif (/gzip/) { |
diff --git a/vfs/extfs/sfs.ini b/vfs/extfs/sfs.ini
index fc77e04..522cca1 100644
a
|
b
|
bz2/1 bzip2 < %1 > %3 |
12 | 12 | ubz2/1 bzip2 -d < %1 > %3 |
13 | 13 | lzma/1 lzma < %1 > %3 |
14 | 14 | ulzma/1 lzma -d < %1 > %3 |
| 15 | xz/1 xz < %1 > %3 |
| 16 | uxz/1 xz -d < %1 > %3 |
15 | 17 | tar/1 tar cf %3 %1 |
16 | 18 | tgz/1 tar czf %3 %1 |
17 | 19 | uhtml/1 lynx -force_html -dump %1 > %3 |