mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
configDB - code improvement
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@5672 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ca9ebcd3b8
commit
7e9e9eb23a
20
configDB.pm
20
configDB.pm
@ -69,6 +69,7 @@
|
|||||||
# 2014-04-23 - added command fileshow, filemove
|
# 2014-04-23 - added command fileshow, filemove
|
||||||
#
|
#
|
||||||
# 2014-04-26 - added migration to generic file handling
|
# 2014-04-26 - added migration to generic file handling
|
||||||
|
# fixed problem on migration of multiline DEFs
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@ -192,16 +193,18 @@ sub cfgDB_AttrRead($) {
|
|||||||
$sth->execute();
|
$sth->execute();
|
||||||
while (@line = $sth->fetchrow_array()) {
|
while (@line = $sth->fetchrow_array()) {
|
||||||
$row = "$line[1],$line[2],$line[3]";
|
$row = "$line[1],$line[2],$line[3]";
|
||||||
|
if($line[1] eq 'configdb') {
|
||||||
|
$attr{configdb}{$line[2]} = $line[3];
|
||||||
|
} else {
|
||||||
push @rets, $row;
|
push @rets, $row;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$fhem_dbh->disconnect();
|
$fhem_dbh->disconnect();
|
||||||
return @rets;
|
return @rets;
|
||||||
}
|
}
|
||||||
|
|
||||||
### work in process ###################
|
# functions for filehandling to be called
|
||||||
# create generice read and write function
|
# from fhem.pl and other fhem modules
|
||||||
# for filehandling to be used from fhem.pl
|
|
||||||
# and other fhem modules
|
|
||||||
|
|
||||||
sub cfgDB_FileRead($) {
|
sub cfgDB_FileRead($) {
|
||||||
my ($filename) = @_;
|
my ($filename) = @_;
|
||||||
@ -244,11 +247,9 @@ sub cfgDB_FileUpdate($) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
#######################################
|
|
||||||
|
|
||||||
# read and execute all commands from
|
# read and execute all commands from
|
||||||
# fhemconfig and fhemstate
|
# fhemconfig and fhemstate
|
||||||
|
|
||||||
sub cfgDB_ReadAll($){
|
sub cfgDB_ReadAll($){
|
||||||
my ($cl) = @_;
|
my ($cl) = @_;
|
||||||
my $ret;
|
my $ret;
|
||||||
@ -264,6 +265,7 @@ sub cfgDB_ReadAll($){
|
|||||||
|
|
||||||
# rotate all older versions to versionnumber+1
|
# rotate all older versions to versionnumber+1
|
||||||
# save running configuration to version 0
|
# save running configuration to version 0
|
||||||
|
|
||||||
sub cfgDB_SaveCfg {
|
sub cfgDB_SaveCfg {
|
||||||
my (%devByNr, @rowList);
|
my (%devByNr, @rowList);
|
||||||
|
|
||||||
@ -291,6 +293,7 @@ sub cfgDB_SaveCfg {
|
|||||||
my $def = $defs{$d}{DEF};
|
my $def = $defs{$d}{DEF};
|
||||||
if(defined($def)) {
|
if(defined($def)) {
|
||||||
$def =~ s/;/;;/g;
|
$def =~ s/;/;;/g;
|
||||||
|
$def =~ s/\n/\n /g;
|
||||||
} else {
|
} else {
|
||||||
$dev = "";
|
$dev = "";
|
||||||
}
|
}
|
||||||
@ -383,6 +386,7 @@ sub cfgDB_svnId {
|
|||||||
return "# ".'$Id$'
|
return "# ".'$Id$'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# return filelist depending on directory and regexp
|
||||||
sub cfgDB_FW_fileList(@$) {
|
sub cfgDB_FW_fileList(@$) {
|
||||||
my ($dir,$re,@ret) = @_;
|
my ($dir,$re,@ret) = @_;
|
||||||
my @files = split(/\n/, _cfgDB_Filelist('notitle'));
|
my @files = split(/\n/, _cfgDB_Filelist('notitle'));
|
||||||
@ -411,7 +415,7 @@ sub cfgDB_Read99() {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
# find SVN Id
|
# return SVN Id from file stored in database
|
||||||
sub cfgDB_Fileversion($$) {
|
sub cfgDB_Fileversion($$) {
|
||||||
my ($file,$ret) = @_;
|
my ($file,$ret) = @_;
|
||||||
my $fhem_dbh = _cfgDB_Connect;
|
my $fhem_dbh = _cfgDB_Connect;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user