line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package X11::WM::Sawfish::UNIX; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright (C) 2003 Craig B. Agricola. All rights reserved. This library is |
4
|
|
|
|
|
|
|
# free software; you can redistribute it and/or modify it under the same terms |
5
|
|
|
|
|
|
|
# as Perl itself. |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
21
|
use 5.005; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
47
|
|
8
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
7
|
use X11::WM::Sawfish; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
94
|
|
14
|
|
|
|
|
|
|
our @ISA = qw(X11::WM::Sawfish); |
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw(); |
16
|
|
|
|
|
|
|
our @EXPORT = qw(); |
17
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
957
|
use IO qw(Socket); |
|
1
|
|
|
|
|
750
|
|
|
1
|
|
|
|
|
6
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
27249
|
use constant req_eval => 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
22
|
1
|
|
|
1
|
|
5
|
use constant req_eval_async => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
23
|
1
|
|
|
1
|
|
4
|
use constant req_end_of_session => 255; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
419
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
0
|
|
|
0
|
1
|
|
my ($package, $display) = @_; |
27
|
0
|
|
0
|
|
|
|
$package = ref($package) || $package; |
28
|
0
|
|
|
|
|
|
my ($self) = {}; |
29
|
0
|
|
|
|
|
|
bless($self, $package); |
30
|
0
|
|
|
|
|
|
$self->{SocketPath} = X11::WM::Sawfish::sawfish_socket_name($display); |
31
|
0
|
|
|
|
|
|
$self->get_server_version(); |
32
|
0
|
0
|
|
|
|
|
if (!defined($self->{Socket})) { |
33
|
0
|
|
|
|
|
|
$!=111; # Connection refused |
34
|
0
|
|
|
|
|
|
return(undef); |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
|
$self->close_socket(); |
37
|
0
|
|
|
|
|
|
return($self); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub open_socket { |
41
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
42
|
0
|
0
|
|
|
|
|
if (!defined($self->{Socket})) { |
43
|
0
|
|
|
|
|
|
$self->{Socket} = new IO::Socket::UNIX(Peer => $self->{SocketPath}); |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
return($self->{Socket}); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub close_socket { |
49
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
50
|
0
|
|
|
|
|
|
syswrite($self->{Socket}, pack("C", req_end_of_session)); |
51
|
0
|
|
|
|
|
|
close($self->{Socket}); |
52
|
0
|
|
|
|
|
|
undef($self->{Socket}); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub eval_form { |
56
|
0
|
|
|
0
|
1
|
|
my ($self, $form) = @_; |
57
|
0
|
|
|
|
|
|
my ($resp_len, $resp, $state); |
58
|
0
|
|
|
|
|
|
my $s = $self->open_socket(); |
59
|
0
|
|
|
|
|
|
$resp = undef; |
60
|
0
|
0
|
|
|
|
|
if (defined($s)) { |
61
|
0
|
|
|
|
|
|
my $data = pack("CIa*", req_eval, length($form), $form); |
62
|
0
|
|
|
|
|
|
syswrite($s, $data); |
63
|
0
|
|
|
|
|
|
sysread($s, $data, 4); |
64
|
0
|
|
|
|
|
|
$resp_len = unpack("I", $data); |
65
|
0
|
|
|
|
|
|
sysread($s, $resp, $resp_len); |
66
|
0
|
|
|
|
|
|
($state, $resp) = unpack("Ca*", $resp); |
67
|
0
|
0
|
|
|
|
|
if ($state != 1) { $resp = undef; } |
|
0
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
return($resp); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
__END__ |