/usr/share/perl5/INetSim/Quotd.pm is in inetsim 1.2.7+dfsg.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | # -*- perl -*-
#
# INetSim::Quotd - Base package for Quotd::TCP and Quotd::UDP
#
# (c)2007 Thomas Hungenberg, Matthias Eckert
#
# Version 0.21 (2007-04-26)
#
# For history/changelog see bottom of this file.
#
#############################################################
package INetSim::Quotd;
use strict;
use warnings;
use base qw(INetSim::GenericServer);
my $selected_author = undef;
my $selected_quote = undef;
sub select_quote{
my $serviceName = shift;
my $quotesfilename = &INetSim::Config::getConfigParameter("Quotd_QuotesFileName");
my $count = 0;
my $author;
my $quote;
my $selected;
my @authors;
my @quotes;
my $line;
if (! open(FH, $quotesfilename)) {
# unable to open quotes file
&INetSim::Log::MainLog("Warning: Unable to open quotes file '$quotesfilename': $!.", $serviceName)
}
else {
while ($line=<FH>) {
chomp($line);
if ($line !~ /^\#/){
my $author = $line;
my $quote = $line;
$author =~ s/^.*\-\-\-(.*)$/$1/;
$quote =~ s/^(.*)\-\-\-.*$/$1/;
$author =~ s/^\s+//;
$author =~ s/\s+$//;
$quote =~ s/^\s+//;
$quote =~ s/\s+$//;
if (($quote ne "") && ($author ne "")) {
push(@authors, $author);
push(@quotes, $quote);
}
}
else {
next;
}
}
close FH;
}
if (! scalar @quotes) {
&INetSim::Log::MainLog("Warning: No quotes available. Using built-in dummy quotes instead.", $serviceName);
# doppelt, wegen rand()
push(@quotes, "No quotes today :-)");
push(@quotes, "No quotes today :-)");
push(@authors, "Matze");
push(@authors, "Matze");
}
$count = @quotes;
$selected = int(rand($count));
return ($authors[$selected], $quotes[$selected]);
}
1;
#############################################################
#
# History:
#
# Version 0.21 (2007-04-26) th
# - use getConfigParameter
#
# Version 0.2 (2007-04-24) th
# - replaced die() call if quotes file not available
# - log warning if quotes file not available or empty
#
# Version 0.1 (2007-03-26) th
#
#############################################################
|