|
From: <jgr...@us...> - 2003-11-10 20:15:48
|
Update of /cvsroot/popfile/engine
In directory sc8-pr-cvs1:/tmp/cvs-serv4335
Modified Files:
popfile.pl tests.pl
Log Message:
"Unixification of POPFile"
--------------------------
1. Change command line parsing to use Getopt so that in future
we can have real command line options. In the past an option
was equivalent to a configuration file item. So you could set
module_param value
inside popfile.cfg, but you could also to
popfile.pl -module_param value
on the command line. The new form of the latter is
popfile.pl --set module_param=value
For the ultimate in laziness you can also use the old style
if you precede the first old style parameter with --, e.g.
the old style command line above would work in the new scheme
if specified as follows
popfile.pl -- -module_param value
It is still even possible to use very old style parameters
from pre-OO days of POPFile with the addition of the --
popfile.pl -- -ui_port 8080
2. Make it possible for a module to disable itself and hence be
unloaded. Unloadable modules have an 'enabled' paramter (currently
supported by all proxies (POP3, NNTP and SMTP) and XML-RPC). If
this parameter is 0 then use if to return the value '2' from start()
which indicates to Loader that the module wishes to be removed.
POPFile/Configuration.pm:
Use Getopt to handle new style command line options. Make
parse_command_line return 0 if there's an error.
POPFile/Module.pm:
Update documentation on start().
POPFile/Loader.pm:
Check the return code from start() and if it is 2 unload the module.
Check the return code from parse_command_line so we halt if there's an
error in command-line parsing.
Proxy/Proxy.pm:
Initialize the 'enabled' parameter to 1.
Proxy/POP3.pm
Proxy/SMTP.pm
Proxy/NNTP.pm:
Use the 'enabled' parameter to return 2 from start() so that if we
are not enabled we get unloaded. Also if not enabled don't register
any UI components.
UI/XMLRPC.pm:
Use the 'enabled' parameter to return 2 from start() so that if we
are not enabled we get unloaded. Also if not enabled don't register
any UI components.
Classifier/Bayes.pm:
When classifying a message without saving to disk, still add the
XPL link.
tests.pl:
Code layout clean up.
tests/TestConfiguration.pm:
Update and improve tests for command-line parsing.
tests/TestProxy.pm:
Check for the initial setting of the 'enabled' parameter.
tests/TestPOP3.pm:
Check that the enabled parameter is interpreted by start() to mean
no start and return 2. Make the XTP tests less time sensitive.
Index: popfile.pl
===================================================================
RCS file: /cvsroot/popfile/engine/popfile.pl,v
retrieving revision 1.217
retrieving revision 1.218
diff -C2 -d -r1.217 -r1.218
*** popfile.pl 10 Nov 2003 10:35:34 -0000 1.217
--- popfile.pl 10 Nov 2003 20:15:13 -0000 1.218
***************
*** 58,73 ****
$POPFile->CORE_link_components();
$POPFile->CORE_initialize();
! $POPFile->CORE_config();
! $POPFile->CORE_enabled_check();
! $POPFile->CORE_start();
! # This is the main POPFile loop that services requests, it will exit only when we
! # need to exit
! $POPFile->CORE_service();
! # Shutdown every POPFile module
! $POPFile->CORE_stop();
# END
--- 58,73 ----
$POPFile->CORE_link_components();
$POPFile->CORE_initialize();
! if ( $POPFile->CORE_config() ) {
! $POPFile->CORE_start();
! # This is the main POPFile loop that services requests, it will exit only when we
! # need to exit
! $POPFile->CORE_service();
! # Shutdown every POPFile module
! $POPFile->CORE_stop();
! }
# END
Index: tests.pl
===================================================================
RCS file: /cvsroot/popfile/engine/tests.pl,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** tests.pl 13 Oct 2003 20:23:40 -0000 1.31
--- tests.pl 10 Nov 2003 20:15:14 -0000 1.32
***************
*** 52,58 ****
{
my ( $ok, $test, $file, $line, $context ) = @_;
!
$test_count += 1;
!
if ( !$ok ) {
$fail_messages .= "\n $file:$line failed '$test'";
--- 52,58 ----
{
my ( $ok, $test, $file, $line, $context ) = @_;
!
$test_count += 1;
!
if ( !$ok ) {
$fail_messages .= "\n $file:$line failed '$test'";
***************
*** 65,69 ****
# print "Test pass at $file:$line ($context)\n";
}
!
flush STDOUT;
}
--- 65,69 ----
# print "Test pass at $file:$line ($context)\n";
}
!
flush STDOUT;
}
***************
*** 86,90 ****
{
my ( $file, $line, $test, $context ) = @_;
!
test_report( eval( $test ), $test, $file, $line, $context );
}
--- 86,90 ----
{
my ( $file, $line, $test, $context ) = @_;
!
test_report( eval( $test ), $test, $file, $line, $context );
}
***************
*** 109,126 ****
sub test_assert_equal
{
! my ( $file, $line, $test, $expected, $context ) = @_;
! my $result;
! if ( !( $expected =~ /[^0-9]/ ) ) {
!
! # This int() and is so that we don't get bitten by odd
! # floating point problems
! my $scale = 1e10;
! $result = ( int( $test * $scale ) == int( $expected * $scale ) );
! } else {
! $result = ( $test eq $expected );
! }
! test_report( $result, "expecting [$expected] and got [$test]", $file, $line, $context );
}
--- 109,127 ----
sub test_assert_equal
{
! my ( $file, $line, $test, $expected, $context ) = @_;
! my $result;
! if ( !( $expected =~ /[^0-9]/ ) ) {
! # This int() and is so that we don't get bitten by odd
! # floating point problems
!
! my $scale = 1e10;
! $result = ( int( $test * $scale ) == int( $expected * $scale ) );
! } else {
! $result = ( $test eq $expected );
! }
!
! test_report( $result, "expecting [$expected] and got [$test]", $file, $line, $context );
}
|