… | |
… | |
509 | my ($self) = @_; |
509 | my ($self) = @_; |
510 | |
510 | |
511 | if (sysread $self->{fh}, $self->{buf}, 65536, length $self->{buf}) { |
511 | if (sysread $self->{fh}, $self->{buf}, 65536, length $self->{buf}) { |
512 | for (;;) { |
512 | for (;;) { |
513 | if ($self->{datalen}) { |
513 | if ($self->{datalen}) { |
514 | warn "expecting new datachunk $self->{datalen}, got ".(length $self->{buf})."\n";#d# |
514 | #warn "expecting new datachunk $self->{datalen}, got ".(length $self->{buf})."\n";#d# |
515 | if (length $self->{buf} >= $self->{datalen}) { |
515 | if (length $self->{buf} >= $self->{datalen}) { |
516 | $self->rcv_data (substr $self->{buf}, 0, delete $self->{datalen}, ""); |
516 | $self->rcv_data (substr $self->{buf}, 0, delete $self->{datalen}, ""); |
517 | } else { |
517 | } else { |
518 | last; |
518 | last; |
519 | } |
519 | } |
520 | } elsif ($self->{buf} =~ s/^DataChunk\015?\012Length=([0-9a-fA-F]+)\015?\012Data\015?\012//) { |
520 | } elsif ($self->{buf} =~ s/^DataChunk\015?\012Length=([0-9a-fA-F]+)\015?\012Data\015?\012//) { |
521 | $self->{datalen} = hex $1; |
521 | $self->{datalen} = hex $1; |
522 | warn "expecting new datachunk $self->{datalen}\n";#d# |
522 | #warn "expecting new datachunk $self->{datalen}\n";#d# |
523 | } elsif ($self->{buf} =~ s/^([a-zA-Z]+)\015?\012(?:(.+?)\015?\012)?EndMessage\015?\012//s) { |
523 | } elsif ($self->{buf} =~ s/^([a-zA-Z]+)\015?\012(?:(.+?)\015?\012)?EndMessage\015?\012//s) { |
524 | $self->rcv ($1, { |
524 | $self->rcv ($1, { |
525 | map { my ($a, $b) = split /=/, $_, 2; ((Net::FCP::tolc $a), $b) } |
525 | map { my ($a, $b) = split /=/, $_, 2; ((Net::FCP::tolc $a), $b) } |
526 | split /\015?\012/, $2 |
526 | split /\015?\012/, $2 |
527 | }); |
527 | }); |