use DXDebug;
use IO::File;
use IO::Socket;
+use IPC::Open2;
use vars qw(@ISA $deftimeout);
my $conn = shift;
my $msg;
+ if ($conn->{csort} eq 'ax25' && exists $conn->{msg}) {
+ $conn->{msg} =~ s/\cM/\cJ/g;
+ }
if ($conn->{state} eq 'WC') {
if (exists $conn->{cmd}) {
if (@{$conn->{cmd}}) {
if ($conn->{state} eq 'WC' && exists $conn->{cmd} && @{$conn->{cmd}} == 0) {
$conn->to_connected($conn->{call}, 'O', 'telnet');
}
- } elsif ($conn->{msg} =~ /\n/) {
- my @lines = split /\r?\n/, $conn->{msg};
- if ($conn->{msg} =~ /\n$/) {
+ } elsif ($conn->{msg} =~ /\cJ/) {
+ my @lines = $conn->{msg} =~ /([^\cM\cJ]*)\cM?\cJ/g;
+ if ($conn->{msg} =~ /\cJ$/) {
delete $conn->{msg};
} else {
$conn->{msg} = pop @lines;
{
my ($conn, $sort, $line) = @_;
my $r;
-
+
+ $sort = lc $sort;
dbg('connect', "CONNECT sort: $sort command: $line");
if ($sort eq 'telnet') {
# this is a straight network connect
dbg('connect', "***Connect Failed to $host $port $!");
}
} elsif ($sort eq 'ax25' || $sort eq 'prog') {
- ;
+ $conn->{sock} = new IO::File;
+ if ($conn->{sock}) {
+ my $outfd = fileno($conn->{sock});
+ my $out = new IO::File ">&$outfd";
+ if ($conn->{pid} = open2($conn->{sock}, $out, $line)) {
+ $conn->{csort} = $sort;
+ $conn->{lineend} = "\cM" if $sort eq 'ax25';
+ dbg('connect', "started $line");
+ } else {
+ dbg('connect', "can't start $line $!");
+ }
+ } else {
+ dbg('connect', "can't start $line $!");
+ }
} else {
dbg('err', "invalid type of connection ($sort)");
$conn->disconnect;
my $conn = shift;
my $cmd = shift;
my $line = shift;
-
+
if ($line) {
my ($expect, $send) = $cmd =~ /^\s*\'(.*)\'\s+\'(.*)\'/;
if ($expect) {
if ($line =~ /$expect/i) {
dbg('connect', "got: \"$expect\" sending: \"$send\"");
$conn->send_later($send);
+ delete $conn->{msg}; # get rid any input if a match
return;
}
}