NewsClipper
view release on metacpan or search on metacpan
NewsClipper.pl view on Meta::CPAN
return ('open error',$warnings);
}
# Check if there were any syntax errors while eval'ing the configuration
# file.
if ($@)
{
$warnings = <<" EOF";
News Clipper found your personal configuration file
"$configFile", but it could not be processed
because of the following error:
$@
EOF
return ('compile error',$warnings);
}
if ($evalWarnings)
{
$warnings = <<" EOF";
News Clipper found your personal configuration file
"$configFile", but encountered some warnings
while processing it:
$evalWarnings
EOF
return ('compile error',$warnings);
}
# No error message means we found it
if ($evalResult)
{
$config{user_config_file} = $configFile;
# Now override main's %config
while (my ($key,$value) = each %NewsClipper::config::config)
{
$main::config{$key} = $value;
}
undef %NewsClipper::config::config;
return ('okay','');
}
else
{
# Can't get here, since there would have been errors or warnings above.
die "Whoa! You shouldn't be here! Send email describing what you ".
"were doing";
}
}
# ------------------------------------------------------------------------------
# Simply gets the home directory. First it tries to get it from the password
# file, then from the Windows registry, and finally from the HOME environment
# variable.
sub GetHomeDirectory()
{
# Get the user's home directory. First try the password info, then the
# registry (if it's a Windows machine), then any HOME environment variable.
my $home = $opts{H} || eval { (getpwuid($>))[7] } ||
GetWinInstallDir() || $ENV{HOME};
# "s cause problems in Windows. Sometimes people set their home variable as
# "c:\Program Files\NewsClipper", which causes when the path is therefore
# "c:\Program Files\NewsClipper"\.NewsClipper\Handler\Acquisition
$home =~ s/"//g if defined $home;
die <<" EOF"
News Clipper could not determine your home directory. On non-Windows
machines, News Clipper attempts to get your home directory using getpwuid,
then the HOME environment variable. On Windows machines, it attempts to
read the registry entry "HKEY_LOCAL_MACHINE\\SOFTWARE\\Spinnaker
Software\\News Clipper\\$VERSION" then tries the HOME environment
variable.
EOF
unless defined $home;
return $home;
}
# ------------------------------------------------------------------------------
sub ValidateConfigFiles
{
die <<" EOF"
Could not find either a system-wide configuration file or a personal
configuration file.
EOF
if $config{sys_config_file} eq 'Not specified' &&
$config{user_config_file} eq 'Not found';
if (!defined $config{for_news_clipper_version} ||
($config{for_news_clipper_version} < $COMPATIBLE_CONFIG_VERSION))
{
my $version_string = $config{for_news_clipper_version};
$version_string = 'pre-1.21' unless defined $version_string;
die <<" EOF";
Your NewsClipper.cfg configuration file is incompatible with this
version of News Clipper (need $COMPATIBLE_CONFIG_VERSION, have $version_string).
Please run "ConvertConfig /path/NewsClipper.cfg" using the ConvertConfig that
came with this distribution of News Clipper.
EOF
}
}
# ------------------------------------------------------------------------------
# Checks the setup (system-wide modified by user's) to make sure everything is
# okay.
sub ValidateSetup()
{
die "\"handler_locations\" in NewsClipper.cfg must be non-empty.\n"
if $#{$config{handler_locations}} == -1;
foreach my $dir (@{$config{handler_locations}})
{
die "\"$dir\" from handler_locations in NewsClipper.cfg is not ".
"a directory.\n" unless -d $dir;
}
CheckRegistration();
# Check that the user isn't trying to use the -i and -o flags for the Trial
# and Personal versions
if (($config{product} eq "Trial" ||
$config{product} eq "Personal") &&
(defined $opts{i} || defined $opts{o}))
{
( run in 1.446 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )