2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 17:26:34 +00:00

fhem() bugfix

git-svn-id: https://svn.fhem.de/fhem/trunk@635 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2010-05-18 08:08:53 +00:00
parent bb1f500b43
commit 7a37734b3f
4 changed files with 14 additions and 29 deletions

View File

@ -103,7 +103,8 @@ at_Exec($)
delete $attr{$name}{skip_next} if($skip); delete $attr{$name}{skip_next} if($skip);
my (undef, $command) = split("[ \t]+", $defs{$name}{DEF}, 2); my (undef, $command) = split("[ \t]+", $defs{$name}{DEF}, 2);
$command = SemicolonEscape($command); $command = SemicolonEscape($command);
AnalyzeCommandChain(undef, $command) if(!$skip && !$disable); my $ret = AnalyzeCommandChain(undef, $command) if(!$skip && !$disable);
Log 3, $ret if($ret);
return if(!$defs{$name}); # Deleted in the Command return if(!$defs{$name}); # Deleted in the Command

View File

@ -79,6 +79,7 @@ notify_Exec($$)
$exec =~ s/____/@/g; $exec =~ s/____/@/g;
my $r = AnalyzeCommandChain(undef, $exec); my $r = AnalyzeCommandChain(undef, $exec);
Log 3, $r if($r);
$ret .= " $r" if($r); $ret .= " $r" if($r);
} }
} }

View File

@ -95,7 +95,8 @@ watchdog_Trigger($)
my $exec = SemicolonEscape($ntfy->{CMD});; my $exec = SemicolonEscape($ntfy->{CMD});;
$ntfy->{STATE} = "triggered"; $ntfy->{STATE} = "triggered";
$ntfy->{INWATCHDOG} = 1; $ntfy->{INWATCHDOG} = 1;
AnalyzeCommandChain(undef, $exec); my $ret = AnalyzeCommandChain(undef, $exec);
Log 3, $ret if($ret);
$ntfy->{INWATCHDOG} = 0; $ntfy->{INWATCHDOG} = 0;
} }

View File

@ -154,14 +154,13 @@ my %client; # Client array
my $rcvdquit; # Used for quit handling in init files my $rcvdquit; # Used for quit handling in init files
my $sig_term = 0; # if set to 1, terminate (saving the state) my $sig_term = 0; # if set to 1, terminate (saving the state)
my $modpath_set; # Check if modpath was used, and report if not. my $modpath_set; # Check if modpath was used, and report if not.
my $global_cl; # To use from perl snippets
my %defaultattr; # Default attributes my %defaultattr; # Default attributes
my %intAt; # Internal at timer hash. my %intAt; # Internal at timer hash.
my $nextat; # Time when next timer will be triggered. my $nextat; # Time when next timer will be triggered.
my $intAtCnt=0; my $intAtCnt=0;
my %duplicate; # Pool of received msg for multi-fhz/cul setups my %duplicate; # Pool of received msg for multi-fhz/cul setups
my $duplidx=0; # helper for the above pool my $duplidx=0; # helper for the above pool
my $cvsid = '$Id: fhem.pl,v 1.106 2010-05-14 12:19:31 rudolfkoenig Exp $'; my $cvsid = '$Id: fhem.pl,v 1.107 2010-05-18 08:08:53 rudolfkoenig Exp $';
my $namedef = my $namedef =
"where <name> is either:\n" . "where <name> is either:\n" .
"- a single device name\n" . "- a single device name\n" .
@ -544,13 +543,17 @@ sub
AnalyzeCommandChain($$) AnalyzeCommandChain($$)
{ {
my ($c, $cmd) = @_; my ($c, $cmd) = @_;
my $ret = "";
$cmd =~ s/#.*$//s; $cmd =~ s/#.*$//s;
$cmd =~ s/;;/____/g; $cmd =~ s/;;/____/g;
foreach my $subcmd (split(";", $cmd)) { foreach my $subcmd (split(";", $cmd)) {
$subcmd =~ s/____/;/g; $subcmd =~ s/____/;/g;
AnalyzeCommand($c, $subcmd); my $lret = AnalyzeCommand($c, $subcmd);
$ret .= $lret if(defined($lret));
last if($c && !defined($client{$c})); # quit last if($c && !defined($client{$c})); # quit
} }
return $ret;
} }
##################################### #####################################
@ -583,16 +586,9 @@ AnalyzeCommand($$)
$month++; $month++;
$year+=1900; $year+=1900;
$global_cl = $cl;
my $ret = eval $cmd; my $ret = eval $cmd;
$ret = $@ if($@); $ret = $@ if($@);
if($ret) { syswrite($client{$cl}{fd}, "$ret\n") if($ret && $cl);
if($cl) {
syswrite($client{$cl}{fd}, "$ret\n")
} else {
Log 3, $ret;
}
}
return $ret; return $ret;
} }
@ -635,13 +631,7 @@ AnalyzeCommand($$)
my $ret = &{$cmds{$fn}{Fn} }($cl, $param); my $ret = &{$cmds{$fn}{Fn} }($cl, $param);
use strict "refs"; use strict "refs";
if($ret) { syswrite($client{$cl}{fd}, $ret . "\n") if($ret && $cl);
if($cl) {
syswrite($client{$cl}{fd}, $ret . "\n");
} else {
Log 3, $ret;
}
}
return $ret; return $ret;
} }
@ -1979,15 +1969,7 @@ sub
fhem($) fhem($)
{ {
my $param = shift; my $param = shift;
return AnalyzeCommandChain($global_cl, $param); return AnalyzeCommandChain(undef, $param);
}
# the "old" name, kept to make upgrade process easier
sub
fhz($)
{
my $param = shift;
return AnalyzeCommandChain($global_cl, $param);
} }
##################################### #####################################