All the files

This commit is contained in:
2024-03-09 15:36:42 +01:00
parent 58e88da2d8
commit 08b6b503a6
22 changed files with 1721 additions and 0 deletions

43
lib/dovecot.pm Normal file
View File

@@ -0,0 +1,43 @@
package My::parser::dovecot;
use strict;
use warnings;
use My::parser::dovecot_parser;
sub new {
my $class = shift;
my $config = shift;
my $self = {};
bless ($self, $class);
$self->{'config'} = $config;
$self->{'parser'} = My::parser::dovecot_parser->new();
return $self;
}
sub parse {
my $self = shift;
my @result;
while(my $string = $self->fetch) {
last unless($string);
if (my $line = $self->{'parser'}->parser($string)) {
push(@result,$line);
}
}
return { retval => 0 } unless(scalar(@result));
return { retval => 1, retmsg => 'Here comes the results', lines => \@result };
}
sub fetch {
my $self = shift;
my $fetcher = $self->{'config'}->get_fetcher('dovecot');
my $line;
my ($nfound,$timeleft,@pending) = File::Tail::select(undef,undef,undef,1,$fetcher);
foreach (@pending) {
$line = $_->read;
chomp($line);
}
return 0 unless($line);
return $line;
}
1;