Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Hook::Filter::Hooker
Wrap subroutines in a firewalling closure

Hook::Filter::Hooker - Wrap subroutines in a firewalling closure


NAME

Hook::Filter::Hooker - Wrap subroutines in a firewalling closure


DESCRIPTION

This module is used internaly by Hook::Filter to generate an anonymous sub that is wrapped around each filtered subroutine and either forwards the call to the subroutine or block it and spoofs return values (undef or an empty list depending on context).


SYNOPSIS


    use Hook::Filter::Hooker;

    my $hooker = new Hook::Filter::Hooker();

    $hooker->filter_sub("My::Package");

    # mylog is declared in the current package

    $hooker->filter_sub("mylog");


INTERFACE

Hook::Filter::Hooker exports no functions by default. But the following functions can be explicitly imported upon using Hook::Filter::Hooker:

$hooker->filter_sub($subname)
Add a filter around the subroutine $subname. $subname must either be a fully qualified function name, or the name of a function located in the current package.

All calls to $subname will thereafter be redirected to a wrapper closure that will evaluate all the rules registered in Hook::Filter::RulePool using the method eval() on the pool. If eval() returns true, the call is forwarded, otherwise it is blocked.

The following class functions are to be used by modules under Hook::Filter::Plugins:: that implement specific test functions for use in filter rules.

Any use of these functions in a different context than inside a plugin implementation is guaranteed to return only garbage.

See Hook::Filter::Plugins::Library for a usage example.

get_caller_package()
Return the name of the package calling the filtered subroutine.

get_caller_file()
Return the name of the file calling the filtered subroutine.

get_caller_line()
Return the line number at which the filtered subroutine was called.

get_caller_subname()
Return the complete name (package+name) of the subroutine calling the filtered subroutine. If the subroutine was called directly from the main namespace, return an empty string.

get_subname()
Return the complete name of the filtered subroutine for which the rules are being eval-ed.

get_arguments()
Return the list of arguments that would be passed to the filtered subroutine.


DIAGNOSTICS

$hook->filter_sub($pkg,$func) croaks when passed invalid arguments.
The closure wrapping all filtered subroutines emits a perl warning when a rule dies upon being eval-ed.


BUGS AND LIMITATIONS

See Hook::Filter


SEE ALSO

See Hook::Filter, Hook::Filter::Rule, Hook::Filter::RulePool, Hook::Filter::Plugins::Library.


VERSION

$Id: Hooker.pm,v 1.8 2007/05/24 14:58:09 erwan_lemonnier Exp $


AUTHOR

Erwan Lemonnier <erwan@cpan.org>.


LICENSE

See Hook::Filter.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy