#!/usr/bin/perl -w

eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
    if 0; # not running under some shell
    eval 'exec perl -S $0 "$@"'
        if 0;

#
# $Id: cope-ns.PL,v 1.4 1997/06/19 14:34:38 schuller Exp $
# Copyright (c) 1997 Lunatech Research / Bart Schuller <schuller@lunatech.com>
# See the file "Artistic" in the distribution for licensing and
# (lack of) warranties.

use Carp;
BEGIN { $SIG{__WARN__} = $SIG{__DIE__} = sub { confess @_ } }

use strict;
use Getopt::Long;
use COPE::CORBA::ORB;
use COPE::CosNaming_skel;
use COPE::Announcer;

my %options;

$options{ior} = 0;
GetOptions( \%options, 'ior!');
my $orb = CORBA::ORB_init();
my $boa = $orb->BOA_init();

my $naming_skel = new CosNaming::NamingContext_skel;
my $namingref = $orb->object_to_string($naming_skel);
if ($options{ior}) {
    local $| = 1;
    print "$namingref\n";
} elsif (!COPE::Announcer::announce('NameService', $namingref)) {
    print STDERR "$0: Warning: couldn't register with cope-announce\n";
}

$boa->impl_is_ready();

__END__

=head1 NAME

cope-ns - CORBA NameService implementation in Perl

=head1 SYNOPSIS

    cope-ns [--ior]

=head1 DESCRIPTION

See the CosNaming documentation for details.

=head1 NOTES

C<cope-ns> tries to register itself with an instance of C<cope-announcer>
(see L<cope-announcer>) running on the local network. If you don't have
an announcer running, you might experience a 10 second delay on start-up.

