From e476d19040ea7bd1dbcfa2bb3fbfac37c399525a Mon Sep 17 00:00:00 2001 From: Koennecke Mark Date: Thu, 14 Apr 2016 14:20:30 +0200 Subject: [PATCH] Fixed an issue with sget throwing excessive error messages when testing for the presence of a Hdb node --- sicsget.c | 2 +- sicshipadaba.c | 37 +++++++++++++++++++++++++++++++++++-- sicshipadaba.h | 8 ++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/sicsget.c b/sicsget.c index a97fad46..117af0d5 100644 --- a/sicsget.c +++ b/sicsget.c @@ -334,7 +334,7 @@ static int GetHdbFunc(void *ms, void *userData) char *geterror = NULL, error[512]; hdbValue ve; - node = FindHdbNode(NULL,self->name,pServ->dummyCon); + node = FindHdbIntern(self->name); if(node != NULL){ geterror = GetHdbProp(node,"geterror"); if(geterror != NULL){ diff --git a/sicshipadaba.c b/sicshipadaba.c index ae8d4e3e..3e7df068 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -1521,7 +1521,10 @@ pHdb AddSICSHdbMemPar(pHdb parent, char *name, int priv, return child; } -/*==================== access support functions ==============================*/ +/*==================== access support functions ============================== +This has become an eierlegendewollmilchsau function. I do not know how and when +that happened +==============================================================================*/ pHdb FindHdbParent(char *rootpath, char *relpath, char **namePtr, SConnection * pCon) { @@ -1597,7 +1600,7 @@ pHdb FindHdbParent(char *rootpath, char *relpath, char **namePtr, SCPrintf(pCon, eError, "ERROR: parent of %s not found", buffer); return NULL; - } + } /* the name must be taken from the end of relpath, as element is no longer valid */ *namePtr = relpath + (element - buffer); return parent; /* parent found, and node does not yet exist */ @@ -1630,7 +1633,37 @@ pHdb FindHdbNode(char *rootpath, char *relpath, SConnection * pCon) { return FindHdbParent(rootpath, relpath, NULL, pCon); } +/*-------------------------------------------------------------------------*/ +pHdb FindHdbIntern(char *path) +{ + char *element, *slash; + pHdb parent = NULL; + pObjectDescriptor pDes = NULL; + element = path; + if(strncmp(element,"/sics/",6) == 0){ + slash = strchr(element+6,'/'); + if(slash != NULL){ + *slash = '\0'; + } + pDes = FindCommandDescriptor(pServ->pSics,element+6); + if(pDes == NULL){ + return NULL; + } + parent = pDes->parNode; + if(parent == NULL){ + return NULL; + } + if(slash == NULL){ + return parent; + } + *slash = '/'; + element = slash + 1; + } else { + parent = GetHipadabaRoot(); + } + return GetHipadabaNode(parent,element); +} /*-------------------------------------------------------------------------- * This does not use strlcpy, strlcat on purpose: it caused a bug * There are so many length checks in the code anyway so that is diff --git a/sicshipadaba.h b/sicshipadaba.h index 527fb250..5b456c19 100644 --- a/sicshipadaba.h +++ b/sicshipadaba.h @@ -281,6 +281,14 @@ pHdb FindHdbParent(char *rootpath, char *relpath, char **namePtr, * the path starts with "/sics/" */ pHdb FindHdbNode(char *rootpath, char *relpath, SConnection * pCon); +/** FindHdbIntern finds a node. It does so without complaining + * on the various bits which can fail. It is for internal use where the caller + * deals with the absence of the desired node. + * @param path the path to search. Paths starting /sics/are searched for in the object database + * @return the found node or NULL on failure + */ +pHdb FindHdbIntern(char *path); + /** Get the absolute path of a node anchored in the * Hipadaba root or in a sics object * @param nodeArg the input node