version 1.318, 2003/01/13 21:52:11
|
version 1.319, 2003/01/15 19:34:03
|
Line 1744 sub dump {
|
Line 1744 sub dump {
|
return %returnhash; |
return %returnhash; |
} |
} |
|
|
# --------------------------------------------------------------- dumpcurrent |
# --------------------------------------------------------------- currentdump |
sub dumpcurrent { |
sub currentdump { |
my ($namespace,$udomain,$uname)=@_; |
my ($namespace,$udomain,$uname)=@_; |
if (!$udomain) { $udomain = $ENV{'user.domain'}; } |
if (!$udomain) { $udomain = $ENV{'user.domain'}; } |
if (!$uname) { $uname = $ENV{'user.name'}; } |
if (!$uname) { $uname = $ENV{'user.name'}; } |
my $uhome = &homeserver($uname,$udomain); |
my $uhome = &homeserver($uname,$udomain); |
my $rep=reply("dumpcurrent:$udomain:$uname:$namespace",$uhome); |
my $rep=reply("currentdump:$udomain:$uname:$namespace",$uhome); |
&logthis("error = ".$rep) if ($rep =~ /^(error|no_such_host)/); |
|
return if ($rep =~ /^(error:|no_such_host)/); |
return if ($rep =~ /^(error:|no_such_host)/); |
my @pairs=split(/\&/,$rep); |
# |
my %returnhash=(); |
my %returnhash=(); |
foreach (@pairs) { |
# |
my ($key,$value)=split(/=/,$_); |
if ($rep eq "unknown_cmd") { |
my ($symb,$param) = split(/:/,$key); |
# an old lond will not know currentdump |
$returnhash{&unescape($symb)}->{&unescape($param)} = &unescape($value); |
# Do a dump and make it look like a currentdump |
|
my @tmp = &dump($namespace,$udomain,$uname,'.'); |
|
return if ($tmp[0] =~ /^(error:|no_such_host)/); |
|
my %hash = @tmp; |
|
@tmp=(); |
|
# Code ripped from lond, essentially. The only difference |
|
# here is the unescaping done by lonnet::dump(). Conceivably |
|
# we might run in to problems with parameter names =~ /^v\./ |
|
while (my ($key,$value) = each(%hash)) { |
|
my ($v,$symb,$param) = split(/:/,$key); |
|
next if ($v eq 'version' || $symb eq 'keys'); |
|
next if (exists($returnhash{$symb}) && |
|
exists($returnhash{$symb}->{$param}) && |
|
$returnhash{$symb}->{'v.'.$param} > $v); |
|
$returnhash{$symb}->{$param}=$value; |
|
$returnhash{$symb}->{'v.'.$param}=$v; |
|
} |
|
# |
|
# Remove all of the keys in the hashes which keep track of |
|
# the version of the parameter. |
|
while (my ($symb,$param_hash) = each(%returnhash)) { |
|
# use a foreach because we are going to delete from the hash. |
|
foreach my $key (keys(%$param_hash)) { |
|
delete($param_hash->{$key}) if ($key =~ /^v\./); |
|
} |
|
} |
|
} else { |
|
my @pairs=split(/\&/,$rep); |
|
foreach (@pairs) { |
|
my ($key,$value)=split(/=/,$_); |
|
my ($symb,$param) = split(/:/,$key); |
|
$returnhash{&unescape($symb)}->{&unescape($param)} = |
|
&unescape($value); |
|
} |
} |
} |
return %returnhash; |
return %returnhash; |
} |
} |