+sub dotimeout
+{
+ my $val = shift;
+ dbg('connect', "timeout set to $val");
+ $timeout = $val;
+}
+
+sub dochat
+{
+ my ($expect, $send) = @_;
+ dbg('connect', "CHAT \"$expect\" -> \"$send\"");
+ my $line;
+
+ # alarm($timeout);
+
+ if ($expect) {
+ if ($csort eq 'telnet') {
+ $line = <$sock>;
+ chomp;
+ } elsif ($csort eq 'ax25') {
+ local $/ = "\r";
+ $line = <$rfh>;
+ $line =~ s/\r//og;
+ }
+ dbg('connect', "received \"$line\"");
+ if ($abort && $line =~ /$abort/i) {
+ dbg('connect', "aborted on /$abort/");
+ cease(11);
+ }
+ }
+ if ($send && (!$expect || $line =~ /$expect/i)) {
+ if ($csort eq 'telnet') {
+ $sock->print("$send\n");
+ } elsif ($csort eq 'ax25') {
+ local $\ = "\r";
+ $wfh->print("$send\r");
+ }
+ dbg('connect', "sent \"$send\"");
+ }
+}
+
+sub timeout
+{
+ dbg('connect', "timed out after $timeout seconds");
+ cease(10);
+}
+
+
+#
+# initialisation
+#
+
+$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
+$mynl = "\n"; # standard terminator
+$lasttime = time; # lasttime something happened on the interface
+$outqueue = ""; # the output queue length
+$buffered = 1; # buffer output
+$savenl = ""; # an NL that has been saved from last time
+$timeout = 30; # default timeout for connects
+$abort = ""; # the current abort string
+$cpath = "$root/connect"; # the basic connect directory
+
+$pid = 0; # the pid of the child program
+$csort = ""; # the connection type
+$sock = 0; # connection socket
+
+$stdin = *STDIN;
+$stdout = *STDOUT;
+$rfh = 0;
+$wfh = 0;
+
+
+#
+# deal with args
+#
+