line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#$Id: VersionUtil.pm,v 1.3 2006/01/17 01:36:51 naoya Exp $ |
2
|
|
|
|
|
|
|
package ModPerl::VersionUtil; |
3
|
5
|
|
|
5
|
|
122497
|
use strict; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
296
|
|
4
|
5
|
|
|
5
|
|
30
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
169
|
|
5
|
5
|
|
|
5
|
|
27
|
use base qw/Class::Data::Inheritable/; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
5515
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata($_) |
11
|
5
|
|
|
5
|
|
3692
|
for qw/mp_version mp_version_string is_mp is_mp1 is_mp19 is_mp2/; |
12
|
|
|
|
|
|
|
|
13
|
5
|
100
|
|
|
|
680
|
if (my $version = $ENV{MOD_PERL}) { |
14
|
|
|
|
|
|
|
# Note: This environment variable could be set in an external script called from mod_perl, |
15
|
|
|
|
|
|
|
# so don't presume we are in mod_perl just yet. |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
39
|
($version) = $version =~ /^\S+\/(\d+(?:[\.\_]\d+)+)/; |
18
|
3
|
|
|
|
|
12
|
__PACKAGE__->mp_version_string($version); |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
26
|
$version =~ s/_//g; |
21
|
3
|
|
|
|
|
14
|
$version =~ s/(\.[^.]+)\./$1/g; |
22
|
3
|
|
|
|
|
14
|
__PACKAGE__->mp_version($version); |
23
|
|
|
|
|
|
|
|
24
|
3
|
100
|
66
|
|
|
49
|
if ($ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2 && exists $INC{'Apache2/RequestRec.pm'}) { |
|
|
50
|
66
|
|
|
|
|
25
|
1
|
|
|
|
|
4
|
__PACKAGE__->is_mp(1); |
26
|
1
|
|
|
|
|
9
|
__PACKAGE__->is_mp2(1) |
27
|
|
|
|
|
|
|
} elsif (exists $INC{'Apache.pm'}) { |
28
|
2
|
|
|
|
|
9
|
__PACKAGE__->is_mp(1); |
29
|
2
|
100
|
|
|
|
23
|
if ( $version >= 1.9901 ) { |
|
|
50
|
|
|
|
|
|
30
|
1
|
|
|
|
|
11
|
__PACKAGE__->is_mp19(1); |
31
|
|
|
|
|
|
|
} elsif ( $version >= 1.24 ) { |
32
|
1
|
|
|
|
|
12
|
__PACKAGE__->is_mp1(1); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
ModPerl::VersionUtil - Makes it easier to investigate your mod_perl |
45
|
|
|
|
|
|
|
version. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use ModPerl::VersionUtil; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
if (ModPerl::VersionUtil->is_mp) { |
52
|
|
|
|
|
|
|
print "It's running under mod_perl."; |
53
|
|
|
|
|
|
|
print "mod_perl version: " . ModPerl::VersionUtil->mp_version_string; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
if (ModPerl::VersionUtil->is_mp2) { |
57
|
|
|
|
|
|
|
require Apache2 (); |
58
|
|
|
|
|
|
|
require Apache2::RequestRec(); |
59
|
|
|
|
|
|
|
require Apache2::RequestIO (); |
60
|
|
|
|
|
|
|
} elsif (ModPerl::VersionUtil->is_mp19) { |
61
|
|
|
|
|
|
|
require Apache2; |
62
|
|
|
|
|
|
|
require Apache::RequestRec(); |
63
|
|
|
|
|
|
|
require Apache::RequestIO (); |
64
|
|
|
|
|
|
|
} elsif (ModPerl::VersionUtil->is_mp1) { |
65
|
|
|
|
|
|
|
require Apache; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This module helps you to investigate your mod_perl version easily. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item is_mp |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Returns true if your application is running under mod_perl. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item is_mp1 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Returns true if your mod_perl version is 1.0. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item is_mp19 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns true if your mod_perl version is 1.9 which is incompatible |
87
|
|
|
|
|
|
|
with 2.0. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item is_mp2 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns true if your mod_perl version is 2.0 or higher. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item mp_version |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns your mod_perl version as number. (e.g. '1.99920') |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item mp_version_string |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns your mod_perl version as string. (e.g. '1.999.20') |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Craig Manley E<lt>CMANLEY@cpan.orgE<gt> gave me a code to handle an |
104
|
|
|
|
|
|
|
external scripts correctly. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Naoya Ito, E<lt>naoya@bloghackers.netE<gt> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Some codes are borrowed from the L<Catalyst> web application framework |
111
|
|
|
|
|
|
|
which can handle any versions of mod_perl elegantly. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
116
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |