Skip to content

Commit

Permalink
Use itemtype 3 for error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Sep 8, 2017
1 parent c33e508 commit 5d7e147
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion IcculusGopher_daemon.pl
Expand Up @@ -186,7 +186,7 @@ sub gopher_mainline {
{ exec $exe, $args; };
syslog("info", "Failed to execute '$exe': $!");
}
send_gopher_menu('i', $no_report_string);
send_gopher_menu('3', $no_report_string);
return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion gopherspace/default
Expand Up @@ -35,5 +35,5 @@ if (opendir(my $dh, $gopherspace)) {
closedir($dh);
}

send_gopher_info(" ...nothing, apparently!") if !$seen;
send_gopher_menu(3, ' ...nothing, apparently!') if !$seen;

29 changes: 22 additions & 7 deletions gopherspace/fortune
Expand Up @@ -3,19 +3,34 @@
use strict;
use warnings;

sub gopher_info {
sub send_gopher_menu {
my ($itemtype, $str, $selector, $host, $port) = @_;
$itemtype = 'i' if not defined $itemtype;
$str = '' if not defined $str;
$selector = '' if not defined $selector;
$host = 'error.host' if not defined $host;
$port = 1 if not defined $port;
print("$itemtype$str\t$selector\t$host\t$port\r\n");
}

sub send_gopher_info {
my $str = shift;
print("i$str\t\terror.host\t1\r\n");
send_gopher_menu('i', $str);
}

my @lines = split /^/m, `/usr/games/fortune`;
gopher_info('');
gopher_info('');
if (scalar(@lines) == 0) {
send_gopher_menu('3', "Uhoh, fortune process didn't work out. Sorry!");
exit(1);
}
send_gopher_info('');
send_gopher_info('');
foreach (@lines) {
chomp;
s/\t/ /g;
gopher_info($_);
send_gopher_info($_);
}
gopher_info('');
gopher_info('');
send_gopher_info('');
send_gopher_info('');

0 comments on commit 5d7e147

Please sign in to comment.