OSSP CVS Repository

ossp - Difference in ossp-pkg/snmpdx/snmpdx versions 1.3 and 1.4
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/snmpdx/snmpdx 1.3 -> 1.4

--- snmpdx       2003/09/02 12:19:41     1.3
+++ snmpdx       2003/09/02 12:35:20     1.4
@@ -33,8 +33,11 @@
 use IO;
 
 #   program information
-my $progname = "snmpdx";
-my $progvers = "0.1.0";
+my $prg = {
+    'name'    => 'OSSP snmpdx',
+    'version' => '0.1.0',
+    'date'    => '01-Sep-2003'
+};
 
 ##  _________________________________________________________________________
 ##
@@ -467,40 +470,42 @@
 my $myroot    = "$FindBin::Bin";
 
 #   parameters (defaults)
-my $config    = "$myroot/snmpdx.cfg";
-my $version   = 0;
-my $help      = 0;
-my $tmpdir    = ($ENV{TMPDIR} || $ENV{TEMPDIR} || "/tmp");
-my $get       = 0;
-my $next      = 0;
-my $bindir    = "/cw/bin";
-my $probedir  = "$myroot/snmpdx.d";
-my $probename = "*";
-my $mibdir    = "$myroot/snmpdx.mib";
-my $mibname   = "snmpdx";
-my $logfile   = "$myroot/snmpdx.log";
-my $loglevel  = 9;
+my $opt = {
+    'config'    => "$myroot/snmpdx.cfg",
+    'version'   => 0,
+    'help'      => 0,
+    'tmpdir'    => ($ENV{TMPDIR} || $ENV{TEMPDIR} || "/tmp"),
+    'get'       => 0,
+    'next'      => 0,
+    'bindir'    => "/cw/bin",
+    'probedir'  => "$myroot/snmpdx.d",
+    'probename' => "*",
+    'mibdir'    => "$myroot/snmpdx.mib",
+    'mibname'   => "snmpdx",
+    'logfile'   => "$myroot/snmpdx.log",
+    'loglevel'  => 9,
+};
 
 #   command line parsing
 my %options = (
-    'c|config=s'    => \$config,
-    'V|version'     => \$version,
-    'h|help'        => \$help,
-    't|tmpdir=s'    => \$tmpdir,
-    'g|get'         => \$get,
-    'n|next'        => \$next,
-    'b|bindir=s'    => \$bindir,
-    'P|probedir=s'  => \$probedir,
-    'p|probename=s' => \$probename,
-    'M|mibdir=s'    => \$mibdir,
-    'm|mibname=s'   => \$mibname,
-    'l|logfile=s'   => \$logfile,
-    'L|loglevel=i'  => \$loglevel,
+    'c|config=s'    => \$opt->{'config'},
+    'V|version'     => \$opt->{'version'},
+    'h|help'        => \$opt->{'help'},
+    't|tmpdir=s'    => \$opt->{'tmpdir'},
+    'g|get'         => \$opt->{'get'},        # FIXME: still unused!
+    'n|next'        => \$opt->{'next'},       # FIXME: still unused!
+    'b|bindir=s'    => \$opt->{'bindir'},
+    'P|probedir=s'  => \$opt->{'probedir'},
+    'p|probename=s' => \$opt->{'probename'},
+    'M|mibdir=s'    => \$opt->{'mibdir'},
+    'm|mibname=s'   => \$opt->{'mibname'},
+    'l|logfile=s'   => \$opt->{'logfile'},
+    'L|loglevel=i'  => \$opt->{'loglevel'},
 );
 Getopt::Long::Configure("bundling");
 my $result = GetOptions(%options) || die "option parsing failed";
-if ($help) {
-    print "Usage: $progname [options] [SPECFILE ...]\n" .
+if ($opt->{'help'}) {
+    print "Usage: $prg->{'name'} [options] [SPECFILE ...]\n" .
           "Available options:\n" .
           " -c,--config=PATH    read command line options from configuration fil\n" .
           " -V,--version        print program version\n" .
@@ -517,14 +522,14 @@
           " -L,--loglevel=NUM   logging level (0...9)\n";
     exit(0);
 }
-if ($version) {
-    print "$progname $progvers\n";
+if ($opt->{'version'}) {
+    print "$prg->{'name'} $prg->{'version'} ($prg->{'date'})\n";
     exit(0);
 }
 
 #   support external configuration file
-if (-f $config) {
-    my $cfg = new IO::File "<$config";
+if (-f $opt->{'config'}) {
+    my $cfg = new IO::File "<$opt->{'config'}";
     my $line;
     while (defined($line = $cfg->getline())) {
         $line =~ s|\r?\n$||s;
@@ -544,14 +549,20 @@
 
 #   create daemon run-time context
 my $ctx = {};
-$ctx->{-log}      = new My::Log ($loglevel, $logfile);
+$ctx->{-prg}      = $prg;
+$ctx->{-opt}      = $opt;
+$ctx->{-log}      = new My::Log ($opt->{'loglevel'}, $opt->{'logfile'});
 $ctx->{-cache}    = new My::Cache;
 $ctx->{-sys}      = new My::System ($ctx->{-log}, $ctx->{-cache});
 $ctx->{-platform} = new My::Platform;
-$ctx->{-log}->printf(1, "startup %s %s (%s)", $progname, $progvers, $ctx->{-platform}->id());
-$ctx->{-mib}      = new My::MIB ($bindir, $mibdir, $mibname);
+$ctx->{-mib}      = new My::MIB ($opt->{'bindir'}, $opt->{'mibdir'}, $opt->{'mibname'});
 $ctx->{-enc}      = new My::Enc;
 
+#   startup information
+$ctx->{-log}->printf(1, "startup %s %s (%s) on %s",
+    $prg->{'name'}, $prg->{'version'}, $prg->{'date'},
+    $ctx->{-platform}->id());
+
 #   exception handling support 
 $SIG{__DIE__} = sub {
     my ($err) = @_;
@@ -597,8 +608,8 @@
     'IpAddress'          => [ 'ipaddress', '0.0.0.0' ],
     'DateAndTime'        => [ 'octet',     $ctx->{-enc}->dat_encode("1970-01-01 01:02:03") ],
 };
-$ctx->{-log}->printf(1, "MIB id: %s", $mibname);
-foreach my $probefile (glob("$probedir/$probename.pm")) {
+$ctx->{-log}->printf(1, "MIB id: %s", $opt->{'mibname'});
+foreach my $probefile (glob($opt->{'probedir'}."/".$opt->{'probename'}.".pm")) {
     my $probe = $probefile;
     $probe =~ s|^.*/([^/]+)\.pm$|$1|sg;
     my $p;

CVSTrac 2.0.1