-
- $f[0] = uc $f[0];
-
- # first deal with copies
- if ($f[0] eq 'C' || $f[0] eq 'CC' || $f[0] eq 'COPY') {
- my $i = 1;
- my $rr = '0';
- if (uc $f[$i] eq 'RR') {
- $rr = '1';
- $i++;
- }
- my $oref = DXMsg::get($f[$i]);
- #return (0, $self->msg('esend1', $f[$i])) if !$oref;
- #return (0, $self->msg('esend2')) if $i+1 > @f;
- return (0, "msgno $f[$i] not found") if !$oref;
- return (0, "need a callsign") if $i+1 > @f;
-
- # separate copy to everyone listed
- for ($i++ ; $i < @f; $i++) {
- my $msgno = DXMsg::next_transno('Msgno');
- my $newsubj = "CC: " . $oref->subject;
- my $newcall = uc $f[$i];
- my $nref = DXMsg->alloc($msgno,
- $newcall,
- $self->call,
- $main::systime,
- '1',
- $newsubj,
- $main::mycall,
- '0',
- $rr);
- my @list;
- my $from = $oref->from;
- my $to = $oref->to;
- my $date = cldate($oref->t);
- my $time = ztime($oref->t);
- my $buf = "Original from: $from To: $to Date: $date $time";
- push @list, $buf;
- push @list, $oref->read_msg_body();
- $nref->store(\@list);
- $nref->add_dir();
- push @out, $self->msg('m2', $oref->msgno, $newcall);
+
+ while (@f) {
+ my $f = uc shift @f;
+
+ # first deal with copies
+ if ($f eq 'C' || $f eq 'CC' || $f eq 'COPY') {
+ my $rr = '0';
+ if (@f && uc $f[0] eq 'RR') {
+ shift @f;
+ $rr = '1';
+ }
+
+ if (@f) {
+ my $m = shift @f;
+ my $oref = DXMsg::get($m);
+ return (0, $self->msg('m4', $m)) unless $oref;
+ return (0, $self->msg('m16')) unless @f;
+
+ # separate copy to everyone listed
+ while (@f) {
+ my $newcall = uc shift @f;
+ my $msgno = DXMsg::next_transno('Msgno');
+ my $newsubj = "CC: " . $oref->subject;
+ my $nref = DXMsg->alloc($msgno,
+ $newcall,
+ $self->call,
+ $main::systime,
+ '1',
+ $newsubj,
+ $main::mycall,
+ '0',
+ $rr);
+ my @list;
+ my $from = $oref->from;
+ my $to = $oref->to;
+ my $date = cldate($oref->t);
+ my $time = ztime($oref->t);
+ my $buf = "Original from: $from To: $to Date: $date $time";
+ push @list, $buf;
+ push @list, $oref->read_msg_body();
+ $nref->store(\@list);
+ $nref->add_dir();
+ push @out, $self->msg('m2', $oref->msgno, $newcall);
+ }
+ }
+ DXMsg::queue_msg();
+ return (1, @out);