3 # this is the operators console.
7 # console.pl [callsign]
9 # if the callsign isn't given then the sysop callsign in DXVars.pm is assumed
11 # Copyright (c) 1999 Dirk Koopman G1TLH
18 # search local then perl directories
20 # root of directory tree for this system
22 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
24 unshift @INC, "$root/perl"; # this IS the right way round!
25 unshift @INC, "$root/local";
36 # cease communications
40 if ($conn && $sendz) {
41 $conn->send_now("Z$call|bye...\n");
45 # $SIG{__WARN__} = sub {my $a = shift; cluck($a); };
50 # terminate program from signal
56 # handle incoming messages
59 my ($con, $msg, $err) = @_;
60 if (defined $err && $err) {
64 my ($sort, $call, $line) = $msg =~ /^(\w)(\S+)\|(.*)$/;
67 $top->addstr("\n$line");
68 } elsif ($sort eq 'Z') { # end, disconnect, go, away .....
84 # $prbuf =~ s/\r/\\r/;
85 # $prbuf =~ s/\n/\\n/;
86 # print "sys: $r ($prbuf)\n";
88 if ($r eq KEY_ENTER || $r eq "\n" || $r eq "\r") {
92 push @history, $inbuf if $inbuf;
93 shift @history if @history > $maxhist;
96 $bot->addstr(substr($inbuf, 0, COLS));
99 # send it to the cluster
100 $inbuf = " " unless $inbuf;
101 $conn->send_later("I$call|$inbuf");
104 } elsif ($r eq KEY_UP || $r eq KEY_PPAGE || $r eq "\020") {
107 $inbuf = $history[$histpos];
108 $pos = $lth = length $inbuf;
112 } elsif ($r eq KEY_DOWN || $r eq KEY_NPAGE || $r eq "\016") {
113 if ($histpos < @history - 1) {
115 $inbuf = $history[$histpos];
116 $pos = $lth = length $inbuf;
120 } elsif ($r eq KEY_LEFT || $r eq "\002") {
126 } elsif ($r eq KEY_RIGHT || $r eq "\006") {
132 } elsif ($r eq KEY_HOME) {
134 } elsif ($r eq KEY_BACKSPACE || $r eq "\010") {
136 my $a = substr($inbuf, 0, $pos-1);
137 my $b = substr($inbuf, $pos) if $pos < $lth;
146 } elsif ($r eq KEY_DC || $r eq "\004") {
148 my $a = substr($inbuf, 0, $pos);
149 my $b = substr($inbuf, $pos+1) if $pos < $lth;
157 } elsif ($r ge ' ' && $r le '~') {
159 my $a = substr($inbuf, 0, $pos);
160 my $b = substr($inbuf, $pos);
161 $inbuf = $a . $r . $b;
167 } elsif ($r eq "\014" || $r eq "\022") {
170 } elsif ($r eq "\013") {
178 $bot->addstr($inbuf);
189 $call = ""; # the callsign being used
190 $conn = 0; # the connection object for the cluster
191 $lasttime = time; # lasttime something happened on the interface
204 $call = uc shift @ARGV if @ARGV;
205 $call = uc $myalias if !$call;
207 if ($call eq $mycall) {
208 print "You cannot connect as your cluster callsign ($mycall)\n";
212 $conn = Msg->connect("$clusteraddr", $clusterport, \&rec_socket);
214 if (-r "$data/offline") {
215 open IN, "$data/offline" or die;
221 print "Sorry, the cluster $mycall is currently off-line\n";
227 $SIG{'INT'} = \&sig_term;
228 $SIG{'TERM'} = \&sig_term;
229 $SIG{'HUP'} = 'IGNORE';
234 $top = $scr->subwin(LINES()-4, COLS, 0, 0);
237 $scr->addstr(LINES()-4, 0, '-' x COLS);
238 $bot = $scr->subwin(3, COLS, LINES()-3, 0);
245 $SIG{__DIE__} = \&sig_term;
249 $conn->send_now("A$call|$connsort");
250 $conn->send_now("I$call|set/page $pages");
251 $conn->send_now("I$call|set/nobeep");
253 Msg->set_event_handler(\*STDIN, "read" => \&rec_stdin);
257 Msg->event_loop(1, 0.010);
258 $top->refresh() if $top->is_wintouched;
261 if ($t > $lasttime) {