our ($fexhome,$idf,$tmpdir,$windoof,$useragent);
our ($xv,%autoview);
our $bs = 2**16; # blocksize for tcp-reading and writing file
-our $version = 20150615;
+our $version = 20150826;
our $CTYPE = 'ISO-8859-1';
our $fexsend = $ENV{FEXSEND} || 'fexsend';
You can set these environment variables also in $HOME/.fex/config.pl, as well as
the $opt_* variables, e.g.:
-
+
$ENV{SSLVERSION} = 'TLSv1';
${'opt_+'} = 1;
$opt_m = 200;
my @rcamel = (
'\e[A
-(_*) _ _
+(_*) _ _
\\\\/ \\/ \\
\ __ )=*
- //\\\\//\\\\
+ //\\\\//\\\\
',
-'\e[A \\\\/\\\\/
+'\e[A \\\\/\\\\/
',
'\e[A //\\\\//\\\\
');
exit if $opt_s eq '-';
unlink $download unless -s $download;
exit 2 unless -f $download;
-
+
if ($windoof) {
print "READY\n";
exit;
}
unless ($opt_X) {
-
+
foreach my $a (keys %autoview) {
if ($download =~ /$a$/i and $autoview{$a}) {
printf "run \"%s %s\" [Yn] ? ",$autoview{$a},basename($download);
next URL;
}
}
-
+
if ($ENV{DISPLAY} and $download =~ /\.(gif|jpg|png|tiff?)$/i) {
# see also mimeopen and xdg-mime
if (my $xv = $xv || pathsearch('xv') || pathsearch('xdg-open')) {
next URL;
}
}
-
+
if ($download =~ /$atype/) {
if ($download =~ /\.(tgz|tar.gz)$/) { extract('tar tvzf','tar xvzf') }
- elsif ($download =~ /\.tar$/) { extract('tar tvf','tar xvf') }
- elsif ($download =~ /\.zip$/i) { extract('unzip -l','unzip') }
+ elsif ($download =~ /\.tar$/) { extract('tar tvf','tar xvf') }
+ elsif ($download =~ /\.zip$/i) { extract('unzip -l','unzip') }
elsif ($download =~ /\.7z$/i) { extract('7z l','7z x') }
else { die "$0: unknown archive \"$download\"\n" }
if ($? == 0) {
my $d = $download;
my $xd = '.';
local $_;
-
+
if (-t and not $windoof) {
print "Files in archive:\n";
system(split(' ',$l),$download);
if ($xd eq '-') {
print "keeping $download\n";
exit;
- }
+ }
if ($xd !~ s/!$//) {
if (-d $xd) {
print "directory $xd does already exist, add \"!\" to overwrite\n";
"GET $uri?COPY HTTP/1.1",
"User-Agent: $useragent",
);
-
+
$_ = <$SH>;
die "$0: no reply from fex server $server\n" unless $_;
warn "<-- $_" if $opt_v;
-
+
unless (/^HTTP.*200/) {
s/^HTTP.... \d+ //;
die "$0: $_";
}
-
+
while (<$SH>) {
s/\r//;
last if /^\n/; # ignore HTML output
}
}
close $list;
-
+
if ($n) {
$cmd = "fexsend -d $n >/dev/null 2>&1";
print "$cmd\n" if $opt_v;
}
close $SH;
close X;
-
+
print $rcamel[2] if ${'opt_+'};
$tt = $t2-$t0;
sub pathsearch {
my $prg = shift;
-
+
foreach my $dir (split(':',$ENV{PATH})) {
return "$dir/$prg" if -x "$dir/$prg";
}
}
-
+
sub quote {
local $_ = shift;
s/([^\w¡-ÿ_%\/=~:.,-])/\\$1/g;
return $_;
}
-
+
{
my $tty;
if (defined(&TIOCSTI) and $tty and open($tty,'>',$tty)) {
print $prompt;
- foreach my $a (split("",$default)) { ioctl($tty,&TIOCSTI,$a) }
+ foreach my $a (split("",$default)) { ioctl($tty,&TIOCSTI,$a) }
chomp($_ = <STDIN>||'');
} else {
$prompt =~ s/([\?:=]\s*)/ [$default]$1/ or $prompt .= " [$default]";
}
return $_;
- }
-}
+ }
+}
### common functions ###
$SSL{SSL_verify_mode} = $ENV{SSLVERIFY} if defined($ENV{SSLVERIFY});
foreach my $opt (qw(
SSL_version
- SSL_cipher_list
- SSL_verify_mode
- SSL_ca_path
+ SSL_cipher_list
+ SSL_verify_mode
+ SSL_ca_path
SSL_ca_file)
) {
my $env = uc($opt);
my ($server,$port) = @_;
my $connect = "CONNECT $server:$port HTTP/1.1";
local $_;
-
+
if ($opt_v and $port == 443 and %SSL) {
foreach my $v (keys %SSL) {
printf "%s => %s\n",$v,$SSL{$v};
}
}
-
+
if ($proxy) {
tcpconnect(split(':',$proxy));
if ($port == 443) {
# set up tcp/ip connection
sub tcpconnect {
my ($server,$port) = @_;
-
+
if ($SH) {
close $SH;
undef $SH;
}
-
+
if ($port == 443) {
# eval "use IO::Socket::SSL qw(debug3)";
eval "use IO::Socket::SSL";
Proto => 'tcp',
);
}
-
+
if ($SH) {
autoflush $SH 1;
} else {
die "$0: cannot connect $server:$port - $@\n";
}
-
+
print "TCPCONNECT to $server:$port\n" if $opt_v;
}
my $sp = shift;
my @head = @_;
my $head;
-
+
push @head,"Host: $sp";
-
+
foreach $head (@head) {
print "--> $head\n" if $opt_v;
print {$SH} $head,"\r\n";
sub nvtsend {
local $SIG{PIPE} = sub { $sigpipe = "@_" };
-
+
$sigpipe = '';
-
+
die "$0: internal error: no active network handle\n" unless $SH;
die "$0: remote host has closed the link\n" unless $SH->connected;
-
+
foreach my $line (@_) {
print {$SH} $line,"\r\n";
if ($sigpipe) {
return 0;
}
}
-
+
return 1;
}
my $res = "";
my $eol = "\n";
my $padding;
-
+
pos($_[0]) = 0;
$res = join '',map(pack('u',$_)=~ /^.(\S*)/, ($_[0]=~/(.{1,45})/gs));
$res =~ tr|` -_|AA-Za-z0-9+/|;