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;
97 $bot->addstr(substr($inbuf, 0, COLS));
100 # send it to the cluster
101 $inbuf = " " unless $inbuf;
102 $conn->send_later("I$call|$inbuf");
105 } elsif ($r eq KEY_UP || $r eq KEY_PPAGE || $r eq "\020") {
108 $inbuf = $history[$histpos];
109 $pos = $lth = length $inbuf;
113 } elsif ($r eq KEY_DOWN || $r eq KEY_NPAGE || $r eq "\016") {
114 if ($histpos < @history - 1) {
116 $inbuf = $history[$histpos];
117 $pos = $lth = length $inbuf;
121 } elsif ($r eq KEY_LEFT || $r eq "\002") {
127 } elsif ($r eq KEY_RIGHT || $r eq "\006") {
133 } elsif ($r eq KEY_HOME || $r eq "\001") {
135 } elsif ($r eq KEY_BACKSPACE || $r eq "\010") {
137 my $a = substr($inbuf, 0, $pos-1);
138 my $b = substr($inbuf, $pos) if $pos < $lth;
147 } elsif ($r eq KEY_DC || $r eq "\004") {
149 my $a = substr($inbuf, 0, $pos);
150 my $b = substr($inbuf, $pos+1) if $pos < $lth;
158 } elsif ($r ge ' ' && $r le '~') {
160 my $a = substr($inbuf, 0, $pos);
161 my $b = substr($inbuf, $pos);
162 $inbuf = $a . $r . $b;
168 } elsif ($r eq "\014" || $r eq "\022") {
171 } elsif ($r eq "\013") {
179 $bot->addstr($inbuf);
190 $call = ""; # the callsign being used
191 $conn = 0; # the connection object for the cluster
192 $lasttime = time; # lasttime something happened on the interface
205 $call = uc shift @ARGV if @ARGV;
206 $call = uc $myalias if !$call;
208 if ($call eq $mycall) {
209 print "You cannot connect as your cluster callsign ($mycall)\n";
213 $conn = Msg->connect("$clusteraddr", $clusterport, \&rec_socket);
215 if (-r "$data/offline") {
216 open IN, "$data/offline" or die;
222 print "Sorry, the cluster $mycall is currently off-line\n";
228 $SIG{'INT'} = \&sig_term;
229 $SIG{'TERM'} = \&sig_term;
230 $SIG{'HUP'} = 'IGNORE';
235 $top = $scr->subwin(LINES()-4, COLS, 0, 0);
238 $scr->addstr(LINES()-4, 0, '-' x COLS);
239 $bot = $scr->subwin(3, COLS, LINES()-3, 0);
246 $SIG{__DIE__} = \&sig_term;
250 $conn->send_now("A$call|$connsort");
251 $conn->send_now("I$call|set/page $pages");
252 $conn->send_now("I$call|set/nobeep");
254 Msg->set_event_handler(\*STDIN, "read" => \&rec_stdin);
258 Msg->event_loop(1, 0.010);
259 $top->refresh() if $top->is_wintouched;
262 if ($t > $lasttime) {