diff options
Diffstat (limited to 'utils/rd-show')
-rwxr-xr-x | utils/rd-show | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/utils/rd-show b/utils/rd-show index 0e53e05..c9a71c9 100755 --- a/utils/rd-show +++ b/utils/rd-show @@ -135,10 +135,54 @@ sub add__get_group_carts return $low_cart; } +sub add__check_arguments +{ + my ($name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_; + + if($name !~ m/^[a-zA-Z0-9_]{1,10}$/) { + print STDERR "name '" . $name . "' contains illegal characters or is too long/short\n"; + print STDERR " only a-z, A-Z, 0-9 and _ are allowed and the length must be between 1 and 10\n"; + return 1; + } + + if($num_carts <= 0) { + print STDERR "num-carts '" . $num_carts . "' must be > 0\n"; + return 1; + } + + if($rhythm !~ m/^[01]{4}$/ || $rhythm eq '0000') { + print STDERR "rhythm '" . $rhythm . "' contains illegal characters or is too long/short\n"; + print STDERR " only 0 or 1 are allowed and, length must be exactly 4 and it must not be '0000'\n"; + return 1; + } + + if($dow < 1 || $dow > 7) { + print STDERR "dow '" . $dow . "' is out of range, must be between 1 and 7 (1=Monday, ..., 7=Sunday)\n"; + return 1; + } + + if($starttime !~ m/^[0-2][0-9][0-5][0-9]$/ || $starttime > 2359) { + print STDERR "starttime '" . $starttime . "' is not a valid time must be HHMM\n"; + return 1; + } + + if($len <= 0) { + print STDERR "len '" . $len . "' must be > 0\n"; + return 1; + } + + return 0; +} + sub add { my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_; + my $ret = add__check_arguments($name, $title, $num_carts, $rhythm, $dow, $starttime, $len); + if($ret) { + return $ret; + } + print " * creating show: " . $title . " (" . $name . ") for group '" . $groupname . "'\n"; my $low_cart = add__get_group_carts($ctx, $groupname, $num_carts); |