line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#============================================================================= |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# $Id: CGI.pm,v 0.01 2002/02/24 20:41:37 mneylon Exp $ |
6
|
|
|
|
|
|
|
# $Revision: 0.01 $ |
7
|
|
|
|
|
|
|
# $Author: mneylon $ |
8
|
|
|
|
|
|
|
# $Date: 2002/02/24 20:41:37 $ |
9
|
|
|
|
|
|
|
# $Log: CGI.pm,v $ |
10
|
|
|
|
|
|
|
# Revision 0.01 2002/02/24 20:41:37 mneylon |
11
|
|
|
|
|
|
|
# Initial Release |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
#============================================================================= |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package XML::Generator::CGI; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
10903
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
19
|
1
|
|
|
1
|
|
1991
|
use CGI; |
|
1
|
|
|
|
|
19163
|
|
|
1
|
|
|
|
|
9
|
|
20
|
1
|
|
|
1
|
|
1668
|
use XML::SAX::Base; |
|
1
|
|
|
|
|
20100
|
|
|
1
|
|
|
|
|
42
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
BEGIN { |
23
|
1
|
|
|
1
|
|
15
|
use Exporter (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
24
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
159
|
|
25
|
1
|
|
|
1
|
|
16
|
$VERSION = sprintf( "%d.%02d", q( $Revision: 0.01 $ ) =~ /\s(\d+)\.(\d+)/ ); |
26
|
1
|
|
|
|
|
19
|
@ISA = qw(Exporter XML::SAX::Base); |
27
|
1
|
|
|
|
|
4
|
@EXPORT = qw(); |
28
|
1
|
|
|
|
|
2
|
@EXPORT_OK = qw( ); |
29
|
1
|
|
|
|
|
492
|
%EXPORT_TAGS = ( ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %defaults = ( |
33
|
|
|
|
|
|
|
RootElement => "cgi", |
34
|
|
|
|
|
|
|
ParameterElement => "parameter", |
35
|
|
|
|
|
|
|
ValueElement => "value", |
36
|
|
|
|
|
|
|
CookieElement => "cookie", |
37
|
|
|
|
|
|
|
Cookies => 1 |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new { |
41
|
0
|
|
|
0
|
1
|
|
my ( $proto, %args ) = @_; |
42
|
0
|
|
0
|
|
|
|
my $class = ref( $proto ) || $proto; |
43
|
0
|
|
|
|
|
|
my $self = { %defaults, %args }; |
44
|
0
|
|
|
|
|
|
bless ( $self, $class ); |
45
|
0
|
|
|
|
|
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub parsecgi { |
49
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my $arg = shift; |
51
|
0
|
0
|
|
|
|
|
if ( UNIVERSAL::isa( $arg, "CGI" ) ) { |
|
|
0
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$self->_parse_cgi( $arg ); |
53
|
|
|
|
|
|
|
} elsif ( defined $arg ) { |
54
|
0
|
|
|
|
|
|
my $cgi = new CGI( $arg ); |
55
|
0
|
|
|
|
|
|
$self->_parse_cgi( $cgi ); |
56
|
|
|
|
|
|
|
} else { |
57
|
0
|
|
|
|
|
|
my $cgi = new CGI; |
58
|
0
|
|
|
|
|
|
$self->_parse_cgi( $cgi ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _parse_cgi { |
63
|
0
|
|
|
0
|
|
|
my ( $self, $cgi ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->SUPER::start_document( {} ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$self->SUPER::start_element( { Name => $self->{ RootElement }, |
68
|
0
|
|
|
|
|
|
Attributes => { version => $VERSION, |
69
|
|
|
|
|
|
|
generator => "XML::Generator::CGI" |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my @params = $self->_distill_params( $cgi->param() ); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
foreach my $param ( @params ) { |
77
|
|
|
|
|
|
|
$self->SUPER::start_element( { Name => $self->{ ParameterElement }, |
78
|
0
|
|
|
|
|
|
Attributes => { name => $param } |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
); |
81
|
0
|
|
|
|
|
|
foreach my $value ( $cgi->param( $param ) ) { |
82
|
0
|
|
|
|
|
|
$self->SUPER::start_element( { Name => $self->{ ValueElement } } ); |
83
|
0
|
|
|
|
|
|
$self->SUPER::characters( { Data => $value } ); |
84
|
0
|
|
|
|
|
|
$self->SUPER::end_element( { Name => $self->{ ValueElement } } ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$self->SUPER::end_element( { Name => $self->{ ParameterElement } } ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$self->SUPER::end_element( { Name => $self->{ RootElement } } ); |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if ( $self->{ Cookies } ) { |
93
|
0
|
|
|
|
|
|
foreach my $cookie ( $cgi->cookie() ) { |
94
|
|
|
|
|
|
|
$self->SUPER::start_element( { Name => $self->{ CookieElement }, |
95
|
0
|
|
|
|
|
|
Attributes => { name => $cookie } |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
); |
98
|
0
|
|
|
|
|
|
$self->SUPER::characters( { Data => $cgi->cookie( $cookie ) } ); |
99
|
0
|
|
|
|
|
|
$self->SUPER::end_element( { Name => $self->{ CookieElement } } ); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$self->SUPER::end_document( {} ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _distill_params { |
107
|
0
|
|
|
0
|
|
|
my $self = shift; |
108
|
0
|
|
|
|
|
|
my @params = @_; |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
if ( $self->{ Exclude } ) { |
111
|
0
|
|
|
|
|
|
my %exclude_hash = map { $_ => 1 } @{ $self->{ Exclude } }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
@params = grep { ! exists $exclude_hash{ $_ } } @params; |
|
0
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if ( $self->{ Include } ) { |
116
|
0
|
|
|
|
|
|
my %include_hash = map { $_ => 1 } @{ $self->{ Include } }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
@params = grep { exists $include_hash{ $_ } } @params; |
|
0
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
119
|
0
|
|
|
|
|
|
return @params; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
__END__ |