package Ocsinventory::Agent::Backend::OS::AIX::Software;

use strict;
use warnings;

sub check {
  my $params = shift;

  # Do not run an package inventory if there is the --nosoft parameter
  return if ($params->{params}->{nosoft});

  `lslpp -l 2>&1`;
  return if ($? >> 8)!=0;
  1;
}

sub run {
  my $params = shift;
  my $inventory = $params->{inventory};

  my @list;
  my $buff;
  foreach (`lslpp -c -l`) {
    my @entry = split /:/,$_;
    next unless (@entry);
    next unless ($entry[1]);
    next if $entry[1] =~ /^device/;

    $inventory->addSoftwares({
	'COMMENTS'      => $entry[6],
	'FOLDER'	=> $entry[0],
	'NAME'          => $entry[1],
	'VERSION'       => $entry[2],
	});
  }
}

1;
