From: djk Date: Mon, 27 Mar 2000 14:26:41 +0000 (+0000) Subject: added export command X-Git-Tag: R_1_39~1 X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=5ba68ecc9ddb9ccdefe75256f73af2ba92fd221c;p=spider.git added export command --- diff --git a/Changes b/Changes index 3e3facdf..10115c53 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ 2. display 'start time' rather than 'user last time in' in who. 3. Allow local users to see their own sh/talk or sh/log stuff. 4. A more robust version of the C client. +5. Added a message exporting command 'export'. 26Mar00======================================================================= 1. first cut of C client 18Mar00======================================================================= diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index c266fa58..f1272ee9 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -216,6 +216,20 @@ You can credit someone else by saying:- The is compared against the available bands set up in the cluster. See SHOW/BANDS for more information. +=== 9^EXPORT ^Export a message to a file +Export a message to a file. This command can only be executed on a local +console with a fully privileged user. The file produced will be in a form +ready to be imported back into the cluster by placing it in the import +directory (/spider/msg/import). + +This command cannot overwrite an existing file. This is to provide some +measure of security. Any files written will owned by the same user as the +main cluster, otherwise you can put the new files anywhere the cluster can +access. For example:- + + EXPORT 2345 /tmp/a + + === 1^FORWARD/OPERNAME ^Send out information on this to all clusters This command sends out any information held in the user file which can be broadcast in PC41 protocol packets. This information is Name, QTH, Location 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); diff --git a/cmd/read.pl b/cmd/read.pl index fbd243cf..21b20e06 100644 --- a/cmd/read.pl +++ b/cmd/read.pl @@ -71,3 +71,5 @@ for $msgno (@f) { } return (1, @out); + + diff --git a/perl/Messages b/perl/Messages index b7d8a648..a70dccc9 100644 --- a/perl/Messages +++ b/perl/Messages @@ -55,10 +55,14 @@ package DXM; e13 => '$_[0] is not a node', e14 => 'First argument must be numeric and > 0', e15 => 'invalid qualifier \"$_[0]\"', + e16 => 'File \"$_[0]\" exists', emaile1 => 'Please enter your email address, set/email ', emaila => 'Your E-Mail Address is now \"$_[0]\"', email => 'E-mail address set to: $_[0]', + export1 => 'usage: export ', + export2 => '$_[3] has error exporting msg $_[0] to $_[1] ($_[2])', + export3 => '$_[2 ] exported msg $_[0] to $_[1]', helpe1 => 'Help system unavailable, tell sysop', helpe2 => 'No help available on $_[0]', heres => 'Here set on $_[0]',