package CS::Plugin;

use Carp;
use strict;
use vars qw(@ISA @EXPORT $VERSION);

require Exporter;

$VERSION = '0.1';
@ISA = qw(Exporter);
@EXPORT = qw(getparams);

=head1 NAME

CS::Plugin - Checkservice module for use in (check)plugins

=head1 SYNOPSIS

use CS::Plugin;

=head1 DESCRIPTION

I<CS::Plugins> provides (check)plugins with generic usefull functions.

=head1 FUNCTIONS

The following function is provided so far.

=over 4

=item getparams(CONFIGREF, FDREF)

Modifies the configuration in the hash referred to by CONFIGREF or creates
one if CONFIGREF is undef. getparams() reads the params from the
filedescriptor referred to by FDREF. Key-value-pairs are expected as
input in the form: key=value\n. Everything else is ignored.

  use CS::Plugin;
  use CS::Config;

  my $conf = gethostc('check', 'smtp');         # Get defaults
  getparams($conf, \*STDIN);                    # Modify hash %$conf with
                                                  params read from STDIN;

=cut

sub getparams {
  my ($conf, $inp) = @_;

  unless ($conf) {				# Create new config hash
    my %newconf;				# if $conf refers to undef.
    my $conf = \%newconf;
  }
  
  while (<$inp>) {
    chomp;
    $conf->{$1} = $2 if /^(\w+)=([\w.]+)$/; 
  }

  return $conf;
}

=head1 COPYRIGHT

Copyright (c) 2001 Paul van Tilburg.  All rights reserved.  This program
is free software; you can redistribute it and/or modify it under the same
terms as Checkservice itself.
  
=head1 AUTHOR INFORMATION
      
Paul van Tilburg <paul@linvision.com>, Checkservice homepage:
http://www.linvision.com/checkservice/
      
=head1 SEE ALSO
  
L<perl(1)>, L<checkservice(5)>.
              
=cut

1;


syntax highlighted by Code2HTML, v. 0.9.1