#!/usr/bin/perl
#-----------------------------------------------------------------------------
#
# POPular -- A POP3 server and proxy for large mail systems
#
# $Id: log-extract,v 1.3 2002/09/15 12:27:14 sqrt Exp $
#
# http://www.remote.org/jochen/mail/popular/
#
#-----------------------------------------------------------------------------
#
# Copyright (C) 1999-2002 Jochen Topf <jochen@remote.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
#
#-----------------------------------------------------------------------------
use strict;
my $mode=0;
my ($code, $lvl, $name, $lnum, $text);
my %hash;
while (<>) {
if ($mode == 0) {
if ($_ =~ m|/\*.*XLOG-DOC:([A-Z]+):([0-9a-f]{4}):([a-z_]+)|) {
$mode = 1;
$text = "";
$lvl = $1;
$code = $2;
$name = $3;
$lnum = $.;
}
} else {
my $line = $_;
$line =~ s/^[ \t\/*]+//;
$line =~ s/[ \t\/*]+$//;
$text .= $line;
if (/\*\//) {
$mode = 0;
if (defined $hash{$code}) {
print STDERR "code $code is not unique: $ARGV:$. and $hash{$code}\n";
exit(1);
}
$hash{$code} = "$ARGV:$.";
(my $file = $ARGV) =~ s|.*/||;
print ":$code:$lvl:$name:$file:$lnum\n";
chomp $text;
print "$text\n";
}
}
} continue {
close ARGV if eof; # Not eof()!
}
#-- THE END ------------------------------------------------------------------
syntax highlighted by Code2HTML, v. 0.9.1