#!/usr/bin/perl
#-----------------------------------------------------------------------------
#
# POPular -- A POP3 server and proxy for large mail systems
#
# $Id: log-raw2xml,v 1.2 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 @all;
my $num;
my $text;
while (<>) {
if (/^:([0-9a-f]{4}):(...):([a-z_]+):(.*):([0-9]+)$/) {
push(@{$all[$num]}, $text) if ($num);
$num = hex($1);
$all[$num] = [ $1, $2, $3, $4, $5 ];
$text = "";
} else {
$text .= $_;
}
}
print <<"EOF";
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE messagelist SYSTEM "messagelist.dtd">
<messagelist>
EOF
foreach (0..@all) {
if (defined $all[$_]) {
print <<"EOF";
<message num="$all[$_]->[0]" level="$all[$_]->[1]" name="$all[$_]->[2]">
<file>$all[$_]->[3]</file>
<line>$all[$_]->[4]</line>
<description>
EOF
write;
print <<"EOF";
</description>
</message>
EOF
}
}
print "</messagelist>\n";
exit 0;
#-----------------------------------------------------------------------------
format =
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
$all[$_]->[5]
.
#-- THE END ------------------------------------------------------------------
syntax highlighted by Code2HTML, v. 0.9.1