line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wily::Connect; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
13
|
use v5.8; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
48
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1218
|
use File::Temp qw/ :POSIX /; |
|
1
|
|
|
|
|
25367
|
|
|
1
|
|
|
|
|
133
|
|
9
|
1
|
|
|
1
|
|
866
|
use IO::Socket; |
|
1
|
|
|
|
|
16981
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
706
|
use Fcntl; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
623
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub connect { |
15
|
0
|
|
|
0
|
0
|
|
local *FILE; |
16
|
0
|
|
|
|
|
|
my $tmpfile = tmpnam(); |
17
|
0
|
|
|
|
|
|
my $sock = IO::Socket::UNIX->new(Local=>$tmpfile,Type=>SOCK_STREAM, Listen=>1); |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
sysopen FILE, wily_fifo_name(), O_WRONLY |
20
|
|
|
|
|
|
|
or croak "Unable to open wily fifo: $!"; |
21
|
0
|
|
|
|
|
|
print FILE $tmpfile; |
22
|
0
|
0
|
|
|
|
|
close FILE or croak "Error closing wily fifo: $!"; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $s = $sock->accept(); |
25
|
0
|
|
|
|
|
|
$sock->close(); |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
unlink $tmpfile or carp "unlink of '$tmpfile' failed: $!"; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
return $s; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub wily_fifo_name { |
33
|
0
|
0
|
|
0
|
0
|
|
if (exists $ENV{WILYFIFO}) { |
34
|
0
|
|
|
|
|
|
return $ENV{WILYFIFO}; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
0
|
|
|
|
|
if (not exists $ENV{DISPLAY}) { |
37
|
0
|
|
|
|
|
|
croak 'No $DISPLAY set'; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
0
|
|
|
|
my $tmp = $ENV{TMPDIR} || '/tmp'; |
40
|
0
|
|
0
|
|
|
|
my $login = getlogin || getpwuid($<); |
41
|
0
|
|
|
|
|
|
return "$tmp/wily$login$ENV{DISPLAY}"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
__END__ |