Mail::Milter::ContextWrapper(3) Perl extension for wrappering the milter context

SYNOPSIS


use Mail::Milter::ContextWrapper;
my $oldctx = ($ctx from callback);
# in the connect_callback
$oldctx->setpriv(new Mail::Milter::ContextWrapper($ctx,
{ methodname => \&methodimpl[, ...] }));
# in all callbacks
my $newctx = $ctx->getpriv();
# in the close_callback
$oldctx->setpriv(undef);

DESCRIPTION

Mail::Milter::ContextWrapper wraps the milter context with replacement methods defined by the caller. This can be used to intercept context object actions and manipulate them from within a Mail::Milter::Wrapper.

Because the wrappering must occur on every callback, this implementation suggests embedding the wrapper inside the private data of the milter itself. This works with existing milters by providing separate ``setpriv'' and ``getpriv'' methods within the wrapper that do not propagate up to the embedded context object.

METHODS

new(CTX, { NAME => \&SUB[, ...] })
Creates a Mail::Milter::ContextWrapper object. This should be called from the ``connect'' callback and passed back to "setpriv()".

NAMEs are names of methods to override within the wrapper. These methods will be called with the wrapper as first argument (like a normal object method).

getpriv()
Returns a private data item set by "setpriv()". See Sendmail::Milter for more information. This implementation stores the datum in the wrapper, thus allowing the parent context to store a reference to the wrapper itself.

This method cannot be overridden by the user.

get_ctx()
Returns the parent context object stored within this wrapper. Typically used by method overrides to defer back to the real method.

This method cannot be overridden by the user.

get_key(NAME)
Get a keyed data item separate from the "getpriv" private data. This provides out-of-band data storage that need not clobber the single ``priv'' data item used by most milters.
getpriv()
Sets a private data item to be returned by "getpriv()". See Sendmail::Milter for more information. This implementation stores the datum in the wrapper, thus allowing the parent context to store a reference to the wrapper itself.

This method cannot be overridden by the user.

set_key(NAME, VALUE)
set_key(NAME => VALUE)
Set a keyed data item separate from the "getpriv" private data. This provides out-of-band data storage that need not clobber the single ``priv'' data item used by most milters.

AUTHOR

Todd Vierling, <[email protected]> <[email protected]>