added export command
authordjk <djk>
Mon, 27 Mar 2000 14:26:41 +0000 (14:26 +0000)
committerdjk <djk>
Mon, 27 Mar 2000 14:26:41 +0000 (14:26 +0000)
Changes
cmd/Commands_en.hlp
cmd/export.pl [new file with mode: 0644]
cmd/read.pl
perl/Messages

diff --git a/Changes b/Changes
index 3e3facdf84b268e7941a27b0e800c5599547dbd2..10115c53013f321f8fe704fbab182832bb2beaea 100644 (file)
--- 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=======================================================================
index c266fa580e3289f2de517a46824d00388cfb77c3..f1272ee9e418a3ac2467eb731c119227f890a3fb 100644 (file)
@@ -216,6 +216,20 @@ You can credit someone else by saying:-
 The <freq> is compared against the available bands set up in the 
 cluster.  See SHOW/BANDS for more information.
 
+=== 9^EXPORT <msgno> <filename>^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 <call>^Send out information on this <call> 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 (file)
index 0000000..723cdcb
--- /dev/null
@@ -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);
index fbd243cf3513a326653f8dfe9d0588c5941fb558..21b20e0699459e407b784a6be8b24e7afafea947 100644 (file)
@@ -71,3 +71,5 @@ for $msgno (@f) {
 }
 
 return (1, @out);
+
+
index b7d8a64885147a6a7790b848242b9a6c2ef71301..a70dccc935915587c321b388ab88cdf2cbe3fb0c 100644 (file)
@@ -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 <your e-mail address>',
                                emaila => 'Your E-Mail Address is now \"$_[0]\"',
                                email => 'E-mail address set to: $_[0]',
+                               export1 => 'usage: export <msgno> <filename>',
+                               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]',