| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | sub fault ($) { print STDERR "$_[0]\n"; exit 8; } |
| 4 | |
| 5 | @ARGV==5 or fault("invalid arguments to $0"); |
| 6 | ($line,$idlesince,$nick,$path,$chan) = @ARGV; |
| 7 | |
| 8 | open X, ">&0" or fault("reopen stdin for output: $!"); |
| 9 | |
| 10 | $timestring= localtime time; |
| 11 | |
| 12 | pline("\a"); |
| 13 | pline("You are cordially invited onto the system's IRC server by \`$nick'"); |
| 14 | pline("($path) at $timestring"); |
| 15 | pline("If you don't know how to use IRC, run \`irc <your-nickname> chiark'"); |
| 16 | pline("When you are on-line, please ". |
| 17 | (length $chan ? "join $chan." : "send a private note to $nick.")); |
| 18 | pline(""); |
| 19 | |
| 20 | close X or outfail(); |
| 21 | |
| 22 | print "ok $line $idlesince\n"; |
| 23 | exit 0; |
| 24 | |
| 25 | sub pline ($) { |
| 26 | my ($s) = @_; |
| 27 | print X "\r", " "x78, "\r $s\r\n" or outfail(); |
| 28 | } |
| 29 | |
| 30 | sub outfail () { |
| 31 | if ($! == &EAGAIN || $! == &EWOULDBLOCK) { |
| 32 | print "failed has a congested terminal\n"; |
| 33 | exit 0; |
| 34 | } else { |
| 35 | print "failed has a broken terminal ($!)\n"; |
| 36 | exit 0; |
| 37 | } |
| 38 | } |