added export command

This commit is contained in:
djk 2000-03-27 14:26:41 +00:00
parent 866bd5c7cd
commit 5ba68ecc9d
5 changed files with 74 additions and 0 deletions

View File

@ -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=======================================================================

View 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

53
cmd/export.pl Normal file
View File

@ -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);

View File

@ -71,3 +71,5 @@ for $msgno (@f) {
}
return (1, @out);

View 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]',