Variable: tramp-perl-decode
tramp-perl-decode is a variable defined in tramp-sh.el.gz.
Value
"%p -e '\nuse strict;\n\nmy %%trans = do {\n my $i = 0;\n map {($_, substr(unpack(q(B8), chr $i++), 2, 6))}\n split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/)\n};\n\nmy %%bytes = map {(unpack(q(B8), chr $_), chr $_)} 0 .. 255;\n\nbinmode(\\*STDOUT);\n\n# We are going to accumulate into $pending to accept any line length\n# (we do not check they are <= 76 chars as the RFC says)\nmy $pending = q();\n\nwhile (my $data = <STDIN>) {\n chomp $data;\n\n # If we find one or two =, we have reached the end and\n # any following data is to be discarded\n my $finished = $data =~ s/(==?).*/$1/;\n $pending .= $data;\n\n my $len = length($pending);\n my $chunk = substr($pending, 0, $len & ~3);\n $pending = substr($pending, $len & ~3 + 1);\n\n # Easy method: translate from chars to (pregenerated) six-bit packets, join,\n # split in 8-bit chunks and convert back to char.\n print join q(),\n map $bytes{$_},\n ((join q(), map {$trans{$_} || q()} split //, $chunk) =~ /......../g);\n\n last if $finished;\n}' %n"
Documentation
Perl program to use for decoding a file.
Format specifiers are replaced by tramp-expand-script, percent
characters need to be doubled.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
;; This script contributed by Juanma Barranquero <lektu@terra.es>.
(defconst tramp-perl-decode "\
%p -e '
use strict;
my %%trans = do {
my $i = 0;
map {($_, substr(unpack(q(B8), chr $i++), 2, 6))}
split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/)
};
my %%bytes = map {(unpack(q(B8), chr $_), chr $_)} 0 .. 255;
binmode(\\*STDOUT);
# We are going to accumulate into $pending to accept any line length
# (we do not check they are <= 76 chars as the RFC says)
my $pending = q();
while (my $data = <STDIN>) {
chomp $data;
# If we find one or two =, we have reached the end and
# any following data is to be discarded
my $finished = $data =~ s/(==?).*/$1/;
$pending .= $data;
my $len = length($pending);
my $chunk = substr($pending, 0, $len & ~3);
$pending = substr($pending, $len & ~3 + 1);
# Easy method: translate from chars to (pregenerated) six-bit packets, join,
# split in 8-bit chunks and convert back to char.
print join q(),
map $bytes{$_},
((join q(), map {$trans{$_} || q()} split //, $chunk) =~ /......../g);
last if $finished;
}' %n"
"Perl program to use for decoding a file.
Format specifiers are replaced by `tramp-expand-script', percent
characters need to be doubled.")