diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-09-30 23:05:11 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-09-30 23:05:11 (GMT) |
commit | 6f1943313a0e503189dd9685483a9ecd1bd7cc6e (patch) | |
tree | 7461bd743125feb61a7f977a06e7698bb184d333 /utils/rd-group | |
parent | 88ba274e7841fedffe9ef98b0933c0610ac6997c (diff) |
introduced rhrd context
Diffstat (limited to 'utils/rd-group')
-rwxr-xr-x | utils/rd-group | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/utils/rd-group b/utils/rd-group index ecf10cb..3898b5e 100755 --- a/utils/rd-group +++ b/utils/rd-group @@ -41,9 +41,9 @@ sub print_usage sub list { - my ($dbh) = @_; + my ($ctx) = @_; - my @groups = RHRD::rddb::list_groups($dbh); + my @groups = RHRD::rddb::list_groups($ctx); if(!defined $groups[0] && defined $groups[1]) { print STDERR "$groups[1]: $groups[2]"; return 1; @@ -56,18 +56,18 @@ sub list sub check { - my ($dbh, $groupname) = @_; + my ($ctx, $groupname) = @_; - my ($result, $status, $errorstring) = RHRD::rddb::check_group($dbh, $groupname); + my ($result, $status, $errorstring) = RHRD::rddb::check_group($ctx, $groupname); print STDERR "$result, $status: $errorstring\n"; return $result; } sub add { - my ($dbh, $groupname, $description) = @_; + my ($ctx, $groupname, $description) = @_; - my ($cnt, $status, $errorstring) = RHRD::rddb::add_group($dbh, $groupname, $description); + my ($cnt, $status, $errorstring) = RHRD::rddb::add_group($ctx, $groupname, $description); unless(defined $cnt) { print STDERR "$errorstring\n"; return 1; @@ -78,9 +78,9 @@ sub add sub remove { - my ($dbh, $groupname) = @_; + my ($ctx, $groupname) = @_; - my @results = RHRD::rddb::remove_group($dbh, $groupname); + my @results = RHRD::rddb::remove_group($ctx, $groupname); if(!defined $results[0] && defined $results[2]) { print STDERR "$results[2]\n"; return 1; @@ -93,9 +93,9 @@ sub remove sub get_members { - my ($dbh, $groupname) = @_; + my ($ctx, $groupname) = @_; - my @users = RHRD::rddb::get_group_members($dbh, $groupname); + my @users = RHRD::rddb::get_group_members($ctx, $groupname); if(!defined $users[0] && defined $users[1]) { print STDERR "$users[2]\n"; return 1; @@ -108,9 +108,9 @@ sub get_members sub add_member { - my ($dbh, $groupname, $username) = @_; + my ($ctx, $groupname, $username) = @_; - my ($cnt, undef, $errorstring) = RHRD::rddb::add_group_member($dbh, $groupname, $username); + my ($cnt, undef, $errorstring) = RHRD::rddb::add_group_member($ctx, $groupname, $username); unless(defined $cnt) { print STDERR "$errorstring\n"; return 1; @@ -121,9 +121,9 @@ sub add_member sub remove_member { - my ($dbh, $groupname, $username) = @_; + my ($ctx, $groupname, $username) = @_; - my ($cnt, undef, $errorstring) = RHRD::rddb::remove_group_member($dbh, $groupname, $username); + my ($cnt, undef, $errorstring) = RHRD::rddb::remove_group_member($ctx, $groupname, $username); unless(defined $cnt) { print STDERR "$errorstring\n"; return 1; @@ -134,9 +134,9 @@ sub remove_member sub is_member { - my ($dbh, $groupname, $username) = @_; + my ($ctx, $groupname, $username) = @_; - my ($cnt, undef, $errorstring) = RHRD::rddb::is_group_member($dbh, $groupname, $username); + my ($cnt, undef, $errorstring) = RHRD::rddb::is_group_member($ctx, $groupname, $username); unless(defined $cnt) { print STDERR "$errorstring\n"; return 1; @@ -147,9 +147,9 @@ sub is_member sub get_carts { - my ($dbh, $groupname) = @_; + my ($ctx, $groupname) = @_; - my ($low, $high, $type, $enforce_range) = RHRD::rddb::get_group_carts($dbh, $groupname); + my ($low, $high, $type, $enforce_range) = RHRD::rddb::get_group_carts($ctx, $groupname); unless(defined $low) { print STDERR "$type\n"; return 1; @@ -160,9 +160,9 @@ sub get_carts sub set_carts { - my ($dbh, $groupname, $low_cart, $high_cart, $cart_type, $enforce_cart_range) = @_; + my ($ctx, $groupname, $low_cart, $high_cart, $cart_type, $enforce_cart_range) = @_; - my ($cnt, undef, $errorstring) = RHRD::rddb::set_group_carts($dbh, $groupname, $low_cart, $high_cart, $cart_type, $enforce_cart_range); + my ($cnt, undef, $errorstring) = RHRD::rddb::set_group_carts($ctx, $groupname, $low_cart, $high_cart, $cart_type, $enforce_cart_range); unless(defined $cnt) { print STDERR "$errorstring\n"; return 1; @@ -173,9 +173,9 @@ sub set_carts sub get_reports { - my ($dbh, $groupname) = @_; + my ($ctx, $groupname) = @_; - my ($nownext, $traffic, $music) = RHRD::rddb::get_group_reports($dbh, $groupname); + my ($nownext, $traffic, $music) = RHRD::rddb::get_group_reports($ctx, $groupname); unless(defined $nownext) { print STDERR "$music\n"; return 1; @@ -186,9 +186,9 @@ sub get_reports sub set_reports { - my ($dbh, $groupname, $now_next, $traffic, $music) = @_; + my ($ctx, $groupname, $now_next, $traffic, $music) = @_; - my ($cnt, undef, $errorstring) = RHRD::rddb::set_group_reports($dbh, $groupname, $now_next, $traffic, $music); + my ($cnt, undef, $errorstring) = RHRD::rddb::set_group_reports($ctx, $groupname, $now_next, $traffic, $music); unless(defined $cnt) { print STDERR "$errorstring\n"; return 1; @@ -208,14 +208,14 @@ my $cmd = $ARGV[0]; my $groupname = $ARGV[1]; 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 "check") { @@ -223,7 +223,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = check($dbh, $groupname); + $ret = check($ctx, $groupname); } } elsif($cmd eq "add") { @@ -231,7 +231,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = add($dbh, $groupname, $ARGV[2]); + $ret = add($ctx, $groupname, $ARGV[2]); } } elsif($cmd eq "remove") { @@ -239,7 +239,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = remove($dbh, $groupname); + $ret = remove($ctx, $groupname); } } elsif($cmd eq "get-members") { @@ -247,7 +247,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = get_members($dbh, $groupname); + $ret = get_members($ctx, $groupname); } } elsif($cmd eq "add-member") { @@ -255,7 +255,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = add_member($dbh, $groupname, $ARGV[2]); + $ret = add_member($ctx, $groupname, $ARGV[2]); } } elsif($cmd eq "remove-member") { @@ -263,7 +263,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = remove_member($dbh, $groupname, $ARGV[2]); + $ret = remove_member($ctx, $groupname, $ARGV[2]); } } elsif($cmd eq "is-member") { @@ -271,7 +271,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = is_member($dbh, $groupname, $ARGV[2]); + $ret = is_member($ctx, $groupname, $ARGV[2]); } } elsif($cmd eq "get-carts") { @@ -279,7 +279,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = get_carts($dbh, $groupname); + $ret = get_carts($ctx, $groupname); } } elsif($cmd eq "set-carts") { @@ -287,7 +287,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = set_carts($dbh, $groupname, $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5]); + $ret = set_carts($ctx, $groupname, $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5]); } } elsif($cmd eq "get-reports") { @@ -295,7 +295,7 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = get_reports($dbh, $groupname); + $ret = get_reports($ctx, $groupname); } } elsif($cmd eq "set-reports") { @@ -303,15 +303,15 @@ if(defined $dbh) { print_usage(); $ret = 1; } else { - $ret = set_reports($dbh, $groupname, $ARGV[2], $ARGV[3], $ARGV[4]); + $ret = set_reports($ctx, $groupname, $ARGV[2], $ARGV[3], $ARGV[4]); } } else { - print STDERR "unknown command\n"; + print_usage(); $ret = 1; } - RHRD::rddb::closedb($dbh); + RHRD::rddb::destroy($ctx); } else { print STDERR "$errorstring\n"; $ret = 1; |