CustomFunctions Params
Julian Field
mailscanner at ecs.soton.ac.uk
Mon Aug 2 20:46:20 IST 2004
Thankyou for writing this, I have been trying to get around to doing it for
months, and never quite remember it when I have the time to do it!
Your patch looks mostly okay. I have tied the regexps to ^ when extracting
the parameters (in the bit of code that is used several times). You have
one bug in your code that I can immediately see, in this bit:
@@ -787,10 +795,11 @@
foreach $custom (values %CustomFunctions) {
next unless $custom;
MailScanner::Log::InfoLog("Config: calling custom end function %s",
- $custom);
- $fn = 'MailScanner::CustomConfig::End' . $custom;
+ $custom . $CustomFunctionsParams{$custom});
+ $fn = 'MailScanner::CustomConfig::End' . $custom .
+ $CustomFunctionsParams{$custom};
no strict 'refs';
- &$fn();
+ eval( $fn );
use strict 'refs';
}
}
In the middle of this, you have used $custom (which is a "value") as they
key into CustomFunctionsParams when calling the End function. You should
have used a "key" and not a "value", so the right parameters are passed to
the End function.
Otherwise it looks great. It will all appear in the next release.
Revised patch is attached.
Many thanks.
At 19:59 02/08/2004, you wrote:
>Hi, I've sent the ConfFile patch, but I couldn't finish
>this patch on time.
>
>Long ago, I have been thinking about having CustomFunctions
>whith parameters, so you could have some kind of
>configuration in MailScanner.conf
>Having the configuration outside the custom functions would
>be a good idea.
>
>So I wrote this little patch ("only" touched Config.pm).
>
>With it, you can write something like:
>
> Spam Checks=&Function_X("param1","path_to_conf.conf")
>
>
>All the parameters will be passed only one time to the
>"InitFunction_X" and "EndFunction_X", so it will be
>relatively inexpensive in cpu usage.
>Function_X will be called as usual.
>If you use &Function_X without params, it will behave
>normally.
>
>
>Saludos
>
>Leonardo Helman
>Pert Consultores
>Argentina
>
>
>-------------------------- MailScanner list ----------------------
>To leave, send leave mailscanner to jiscmail at jiscmail.ac.uk
>Before posting, please see the Most Asked Questions at
>http://www.mailscanner.biz/maq/ and the archives at
>http://www.jiscmail.ac.uk/lists/mailscanner.html
-------------------------- MailScanner list ----------------------
To leave, send leave mailscanner to jiscmail at jiscmail.ac.uk
Before posting, please see the Most Asked Questions at
http://www.mailscanner.biz/maq/ and the archives at
http://www.jiscmail.ac.uk/lists/mailscanner.html
[ Part 2, Application/OCTET-STREAM (Name: "Config.pm.patch") 6.7KB. ]
[ Unable to print this part. ]
[ Part 3: "Attached Text" ]
--
Julian Field
www.MailScanner.info
Professional Support Services at www.MailScanner.biz
MailScanner thanks transtec Computers for their support
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
-------------------------- MailScanner list ----------------------
To leave, send leave mailscanner to jiscmail at jiscmail.ac.uk
Before posting, please see the Most Asked Questions at
http://www.mailscanner.biz/maq/ and the archives at
http://www.jiscmail.ac.uk/lists/mailscanner.html
More information about the MailScanner
mailing list