| ClamAV-Client documentation | Contained in the ClamAV-Client distribution. |
ClamAV::Config - A Perl class providing configuration information for Perl modules related to ClamAV
0.11
use ClamAV::Config;
# ClamAV base configuration:
ClamAV::Config->config_dir;
ClamAV::Config->clamd_config_file;
# clamd run-time configuration:
ClamAV::Config->clamd_config;
ClamAV::Config->clamd_option($option);
This class provides configuration information for Perl modules related to the ClamAV virus scanner, e.g. installation specific file system paths and run-time configuration options.
The following ClamAV base configuration information is provided as class methods:
The base configuration directory of ClamAV.
The absolute file name of the clamd configuration file.
The following clamd run-time configuration information is provided as class methods:
Returns all clamd run-time configuration options as a hash reference.
Returns the value of the specified clamd run-time configuration option.
For AVAILABILITY, SUPPORT, and LICENSE information, see ClamAV::Client.
Julian Mehnle <julian@mehnle.net>
| ClamAV-Client documentation | Contained in the ClamAV-Client distribution. |
# # ClamAV::Config class # # (C) 2004-2005 Julian Mehnle <julian@mehnle.net> # $Id: Config.pm,v 1.3 2005/01/21 22:50:14 julian Exp $ # ##############################################################################
package ClamAV::Config;
our $VERSION = 0.11;
use warnings; use strict; use Error qw(:try); use IO::File; # Private declarations: ############################################################################## use constant TRUE => (0 == 0); use constant FALSE => not TRUE; my $clamd_config; # Interface: ##############################################################################
sub clamd_option; # Implementation: ##############################################################################
use constant config_dir => '/etc/clamav';
use constant clamd_config_file => config_dir . '/clamd.conf';
sub clamd_config { my ($self) = @_; return $clamd_config if $clamd_config; my $file = IO::File->new($self->clamd_config_file); if (not $file) { $clamd_config = {}; throw ClamAV::Config::Error( 'Could not open clamd config file "' . $self->clamd_config_file . '" for reading' ); } while (my $line = $file->getline) { chomp($line); next if $line =~ /^\s*#/; if (not $line =~ /^\s*(\w+)(?:\s+(\S+))?\s*$/) { $clamd_config = {}; throw ClamAV::Config::Error('Malformed line in clamd configuration file encountered'); } $clamd_config->{$1} = (defined($2) ? $2 : TRUE); } return $clamd_config; }
sub clamd_option { my ($self, $option) = @_; return $self->clamd_config->{$option}; }
package ClamAV::Config::Error; use base qw(Error::Simple); package ClamAV::Config; TRUE; # vim:tw=79