aqhome-react: add "varsFile" (will write variables later).
This commit is contained in:
@@ -48,6 +48,7 @@ void AqHomeReact_free(AQHOME_REACT *aqh)
|
||||
AQHREACT_Unit_List_free(aqh->unitList);
|
||||
GWEN_MsgEndpoint_free(aqh->brokerEndpoint);
|
||||
GWEN_DB_Group_free(aqh->dbArgs);
|
||||
free(aqh->varsFile);
|
||||
free(aqh->pidFile);
|
||||
|
||||
GWEN_FREE_OBJECT(aqh);
|
||||
@@ -88,6 +89,23 @@ void AqHomeReact_SetPidFile(AQHOME_REACT *aqh, const char *s)
|
||||
|
||||
|
||||
|
||||
const char *AqHomeReact_GetVarsFile(const AQHOME_REACT *aqh)
|
||||
{
|
||||
return aqh?aqh->varsFile:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AqHomeReact_SetVarsFile(AQHOME_REACT *aqh, const char *s)
|
||||
{
|
||||
if (aqh) {
|
||||
free(aqh->varsFile);
|
||||
aqh->varsFile=s?strdup(s):NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AqHomeReact_GetTimeout(const AQHOME_REACT *aqh)
|
||||
{
|
||||
return aqh?aqh->timeout:0;
|
||||
|
||||
@@ -28,6 +28,9 @@ GWEN_DB_NODE *AqHomeReact_GetDbArgs(const AQHOME_REACT *aqh);
|
||||
const char *AqHomeReact_GetPidFile(const AQHOME_REACT *aqh);
|
||||
void AqHomeReact_SetPidFile(AQHOME_REACT *aqh, const char *s);
|
||||
|
||||
const char *AqHomeReact_GetVarsFile(const AQHOME_REACT *aqh);
|
||||
void AqHomeReact_SetVarsFile(AQHOME_REACT *aqh, const char *s);
|
||||
|
||||
int AqHomeReact_GetTimeout(const AQHOME_REACT *aqh);
|
||||
|
||||
time_t AqHomeReact_GetLatestNetworkFileTime(const AQHOME_REACT *aqh);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#define AQHOME_REACT_DEFAULT_PIDFILE "/var/run/aqhome-react.pid"
|
||||
#define AQHOME_REACT_DEFAULT_DATADIR "/var/lib/aqhome-react"
|
||||
#define AQHOME_REACT_DEFAULT_VARSFILE "vars.conf"
|
||||
|
||||
#define AQHOME_REACT_DEFAULT_BROKER_PORT 1899
|
||||
#define AQHOME_REACT_DEFAULT_BROKER_CLIENTID "react"
|
||||
@@ -29,6 +30,8 @@ struct AQHOME_REACT {
|
||||
|
||||
GWEN_DB_NODE *dbArgs;
|
||||
char *pidFile;
|
||||
char *varsFile;
|
||||
|
||||
int timeout; /* timeout for run e.g. inside valgrind */
|
||||
|
||||
AQHREACT_UNIT *timerUnit;
|
||||
|
||||
@@ -103,8 +103,28 @@ int AqHomeReact_Init(AQHOME_REACT *aqh, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
s=GWEN_DB_GetCharValue(dbArgs, "varsfile", 0, NULL);
|
||||
if (s && *s) {
|
||||
AqHomeReact_SetVarsFile(aqh, s);
|
||||
}
|
||||
else {
|
||||
GWEN_BUFFER *bufFilename;
|
||||
|
||||
bufFilename=AQH_GetRuntimeFilePath(AQHOME_REACT_DEFAULT_VARSFILE);
|
||||
if (bufFilename) {
|
||||
AqHomeReact_SetVarsFile(aqh, GWEN_Buffer_GetStart(bufFilename));
|
||||
GWEN_Buffer_free(bufFilename);
|
||||
}
|
||||
else {
|
||||
DBG_ERROR(NULL, "Could not setup filename for vars, please specify via command line argument");
|
||||
return GWEN_ERROR_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
aqh->localVars=AQH_Vars_CreateGroup("localVars");
|
||||
|
||||
// @TODO: read vars from file
|
||||
|
||||
rv=AqHomeReact_ReloadUnitNets(aqh);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "Error reading unit network files (%d)", rv);
|
||||
@@ -354,6 +374,17 @@ int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs)
|
||||
I18S("Specify the device file"),
|
||||
I18S("Specify the device file")
|
||||
},
|
||||
{
|
||||
GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
|
||||
GWEN_ArgsType_Char, /* type */
|
||||
"varsfile", /* name */
|
||||
0, /* minnum */
|
||||
1, /* maxnum */
|
||||
"V", /* short option */
|
||||
"varsfile", /* long option */
|
||||
I18S("Specify the vars file"),
|
||||
I18S("Specify the vars file")
|
||||
},
|
||||
{
|
||||
GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */
|
||||
GWEN_ArgsType_Int, /* type */
|
||||
|
||||
Reference in New Issue
Block a user