- modified DeleteCallbackChain interface

- fixed killNode message to be sent for every node killed
This commit is contained in:
zolliker
2008-06-13 11:18:14 +00:00
parent 0305826724
commit d75eee789b
3 changed files with 15 additions and 14 deletions

View File

@ -64,10 +64,14 @@ pHdbMessage GetHdbKillNodeMessage(pHdbMessage toTest){
return NULL; return NULL;
} }
/*================== internal functions ===================================*/ /*================== internal functions ===================================*/
void DeleteCallbackChain(pHdbCallback root){ void DeleteCallbackChain(pHdb node){
pHdbCallback current = NULL, thisEntry; pHdbCallback current = NULL, thisEntry;
hdbMessage killNodeMsg;
current = root; killNodeMsg.type = killNode;
InvokeCallbackChain(node, &killNodeMsg);
current = node->callBackChain;
while(current != NULL){ while(current != NULL){
if(current->killFunc != NULL){ if(current->killFunc != NULL){
current->killFunc(current->userData); current->killFunc(current->userData);
@ -95,7 +99,8 @@ void DeleteNodeData(pHdb node){
if(node == NULL){ if(node == NULL){
return; return;
} }
DeleteCallbackChain(node->callBackChain);
DeleteCallbackChain(node);
if(node->properties != NULL){ if(node->properties != NULL){
DeleteStringDict(node->properties); DeleteStringDict(node->properties);
} }
@ -595,15 +600,11 @@ void AddHipadabaChild(pHdb parent, pHdb child, void *callData){
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
void DeleteHipadabaNode(pHdb node, void *callData){ void DeleteHipadabaNode(pHdb node, void *callData){
pHdb current = NULL, tmp = NULL; pHdb current = NULL, tmp = NULL;
hdbMessage killNodeMsg;
if(node == NULL){ if(node == NULL){
return; return;
} }
killNodeMsg.type = killNode;
InvokeCallbackChain(node, &killNodeMsg);
RemoveHdbNodeFromParent(node, callData); RemoveHdbNodeFromParent(node, callData);
DeleteNodeData(node); DeleteNodeData(node);

View File

@ -352,11 +352,11 @@ void *FindHdbCallbackData(pHdb node, void *userPtr);
*/ */
int InvokeCallbackChain(pHdb node, pHdbMessage message); int InvokeCallbackChain(pHdb node, pHdbMessage message);
/** /**
* Deletes a callback chain. This is internal, normal users * Deletes the callback chain of a node. This is internal, normal users
* should nto use this function. Or you create a mess! * should not use this function. Or you create a mess!
* @param root The callback chain to remove * @param node The node
*/ */
void DeleteCallbackChain(pHdbCallback root); void DeleteCallbackChain(pHdb node);
/** /**
* apply message to the node and all its children * apply message to the node and all its children
* @param node Th node where to start recursing * @param node Th node where to start recursing

View File

@ -1176,7 +1176,7 @@ static void SICSDeleteNodeData(pHdb node){
if(node->properties != NULL){ if(node->properties != NULL){
DeleteStringDict(node->properties); DeleteStringDict(node->properties);
} }
DeleteCallbackChain(node->callBackChain); DeleteCallbackChain(node);
if(node->name != NULL){ if(node->name != NULL){
free(node->name); free(node->name);
@ -2079,7 +2079,7 @@ static int DeleteHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon,"ERROR: need path to node to delete",eError); SCWrite(pCon,"ERROR: need path to node to delete",eError);
return 0; return 0;
} }
killNode = GetHipadabaNode(root,argv[1]); killNode = FindHdbNode(NULL, argv[1], pCon);
if(killNode == NULL){ if(killNode == NULL){
SCWrite(pCon,"ERROR: node to delete not found",eError); SCWrite(pCon,"ERROR: node to delete not found",eError);
return 0; return 0;
@ -2998,7 +2998,7 @@ static int GetSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
} }
status = GetHdbProperty(targetNode,argv[2],buffer,511); status = GetHdbProperty(targetNode,argv[2],buffer,511);
if(status != 1){ if(status != 1){
SCWrite(pCon,"ERROR: attribute not found",eValue); SCPrintf(pCon,eValue,"ERROR: property %s not found", argv[2]);
return 0; return 0;
} }
SCPrintf(pCon,eValue,"%s.%s = %s", argv[1], argv[2], buffer); SCPrintf(pCon,eValue,"%s.%s = %s", argv[1], argv[2], buffer);