- Fixed a couple of Hipadaba Issues
- Added properties to Hipadaba Nodes - Made Morpheus Hipadaba aware and implemented scans for Morpheus and Hipadaba SKIPPED: psi/tecs/make_crv
This commit is contained in:
136
sicshipadaba.c
136
sicshipadaba.c
@@ -8,6 +8,11 @@
|
||||
* Mark Koennecke, June 2006
|
||||
*
|
||||
* Introduced notification on tree changes, Mark Koennecke, November 2006
|
||||
*
|
||||
* Added Property functions, Mark Koennecke, January 2007
|
||||
*
|
||||
* TODO: separate this into two modules: sicshipadaba proper and sicshipadabaint for the
|
||||
* interpreter interface.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -745,6 +750,9 @@ static void SICSDeleteNodeData(pHdb node){
|
||||
node->child = node->child->next;
|
||||
SICSDeleteNodeData(tmp);
|
||||
}
|
||||
if(node->properties != NULL){
|
||||
DeleteStringDict(node->properties);
|
||||
}
|
||||
DeleteCallbackChain(node->writeCallbacks);
|
||||
DeleteCallbackChain(node->updateCallbacks);
|
||||
DeleteCallbackChain(node->readCallbacks);
|
||||
@@ -1611,7 +1619,7 @@ static int UpdateHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(argc < 3) {
|
||||
if(argc < 2) {
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to UpdateHdbNode",
|
||||
eError);
|
||||
return 0;
|
||||
@@ -1621,26 +1629,30 @@ static int UpdateHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
if(targetNode == NULL){
|
||||
return 0;
|
||||
}
|
||||
if(!cloneHdbValue(&targetNode->value,&newValue)){
|
||||
SCWrite(pCon,"ERROR: out of mmeory cloning node",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
parData = CreateDynString(64,64);
|
||||
if(parData == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory reading parameter",eError);
|
||||
return 0;
|
||||
}
|
||||
for(i = 2; i < argc; i++){
|
||||
DynStringConcat(parData," ");
|
||||
DynStringConcat(parData, argv[i]);
|
||||
}
|
||||
strcpy(error,"ERROR: ");
|
||||
if(!readHdbValue(&newValue, GetCharArray(parData),
|
||||
error+7,512-7)){
|
||||
SCWrite(pCon,error, eError);
|
||||
return 0;
|
||||
}
|
||||
if(argc > 2){
|
||||
if(!cloneHdbValue(&targetNode->value,&newValue)){
|
||||
SCWrite(pCon,"ERROR: out of mmeory cloning node",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
parData = CreateDynString(64,64);
|
||||
if(parData == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory reading parameter",eError);
|
||||
return 0;
|
||||
}
|
||||
for(i = 2; i < argc; i++){
|
||||
DynStringConcat(parData," ");
|
||||
DynStringConcat(parData, argv[i]);
|
||||
}
|
||||
strcpy(error,"ERROR: ");
|
||||
if(!readHdbValue(&newValue, GetCharArray(parData),
|
||||
error+7,512-7)){
|
||||
SCWrite(pCon,error, eError);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
GetHipadabaPar(targetNode,&newValue,pCon);
|
||||
}
|
||||
status = UpdateHipadabaPar(targetNode,newValue,pCon);
|
||||
ReleaseHdbValue(&newValue);
|
||||
if(status == 1){
|
||||
@@ -2243,7 +2255,84 @@ static int SicsCommandNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*======================= Property Functions ================================*/
|
||||
static int SetSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
pHdb targetNode = NULL;
|
||||
char buffer[512];
|
||||
|
||||
if(argc < 4) {
|
||||
SCWrite(pCon,"ERROR: need path key value as parameters",eError);
|
||||
return 0;
|
||||
}
|
||||
targetNode = locateSICSNode(pSics,pCon,argv[1]);
|
||||
if(targetNode == NULL){
|
||||
SCWrite(pCon,"ERROR: node not found",eError);
|
||||
return 0;
|
||||
}
|
||||
Arg2Text(argc-3, &argv[3], buffer,512);
|
||||
SetHdbProperty(targetNode,argv[2], buffer);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int GetSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
pHdb targetNode = NULL;
|
||||
char buffer[512];
|
||||
int status;
|
||||
|
||||
if(argc < 3) {
|
||||
SCWrite(pCon,"ERROR: need path key as parameters",eError);
|
||||
return 0;
|
||||
}
|
||||
targetNode = locateSICSNode(pSics,pCon,argv[1]);
|
||||
if(targetNode == NULL){
|
||||
SCWrite(pCon,"ERROR: node not found",eError);
|
||||
return 0;
|
||||
}
|
||||
status = GetHdbProperty(targetNode,argv[2],buffer,511);
|
||||
if(status != 1){
|
||||
SCWrite(pCon,"ERROR: attribute not found",eError);
|
||||
return 0;
|
||||
}
|
||||
SCPrintf(pCon,eValue,"%s.%s = %s", argv[1], argv[2], buffer);
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int ListSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
pHdb targetNode = NULL;
|
||||
char buffer[512];
|
||||
const char *pKey = NULL;
|
||||
pDynString data = NULL;
|
||||
|
||||
if(argc < 2) {
|
||||
SCWrite(pCon,"ERROR: need path as parameter",eError);
|
||||
return 0;
|
||||
}
|
||||
targetNode = locateSICSNode(pSics,pCon,argv[1]);
|
||||
if(targetNode == NULL){
|
||||
SCWrite(pCon,"ERROR: node not found",eError);
|
||||
return 0;
|
||||
}
|
||||
data = CreateDynString(64,64);
|
||||
if(data == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory in ListSICSHdbProperty",eError);
|
||||
return 0;
|
||||
}
|
||||
InitHdbPropertySearch(targetNode);
|
||||
while((pKey = GetNextHdbProperty(targetNode, buffer, 511)) != NULL){
|
||||
DynStringConcat(data,(char *)pKey);
|
||||
DynStringConcat(data,"=");
|
||||
DynStringConcat(data,buffer);
|
||||
DynStringConcat(data,"\n");
|
||||
}
|
||||
SCWrite(pCon,GetCharArray(data), eValue);
|
||||
DeleteDynString(data);
|
||||
return 1;
|
||||
}
|
||||
/*======================= Factory Functions =================================*/
|
||||
void killSICSHipadaba(){
|
||||
if(root != NULL){
|
||||
DeleteHipadabaNode(root,NULL);
|
||||
@@ -2271,6 +2360,9 @@ int InstallSICSHipadaba(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
AddCommand(pSics,"hval", HdbNodeVal, NULL, NULL);
|
||||
AddCommand(pSics,"hchain", ChainHdbNode, NULL, NULL);
|
||||
AddCommand(pSics,"hcommand",SicsCommandNode, NULL, NULL);
|
||||
AddCommand(pSics,"hsetprop",SetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hgetprop",GetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hlistprop",ListSICSHdbProperty, NULL, NULL);
|
||||
|
||||
InstallSICSPoll(pCon,pSics,pData,argc,argv);
|
||||
poller = (pSicsPoll)FindCommandData(pSics,"sicspoll","SicsPoll");
|
||||
|
||||
Reference in New Issue
Block a user