Commit 4d26f05e authored by claes's avatar claes

dbmopen replaced by tie

parent 9af49afb
...@@ -98,7 +98,7 @@ if ($amb == 1) { ...@@ -98,7 +98,7 @@ if ($amb == 1) {
help(); help();
exit 1; exit 1;
} }
# #
# Verb subroutines # Verb subroutines
...@@ -109,7 +109,8 @@ if ($amb == 1) { ...@@ -109,7 +109,8 @@ if ($amb == 1) {
sub add () sub add ()
{ {
dbmopen(%envdb, $dbname, 0644) || die "++ can't dbmopen $dbname!"; use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0]; $label = $_[0];
$varstr = $envdb{$label}; $varstr = $envdb{$label};
if ($varstr ne "") { if ($varstr ne "") {
...@@ -118,7 +119,7 @@ sub add () ...@@ -118,7 +119,7 @@ sub add ()
get_vars(); get_vars();
update_db(); update_db();
} }
dbmclose(%envdb) || die "++ can't dbmclose $dbname!"; untie(%envdb)|| die "++ can't untie $dbname!";
} }
...@@ -365,7 +366,8 @@ sub create() ...@@ -365,7 +366,8 @@ sub create()
sub dele () sub dele ()
{ {
dbmopen(%envdb, $dbname, undef) || die "++ can't dbmopen $dbname!"; use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0]; $label = $_[0];
...@@ -383,7 +385,7 @@ sub dele () ...@@ -383,7 +385,7 @@ sub dele ()
printf("++ Environment \"%s\" doesn't exists\n", $label); printf("++ Environment \"%s\" doesn't exists\n", $label);
} }
dbmclose(%envdb) || die "++ can't dbmclose $dbname!"; untie(%envdb)|| die "++ can't untie $dbname!";
} }
# #
...@@ -416,8 +418,10 @@ sub help () ...@@ -416,8 +418,10 @@ sub help ()
sub list () sub list ()
{ {
my($env); my($env);
printf("Using Database:%s\n",$dbname);
dbmopen(%envdb, $dbname, undef) || die "++ can't dbmopen $dbname!"; use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
print("-- Defined environments:\n"); print("-- Defined environments:\n");
foreach $env (sort keys (%envdb)) { foreach $env (sort keys (%envdb)) {
...@@ -425,7 +429,7 @@ sub list () ...@@ -425,7 +429,7 @@ sub list ()
} }
print("--\n"); print("--\n");
dbmclose(%envdb) || die "++ can't dbmclose $dbname!"; untie(%envdb)|| die "++ can't untie $dbname!";
} }
...@@ -435,7 +439,8 @@ sub list () ...@@ -435,7 +439,8 @@ sub list ()
# #
sub modify () sub modify ()
{ {
dbmopen(%envdb, $dbname, undef) || die "++ can't dbmopen $dbname!"; use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0]; $label = $_[0];
$varstr = $envdb{$label}; $varstr = $envdb{$label};
if ($varstr ne "") { if ($varstr ne "") {
...@@ -445,7 +450,7 @@ sub modify () ...@@ -445,7 +450,7 @@ sub modify ()
} else { } else {
printf("Environment %s doesn't exists\n", $label); printf("Environment %s doesn't exists\n", $label);
} }
dbmclose(%envdb) || die "++ can't dbmclose $dbname!"; untie(%envdb)|| die "++ can't untie $dbname!";
} }
...@@ -465,7 +470,8 @@ sub show () ...@@ -465,7 +470,8 @@ sub show ()
} }
} }
dbmopen(%envdb, $dbname, undef) || die "++ can't dbmopen $dbname!"; use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
read_vars(); read_vars();
if ($varstr ne "") { if ($varstr ne "") {
...@@ -476,7 +482,7 @@ sub show () ...@@ -476,7 +482,7 @@ sub show ()
} else { } else {
printf("++ Environment %s doesn't exists\n", $label); printf("++ Environment %s doesn't exists\n", $label);
} }
dbmclose(%envdb) || die "++ can't dbmclose $dbname!"; untie(%envdb)|| die "++ can't untie $dbname!";
} }
# #
...@@ -551,7 +557,8 @@ sub _build () # args: branch, subbranch, phase ...@@ -551,7 +557,8 @@ sub _build () # args: branch, subbranch, phase
sub _exists () sub _exists ()
{ {
my($ret) = 1; my($ret) = 1;
dbmopen(%envdb, $dbname, undef) || die "++ can't dbmopen $dbname!"; use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0]; $label = $_[0];
...@@ -559,7 +566,7 @@ sub _exists () ...@@ -559,7 +566,7 @@ sub _exists ()
$ret = 0; $ret = 0;
} }
dbmclose(%envdb) || die "++ can't dbmclose $dbname!"; untie(%envdb)|| die "++ can't untie $dbname!";
exit $ret; exit $ret;
} }
...@@ -569,7 +576,8 @@ sub _exists () ...@@ -569,7 +576,8 @@ sub _exists ()
sub _print () sub _print ()
{ {
dbmopen(%envdb, $dbname, undef) || die "++ can't dbmopen $dbname!"; use DB_File;
tie(%envdb, "DB_File", $dbname, O_CREAT|O_RDWR, 0644) || die "++ can't tie $dbname!";
$label = $_[0]; $label = $_[0];
read_vars(); read_vars();
...@@ -584,10 +592,10 @@ sub _print () ...@@ -584,10 +592,10 @@ sub _print ()
} else { } else {
printf("++ Environment %s doesn't exists\n", $label); printf("++ Environment %s doesn't exists\n", $label);
} }
dbmclose(%envdb) || die "++ can't dbmclose $dbname!"; untie(%envdb)|| die "++ can't untie $dbname!";
} }
# #
# Misc. subroutines # Misc. subroutines
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment