line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Gopher::Server::Response; |
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
396
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new |
8
|
|
|
|
|
|
|
{ |
9
|
0
|
|
|
0
|
0
|
|
my ($class, $in) = @_; |
10
|
0
|
0
|
|
|
|
|
die "Need a hashref" unless ref $in eq 'HASH'; |
11
|
|
|
|
|
|
|
|
12
|
0
|
0
|
|
|
|
|
my $request = $in->{request} |
13
|
|
|
|
|
|
|
or die "Need a request to give a response to"; |
14
|
0
|
|
|
|
|
|
my $self = { |
15
|
|
|
|
|
|
|
request => $request, |
16
|
|
|
|
|
|
|
gopher_plus => $in->{gopher_plus}, |
17
|
|
|
|
|
|
|
fh => $in->{fh}, |
18
|
|
|
|
|
|
|
information_blocks => $in->{information_blocks}, |
19
|
|
|
|
|
|
|
menu_items => $in->{menu_items}, |
20
|
|
|
|
|
|
|
}; |
21
|
0
|
|
|
|
|
|
bless $self, $class; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub print_to |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
28
|
0
|
|
0
|
|
|
|
my $fh = shift || *STDOUT; |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if($self->{fh}) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$self->_print_filehandle( $fh ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif($self->{menu_items}) { |
34
|
0
|
|
|
|
|
|
$self->_print_menu( $fh ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif($self->{information_blocks}) { |
37
|
0
|
|
|
|
|
|
$self->_print_info( $fh ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
0
|
|
|
|
|
|
die "Don't have anything to print!"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _print_filehandle |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
0
|
|
|
my ($self, $fh) = @_; |
47
|
0
|
|
|
|
|
|
my $in = $self->{fh}; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
while( read( $in, my $buf, 8192 ) ) { |
50
|
0
|
|
|
|
|
|
print $fh $buf; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _print_menu |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
|
|
my ($self, $fh) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
foreach my $menu_item (@{ $self->{menu_items} }) { |
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
print $fh $menu_item->as_string, "\r\n"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
print $fh ".\r\n"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _print_info |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
0
|
|
|
my ($self, $fh) = @_; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
0
|
0
|
|
sub request { $_[0]->{request} } |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |