Parser/Ncsa.pm: Assure that at least 20 search terms are printed.
[yaala.git] / yaala
1 #!/usr/bin/perl
2 ##########################################################################
3 #    yaala 0.7.3                                              2004-11-10 #
4 #---=============--------------------------------------------------------#
5 # Language: Perl                                                         #
6 # Purpose:  Generating statistics                                        #
7 # Input:    Logfiles                                                     #
8 # Output:   One or more HTML-files (depending on the output module)      #
9 # Version:  0.7.3 (stable)                                               #
10 # License:  GPL                                                          #
11 # Homepage: http://yaala.org/                                            #
12 # Authors:  Florian octo Forster <octo@verplant.org>                     #
13 #           Contributions are listed in AUTHORS                          #
14 ##########################################################################
15
16 BEGIN
17 {
18         if ($0 =~ m#^(.*)[/\\]#) { chdir ($1); }
19         
20         unshift (@::INC, 'lib');
21         
22 # 0x010: lib/Data/Core.pm
23 # 0x020: lib/Data/Setup.pm
24 # 0x040: lib/Data/Convert.pm
25 # 0x080: lib/Data/Core.pm (dump any data stored!)
26 # 0x100: lib/Report/GDGraph.pm
27 # 0x200: lib/Data/Persistent.pm
28         $::DEBUG = 0x0000;
29 }
30
31 use strict;
32 use warnings;
33 use vars qw(
34         $DEBUG
35         $EXTRA
36
37         $NAME
38         $VERSION
39         $HOMEPAGE
40 );
41
42 use Carp;
43 use Yaala::Config qw#get_config parse_argv read_config#;
44
45 $NAME = 'yaala';
46 $VERSION = '0.7.3';
47 $HOMEPAGE = 'http://yaala.org/';
48
49 if ($DEBUG)
50 {
51         select STDOUT;
52         $| = 1;
53 }
54
55 $EXTRA = {};
56
57 print STDERR $/, __FILE__, ': $Id: yaala,v 1.17 2004/11/10 10:07:43 octo Exp $' if ($DEBUG);
58
59 parse_argv (@ARGV);
60 read_config (get_config ('config') ? get_config ('config') : 'config');
61
62 unless (get_config ('input'))
63 {
64         usage ();
65         exit (1);
66 }
67
68 # report and data initialization needs parser module
69 my $logtype = get_config ('logtype');
70 my $report  = get_config ('report' );
71 $logtype ||= 'Common';
72 $report  ||= 'Combined';
73 $logtype = ucfirst (lc ($logtype));
74 $report  = ucfirst (lc ($report ));
75
76 require "Yaala/Parser/$logtype.pm";
77 require "Yaala/Report/$report.pm";
78 import Yaala::Parser qw#parse extra#;
79 import Yaala::Report qw#generate#;
80
81 print STDERR $/, __FILE__, ": Accumulating data.." if ($DEBUG);
82
83 my $num_read_files = 0;
84
85 for (get_config ('input'))
86 {
87         #no strict 'refs';
88         if (open (LOGFILE, '< ' . $_))
89         {
90                 print STDERR $/, __FILE__, qq#: Reading "$_"# if ($DEBUG);
91                 $num_read_files++;
92                 
93                 parse ($_) while (<LOGFILE>);
94                 
95                 close LOGFILE;
96         }
97         else
98         {
99                 print STDERR $/, __FILE__, qq#: Error opening "$_": $!#;
100         }
101 }
102 if (!$num_read_files)
103 {
104         print STDERR $/, __FILE__, ": Could not read any files. Exiting.\n";
105         exit (1);
106 }
107
108 extra ();
109
110 print STDERR $/, __FILE__, ': Generating pages..' if ($DEBUG);
111 generate ();
112
113 print STDERR $/, __FILE__, ": Exiting.." if ($DEBUG);
114
115 exit (0);
116
117 ##################################################
118 #    end of main program                         #
119 #---=====================------------------------#
120 # surprised?? well, it's pretty short, cause all #
121 # the _real_ work is done in the the modules.    #
122 # If you write a modul by your own: PLEASE send  #
123 # me a copy so that i can include it in the      #
124 # package.                                       #
125 # And how about 12 modules at a time ? -- qmax   #
126 # Awesome :) -- octo                             #
127 ##################################################
128
129 sub usage
130 {
131         print STDOUT <<EOF;
132
133 Usage: $0 [--<key> <value>] file1 .. fileN
134
135 Options:
136         --config        Specify alternate config file
137         --directory     yaala will write all generated files to this
138                         directory (and overwrite existing ones without
139                         prompting!)
140         --report        Selects the report type to use
141         --logtype       Specifies the type of logfiles to parse
142         --select        Select statements. See README.selections
143
144 You can prepend two dashes to every keyword in the config file and
145 configure yaala from the command line.
146 EOF
147         return (1);
148 }
149
150 END
151 {
152         print STDERR $/ if ($DEBUG);
153 }