| 1 |
package Qpsmtpd::Constants; |
| 2 |
use strict; |
| 3 |
require Exporter; |
| 4 |
|
| 5 |
# log levels |
| 6 |
my %log_levels = ( |
| 7 |
LOGDEBUG => 7, |
| 8 |
LOGINFO => 6, |
| 9 |
LOGNOTICE => 5, |
| 10 |
LOGWARN => 4, |
| 11 |
LOGERROR => 3, |
| 12 |
LOGCRIT => 2, |
| 13 |
LOGALERT => 1, |
| 14 |
LOGEMERG => 0, |
| 15 |
LOGRADAR => 0, |
| 16 |
); |
| 17 |
|
| 18 |
# return codes |
| 19 |
my %return_codes = ( |
| 20 |
OK => 900, |
| 21 |
DENY => 901, # 550 |
| 22 |
DENYSOFT => 902, # 450 |
| 23 |
DENYHARD => 903, # 550 + disconnect (deprecated in 0.29) |
| 24 |
DENY_DISCONNECT => 903, # 550 + disconnect |
| 25 |
DENYSOFT_DISCONNECT => 904, # 450 + disconnect |
| 26 |
DECLINED => 909, |
| 27 |
DONE => 910, |
| 28 |
CONTINUATION => 911, # deprecated - use YIELD |
| 29 |
YIELD => 911, |
| 30 |
); |
| 31 |
|
| 32 |
use vars qw(@ISA @EXPORT); |
| 33 |
@ISA = qw(Exporter); |
| 34 |
@EXPORT = (keys(%return_codes), keys(%log_levels), "return_code", "log_level"); |
| 35 |
|
| 36 |
foreach (keys %return_codes) { |
| 37 |
eval "use constant $_ => " . $return_codes{$_}; |
| 38 |
} |
| 39 |
|
| 40 |
foreach (keys %log_levels) { |
| 41 |
eval "use constant $_ => " . $log_levels{$_}; |
| 42 |
} |
| 43 |
|
| 44 |
sub return_code { |
| 45 |
my $test = shift; |
| 46 |
if ($test =~ /^\d+$/) { # need to return the textural form |
| 47 |
foreach (keys %return_codes) { |
| 48 |
return $_ if $return_codes{$_} =~ /$test/; |
| 49 |
} |
| 50 |
} |
| 51 |
else { # just return the numeric value |
| 52 |
return $return_codes{$test}; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
sub log_level { |
| 57 |
my $test = shift; |
| 58 |
if ($test =~ /^\d+$/) { # need to return the textural form |
| 59 |
foreach (keys %log_levels) { |
| 60 |
return $_ if $log_levels{$_} =~ /$test/; |
| 61 |
} |
| 62 |
} |
| 63 |
else { # just return the numeric value |
| 64 |
return $log_levels{$test}; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
1; |
| 69 |
|
| 70 |
=head1 NAME |
| 71 |
|
| 72 |
Qpsmtpd::Constants - Constants for plugins to use |
| 73 |
|
| 74 |
=head1 CONSTANTS |
| 75 |
|
| 76 |
See L<README.plugins> for hook specific information on applicable |
| 77 |
constants. |
| 78 |
|
| 79 |
Constants available: |
| 80 |
|
| 81 |
=over 4 |
| 82 |
|
| 83 |
=item C<OK> |
| 84 |
|
| 85 |
Return this only from the queue phase to indicate the mail was queued |
| 86 |
successfully. |
| 87 |
|
| 88 |
=item C<DENY> |
| 89 |
|
| 90 |
Returning this from a hook causes a 5xx error (hard failure) to be |
| 91 |
returned to the connecting client. |
| 92 |
|
| 93 |
=item C<DENYSOFT> |
| 94 |
|
| 95 |
Returning this from a hook causes a 4xx error (temporary failure - try |
| 96 |
again later) to be returned to the connecting client. |
| 97 |
|
| 98 |
=item C<DECLINED> |
| 99 |
|
| 100 |
Returning this from a hook implies success, but tells qpsmtpd to go |
| 101 |
on to the next plugin. |
| 102 |
|
| 103 |
=item C<DONE> |
| 104 |
|
| 105 |
Returning this from a hook implies success, but tells qpsmtpd to |
| 106 |
skip any remaining plugins for this phase. |
| 107 |
|
| 108 |
=back |
| 109 |
|
| 110 |
=cut |