Started working on aqhome-nodes which will replace aqhomed.
This commit is contained in:
159
apps/aqhome-nodes/aqhomed.c
Normal file
159
apps/aqhome-nodes/aqhomed.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "./aqhomed_p.h"
|
||||
#include "./tty_log.h"
|
||||
|
||||
#include "aqhome/msg/endpoint_tty.h"
|
||||
#include "aqhome/ipc/endpoint_ipc.h"
|
||||
|
||||
#include <gwenhywfar/gwenhywfar.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* defines
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define I18N(msg) msg
|
||||
#define I18S(msg) msg
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* implementations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
AQHOMED *AqHomed_new(void)
|
||||
{
|
||||
AQHOMED *aqh;
|
||||
|
||||
GWEN_NEW_OBJECT(AQHOMED, aqh);
|
||||
aqh->rootEndpoint=GWEN_MsgEndpoint_new("root", 0);
|
||||
aqh->nodeDb=AQH_NodeDb_new();
|
||||
|
||||
return aqh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AqHomed_free(AQHOMED *aqh)
|
||||
{
|
||||
if (aqh) {
|
||||
GWEN_MsgEndpoint_free(aqh->rootEndpoint);
|
||||
aqh->rootEndpoint=NULL;
|
||||
aqh->ttyEndpoint=NULL;
|
||||
aqh->ipcdEndpoint=NULL;
|
||||
aqh->brokerEndpoint=NULL;
|
||||
GWEN_DB_Group_free(aqh->dbArgs);
|
||||
AQH_NodeDb_free(aqh->nodeDb);
|
||||
aqh->dbArgs=NULL;
|
||||
free(aqh->logFile);
|
||||
free(aqh->pidFile);
|
||||
free(aqh->dbFile);
|
||||
|
||||
GWEN_FREE_OBJECT(aqh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *AqHomed_GetTtyEndpoint(const AQHOMED *aqh)
|
||||
{
|
||||
return aqh?aqh->ttyEndpoint:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *AqHomed_GetIpcdEndpoint(const AQHOMED *aqh)
|
||||
{
|
||||
return aqh?aqh->ipcdEndpoint:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *AqHomed_GetBrokerEndpoint(const AQHOMED *aqh)
|
||||
{
|
||||
return aqh?aqh->brokerEndpoint:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_DB_NODE *AqHomed_GetDbArgs(const AQHOMED *aqh)
|
||||
{
|
||||
return aqh?aqh->dbArgs:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AqHomed_GetLogFile(const AQHOMED *aqh)
|
||||
{
|
||||
return aqh?aqh->logFile:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AqHomed_SetLogFile(AQHOMED *aqh, const char *s)
|
||||
{
|
||||
if (aqh) {
|
||||
free(aqh->logFile);
|
||||
aqh->logFile=s?strdup(s):NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AqHomed_GetPidFile(const AQHOMED *aqh)
|
||||
{
|
||||
return aqh?aqh->pidFile:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AqHomed_SetPidFile(AQHOMED *aqh, const char *s)
|
||||
{
|
||||
if (aqh) {
|
||||
free(aqh->pidFile);
|
||||
aqh->pidFile=s?strdup(s):NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AqHomed_GetDbFile(const AQHOMED *aqh)
|
||||
{
|
||||
return aqh?aqh->dbFile:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AqHomed_SetDbFile(AQHOMED *aqh, const char *s)
|
||||
{
|
||||
if (aqh) {
|
||||
free(aqh->dbFile);
|
||||
aqh->dbFile=s?strdup(s):NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user