PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|C|nagios-plugins-1.4.10|NPTest.pm =

page 5 of 7



  }
  return undef;	# Need this to say "nothing found"
}

sub SetCacheParameter
{
  my( $param, $scope, $value ) = @_;

  if ( defined( $scope ) )
  {
    $CACHE{$scope}{$param} = $value;
  }
  else
  {
    $CACHE{$param} = $value;
  }

  SaveCache();
}

sub LoadCache
{
  return if exists( $CACHE{'_cache_loaded_'} );

  if ( -f $CACHEFILENAME )
  {
    my( $fileHandle ) = new IO::File;

    if ( ! $fileHandle->open( "< ${CACHEFILENAME}" ) )
    {
      print STDERR "NPTest::LoadCache() : Problem opening ${CACHEFILENAME} : $!\n";
      return;
    }

    my( $fileContents ) = join( "\n", <$fileHandle> );

    $fileHandle->close();

    my( $contentsRef ) = eval $fileContents;
    %CACHE = %{$contentsRef};

  }

  $CACHE{'_cache_loaded_'} = 1;
}


sub SaveCache
{
  delete $CACHE{'_cache_loaded_'};

  my( $fileHandle ) = new IO::File;

  if ( ! $fileHandle->open( "> ${CACHEFILENAME}" ) )
  {
    print STDERR "NPTest::LoadCache() : Problem saving ${CACHEFILENAME} : $!\n";
    return;
  }

  my( $dataDumper ) = new Data::Dumper( [ \%CACHE ] );

  $dataDumper->Terse(1);

  print $fileHandle $dataDumper->Dump();

  $fileHandle->close();

  $CACHE{'_cache_loaded_'} = 1;
}

#
# (Questionable) Public Cache Management Functions
#

sub SetCacheFilename
{
  my( $filename ) = @_;

  # Unfortunately we can not validate the filename
  # in any meaningful way, as it may not yet exist
  $CACHEFILENAME = $filename;
}


#
# Test Harness Wrapper Functions
#

sub DetermineTestHarnessDirectory
{
  my( $userSupplied ) = @_;

  # User Supplied
  if ( defined( $userSupplied ) && $userSupplied )
  {
    if ( -d $userSupplied )
    {
      return $userSupplied;
    }
    else
=5=

1|2|3|4| < PREV = PAGE 5 = NEXT > |6|7

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.00592494 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)