X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fexport.pl;fp=cmd%2Fexport.pl;h=723cdcb6ea33ed3ff9ec5d1cdfd3d0f989fef0f2;hb=5ba68ecc9ddb9ccdefe75256f73af2ba92fd221c;hp=0000000000000000000000000000000000000000;hpb=866bd5c7cd0fd6c8167d6e6a0c9acfe5feb0ba65;p=spider.git diff --git a/cmd/export.pl b/cmd/export.pl new file mode 100644 index 00000000..723cdcb6 --- /dev/null +++ b/cmd/export.pl @@ -0,0 +1,53 @@ +# +# export a message +# +# Copyright (c) Dirk Koopman G1TLH +# +# $Id$ +# + +my ($self, $line) = @_; +my @f = split /\s+/, $line; +my $msgno; +my @out; +my @body; +my $ref; +my $fn; + +return (1, $self->msg("e5")) if $self->priv < 9 || $self->consort ne 'local' || $self->remotecmd; + +return (1, $self->msg("export1")) unless @f == 2 && $f[0] =~ /^\d+$/; +$msgno = $f[0]; +$fn = $f[1]; + +$ref = DXMsg::get($f[0]); +return (1, $self->msg('read2', $msgno)) unless $ref; +if (-e $fn) { + my $m = $self->msg('e16', $fn); + Log('msg', $self->call . " tried to export $m"); + dbg('msg', $m); + return (1, $m); +} + +return (1, $self->msg('e16', $fn)) if -e $fn; + +my $s = $ref->private ? "SP " : "SB " ; +push @body, $s . $ref->to . " < " . $ref->from; +push @body, $ref->subject; +push @body, $ref->read_msg_body; +push @body, "/EX"; + +my $fh = new IO::File ">$fn"; +my $m; +if ($fh) { + print $fh map { "$_\n" } @body; + $fh->close; + $m = $self->msg('export3', $msgno, $fn, $self->call); +} else { + $m = $self->msg('export2', $msgno, $fn, $!, $self->call); +} +Log('msg', $m); +dbg('msg', $m); +push @out, $m; + +return (1, @out);