version 1.99, 2002/09/20 02:04:07
|
version 1.102, 2002/10/07 13:50:36
|
Line 1015 sub make_new_child {
|
Line 1015 sub make_new_child {
|
# ------------------------------------------------------------------- subscribe |
# ------------------------------------------------------------------- subscribe |
} elsif ($userinput =~ /^sub/) { |
} elsif ($userinput =~ /^sub/) { |
print $client &subscribe($userinput,$clientip); |
print $client &subscribe($userinput,$clientip); |
|
# ------------------------------------------------------------- current version |
|
} elsif ($userinput =~ /^currentversion/) { |
|
my ($cmd,$fname)=split(/:/,$userinput); |
|
print $client ¤tversion($fname)."\n"; |
# ------------------------------------------------------------------------- log |
# ------------------------------------------------------------------------- log |
} elsif ($userinput =~ /^log/) { |
} elsif ($userinput =~ /^log/) { |
my ($cmd,$udom,$uname,$what)=split(/:/,$userinput); |
my ($cmd,$udom,$uname,$what)=split(/:/,$userinput); |
Line 1224 sub make_new_child {
|
Line 1228 sub make_new_child {
|
} else { |
} else { |
$regexp='.'; |
$regexp='.'; |
} |
} |
my $proname=propath($udom,$uname); |
|
my $qresult=''; |
my $qresult=''; |
if (tie(%hash,'GDBM_File',"$proname/$namespace.db",&GDBM_READER,0640)) { |
my $proname=propath($udom,$uname); |
|
if (tie(%hash,'GDBM_File',"$proname/$namespace.db",&GDBM_READER(),0640)) { |
study($regexp); |
study($regexp); |
foreach $key (keys %hash) { |
while (($key,$value) = each(%hash)) { |
my $unescapeKey = &unescape($key); |
if ($regexp eq '.') { |
if (eval('$unescapeKey=~/$regexp/')) { |
$qresult.=$key.'='.$value.'&'; |
$qresult.="$key=$hash{$key}&"; |
} else { |
} |
my $unescapeKey = &unescape($key); |
|
if (eval('$unescapeKey=~/$regexp/')) { |
|
$qresult.="$key=$value&"; |
|
} |
|
} |
} |
} |
if (untie(%hash)) { |
if (untie(%hash)) { |
$qresult=~s/\&$//; |
chop($qresult); |
print $client "$qresult\n"; |
print $client "$qresult\n"; |
} else { |
} else { |
print $client "error:$!\n"; |
print $client "error:$!\n"; |
} |
} |
} else { |
} else { |
print $client "error:$!\n"; |
print $client "error:$!\n"; |
Line 1643 sub unsub {
|
Line 1651 sub unsub {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub currentversion { |
|
my $fname=shift; |
|
my $version=-1; |
|
my $ulsdir=''; |
|
if ($fname=~/^(.+)\/[^\/]+$/) { |
|
$ulsdir=$1; |
|
} |
|
$fname=~s/\.\d+\.(\w+(?:\.meta)*)$/\.$1/; |
|
$fname=~s/\.(\w+(?:\.meta)*)$/\.\(\\d\+\)\.$1\$/; |
|
|
|
if (-e $fname) { $version=1; } |
|
if (-e $ulsdir) { |
|
if(-d $ulsdir) { |
|
if (opendir(LSDIR,$ulsdir)) { |
|
while ($ulsfn=readdir(LSDIR)) { |
|
# see if this is a regular file (ignore links produced earlier) |
|
my $thisfile=$ulsdir.'/'.$ulsfn; |
|
unless (-l $thisfile) { |
|
if ($thisfile=~/$fname/) { |
|
if ($1>$version) { $version=$1; } |
|
} |
|
} |
|
} |
|
closedir(LSDIR); |
|
$version++; |
|
} |
|
} |
|
} |
|
return $version; |
|
} |
|
|
|
sub thisversion { |
|
my $fname=shift; |
|
my $version=-1; |
|
if ($fname=~/\.(\d+)\.\w+(?:\.meta)*$/) { |
|
$version=$1; |
|
} |
|
return $version; |
|
} |
|
|
sub subscribe { |
sub subscribe { |
my ($userinput,$clientip)=@_; |
my ($userinput,$clientip)=@_; |
my $result; |
my $result; |
my ($cmd,$fname)=split(/:/,$userinput); |
my ($cmd,$fname)=split(/:/,$userinput); |
my $ownership=&ishome($fname); |
my $ownership=&ishome($fname); |
if ($ownership eq 'owner') { |
if ($ownership eq 'owner') { |
|
# explitly asking for the current version? |
|
unless (-e $fname) { |
|
my $currentversion=¤tversion($fname); |
|
if (&thisversion($fname)==$currentversion) { |
|
if ($fname=~/^(.+)\.\d+\.(\w+(?:\.meta)*)$/) { |
|
my $root=$1; |
|
my $extension=$2; |
|
symlink($root.'.'.$extension, |
|
$root.'.'.$currentversion.'.'.$extension); |
|
unless ($extension=~/\.meta$/) { |
|
symlink($root.'.'.$extension.'.meta', |
|
$root.'.'.$currentversion.'.'.$extension.'.meta'); |
|
} |
|
} |
|
} |
|
} |
if (-e $fname) { |
if (-e $fname) { |
if (-d $fname) { |
if (-d $fname) { |
$result="directory\n"; |
$result="directory\n"; |