diff options
Diffstat (limited to 'utils/rd-show')
-rwxr-xr-x | utils/rd-show | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/utils/rd-show b/utils/rd-show index 17286e9..0e53e05 100755 --- a/utils/rd-show +++ b/utils/rd-show @@ -39,9 +39,9 @@ sub print_usage sub list { - my ($dbh) = @_; + my ($ctx) = @_; - my @shows = RHRD::rddb::list_shows($dbh); + my @shows = RHRD::rddb::list_shows($ctx); if(!defined $shows[0] && defined $shows[1]) { print STDERR "$shows[1]: $shows[2]"; return 1; @@ -54,14 +54,14 @@ sub list sub show { - my ($dbh, $show_id) = @_; + my ($ctx, $show_id) = @_; - my @carts = RHRD::rddb::get_show_carts($dbh, $show_id); + my @carts = RHRD::rddb::get_show_carts($ctx, $show_id); if(!defined $carts[0] && defined $carts[1]) { print STDERR "$carts[1]: $carts[2]\n"; return 1; } - my ($title, undef, $status, $errorstring) = RHRD::rddb::get_show_title_and_log($dbh, $show_id); + my ($title, undef, $status, $errorstring) = RHRD::rddb::get_show_title_and_log($ctx, $show_id); unless (defined $title) { print STDERR "$errorstring\n"; return 1; @@ -77,24 +77,24 @@ sub show sub add__create_group { - my ($dbh, $groupname) = @_; + my ($ctx, $groupname) = @_; print " > '" . $groupname . "' does not exist - creating it .. "; - my ($cnt, $status, $errorstring) = RHRD::rddb::add_group($dbh, $groupname); + my ($cnt, $status, $errorstring) = RHRD::rddb::add_group($ctx, $groupname); unless(defined $cnt) { print STDERR $status . ": " . $errorstring . "\n"; return undef; } print int($cnt) . " rows affected\n"; - (my $low_cart, my $high_cart, $errorstring) = RHRD::rddb::get_shows_next_free_slot($dbh); + (my $low_cart, my $high_cart, $errorstring) = RHRD::rddb::get_shows_next_free_slot($ctx); if(!$low_cart) { print $high_cart . ": " . $errorstring . "\n"; return undef; } print " using carts " . $low_cart . " - " . $high_cart . " for new group .. "; - ($cnt, $status, $errorstring) = RHRD::rddb::set_group_carts($dbh, $groupname, $low_cart, $high_cart, 1, 'Y'); + ($cnt, $status, $errorstring) = RHRD::rddb::set_group_carts($ctx, $groupname, $low_cart, $high_cart, 1, 'Y'); unless(defined $cnt) { print STDERR $status . ": " . $errorstring . "\n"; return undef; @@ -102,7 +102,7 @@ sub add__create_group print int($cnt) . " rows affected\n"; print " enabling reports .. "; - ($cnt, $status, $errorstring) = RHRD::rddb::set_group_reports($dbh, $groupname, 'Y', 'Y', 'Y'); + ($cnt, $status, $errorstring) = RHRD::rddb::set_group_reports($ctx, $groupname, 'Y', 'Y', 'Y'); unless(defined $cnt) { print STDERR $status . ": " . $errorstring . "\n"; return undef; @@ -114,9 +114,9 @@ sub add__create_group sub add__get_group_carts { - my ($dbh, $groupname, $num_carts) = @_; + my ($ctx, $groupname, $num_carts) = @_; - my ($result, $status, $errorstring) = RHRD::rddb::check_group($dbh, $groupname); + my ($result, $status, $errorstring) = RHRD::rddb::check_group($ctx, $groupname); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; return undef; @@ -129,7 +129,7 @@ sub add__get_group_carts # find free range in group which is big enough for $num_carts carts } else { - $low_cart = add__create_group($dbh, $groupname); + $low_cart = add__create_group($ctx, $groupname); } return $low_cart; @@ -137,11 +137,11 @@ sub add__get_group_carts sub add { - my ($dbh, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_; + my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_; print " * creating show: " . $title . " (" . $name . ") for group '" . $groupname . "'\n"; - my $low_cart = add__get_group_carts($dbh, $groupname, $num_carts); + my $low_cart = add__get_group_carts($ctx, $groupname, $num_carts); return 1 unless defined($low_cart); my $high_cart = $low_cart + $num_carts - 1; print " * will be using carts: " . $low_cart . " - " . $high_cart . "\n"; @@ -158,7 +158,7 @@ sub add sub remove { - my ($dbh, $show_id) = @_; + my ($ctx, $show_id) = @_; print "removing show " . $show_id . ", not yet implemented!\n"; return 0; @@ -172,14 +172,14 @@ if($num_args < 1) { my $cmd = $ARGV[0]; my $ret = 0; -my ($dbh, $status, $errorstring) = RHRD::rddb::opendb(); -if(defined $dbh) { +my ($ctx, $status, $errorstring) = RHRD::rddb::init(); +if(defined $ctx) { if($cmd eq "list") { if($num_args != 1) { print_usage(); $ret = 1; } else { - $ret = list($dbh) + $ret = list($ctx) } } elsif($cmd eq "show") { @@ -187,7 +187,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = show($dbh, $ARGV[1]) + $ret = show($ctx, $ARGV[1]) } } elsif($cmd eq "remove") { @@ -195,7 +195,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = remove($dbh, $ARGV[1]); + $ret = remove($ctx, $ARGV[1]); } } elsif($cmd eq "add") { @@ -203,14 +203,14 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = add($dbh, $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6], $ARGV[7], $ARGV[8]); + $ret = add($ctx, $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6], $ARGV[7], $ARGV[8]); } } else { print_usage(); $ret = 1; } - RHRD::rddb::closedb($dbh); + RHRD::rddb::destroy($ctx); } else { print STDERR "$errorstring\n"; $ret = 1; |