1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | # untested dm support extension |
3 | # untested dm support extension |
4 | |
4 | |
5 | use Storable qw/freeze thaw/; |
5 | use Storable qw/nfreeze thaw/; |
6 | |
6 | |
|
|
7 | my %global; # for use by eval'ed commands |
|
|
8 | |
7 | #cf::register_extcmd perleval => sub { |
9 | cf::register_extcmd perl_eval => sub { |
8 | # my ($pl, $indata) = @_; |
10 | my ($pl, $data) = @_; |
9 | # |
11 | |
10 | # my ($token, $evaldata) = split / /, $indata, 2; |
12 | my ($token, $data) = split / /, $data, 2; |
11 | # my ($code, $storablein) = split /\0/, $evaldata, 2; |
13 | |
12 | # |
|
|
13 | # unless ($pl->flag (cf::FLAG_WIZ)) { |
14 | unless ($pl->flag (cf::FLAG_WIZ)) { |
14 | # $pl->send ("ext $token"); |
15 | $pl->send ("ext $token error permission denied"); |
15 | # return; |
16 | return; |
16 | # } |
17 | } |
17 | # |
18 | |
18 | # my $data = thaw $storablein; |
19 | my ($code, $arg) = split /\0/, $data, 2; |
19 | # |
20 | |
20 | # $pl->send ("ext $token " . freeze eval $code); |
21 | $arg = eval { thaw $arg }; |
|
|
22 | my @res = eval $code; |
|
|
23 | |
|
|
24 | $@ ? $pl->send ("ext $token error " . nfreeze $@) |
|
|
25 | : $pl->send ("ext $token ok " . nfreeze \@res); |
21 | #}; |
26 | }; |