File Coverage

blib/lib/Logfile/Wn.pm
Criterion Covered Total %
statement 25 49 51.0
branch 10 26 38.4
condition 1 5 20.0
subroutine 1 2 50.0
pod 0 2 0.0
total 37 84 44.0


line stmt bran cond sub pod time code
1             # -*- Mode: Perl -*-
2             # Wn.pm --
3             # ITIID : $ITI$ $Header $__Header$
4             # Author : Ulrich Pfeifer
5             # Created On : Wed May 22 13:17:07 1996
6             # Last Modified By: Ulrich Pfeifer
7             # Last Modified On: Fri May 29 15:29:14 1998
8             # Language : CPerl
9             # Update Count : 14
10             # Status : Unknown, Use with caution!
11             #
12             # (C) Copyright 1996, Universität Dortmund, all rights reserved.
13             #
14             # $Locker: pfeifer $
15             # $Log: Wn.pm,v $
16             # Revision 0.1.1.1 1996/06/04 14:35:31 pfeifer
17             # patch13: Support for the WN http server.
18             #
19             # Revision 1.1 1996/05/23 13:46:05 pfeifer
20             # Initial revision
21             #
22             #
23             package Logfile::Wn;
24             require Logfile::Base;
25              
26             @ISA = qw ( Logfile::Base ) ;
27              
28             sub next {
29 2     2 0 9 my $self = shift;
30 2         11 my $fh = $self->{Fh};
31 2         132 my ($host, $bytes, $error, $code, $dummy, $date, $request, $client, $referer)
32             = ('') x 9;
33 2         10 *S = $fh;
34 2         3 while (1) {
35 3         23 my $line = ;
36 3 50       10 return undef unless defined $line;
37 3 50       28 if ($line =~ s/(\S+)\s+//) {
38 3         11 $host = $1;
39             } else {
40 0         0 next;
41             }
42 3 50       19 unless ($line =~ s/(\S+)\s+(\S+)\s+//) {
43 0         0 next;
44             }
45 3 100       27 if ($line =~ s/\[(.*?)\]\s+//) {
46 2         4 $date = $1;
47             } else {
48 1         3 next;
49             }
50 2 50       15 if ($line =~ s/\"(.*?)\"\s+//) {
51 2         5 $request = $1;
52 2         12 $request =~ s/^(GET|HEAD) //;
53 2         8 $request =~ s: HTTP/1.0$::;
54             } else {
55             next
56 0         0 }
57 2 50       43 if ($line =~ s/(\S+)\s+(\d+)\s+//) {
58 0         0 $code = $1;
59 0         0 $bytes = $2;
60             }
61 2 50       12 if ($line =~ s/\<(.*?)\>\s+//) {
62 2         4 $error = $1;
63             } else {
64             next
65 0         0 }
66 2 50       12 if ($line =~ s/\<(.*?)\>\s+//) {
67 2         5 $client = $1;
68             } else {
69             next
70 0         0 }
71 2 50       9 if ($line =~ s/\<(.*?)\>\s+//) {
72 2         5 $referer = $1;
73             } else {
74             next
75 0         0 }
76 2   50     34 return(Logfile::Base::Record->new(Host => $host,
77             Date => $date,
78             Error => $error,
79             Client => $client,
80             Referer => $referer,
81             File => $request,
82             Bytes => $bytes||0,
83             )
84             );
85             }
86             }
87              
88             sub norm {
89 0     0 0   my ($self, $key, $val) = @_;
90              
91 0 0 0       if ($key eq File or $key eq Referer) {
    0          
    0          
92 0           $val =~ s/\?.*//; # remove that !!!
93 0           $val =~ s/GET //;
94 0 0         $val = '/' unless $val;
95 0           $val =~ s/\.\w+$//;
96 0           $val =~ s!%([\da-f][\da-f])!chr(hex($1))!eig;
  0            
97 0           $val =~ s!~(\w+)/.*!~$1!;
98             # proxy
99 0           $val =~ s!^((http|ftp|wais)://[^/]+)/.*!$1!;
100 0           $val;
101             } elsif ($key eq Bytes) {
102 0           $val =~ s/\D.*//;
103             } elsif ($key eq Error) {
104 0           $val =~ s:^\s*\(\d+/\d+\)\s+::;
105 0           $val = substr($val,0,$Logfile::MAXWIDTH);
106 0           $val;
107             } else {
108 0           $val;
109             }
110             }
111              
112             1;