summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-12-02 20:54:48 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-12-02 20:54:48 (GMT)
commitcb42bb3574fab1e761c6562c60ee3b5e3c8af09d (patch)
tree34b6d4a8f0bc434a8928000004cd8cd8366e3b3d
parenta89236d00fdae5826329bbacf28cd39230080b17 (diff)
make len, dow and startime checks more relax (for specials)
-rwxr-xr-xlib/RHRD/utils.pm15
-rwxr-xr-xutils/rhrd-show24
2 files changed, 20 insertions, 19 deletions
diff --git a/lib/RHRD/utils.pm b/lib/RHRD/utils.pm
index 834f9fa..756707b 100755
--- a/lib/RHRD/utils.pm
+++ b/lib/RHRD/utils.pm
@@ -66,13 +66,13 @@ sub get_rd_week
use constant {
DB_PARAM_TYPE_HINT => "only S, M and J are allowed with S -> Show, M -> Musicpool, J -> Jingles",
DB_PARAM_RHYTHM_HINT => "only 0 or 1 are allowed, length must be exactly 4 and it must not be '0000'",
- DB_PARAM_DOW_HINT => "must be between 1 and 7 (1=Monday, ..., 7=Sunday)",
- DB_PARAM_STARTTIME_HINT => "must be in format HHMM (without seperator) in 24 hour format",
- DB_PARAM_LEN_HINT => "must be a positive number below 1440",
+ DB_PARAM_DOW_HINT => "must be between 1 and 7 (1=Monday, ..., 7=Sunday), use 0 for specials",
+ DB_PARAM_STARTTIME_HINT => "must be in format HHMM (without seperator) in 24 hour format, use '----' for specials",
+ DB_PARAM_LEN_HINT => "must be a positive number below 1440, use 0 for specials",
DB_PARAM_SHOWTYPE_HINT => "only n, r and s are allowed with n -> normal, r -> re-run, s -> special",
CMDLINE_WEEK_HINT => "must be one of W1, W2, W3, W4",
- CMDLINE_DOW_HINT => "must be one of MO, TU, WE, TH, FR, SA, SU",
+ CMDLINE_DOW_HINT => "must be one of MO, TU, WE, TH, FR, SA, SU use - for specials",
# this is a subset of the colors from: stackoverflow.com/questions/2328339
POOL_COLORS => ["#FFFFFF", "#FFFF00", "#1CE6FF", "#FF34FF", "#FF4A46", "#008941", "#006FA6",
@@ -133,8 +133,7 @@ sub dropbox_param_dow_ok
sub dropbox_param_starttime_ok
{
my ($starttime) = @_;
-
- if(!defined($starttime) || $starttime !~ m/^[0-2][0-9][0-5][0-9]$/ || $starttime > 2359) {
+ if(!defined($starttime) || ($starttime ne '----' && ($starttime !~ m/^[0-2][0-9][0-5][0-9]$/ || $starttime > 2359))) {
return (0, "starttime '" . (defined($starttime) ? $starttime : 'undef') . "' is not a valid clock time", DB_PARAM_STARTTIME_HINT);
}
return (1, 'OK', DB_PARAM_STARTTIME_HINT);
@@ -144,7 +143,7 @@ sub dropbox_param_len_ok
{
my ($len) = @_;
- if(!defined($len) || $len <= 0 || $len > 1440) {
+ if(!defined($len) || $len < 0 || $len > 1440) {
return (0, "len '" . (defined($len) ? $len : 'undef') . "' is out of bounds", DB_PARAM_LEN_HINT);
}
return (1, 'OK', DB_PARAM_LEN_HINT);
@@ -208,6 +207,8 @@ sub cmdline_dow
return (6, 'OK', CMDLINE_DOW_HINT);
} elsif(uc($dow) eq "SU") {
return (7, 'OK', CMDLINE_DOW_HINT);
+ } elsif(uc($dow) eq "-") {
+ return (0, 'OK', CMDLINE_DOW_HINT);
}
return (undef, 'invalid day-of-week', CMDLINE_DOW_HINT);
}
diff --git a/utils/rhrd-show b/utils/rhrd-show
index a9e0abc..daa3060 100755
--- a/utils/rhrd-show
+++ b/utils/rhrd-show
@@ -123,31 +123,31 @@ sub add__check_arguments
}
my ($result, $err, $hint) = RHRD::utils::dropbox_param_rhythm_ok($rhythm);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
($result, $err, $hint) = RHRD::utils::cmdline_dow($dow);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
($result, $err, $hint) = RHRD::utils::dropbox_param_starttime_ok($starttime);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
($result, $err, $hint) = RHRD::utils::dropbox_param_len_ok($len);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
($result, $err, $hint) = RHRD::utils::dropbox_param_showtype_ok($type);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
@@ -221,31 +221,31 @@ sub edit__check_arguments
my ($showid, $title, $rhythm, $dow, $starttime, $len, $type) = @_;
my ($result, $err, $hint) = RHRD::utils::dropbox_param_rhythm_ok($rhythm);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
($result, $err, $hint) = RHRD::utils::cmdline_dow($dow);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
($result, $err, $hint) = RHRD::utils::dropbox_param_starttime_ok($starttime);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
($result, $err, $hint) = RHRD::utils::dropbox_param_len_ok($len);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
($result, $err, $hint) = RHRD::utils::dropbox_param_showtype_ok($type);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
@@ -410,7 +410,7 @@ sub multi_add
my $type = shift;
my ($result, $err, $hint) = RHRD::utils::dropbox_param_showtype_ok($type);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}
@@ -442,7 +442,7 @@ sub multi_edit
my $type = shift;
my ($result, $err, $hint) = RHRD::utils::dropbox_param_showtype_ok($type);
- unless($result) {
+ unless(defined $result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
}