2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 10:46:53 +00:00

Rename added, rereadcfg bugfix

git-svn-id: https://svn.fhem.de/fhem/trunk@31 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2007-03-19 15:34:34 +00:00
parent 1af4b93426
commit 2c8f2dd2c2
4 changed files with 73 additions and 29 deletions

View File

@ -294,7 +294,7 @@
- bugfix: empty FHT battery is not reported (by Holger) - bugfix: empty FHT battery is not reported (by Holger)
- feature: new FHT codes, e.g. month/day/hour/minute setting (by Holger) - feature: new FHT codes, e.g. month/day/hour/minute setting (by Holger)
- ==DATE== (3.4) - ==DATE== (4.0)
- bugfix: deny at +{3}... (only +*{3} allowed), reported by Bernd, 25.01 - bugfix: deny at +{3}... (only +*{3} allowed), reported by Bernd, 25.01
- bugfix: allow numbers greater then 9 in at +{<number>} - bugfix: allow numbers greater then 9 in at +{<number>}
- feature: new 50_WS300.pm from Martin (bugfix + rain statistics, 26.01) - feature: new 50_WS300.pm from Martin (bugfix + rain statistics, 26.01)
@ -315,6 +315,6 @@
- list/xmllist format changed - list/xmllist format changed
- disable attribute for at/notify/filelog - disable attribute for at/notify/filelog
See HISTORY for details and reasoning See HISTORY for details and reasoning
- TODO: bugfix: more thorough serial line initialization - added rename command
- RENAME - TODO: bugfix: more thorough serial line initialization

View File

@ -236,7 +236,7 @@ FHZ_Undef($$)
my ($hash, $arg) = @_; my ($hash, $arg) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
foreach my $d (keys %defs) { foreach my $d (sort keys %defs) {
if(defined($defs{$d}) && if(defined($defs{$d}) &&
defined($defs{$d}{IODev}) && defined($defs{$d}{IODev}) &&
$defs{$d}{IODev} == $hash) $defs{$d}{IODev} == $hash)
@ -245,7 +245,7 @@ FHZ_Undef($$)
delete $defs{$d}{IODev}; delete $defs{$d}{IODev};
} }
} }
$hash->{PortObj}->close(); $hash->{PortObj}->close() if($hash->{PortObj});
return undef; return undef;
} }

View File

@ -15,7 +15,13 @@
- Added doc/linux.html (multiple USDB devices, udev links) - Added doc/linux.html (multiple USDB devices, udev links)
- Linked fhem.html and commandref.html to linux.html - Linked fhem.html and commandref.html to linux.html
- rudi, Sun Mar 4 11:18:10 MET 2007 - Martin Haas, Fri Feb 23 10:18 MET 2007
- ARM-Section (NSLU2) added to doc/linux.html
- Pest, Sat Feb 24 18:30 MET 2007
- doc/linux.html: Module build re-written.
- Rudi, Sun Mar 4 11:18:10 MET 2007
Reorganization. Goal: making attribute adding/deleting more uniform Reorganization. Goal: making attribute adding/deleting more uniform
("at/notify" and other device differences), and making web-configuration ("at/notify" and other device differences), and making web-configuration
possible (i.e. saving the configfile, list of possible devices etc). possible (i.e. saving the configfile, list of possible devices etc).
@ -48,9 +54,4 @@
- "define/set/get/attr name ?" returns a list of possible arguments - "define/set/get/attr name ?" returns a list of possible arguments
in the same format. This data is contained in the xmllist. in the same format. This data is contained in the xmllist.
- disable attribute for at/notify/filelog - disable attribute for at/notify/filelog
- rename added
- Martin Haas, Fri Feb 23 10:18 MET 2007
- ARM-Section (NSLU2) added to doc/linux.html
- Pest, Sat Feb 24 18:30 MET 2007
- doc/linux.html: Module build re-written.

View File

