Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, March 28, 2024

File: [Platon] / iotta / iotta.pl (download)

Revision 1.4, Sat Apr 5 16:30:11 2003 UTC (20 years, 11 months ago) by yenar


Changes since 1.3: +1 -1 lines

bugfix: use iotta.cf as default config like before [iotta.pl]

#!/usr/bin/perl
require Iotta::Ctrl;
use strict;
use Getopt::Long;

my (%cfg);

#sub init_mods {
#    my ($mods, $pre, $fname);
#
#    $fname = $cfg{"init/mods"};
#    $fname = "iotta.mods" unless $fname;
#
#    open (INPUT, $fname) || return 1;
#    while (<INPUT>) { $mods.=$_; }
#    close (INPUT);
#
#    for (split (/\n/, $mods)) {
#        my $b = $_;
#        s/::/\//g;
#        print STDERR "loading $b ($_.pm)\n";
#        require "$_.pm" unless /^[ \t]*#.*$/;
#    }
#}

sub init_conf {
    my @confs;
    my ($conf, $key, $val, @fname);

    &Getopt::Long::Configure ("pass_through");
    &GetOptions ("conf=s" => \@confs, "conffile=s" => \@fname);
    $conf = join ("\n", @confs);

    push @fname, "iotta.cf" if (!scalar @fname);
    for my $fname (@fname) {
        print STDERR "loading configuration file $fname...\n";

        open (CF, $fname); #|| die "couldn't open configuration file $fname\n";
        while (<CF>) { $conf .= $_; };
        close CF;
    }

    $conf =~ s/^#.*//;

    for (split (/\n/, $conf)) {
        ($key,$val) = split (/=/, $_);
        $cfg{$key}=$val;
    }
}

sub start_control {
    my ($ctrl, $ctrln, $retval);
    $ctrln = $cfg{"ctrl"};
    $ctrln = "Iotta::Ctrl" if (!$ctrln);
    print STDERR "starting control module: $ctrln...\n";
    my $req = $ctrln;
    $req =~ s/::/\//g;
    require "$req.pm";
    $ctrl = $ctrln->new;
    $ctrl->config(\%cfg);
    $retval = $ctrl->main;
    exit ($retval);
}

&init_conf (@ARGV);

#&init_mods ();

&start_control ();

exit (0);

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top