diff --git a/aqhome/data/vars.c b/aqhome/data/vars.c index 7e5ccef..f00f144 100644 --- a/aqhome/data/vars.c +++ b/aqhome/data/vars.c @@ -97,16 +97,16 @@ void AQH_Vars_free(AQH_VARS *vt) -AQH_VARS *AQH_Vars_CreateGroup(char *s) +AQH_VARS *AQH_Vars_CreateGroup(const char *s) { - return _newStringElement(s, AQH_Vars_DataType_Group); + return _newStringElement(s?strdup(s):NULL, AQH_Vars_DataType_Group); } -AQH_VARS *AQH_Vars_CreateVariable(char *s) +AQH_VARS *AQH_Vars_CreateVariable(const char *s) { - return _newStringElement(s, AQH_Vars_DataType_Variable); + return _newStringElement(s?strdup(s):NULL, AQH_Vars_DataType_Variable); } @@ -265,7 +265,7 @@ AQH_VARS *AQH_Vars_GetNextByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt) -int AQH_Vars_SetCharValue(AQH_VARS *vt, uint32_t flags, const char *path, char *value) +int AQH_Vars_SetCharValue(AQH_VARS *vt, uint32_t flags, const char *path, const char *value) { if (vt) { AQH_VARS *vtChild; @@ -276,7 +276,7 @@ int AQH_Vars_SetCharValue(AQH_VARS *vt, uint32_t flags, const char *path, char * DBG_ERROR(AQH_LOGDOMAIN, "Error getting path for var \"%s\"", path); return GWEN_ERROR_GENERIC; } - vtValue=AQH_Vars_CreateStringValue(value); + vtValue=AQH_Vars_CreateStringValue(value?strdup(value):NULL); AQH_Vars_Tree2_AddChild(vtChild, vtValue); return 0; } @@ -397,10 +397,5 @@ AQH_VARS *_getNodeByTypeAndName(const AQH_VARS *vt, AQH_VARS_DATATYPE dt, const - - - - - - +#include "./vars-t.c" diff --git a/aqhome/data/vars.h b/aqhome/data/vars.h index 0b50786..21d8036 100644 --- a/aqhome/data/vars.h +++ b/aqhome/data/vars.h @@ -33,8 +33,8 @@ typedef struct AQH_VARS AQH_VARS; GWEN_TREE2_FUNCTION_DEFS(AQH_VARS, AQH_Vars); -AQH_VARS *AQH_Vars_CreateGroup(char *s); -AQH_VARS *AQH_Vars_CreateVariable(char *s); +AQH_VARS *AQH_Vars_CreateGroup(const char *s); +AQH_VARS *AQH_Vars_CreateVariable(const char *s); AQH_VARS *AQH_Vars_CreateStringValue(char *s); AQH_VARS *AQH_Vars_CreateIntValue(int d); AQH_VARS *AQH_Vars_CreateDoubleValue(double d); @@ -59,7 +59,7 @@ AQH_VARS *AQH_Vars_GetFirstChildByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt) AQH_VARS *AQH_Vars_GetNextByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt); -int AQH_Vars_SetCharValue(AQH_VARS *vt, uint32_t flags, const char *path, char *value); +int AQH_Vars_SetCharValue(AQH_VARS *vt, uint32_t flags, const char *path, const char *value); const char *AQH_Vars_GetCharValue(AQH_VARS *vt, const char *path, int idx, const char *defaultValue);