Multiple functions called from "Always Looked Up Last"

paddy paddy at PANICI.NET
Thu Dec 2 16:48:09 GMT 2004


On Thu, Dec 02, 2004 at 03:57:02PM +0000, Joey Trungale wrote:
> Hello,
>
> I found this to be useful, so I thought I would share it.
>
> If you need to call more than one function using the "Always Looked Up
> Last" setting, you can use something like this...

Joey,

We share a common interest!

Here's one _I_ made earlier ...

(but it's probably dangerous! I've no idea what the prefix stuff is about,
and some of the rest looks bizarre! looks like I've been running this since
march, I hope I've come a little way with perl since then :)

I noticed that some parameterisation was added to CFs but I haven't
looked at it.  Perhaps it would now be possible to pass in @MLCF from
the main MailScanner.cf file??  Then again is it worth the bother ...

What I really want is howto integrate with the config system from
within custom functions.  For example, I'm just this moment putting
the WLFS function I posted into production, but I want to retain the
existing spam.whitelist.rules capability.  I ended up bodging around
it for now.  A built-in capability like this might solve that problem
but it wouldn't be as big a deal as exposing the power of the config
system through the CF interface.

------
# Okay, so I'm guessing at a few bits.

package MailScanner::CustomConfig;

my @MLCF = ( 'BigLogging', 'MailWatchLogging' );

sub InitMultiLast {
#       MailScanner::Log::InfoLog("InitMultiLast");
        MLCallAll('Init');
}

sub MultiLast {
        my ($msg) = @_;

#       MailScanner::Log::InfoLog("MultiLast");
        &MLCallAll('',$msg);
}

sub EndMultiLast {
#       MailScanner::Log::InfoLog("EndMultiLast");
        &MLCallAll('End');
}

sub MLCallAll {
        my ($prefix,$msg) = @_;

#       MailScanner::Log::InfoLog("MLCallAll $prefix");
        my($custom, $fn);
        foreach $custom (@MLCF) {
                next unless $custom;
                $fn = 'MailScanner::CustomConfig::' . $prefix . $custom;
#               MailScanner::Log::InfoLog("MLConfig: calling custom init function %s", $fn);
                no strict 'refs';
                &$fn($msg);
                use strict 'refs';
        }
}

1;
-------

Regards,
Paddy
--
Perl 6 will give you the big knob. -- Larry Wall

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!




More information about the MailScanner mailing list