X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fclient.pl;h=c3efad349185290ce4161c976d8bffef90ce27fc;hb=6b6a8002929017b6d4217f68fa492a2d728ee1fe;hp=a5caec450e67b922eeeb7b9807fa8d56d92448da;hpb=f77b59f4fcceb428142461972e94345419cbda28;p=spider.git diff --git a/perl/client.pl b/perl/client.pl index a5caec45..c3efad34 100755 --- a/perl/client.pl +++ b/perl/client.pl @@ -20,12 +20,12 @@ BEGIN { use Msg; use DXVars; -$mode = 1; # 1 - \n = \r as EOL, 2 - \n = \n, 0 - transparent +$mode = 2; # 1 - \n = \r as EOL, 2 - \n = \n, 0 - transparent $call = ""; # the callsign being used @stdoutq = (); # the queue of stuff to send out to the user $conn = 0; # the connection object for the cluster $lastbit = ""; # the last bit of an incomplete input line -$nl = "\r"; +$mynl = "\n"; # standard terminator # cease communications sub cease @@ -43,6 +43,16 @@ sub sig_term cease(1); } +sub setmode +{ + if ($mode == 1) { + $mynl = "\r"; + } else { + $mynl = "\n"; + } + $/ = $mynl; +} + # handle incoming messages sub rec_socket { @@ -54,12 +64,16 @@ sub rec_socket my ($sort, $call, $line) = $msg =~ /^(\w)(\S+)\|(.*)$/; if ($sort eq 'D') { - $nl = "" if $mode == 0; + my $snl = $mynl; + $snl = "" if $mode == 0; + $snl = ' ' if ($mode && $line =~ />$/); $line =~ s/\n/\r/og if $mode == 1; - print $line; + #my $p = qq($line$snl); + print $line, $snl; } elsif ($sort eq 'M') { $mode = $line; # set new mode from cluster - } elsif ($sort eq 'Z') { # end, disconnect, go, away ..... + setmode(); + } elsif ($sort eq 'Z') { # end, disconnect, go, away ..... cease(0); } } @@ -100,23 +114,22 @@ sub rec_stdin } } -$call = uc $ARGV[0]; -die "client.pl []\r\n" if (!$call); -$mode = $ARGV[1] if (@ARGV > 1); - -if ($mode != 1) { - $nl = "\n"; - $\ = $nl; -} +$call = uc shift @ARGV; +$call = uc $mycall if !$call; +$connsort = lc shift @ARGV; +$connsort = 'local' if !$connsort; +$mode = ($connsort =~ /^ax/) ? 1 : 2; +setmode(); -select STDOUT; $| = 1; +#select STDOUT; $| = 1; +STDOUT->autoflush(1); $SIG{'INT'} = \&sig_term; $SIG{'TERM'} = \&sig_term; $SIG{'HUP'} = \&sig_term; $conn = Msg->connect("$clusteraddr", $clusterport, \&rec_socket); -$conn->send_now("A$call|start"); +$conn->send_now("A$call|$connsort"); Msg->set_event_handler(\*STDIN, "read" => \&rec_stdin); Msg->event_loop();