aqhome-react: Unified function names.
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
@@ -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,47 +56,26 @@ 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");
|
||||||
if (sl) {
|
t1=_getNewestFiletimeFromFileList(aqh, sl);
|
||||||
GWEN_STRINGLISTENTRY *se;
|
GWEN_StringList_free(sl);
|
||||||
|
|
||||||
se=GWEN_StringList_FirstEntry(sl);
|
|
||||||
while(se) {
|
|
||||||
const char *s;
|
|
||||||
|
|
||||||
s=GWEN_StringListEntry_Data(se);
|
|
||||||
if (s && *s) {
|
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
if (stat(s, &sb)==0) {
|
sl=AQH_GetListOfMatchingSysconfFiles("aqhome/react/networks", "*.xml");
|
||||||
time_t t;
|
t2=_getNewestFiletimeFromFileList(aqh, sl);
|
||||||
|
GWEN_StringList_free(sl);
|
||||||
|
|
||||||
t=sb.st_mtim.tv_sec;
|
return (t1>t2)?t1:t2;
|
||||||
if (t>resultTime)
|
|
||||||
resultTime=t;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DBG_WARN(NULL, "Error on stat(%s): %s (%d)", s, strerror(errno), errno);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
se=GWEN_StringListEntry_Next(se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DBG_ERROR(NULL, "No unit network files");
|
|
||||||
}
|
|
||||||
|
|
||||||
return resultTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQHREACT_UNIT_NET_LIST *AQHREACT_ReadUnitNetFiles(AQHOME_REACT *aqh)
|
AQHREACT_UNIT_NET_LIST *AQHomeReact_ReadUnitNetFiles(AQHOME_REACT *aqh)
|
||||||
{
|
{
|
||||||
GWEN_STRINGLIST *sl;
|
GWEN_STRINGLIST *sl;
|
||||||
|
|
||||||
@@ -119,6 +99,40 @@ AQHREACT_UNIT_NET_LIST *AQHREACT_ReadUnitNetFiles(AQHOME_REACT *aqh)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
time_t _getNewestFiletimeFromFileList(const AQHOME_REACT *aqh, const GWEN_STRINGLIST *sl)
|
||||||
|
{
|
||||||
|
time_t resultTime=0;
|
||||||
|
|
||||||
|
if (sl) {
|
||||||
|
GWEN_STRINGLISTENTRY *se;
|
||||||
|
|
||||||
|
se=GWEN_StringList_FirstEntry(sl);
|
||||||
|
while(se) {
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=GWEN_StringListEntry_Data(se);
|
||||||
|
if (s && *s) {
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if (stat(s, &sb)==0) {
|
||||||
|
time_t t;
|
||||||
|
|
||||||
|
t=sb.st_mtim.tv_sec;
|
||||||
|
if (t>resultTime)
|
||||||
|
resultTime=t;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DBG_WARN(NULL, "Error on stat(%s): %s (%d)", s, strerror(errno), errno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
se=GWEN_StringListEntry_Next(se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_XMLNODE *_readNetworkFromSysconfIntoXml(AQHOME_REACT *aqh, const char *networkName)
|
GWEN_XMLNODE *_readNetworkFromSysconfIntoXml(AQHOME_REACT *aqh, const char *networkName)
|
||||||
{
|
{
|
||||||
GWEN_XMLNODE *n;
|
GWEN_XMLNODE *n;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user