*** empty log message ***
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include <splitter.h>
|
||||
#include "sicsobj.h"
|
||||
|
||||
/*== there can be only hipadaba in SICS, some globals to care for that == */
|
||||
/*== there can be only one hipadaba in SICS, some globals to care for that == */
|
||||
static pHdb root = NULL;
|
||||
static pSicsPoll poller = NULL;
|
||||
typedef enum {
|
||||
@@ -173,7 +173,7 @@ static int SICSFuncCallback(void *userData, void *callData, pHdb node,
|
||||
}
|
||||
func = (SICSOBJFunc)node->value.v.obj;
|
||||
if(func != NULL){
|
||||
return func((pSICSOBJ)userData,(SConnection *)callData, par,nPar);
|
||||
return func((pSICSOBJ)userData,(SConnection *)callData, node, par,nPar);
|
||||
} else {
|
||||
printf("Great Badness in calling SICSFuncCallback\n");
|
||||
return 0;
|
||||
@@ -1241,7 +1241,7 @@ int ProcessSICSHdbPar(pHdb root, SConnection *pCon,
|
||||
SCWrite(pCon,"ERROR: out of memory reading parameter data",eError);
|
||||
return 0;
|
||||
}
|
||||
DynStringInsert(parData," =", 0);
|
||||
DynStringInsert(parData," = ", 0);
|
||||
DynStringInsert(parData,argv[0],0);
|
||||
if(printPrefix != NULL){
|
||||
DynStringInsert(parData,printPrefix,0);
|
||||
@@ -1521,7 +1521,7 @@ static char *hdbTypes[] = {"none",
|
||||
"func",
|
||||
NULL};
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int convertHdbType(char *text){
|
||||
int convertHdbType(char *text){
|
||||
int type;
|
||||
|
||||
type = 0;
|
||||
@@ -1594,7 +1594,7 @@ static int MakeHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
if(strlen(pPtr) < 1) {
|
||||
parent = root;
|
||||
} else {
|
||||
parent = GetHipadabaNode(root,buffer);
|
||||
parent = locateSICSNode(pSics,pCon,buffer);
|
||||
}
|
||||
if(parent == NULL){
|
||||
snprintf(buffer2,512,"ERROR: parent %s for new node does not exist",
|
||||
@@ -1672,7 +1672,7 @@ static int MakeHdbScriptNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
if(strlen(pPtr) < 1) {
|
||||
parent = root;
|
||||
} else {
|
||||
parent = GetHipadabaNode(root,buffer);
|
||||
parent = locateSICSNode(pSics,pCon,buffer);
|
||||
}
|
||||
if(parent == NULL){
|
||||
snprintf(buffer2,512,"ERROR: parent %s for new node does not exist",
|
||||
@@ -1742,7 +1742,7 @@ static int DeleteHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static pHdb locateSICSNode(SicsInterp *pSics, SConnection *pCon, char *path){
|
||||
pHdb locateSICSNode(SicsInterp *pSics, SConnection *pCon, char *path){
|
||||
pHdb result = NULL;
|
||||
char *pPtr = NULL, sicsObj[128], error[256];
|
||||
pDummy pDum = NULL;
|
||||
@@ -1840,9 +1840,11 @@ static int UpdateHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
char error[512];
|
||||
int i, status;
|
||||
|
||||
/*
|
||||
if(!SCMatchRights(pCon,usUser)){
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
if(argc < 2) {
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to UpdateHdbNode",
|
||||
@@ -1856,7 +1858,7 @@ static int UpdateHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
}
|
||||
if(argc > 2){
|
||||
if(!cloneHdbValue(&targetNode->value,&newValue)){
|
||||
SCWrite(pCon,"ERROR: out of mmeory cloning node",
|
||||
SCWrite(pCon,"ERROR: out of memory cloning node",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
@@ -1875,6 +1877,7 @@ static int UpdateHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCWrite(pCon,error, eError);
|
||||
return 0;
|
||||
}
|
||||
DeleteDynString(parData);
|
||||
} else {
|
||||
memset(&newValue,0,sizeof(hdbValue));
|
||||
GetHipadabaPar(targetNode,&newValue,pCon);
|
||||
@@ -1956,6 +1959,44 @@ static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int GetHdbVal(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
pHdb targetNode = NULL;
|
||||
hdbValue newValue;
|
||||
pDynString parData = NULL;
|
||||
char error[512], oriPath[512];
|
||||
int i, status, protocol, outCode;
|
||||
char value[80];
|
||||
|
||||
if(argc < 2) {
|
||||
SCWrite(pCon,"ERROR: need path to node to print",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(oriPath,argv[1], 511);
|
||||
targetNode = locateSICSNode(pSics,pCon,argv[1]);
|
||||
if(targetNode == NULL){
|
||||
return 0;
|
||||
}
|
||||
memset(&newValue,0,sizeof(hdbValue));
|
||||
GetHipadabaPar(targetNode, &newValue, pCon);
|
||||
parData = formatValue(newValue);
|
||||
if(parData == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory formatting data",eError);
|
||||
return 0;
|
||||
} else {
|
||||
if ((protocol = isJSON(pCon)) == 1)
|
||||
outCode = eHdbEvent;
|
||||
else
|
||||
outCode = eEvent;
|
||||
SCWrite(pCon,GetCharArray(parData), outCode);
|
||||
DeleteDynString(parData);
|
||||
ReleaseHdbValue(&newValue);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int countChildren(pHdb node){
|
||||
pHdb current = NULL;
|
||||
@@ -2539,7 +2580,7 @@ static int SicsCommandNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
if(strlen(pPtr) < 1) {
|
||||
parent = root;
|
||||
} else {
|
||||
parent = GetHipadabaNode(root,buffer);
|
||||
parent = locateSICSNode(pSics,pCon,buffer);
|
||||
}
|
||||
if(parent == NULL){
|
||||
snprintf(buffer2,512,"ERROR: parent %s for new node does not exist",
|
||||
@@ -2607,18 +2648,42 @@ static int GetSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
}
|
||||
targetNode = locateSICSNode(pSics,pCon,argv[1]);
|
||||
if(targetNode == NULL){
|
||||
SCWrite(pCon,"ERROR: node not found",eValue);
|
||||
SCWrite(pCon,"ERROR: node not found",eValue);
|
||||
return 0;
|
||||
}
|
||||
status = GetHdbProperty(targetNode,argv[2],buffer,511);
|
||||
if(status != 1){
|
||||
SCWrite(pCon,"ERROR: attribute not found",eValue);
|
||||
return 0;
|
||||
SCWrite(pCon,"ERROR: attribute not found",eValue);
|
||||
return 0;
|
||||
}
|
||||
SCPrintf(pCon,eValue,"%s.%s = %s", argv[1], argv[2], buffer);
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int GetSICSHdbPropertyVal(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",eValue);
|
||||
return 0;
|
||||
}
|
||||
status = GetHdbProperty(targetNode,argv[2],buffer,511);
|
||||
if(status != 1){
|
||||
SCWrite(pCon,"ERROR: attribute not found",eValue);
|
||||
return 0;
|
||||
}
|
||||
SCPrintf(pCon,eValue,"%s", buffer);
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int ListSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
pHdb targetNode = NULL;
|
||||
@@ -2670,6 +2735,7 @@ int InstallSICSHipadaba(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
AddCommand(pSics,"hset", SetHdbNode, NULL, NULL);
|
||||
AddCommand(pSics,"hupdate", UpdateHdbNode, NULL, NULL);
|
||||
AddCommand(pSics,"hget", GetHdbNode, NULL, NULL);
|
||||
AddCommand(pSics,"hval", GetHdbVal, NULL, NULL);
|
||||
AddCommand(pSics,"hzipget",ZipGetHdbNode, NULL, NULL);
|
||||
AddCommand(pSics,"hlist", ListHdbNode, NULL, NULL);
|
||||
AddCommand(pSics,"hnotify", AutoNotifyHdbNode, NULL, NULL);
|
||||
@@ -2681,6 +2747,7 @@ int InstallSICSHipadaba(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
AddCommand(pSics,"hcommand",SicsCommandNode, NULL, NULL);
|
||||
AddCommand(pSics,"hsetprop",SetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hgetprop",GetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hgetpropval",GetSICSHdbPropertyVal, NULL, NULL);
|
||||
AddCommand(pSics,"hlistprop",ListSICSHdbProperty, NULL, NULL);
|
||||
|
||||
InstallSICSPoll(pCon,pSics,pData,argc,argv);
|
||||
|
||||
Reference in New Issue
Block a user