aqhome-react: Unified function names.

This commit is contained in:
Martin Preuss
2024-04-03 21:58:34 +02:00
parent 5305aa7fe3
commit c62165cd92
4 changed files with 49 additions and 35 deletions

View File

@@ -120,7 +120,7 @@ void AqHomeReact_ReloadUnitNets(AQHOME_REACT *aqh)
_setupBuiltinUnits(aqh); _setupBuiltinUnits(aqh);
unitNetList=AQHREACT_ReadUnitNetFiles(aqh); unitNetList=AQHomeReact_ReadUnitNetFiles(aqh);
if (unitNetList) { if (unitNetList) {
AQHREACT_UnitNet_List_free(aqh->unitNetList); AQHREACT_UnitNet_List_free(aqh->unitNetList);
aqh->unitNetList=unitNetList; aqh->unitNetList=unitNetList;

View File

@@ -182,7 +182,7 @@ void _serve(AQHOME_REACT *aqh)
time_t t; time_t t;
DBG_INFO(NULL, "Checking network files"); DBG_INFO(NULL, "Checking network files");
tNew=AQHREACT_GetNewestUnitNetFiletime(aqh); tNew=AQHomeReact_GetNewestUnitNetFiletime(aqh);
t=AqHomeReact_GetLatestNetworkFileTime(aqh); t=AqHomeReact_GetLatestNetworkFileTime(aqh);
if (tNew && tNew>t) { if (tNew && tNew>t) {
DBG_INFO(NULL, "Reloading network files"); DBG_INFO(NULL, "Reloading network files");

View File

@@ -32,6 +32,7 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
static time_t _getNewestFiletimeFromFileList(const AQHOME_REACT *aqh, const GWEN_STRINGLIST *sl);
static AQHREACT_UNIT_NET_LIST *_readUnitNetFiles(AQHOME_REACT *aqh, const GWEN_STRINGLIST *sl); static AQHREACT_UNIT_NET_LIST *_readUnitNetFiles(AQHOME_REACT *aqh, const GWEN_STRINGLIST *sl);
static int _readAllNetworksFromFileIntoList(AQHOME_REACT *aqh, const char *sFilename, AQHREACT_UNIT_NET_LIST *unitNetList); static int _readAllNetworksFromFileIntoList(AQHOME_REACT *aqh, const char *sFilename, AQHREACT_UNIT_NET_LIST *unitNetList);
static GWEN_XMLNODE *_readNetworkFromSysconfIntoXml(AQHOME_REACT *aqh, const char *networkName); static GWEN_XMLNODE *_readNetworkFromSysconfIntoXml(AQHOME_REACT *aqh, const char *networkName);
@@ -55,12 +56,53 @@ static int _setParamDoubleValueFromString(AQHREACT_PARAM *param, const char *s);
*/ */
time_t AQHREACT_GetNewestUnitNetFiletime(const AQHOME_REACT *aqh) time_t AQHomeReact_GetNewestUnitNetFiletime(const AQHOME_REACT *aqh)
{ {
GWEN_STRINGLIST *sl; GWEN_STRINGLIST *sl;
time_t resultTime=0; time_t t1;
time_t t2;
sl=AQH_GetListOfMatchingDataFiles("aqhome/react/networks", "*.xml"); sl=AQH_GetListOfMatchingDataFiles("aqhome/react/networks", "*.xml");
t1=_getNewestFiletimeFromFileList(aqh, sl);
GWEN_StringList_free(sl);
sl=AQH_GetListOfMatchingSysconfFiles("aqhome/react/networks", "*.xml");
t2=_getNewestFiletimeFromFileList(aqh, sl);
GWEN_StringList_free(sl);
return (t1>t2)?t1:t2;
}
AQHREACT_UNIT_NET_LIST *AQHomeReact_ReadUnitNetFiles(AQHOME_REACT *aqh)
{
GWEN_STRINGLIST *sl;
sl=AQH_GetListOfMatchingDataFiles("aqhome/react/networks", "*.xml");
if (sl) {
AQHREACT_UNIT_NET_LIST *unitNetList;
unitNetList=_readUnitNetFiles(aqh, sl);
GWEN_StringList_free(sl);
if (unitNetList==NULL) {
DBG_INFO(NULL, "Error reading unit network files");
return NULL;
}
return unitNetList;
}
else {
DBG_ERROR(NULL, "No unit network files");
return NULL;
}
}
time_t _getNewestFiletimeFromFileList(const AQHOME_REACT *aqh, const GWEN_STRINGLIST *sl)
{
time_t resultTime=0;
if (sl) { if (sl) {
GWEN_STRINGLISTENTRY *se; GWEN_STRINGLISTENTRY *se;
@@ -86,39 +128,11 @@ time_t AQHREACT_GetNewestUnitNetFiletime(const AQHOME_REACT *aqh)
se=GWEN_StringListEntry_Next(se); se=GWEN_StringListEntry_Next(se);
} }
} }
else {
DBG_ERROR(NULL, "No unit network files");
}
return resultTime; return resultTime;
} }
AQHREACT_UNIT_NET_LIST *AQHREACT_ReadUnitNetFiles(AQHOME_REACT *aqh)
{
GWEN_STRINGLIST *sl;
sl=AQH_GetListOfMatchingDataFiles("aqhome/react/networks", "*.xml");
if (sl) {
AQHREACT_UNIT_NET_LIST *unitNetList;
unitNetList=_readUnitNetFiles(aqh, sl);
GWEN_StringList_free(sl);
if (unitNetList==NULL) {
DBG_INFO(NULL, "Error reading unit network files");
return NULL;
}
return unitNetList;
}
else {
DBG_ERROR(NULL, "No unit network files");
return NULL;
}
}
GWEN_XMLNODE *_readNetworkFromSysconfIntoXml(AQHOME_REACT *aqh, const char *networkName) GWEN_XMLNODE *_readNetworkFromSysconfIntoXml(AQHOME_REACT *aqh, const char *networkName)
{ {
GWEN_XMLNODE *n; GWEN_XMLNODE *n;

View File

@@ -13,9 +13,9 @@
#include "./aqhome_react.h" #include "./aqhome_react.h"
AQHREACT_UNIT_NET_LIST *AQHREACT_ReadUnitNetFiles(AQHOME_REACT *aqh); AQHREACT_UNIT_NET_LIST *AQHomeReact_ReadUnitNetFiles(AQHOME_REACT *aqh);
time_t AQHREACT_GetNewestUnitNetFiletime(const AQHOME_REACT *aqh); time_t AQHomeReact_GetNewestUnitNetFiletime(const AQHOME_REACT *aqh);
#endif #endif