@ -60,6 +60,7 @@ sub TimeNow();
sub WriteStatefile(); sub WriteStatefile();
sub XmlEscape($); sub XmlEscape($);
sub fhem($); sub fhem($);
sub doGlobalDef($);
sub CommandAttr($$); sub CommandAttr($$);
sub CommandDefAttr($$); sub CommandDefAttr($$);
@ -72,6 +73,7 @@ sub CommandInclude($$);
sub CommandInform($$); sub CommandInform($$);
sub CommandList($$); sub CommandList($$);
sub CommandRereadCfg($$); sub CommandRereadCfg($$);
sub CommandRename($$);
sub CommandQuit($$); sub CommandQuit($$);
sub CommandSave($$); sub CommandSave($$);
sub CommandSet($$); sub CommandSet($$);
@ -129,6 +131,7 @@ my %defattr; # Default attributes
my %intAt; # Internal at timer hash. my %intAt; # Internal at timer hash.
my $intAtCnt=0; my $intAtCnt=0;
my $init_done = 0; my $init_done = 0;
my $reread_active = 0;
my $AttrList = "room"; my $AttrList = "room";
@ -136,15 +139,7 @@ $modules{Internal}{ORDER} = -1;
$modules{Internal}{AttrList} = "configfile logfile modpath " . $modules{Internal}{AttrList} = "configfile logfile modpath " .
"pidfilename port statefile userattr verbose:1,2,3,4,5 version"; "pidfilename port statefile userattr verbose:1,2,3,4,5 version";
$defs{global}{NR} = $devcount++; doGlobalDef($ARGV[0]);
$defs{global}{TYPE} = "Internal";
$defs{global}{STATE} = "Internal";
$defs{global}{DEF} = "<no definition>";
CommandAttr(undef, "global verbose 3");
CommandAttr(undef, "global configfile $ARGV[0]");
CommandAttr(undef, "global logfile -");
CommandAttr(undef, "global version =VERS= from =DATE=");
my %cmds = ( my %cmds = (
"?" => { Fn=>"CommandHelp", "?" => { Fn=>"CommandHelp",
@ -173,6 +168,8 @@ my %cmds = (
Hlp=>",end the client session" }, Hlp=>",end the client session" },
"reload" => { Fn=>"CommandReload", "reload" => { Fn=>"CommandReload",
Hlp=>"<module-name>,reload the given module (e.g. 99_PRIV)" }, Hlp=>"<module-name>,reload the given module (e.g. 99_PRIV)" },
"rename" => { Fn=>"CommandRename",
Hlp=>"<old> <new>,rename a definition" },
"rereadcfg" => { Fn=>"CommandRereadCfg", "rereadcfg" => { Fn=>"CommandRereadCfg",
Hlp=>",reread the config file" }, Hlp=>",reread the config file" },
"save" => { Fn=>"CommandSave", "save" => { Fn=>"CommandSave",
@ -604,14 +601,20 @@ CommandRereadCfg($$)
return $ret if($ret); return $ret if($ret);
} }
my $cfgfile = $attr{global}{configfile};
%defs = (); %defs = ();
%attr = (); %attr = ();
doGlobalDef($cfgfile);
my $ret;
$ret = CommandInclude($cl, $attr{global}{configfile}); $reread_active=1;
return $ret if($ret);
$ret = CommandInclude($cl, $attr{global}{statefile}) my $ret = CommandInclude($cl, $cfgfile);
if($attr{global}{statefile} && -r $attr{global}{statefile}); if(!$ret && $attr{global}{statefile} && -r $attr{global}{statefile}) {
$ret = CommandInclude($cl, $attr{global}{statefile});
}
$reread_active=0;
return $ret; return $ret;
} }
@ -916,6 +919,7 @@ CommandDelete($$)
{ {
my ($cl, $def) = @_; my ($cl, $def) = @_;
return "Please define $def first" if(!defined($defs{$def}));
my $ret = CallFn($def, "UndefFn", $defs{$def}, $def); my $ret = CallFn($def, "UndefFn", $defs{$def}, $def);
return $ret if($ret); return $ret if($ret);
@ -1107,6 +1111,26 @@ CommandReload($$)
return undef; return undef;
} }
#####################################
sub
CommandRename($$)
{
my ($cl, $param) = @_;
my ($old, $new) = split(" ", $param);
return "Please define $old first" if(!defined($defs{$old}));
return "Invalid characters in name (not A-Za-z0-9.:-): $new"
if($new !~ m/^[a-z0-9.:_-]*$/i);
return "Cannot rename global" if($old eq "global");
$defs{$new} = $defs{$old};
delete($defs{$old});
$attr{$new} = $attr{$old};
delete($attr{$old});
return undef;
}
##################################### #####################################
sub sub
@ -1163,6 +1187,8 @@ CommandAttr($$)
################ ################
elsif($a[1] eq "port") { elsif($a[1] eq "port") {
return undef if($reread_active);
my ($port, $global) = split(" ", $a[2]); my ($port, $global) = split(" ", $a[2]);
if($global && $global ne "global") { if($global && $global ne "global") {
return "Bad syntax, usage: attr global port <portnumber> [global]"; return "Bad syntax, usage: attr global port <portnumber> [global]";
@ -1174,9 +1200,10 @@ CommandAttr($$)
LocalPort => $port, LocalPort => $port,
Listen => 10, Listen => 10,
ReuseAddr => 1); ReuseAddr => 1);
if($ret) { if(!$server2) {
return $ret if($init_done); Log 1, "Can't open server port at $port: $!\n";
die "Can't open server port at $port\n"; return "$!" if($init_done);
die "Can't open server port at $port: $!\n";
} }
close($server) if($server); close($server) if($server);
$server = $server2; $server = $server2;
@ -1550,3 +1577,19 @@ fhem($)
return AnalyzeCommandChain($global_cl, $param); return AnalyzeCommandChain($global_cl, $param);
} }
sub
doGlobalDef($)
{
my ($arg) = @_;
$devcount = 0;
$defs{global}{NR} = $devcount++;
$defs{global}{TYPE} = "Internal";
$defs{global}{STATE} = "Internal";
$defs{global}{DEF} = "<no definition>";
CommandAttr(undef, "global verbose 3");
CommandAttr(undef, "global configfile $arg");
CommandAttr(undef, "global logfile -");
CommandAttr(undef, "global version =VERS= from =DATE=");
}