+ $ref->{msgno} = next_transno("Msgno");
+ push @{$ref->{gotit}}, $f[2]; # mark this up as being received
+ $ref->store($ref->{lines});
+ add_dir($ref);
+ my $dxchan = DXChannel->get($ref->{to});
+ $dxchan->send($dxchan->msg('m9')) if $dxchan && $dxchan->is_user;
+ Log('msg', "Message $ref->{msgno} from $ref->{from} received from $f[2] for $ref->{to}");
+ }
+ }
+ $ref->stop_msg($self->call);
+ } else {
+ dbg('msg', "PC32 from unknown stream $f[3] from $f[2]" );
+ $self->send(DXProt::pc42($f[2], $f[1], $f[3])); # unknown stream
+ }
+ # queue_msg(0);
+ last SWITCH;
+ }
+
+ if ($pcno == 33) { # acknowledge the end of message
+ my $ref = $work{"$f[2]$f[3]"};
+ if ($ref) {
+ if ($ref->{private}) { # remove it if it private and gone off site#
+ Log('msg', "Message $ref->{msgno} from $ref->{from} sent to $f[2] and deleted");
+ $ref->del_msg;
+ } else {
+ Log('msg', "Message $ref->{msgno} from $ref->{from} sent to $f[2]");
+ push @{$ref->{gotit}}, $f[2]; # mark this up as being received
+ $ref->store($ref->{lines}); # re- store the file
+ }
+ $ref->stop_msg($self->call);
+ } else {
+ dbg('msg', "PC33 from unknown stream $f[3] from $f[2]" );
+ $self->send(DXProt::pc42($f[2], $f[1], $f[3])); # unknown stream
+ }
+
+ # send next one if present
+ queue_msg(0);
+ last SWITCH;
+ }
+
+ if ($pcno == 40) { # this is a file request
+ $f[3] =~ s/\\/\//og; # change the slashes
+ $f[3] =~ s/\.//og; # remove dots
+ $f[3] =~ s/^\///o; # remove the leading /
+ $f[3] = lc $f[3]; # to lower case;
+ dbg('msg', "incoming file $f[3]\n");
+ $f[3] = 'packclus/' . $f[3] unless $f[3] =~ /^packclus\//o;
+
+ # create any directories
+ my @part = split /\//, $f[3];
+ my $part;
+ my $fn = "$main::root";
+ pop @part; # remove last part
+ foreach $part (@part) {
+ $fn .= "/$part";
+ next if -e $fn;
+ last SWITCH if !mkdir $fn, 0777;
+ dbg('msg', "created directory $fn\n");
+ }
+ my $stream = next_transno($f[2]);
+ my $ref = DXMsg->alloc($stream, "$main::root/$f[3]", $self->call, time, !$f[4], $f[3], ' ', '0', '0');
+
+ # forwarding variables
+ $ref->{fromnode} = $f[1];
+ $ref->{tonode} = $f[2];
+ $ref->{linesreq} = $f[5];
+ $ref->{stream} = $stream;
+ $ref->{count} = 0; # no of lines between PC31s
+ $ref->{file} = 1;
+ $ref->{lastt} = $main::systime;
+ $work{"$f[2]$stream"} = $ref; # store in work
+ $self->send(DXProt::pc30($f[2], $f[1], $stream)); # send ack
+
+ last SWITCH;
+ }
+
+ if ($pcno == 42) { # abort transfer
+ dbg('msg', "stream $f[3]: abort received\n");
+ my $ref = $work{"$f[2]$f[3]"};
+ if ($ref) {
+ $ref->stop_msg($self->call);
+ $ref = undef;
+ }
+ last SWITCH;
+ }
+
+ if ($pcno == 49) { # global delete on subject
+ for (@msg) {
+ if ($_->{from} eq $f[1] && $_->{subject} eq $f[2]) {
+ $_->del_msg();
+ Log('msg', "Message $_->{msgno} from $_->{from} ($_->{subject}) fully deleted");
+ DXProt::broadcast_ak1a($line, $self);
+ }
+ }
+ }
+ }