line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2001-2006 The Apache Software Foundation |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
5
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
10
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
11
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
13
|
|
|
|
|
|
|
# limitations under the License. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# System constants. Mostly plugin return codes and HTTP response codes |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package AxKit2::Constants; |
19
|
|
|
|
|
|
|
|
20
|
9
|
|
|
9
|
|
50
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
562
|
|
21
|
9
|
|
|
9
|
|
52
|
use warnings; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
302
|
|
22
|
|
|
|
|
|
|
|
23
|
9
|
|
|
9
|
|
48
|
use Exporter (); |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
870
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# log levels |
26
|
|
|
|
|
|
|
my %log_levels = ( |
27
|
|
|
|
|
|
|
LOGDEBUG => 7, |
28
|
|
|
|
|
|
|
LOGINFO => 6, |
29
|
|
|
|
|
|
|
LOGNOTICE => 5, |
30
|
|
|
|
|
|
|
LOGWARN => 4, |
31
|
|
|
|
|
|
|
LOGERROR => 3, |
32
|
|
|
|
|
|
|
LOGCRIT => 2, |
33
|
|
|
|
|
|
|
LOGALERT => 1, |
34
|
|
|
|
|
|
|
LOGEMERG => 0, |
35
|
|
|
|
|
|
|
LOGRADAR => 0, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# return codes |
39
|
|
|
|
|
|
|
my %return_codes = ( |
40
|
|
|
|
|
|
|
# HTTP Codes |
41
|
|
|
|
|
|
|
OK => 200, |
42
|
|
|
|
|
|
|
NO_CONTENT => 204, |
43
|
|
|
|
|
|
|
PARTIAL_CONTENT => 206, |
44
|
|
|
|
|
|
|
REDIRECT => 302, |
45
|
|
|
|
|
|
|
NOT_MODIFIED => 304, |
46
|
|
|
|
|
|
|
BAD_REQUEST => 400, |
47
|
|
|
|
|
|
|
UNAUTHORIZED => 401, |
48
|
|
|
|
|
|
|
FORBIDDEN => 403, |
49
|
|
|
|
|
|
|
NOT_FOUND => 404, |
50
|
|
|
|
|
|
|
SERVER_ERROR => 500, |
51
|
|
|
|
|
|
|
NOT_IMPLEMENTED => 501, |
52
|
|
|
|
|
|
|
SERVICE_UNAVAILABLE => 503, |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# AxKit specific codes |
55
|
|
|
|
|
|
|
DECLINED => 909, |
56
|
|
|
|
|
|
|
DONE => 910, |
57
|
|
|
|
|
|
|
CONTINUATION => 911, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
9
|
|
|
9
|
|
57
|
use vars qw(@ISA @EXPORT); |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
3121
|
|
61
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
62
|
|
|
|
|
|
|
@EXPORT = (keys(%return_codes), keys(%log_levels), "return_code", "log_level"); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
foreach (keys %return_codes ) { |
65
|
9
|
|
|
9
|
|
97
|
eval "use constant $_ => ".$return_codes{$_}; |
|
9
|
|
|
9
|
|
34
|
|
|
9
|
|
|
9
|
|
527
|
|
|
9
|
|
|
9
|
|
46
|
|
|
9
|
|
|
9
|
|
17
|
|
|
9
|
|
|
9
|
|
265
|
|
|
9
|
|
|
9
|
|
48
|
|
|
9
|
|
|
9
|
|
18
|
|
|
9
|
|
|
9
|
|
294
|
|
|
9
|
|
|
9
|
|
45
|
|
|
9
|
|
|
9
|
|
17
|
|
|
9
|
|
|
9
|
|
286
|
|
|
9
|
|
|
9
|
|
45
|
|
|
9
|
|
|
9
|
|
19
|
|
|
9
|
|
|
9
|
|
357
|
|
|
9
|
|
|
|
|
97
|
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
273
|
|
|
9
|
|
|
|
|
48
|
|
|
9
|
|
|
|
|
36
|
|
|
9
|
|
|
|
|
293
|
|
|
9
|
|
|
|
|
50
|
|
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
272
|
|
|
9
|
|
|
|
|
49
|
|
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
352
|
|
|
9
|
|
|
|
|
46
|
|
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
555
|
|
|
9
|
|
|
|
|
84
|
|
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
302
|
|
|
9
|
|
|
|
|
44
|
|
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
271
|
|
|
9
|
|
|
|
|
46
|
|
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
346
|
|
|
9
|
|
|
|
|
43
|
|
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
265
|
|
|
9
|
|
|
|
|
48
|
|
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
577
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
foreach (keys %log_levels ) { |
69
|
9
|
|
|
9
|
|
46
|
eval "use constant $_ => ".$log_levels{$_}; |
|
9
|
|
|
9
|
|
15
|
|
|
9
|
|
|
9
|
|
517
|
|
|
9
|
|
|
9
|
|
50
|
|
|
9
|
|
|
9
|
|
16
|
|
|
9
|
|
|
9
|
|
271
|
|
|
9
|
|
|
9
|
|
48
|
|
|
9
|
|
|
9
|
|
14
|
|
|
9
|
|
|
9
|
|
277
|
|
|
9
|
|
|
|
|
47
|
|
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
297
|
|
|
9
|
|
|
|
|
61
|
|
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
265
|
|
|
9
|
|
|
|
|
48
|
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
261
|
|
|
9
|
|
|
|
|
42
|
|
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
253
|
|
|
9
|
|
|
|
|
45
|
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
291
|
|
|
9
|
|
|
|
|
50
|
|
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
277
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub return_code { |
73
|
0
|
|
|
0
|
0
|
|
my $test = shift; |
74
|
0
|
0
|
|
|
|
|
if ( $test =~ /^\d+$/ ) { # need to return the textural form |
75
|
0
|
|
|
|
|
|
foreach ( keys %return_codes ) { |
76
|
0
|
0
|
|
|
|
|
return $_ if $return_codes{$_} =~ /$test/; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { # just return the numeric value |
80
|
0
|
|
|
|
|
|
return $return_codes{$test}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub log_level { |
85
|
0
|
|
|
0
|
0
|
|
my $test = shift; |
86
|
0
|
0
|
|
|
|
|
if ( $test =~ /^\d+$/ ) { # need to return the textural form |
87
|
0
|
|
|
|
|
|
foreach ( keys %log_levels ) { |
88
|
0
|
0
|
|
|
|
|
return $_ if $log_levels{$_} =~ /$test/; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { # just return the numeric value |
92
|
0
|
|
|
|
|
|
return $log_levels{$test}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
AxKit2::Constants - Constants for plugins to use |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 HOOK CONSTANTS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
See L for hook specific information on applicable |
105
|
|
|
|
|
|
|
constants. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Constants available: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=over 4 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item C |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Returning this from a hook implies success, but tells axkit to go |
114
|
|
|
|
|
|
|
on to the next plugin. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item C |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returning this from a hook implies success, but tells axkit to skip any more |
119
|
|
|
|
|
|
|
plugins for this phase. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item C |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
C is generally hook specific, see L for |
124
|
|
|
|
|
|
|
details. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
You can, in most hooks, return any of the HTTP response codes below. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 HTTP RESPONSE CONSTANTS |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
OK => 200, |
133
|
|
|
|
|
|
|
NO_CONTENT => 204, |
134
|
|
|
|
|
|
|
PARTIAL_CONTENT => 206, |
135
|
|
|
|
|
|
|
REDIRECT => 302, |
136
|
|
|
|
|
|
|
NOT_MODIFIED => 304, |
137
|
|
|
|
|
|
|
BAD_REQUEST => 400, |
138
|
|
|
|
|
|
|
UNAUTHORIZED => 401, |
139
|
|
|
|
|
|
|
FORBIDDEN => 403, |
140
|
|
|
|
|
|
|
NOT_FOUND => 404, |
141
|
|
|
|
|
|
|
SERVER_ERROR => 500, |
142
|
|
|
|
|
|
|
NOT_IMPLEMENTED => 501, |
143
|
|
|
|
|
|
|
SERVICE_UNAVAILABLE => 503, |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 LOGGING CONSTANTS |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The following log level constants are also available: |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
LOGDEBUG => 7, |
150
|
|
|
|
|
|
|
LOGINFO => 6, |
151
|
|
|
|
|
|
|
LOGNOTICE => 5, |
152
|
|
|
|
|
|
|
LOGWARN => 4, |
153
|
|
|
|
|
|
|
LOGERROR => 3, |
154
|
|
|
|
|
|
|
LOGCRIT => 2, |
155
|
|
|
|
|
|
|
LOGALERT => 1, |
156
|
|
|
|
|
|
|
LOGEMERG => 0, |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |