/**************************************************************************** * 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 #endif #include "./aqhomestorage_p.h" #include #include AQHOME_STORAGE *AqHomeStorage_new() { AQHOME_STORAGE *aqh; GWEN_NEW_OBJECT(AQHOME_STORAGE, aqh); aqh->rootEndpoint=GWEN_MsgEndpoint_new("root", 0); return aqh; } void AqHomeStorage_free(AQHOME_STORAGE *aqh) { if (aqh) { AQH_Service_free(aqh->httpService); aqh->httpService=NULL; AQH_Storage_free(aqh->storage); aqh->storage=NULL; GWEN_MsgEndpoint_free(aqh->rootEndpoint); aqh->rootEndpoint=NULL; aqh->ipcdEndpoint=NULL; aqh->mqttEndpoint=NULL; aqh->httpdEndpoint=NULL; GWEN_DB_Group_free(aqh->dbArgs); aqh->dbArgs=NULL; free(aqh->pidFile); GWEN_FREE_OBJECT(aqh); } } GWEN_MSG_ENDPOINT *AqHomeStorage_GetRootEndpoint(const AQHOME_STORAGE *aqh) { return aqh?(aqh->rootEndpoint):NULL; } GWEN_MSG_ENDPOINT *AqHomeStorage_GetIpcdEndpoint(const AQHOME_STORAGE *aqh) { return aqh?(aqh->ipcdEndpoint):NULL; } GWEN_MSG_ENDPOINT *AqHomeStorage_GetMqttEndpoint(const AQHOME_STORAGE *aqh) { return aqh?(aqh->mqttEndpoint):NULL; } GWEN_MSG_ENDPOINT *AqHomeStorage_GetHttpdEndpoint(const AQHOME_STORAGE *aqh) { return aqh?(aqh->httpdEndpoint):NULL; } GWEN_DB_NODE *AqHomeStorage_GetDbArgs(const AQHOME_STORAGE *aqh) { return aqh?(aqh->dbArgs):NULL; } AQH_STORAGE *AqHomeStorage_GetStorage(const AQHOME_STORAGE *aqh) { return aqh?(aqh->storage):NULL; } const char *AqHomeStorage_GetPidFile(const AQHOME_STORAGE *aqh) { return aqh?aqh->pidFile:NULL; } void AqHomeStorage_SetPidFile(AQHOME_STORAGE *aqh, const char *s) { if (aqh) { free(aqh->pidFile); aqh->pidFile=s?strdup(s):NULL; } } int AqHomeStorage_GetTimeout(const AQHOME_STORAGE *aqh) { return aqh?aqh->timeout:0; }