| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: DefaultCommands.pm 230 2004-04-25 15:49:02Z sungo $ |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
POE::Component::ControlPort::DefaultCommands - Set of default commands available to the control port |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package POE::Component::ControlPort::DefaultCommands; |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1241
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
22
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
1087
|
use Getopt::Long; |
|
|
1
|
|
|
|
|
11795
|
|
|
|
1
|
|
|
|
|
6
|
|
|
17
|
1
|
|
|
1
|
|
167
|
use POE::Component::ControlPort::Command; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
566
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.'.sprintf "%04d", (qw($Rev: 230 $))[1]; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @COMMANDS = ( #{{{ |
|
22
|
|
|
|
|
|
|
{ |
|
23
|
|
|
|
|
|
|
help_text => 'Display general port status', |
|
24
|
|
|
|
|
|
|
usage => 'status', |
|
25
|
|
|
|
|
|
|
topic => 'general', |
|
26
|
|
|
|
|
|
|
name => 'status', |
|
27
|
|
|
|
|
|
|
command => \&status, |
|
28
|
|
|
|
|
|
|
}, |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
|
31
|
|
|
|
|
|
|
help_text => 'Display help about available commands', |
|
32
|
|
|
|
|
|
|
usage => 'help [ topic || command ]', |
|
33
|
|
|
|
|
|
|
topic => 'general', |
|
34
|
|
|
|
|
|
|
name => 'help', |
|
35
|
|
|
|
|
|
|
command => \&help, |
|
36
|
|
|
|
|
|
|
}, |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
); #}}} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $START_TIME = time; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub status { |
|
44
|
1
|
|
|
1
|
0
|
469
|
my %args = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
213
|
my $time = localtime($START_TIME); |
|
47
|
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
13
|
return qq| |
|
49
|
|
|
|
|
|
|
Control port online since $time. |
|
50
|
|
|
|
|
|
|
Application $args{oob}{appname} on host $args{oob}{hostname} |
|
51
|
|
|
|
|
|
|
Client is $args{oob}{client_addr} port $args{oob}{client_port} |
|
52
|
|
|
|
|
|
|
|; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub help { |
|
57
|
4
|
|
|
4
|
0
|
3225
|
my %args = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
6
|
my @args = @{$args{args}}; |
|
|
4
|
|
|
|
|
38
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
4
|
100
|
|
|
|
15
|
if(scalar @args > 1) { |
|
62
|
1
|
|
|
|
|
5
|
return "ERROR: Can only provide help on one thing at a time. "; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
7
|
my $help = shift @args; |
|
66
|
|
|
|
|
|
|
|
|
67
|
3
|
|
|
|
|
4
|
my $txt; |
|
68
|
3
|
50
|
|
|
|
7
|
if(defined $help) { |
|
69
|
3
|
100
|
|
|
|
13
|
if(defined $POE::Component::ControlPort::Command::TOPICS{$help}) { |
|
|
|
100
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
3
|
$txt = "Commands available in topic '$help':\n"; |
|
71
|
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
3
|
foreach my $cmd (sort @{ $POE::Component::ControlPort::Command::TOPICS{$help} }) { |
|
|
1
|
|
|
|
|
7
|
|
|
73
|
2
|
|
|
|
|
6
|
$txt .= "\t* $cmd\n"; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} elsif (defined $POE::Component::ControlPort::Command::REGISTERED_COMMANDS{$help}) { |
|
77
|
1
|
|
|
|
|
2
|
my $data = $POE::Component::ControlPort::Command::REGISTERED_COMMANDS{$help}; |
|
78
|
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
4
|
$txt = "Help for command '$help'\n"; |
|
80
|
1
|
|
|
|
|
3
|
$txt .= "Usage: ".$data->{usage}."\n"; |
|
81
|
1
|
|
|
|
|
4
|
$txt .= $data->{help_text}."\n"; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} else { |
|
85
|
1
|
|
|
|
|
4
|
$txt = "'$help' is an unknown command or help topic\n"; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} else { |
|
88
|
0
|
|
|
|
|
0
|
$txt = "The following help topics are available:\n"; |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
foreach my $topic ( sort keys %POE::Component::ControlPort::Command::TOPICS ) { |
|
91
|
0
|
|
|
|
|
0
|
$txt .= "\t * $topic\n"; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
3
|
|
|
|
|
13
|
return $txt; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _add_poe_debug_commands { |
|
100
|
0
|
|
|
0
|
|
|
eval "use POE::Component::DebugShell; use POE::API::Peek"; |
|
101
|
0
|
0
|
|
|
|
|
unless($@) { |
|
102
|
0
|
0
|
|
|
|
|
if($POE::Component::DebugShell::VERSION >= '1.017') { |
|
103
|
0
|
|
|
|
|
|
my $cmds = POE::Component::DebugShell->_raw_commands(); |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
foreach my $cmd_name (keys %$cmds) { |
|
106
|
0
|
|
|
|
|
|
my $cmd_data = $cmds->{$cmd_name}; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
next if $cmd_name eq 'status'; |
|
109
|
0
|
0
|
|
|
|
|
next if $cmd_name eq 'help'; |
|
110
|
0
|
0
|
|
|
|
|
next if $cmd_name eq 'exit'; |
|
111
|
0
|
0
|
|
|
|
|
next if $cmd_name eq 'reload'; |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $api = POE::API::Peek->new(); |
|
114
|
|
|
|
|
|
|
POE::Component::ControlPort::Command->register( |
|
115
|
|
|
|
|
|
|
name => $cmd_name, |
|
116
|
|
|
|
|
|
|
usage => $cmd_name, |
|
117
|
|
|
|
|
|
|
help_text => $cmd_data->{help}, |
|
118
|
|
|
|
|
|
|
topic => 'poe_debug', |
|
119
|
|
|
|
|
|
|
command => sub { |
|
120
|
0
|
|
|
0
|
|
|
my %args = @_; |
|
121
|
0
|
|
|
|
|
|
return $cmd_data->{cmd}->( |
|
122
|
|
|
|
|
|
|
api => $api, |
|
123
|
|
|
|
|
|
|
args => $args{args} |
|
124
|
|
|
|
|
|
|
); |
|
125
|
|
|
|
|
|
|
}, |
|
126
|
0
|
|
|
|
|
|
); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
|
134
|
|
|
|
|
|
|
__END__ |