--- cf.schmorp.de/server/lib/cf.pm 2006/03/31 22:47:35 1.14 +++ cf.schmorp.de/server/lib/cf.pm 2006/06/11 15:02:16 1.15 @@ -67,6 +67,7 @@ my @exts; my @hook; my %command; +my %extcmd; sub inject_event { my $extension = shift; @@ -174,6 +175,20 @@ } } + # remove extcmds + for my $name (keys %command) { + my @cb = grep $_->[2] ne $pkg, @{ $command{$name} }; + + if (@cb) { + $command{$name} = \@cb; + $COMMAND{"$name\000"} = List::Util::max map $_->[0], @cb; + } else { + delete $command{$name}; + delete $COMMAND{"$name\000"}; + } + } + + Symbol::delete_package $pkg; } @@ -216,6 +231,20 @@ }; ############################################################################# +# extcmd framework, basically convert ext arg1 args +# into pkg::->on_extcmd_arg1 (...) while shortcutting a few + +sub on_extcmd { + my ($pl, $buf) = @_; + + my ($id, $pkg, $name, $data) = split / /, $buf, 4; + + if (my $method = "cf::ext::$pkg"->can ("on_extcmd_$name")) { + $method->($pl, $id, $buf); + } +} + +############################################################################# # load/save/clean perl data associated with a map *on_mapclean = sub {