#! /usr/bin/perl -w

# vim:syntax=perl

use strict;

use lib '/usr/local/share/perl5';

use Lire::Config;
use Lire::Program qw( :msg $PROG );

lr_err( "Usage: $PROG <service>|-l" ) unless @ARGV == 1;

if ($ARGV[0] eq '-l') {
    print join("\n", @Lire::Config::SUPERSERVICES ), "\n";
    exit 0;
}

my $service = shift;

print Lire::Config::check_superservice($service), "\n";

exit 0;

__END__

=pod

=head1 NAME

lr_check_superservice - map Lire service to Lire superservice

=head1 SYNOPSIS

B<lr_check_superservice> I<service>
B<lr_check_superservice> B<-l>

=head1 DESCRIPTION

B<lr_check_superservice> takes a Lire service as argument, and returns the
I<superservice> this I<service> belongs to.  In case the service is unknown, a
userfriendly errormessage is given.  The given I<service> could be in its
non-canonical name.

B<lr_check_superservice> calls Lire::Config::check_superservice to perform the
real work: this script is supplied only to enable access to this perl routine
from shell scripts.

B<lr_check_superservice> exits 0, even if I<service> is unknown.

When called with the B<-l> option, this script prints all supported
superservices.

Refer to the Lire::Config(3pm) manpage for details.

=head1 EXAMPLE

Call this script in shell scripts as

 LR_SERVICE="$1"

 LR_SUPERSERVICE=`lr_check_superservice "$LR_SERVICE"`
 if test -z "$LR_SUPERSERVICE"
 then
    echo >&2 "$tag err lr_check_superservice failed"
    exit 1
 fi

 # now go using $LR_SUPERSERVICE

.


=head1 SEE ALSO

Lire::Config(3pm)

=head1 VERSION

$Id: lr_check_superservice.in,v 1.4 2002/08/18 16:49:40 flacoste Exp $

=head1 COPYRIGHT

Copyright (C) 2002 Stichting LogReport Foundation LogReport@LogReport.org

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.

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.

You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html or write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.

=head1 AUTHOR

Joost van Baal <joostvb@logreport.org>

=cut

# Local Variables:
# mode: cperl
# End:

