From dc2f0f29c8fd085f421769dddb6e6a41b137953f Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Tue, 23 Jun 2015 10:50:23 +0200 Subject: [PATCH] - added hvali command (does not throw an error when geterror is defined) --- sicshipadaba.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sicshipadaba.c b/sicshipadaba.c index 1c62c932..2de8ab68 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -2850,6 +2850,37 @@ static int GetHdbVal(SConnection * pCon, SicsInterp * pSics, void *pData, return 1; } +/*---------------------------------------------------------------------------*/ +static int GetHdbValIgnoreError( + SConnection * pCon, SicsInterp * pSics, void *pData, int argc, char *argv[]) +{ + pHdb targetNode = NULL; + pDynString parData = NULL; + int protocol, outCode; + + if (argc != 2) { + SCWrite(pCon, "ERROR: syntax must be: hvali ", eError); + return 0; + } + + targetNode = FindHdbNode(NULL, argv[1], pCon); + if (targetNode == NULL) { + return 0; + } + parData = formatValue(targetNode->value, targetNode); + if (parData == NULL) { + SCWrite(pCon, "ERROR: out of memory formatting data", eError); + return 0; + } + if ((protocol = isJSON(pCon, 0)) == 1) + outCode = eHdbEvent; + else + outCode = eValue; + SCWrite(pCon, GetCharArray(parData), outCode); + DeleteDynString(parData); + return 1; +} + /*--------------------------------------------------------------------------*/ static int countChildren(pHdb node) { @@ -4269,6 +4300,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics, AddCommand(pSics, "hupdate", UpdateHdbNode, NULL, NULL); AddCommand(pSics, "hget", GetHdbNode, NULL, NULL); AddCommand(pSics, "hval", GetHdbVal, NULL, NULL); + AddCommand(pSics, "hvali", GetHdbValIgnoreError, NULL, NULL); AddCommand(pSics, "hzipget", ZipGetHdbNode, NULL, NULL); AddCommand(pSics, "hzipread", ZipReadHdbNode, NULL, NULL); AddCommand(pSics, "hbinread", BinReadHdbNode, NULL, NULL); @@ -4277,7 +4309,6 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics, AddCommand(pSics, "hdelcb", RemoveHdbCallback, NULL, NULL); AddCommand(pSics, "hlink", LinkHdbNode, NULL, NULL); AddCommand(pSics, "hinfo", HdbNodeInfo, NULL, NULL); - /* AddCommand(pSics, "hval", HdbNodeVal, NULL, NULL);*/ AddCommand(pSics, "hchain", ChainHdbNode, NULL, NULL); AddCommand(pSics, "hcommand", SicsCommandNode, NULL, NULL); AddCommand(pSics, "harray", HdbArrayNode, NULL, NULL);