#
# $Id: SecurityAlert.pm,v 1.1 2002/03/05 23:44:51 fpmip Exp $
#

# Author : Tycho Fruru <tycho@fruru.com>

# Copyright (C) 2001 Tycho Fruru <tycho@fruru.com>
# Copyright (C) 2001 Conostix S.A. Luxembourg - Tycho Fruru <tycho@conostix.com>

# 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.  See <http://www.fsf.org/copyleft/gpl.txt>.
#
# 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.
#

package IPFC::Parse::Event::SecurityAlert;

use strict;
use warnings;
use IPFC::Log;

BEGIN {
	use Exporter   ();
        our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

        # set the version for version checking
        $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker

        @ISA         = qw(Exporter);
        @EXPORT      = qw( );
        %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
        @EXPORT_OK   = qw( );
}
our @EXPORT_OK;

sub parse($$$) {
	shift; # current class
	my $dbh = shift;
	my $entry = shift;
	my $r_sql_hash = shift;
	
	# make local copies so that we don't pollute the global variables
	my %sql_hash = %{$r_sql_hash};
	
	if (defined($entry->{'id'}->[0])) { 
		$sql_hash{'alert_id'}=$entry->{'id'}->[0];
	} else {
		warn "No alert_id, check XML ...";
	}
	
	if (defined($entry->{'alert-text'}->[0])) {
		$sql_hash{'alert_text'}=$entry->{'alert-text'}->[0];
	} else {
		warn "No alert_text, check XML ...";
	}
	
	
	my $rc = IPFC::DB::Event::put_event($dbh,\%sql_hash);
	
	IPFC::Log::logger(5,"return value for securityalert_1 : $rc\n");
	return $rc;
}

return 1;
