#! /usr/bin/perl
+###
+### Mail redirection userv interface for Odin
+###
+### (c) 2015 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the `odin.gg' service, `odin-cgi'.
+###
+### `odin-cgi' is free software; you can redistribute it and/or modify
+### it under the terms of the GNU Affero General Public License as
+### published by the Free Software Foundation; either version 3 of the
+### License, or (at your option) any later version.
+###
+### `odin-cgi' is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+### GNU Affero General Public License for more details.
+###
+### You should have received a copy of the GNU Affero General Public
+### License along with `odin-cgi'; if not, see
+### <http://www.gnu.org/licenses/>.
use lib 'lib';
disable LPART ...
dormant
+ giveaway LPART OWNER
help
list
- new [-GENOPTS] [-RECOPTS] RECIP
+ new [-n COUNT] [-GENOPTS] [-RECOPTS] [RECIP]
release LPART ...
reserve [-GENOPTS] N
reserved
- set [-RECOPTS] LPART
+ set [-RECOPTS] LPART ...
GENOPTS ::= [-g GENERATOR] [-p PARAM=VALUE]
RECOPTS ::= [-c COMMENT] [-r RECIP] [-x EXPIRES]
my ($lpart, $expire, $recip, $comment) = @$r;
Odin::print_columns $lpart => 24, $recip => 32, $comment => 0;
}
+} elsif ($op eq "giveaway") {
+ @ARGV >= 2 or Odin::fail "usage: giveaway OWNER LPART ...";
+ my $owner = shift @ARGV;
+ my @l = @ARGV;
+ getpwnam $owner or Odin::fail "unknown user `$owner'";
+ my %r = (owner => $owner);
+ Odin::modify_redir $dom, %r, @l;
} elsif ($op eq "reserved") {
@ARGV and Odin::fail "usage: reserved";
for my $r (Odin::redir_query Odin::open_db, $dom, $Odin::WHO,
my $gencls = Odin::default_generator_class $dom;
my %gp = ();
my %r = ();
+ my $n = 1;
while (my $o = $op->get) {
- gen_opt $dom, $gencls, %gp, $o, $op
- or record_opt %r, $o, $op
- or $op->unk;
+ if ($o eq "n") { $n = $op->intarg(undef, 0) }
+ else {
+ gen_opt $dom, $gencls, %gp, $o, $op
+ or record_opt %r, $o, $op
+ or $op->unk;
+ }
}
my @a = $op->rest;
if (@a) { $r{recip} = shift @a; }
!@a or $op->bad;
- $op->ok or Odin::fail "usage: new [-GENOPTS] [-RECOPTS] RECIP";
+ $op->ok or
+ Odin::fail "usage: new [-n COUNT] [-GENOPTS] [-RECOPTS] [RECIP]";
my $gen = $gencls->new($dom, \%gp);
- my $l = Odin::new_redir $dom, $gen, %r;
- print $l, "\n";
+ my @l = Odin::new_redir $dom, $gen, %r, $n;
+ print map { $_ . "\n" } @l;
} elsif ($op eq "reserve") {
my $op = Odin::OptParse->new(@ARGV);
my $gencls = Odin::default_generator_class $dom;
or $op->unk;
}
my @a = $op->rest;
- my $l = shift @a or $op->bad;
- @a and $op->bad;
- $op->ok or Odin::fail "usage: set [-RECOPTS] LPART";
- Odin::modify_redir $dom, $l, %r;
+ @a or $op->bad;
+ $op->ok or Odin::fail "usage: set [-RECOPTS] LPART ...";
+ Odin::modify_redir $dom, %r, @a;
} else {
Odin::fail "unknown operation `$op'";
}