- Fixed a bug in splitter.c
- Added hupdate and hzipget to Hipadaba
This commit is contained in:
142
sicshipadaba.c
142
sicshipadaba.c
@ -152,25 +152,32 @@ static int SICSNotifyCallback(void *userData, void *callData, pHdb node,
|
|||||||
|
|
||||||
cbInfo = (HdbCBInfo *)userData;
|
cbInfo = (HdbCBInfo *)userData;
|
||||||
pPath = GetHipadabaPath(node);
|
pPath = GetHipadabaPath(node);
|
||||||
printedData = formatValue(v);
|
|
||||||
result = CreateDynString(128,128);
|
result = CreateDynString(128,128);
|
||||||
if(pPath == NULL || printedData == NULL || result == NULL){
|
if(v.arrayLength < 100){
|
||||||
SCWriteInContext(cbInfo->pCon,"ERROR: out of memory formatting data" ,
|
printedData = formatValue(v);
|
||||||
eEvent,cbInfo->context);
|
if(pPath == NULL || printedData == NULL || result == NULL){
|
||||||
/*
|
SCWriteInContext(cbInfo->pCon,"ERROR: out of memory formatting data" ,
|
||||||
* no need to interrupt something because writing data to a client does
|
|
||||||
* not work
|
|
||||||
*/
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
DynStringCopy(result,pPath);
|
|
||||||
DynStringConcat(result," = ");
|
|
||||||
DynStringConcat(result,GetCharArray(printedData));
|
|
||||||
SCWriteInContext(cbInfo->pCon,GetCharArray(result),
|
|
||||||
eEvent,cbInfo->context);
|
eEvent,cbInfo->context);
|
||||||
|
/*
|
||||||
|
* no need to interrupt something because writing data to a client does
|
||||||
|
* not work
|
||||||
|
*/
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
DynStringCopy(result,pPath);
|
||||||
|
DynStringConcat(result," = ");
|
||||||
|
DynStringConcat(result,GetCharArray(printedData));
|
||||||
|
SCWriteInContext(cbInfo->pCon,GetCharArray(result),
|
||||||
|
eEvent,cbInfo->context);
|
||||||
|
DeleteDynString(printedData);
|
||||||
|
} else {
|
||||||
|
DynStringCopy(result,"!!datachange!! = ");
|
||||||
|
DynStringConcat(result,pPath);
|
||||||
|
SCWriteInContext(cbInfo->pCon,GetCharArray(result),
|
||||||
|
eEvent,cbInfo->context);
|
||||||
|
}
|
||||||
free(pPath);
|
free(pPath);
|
||||||
DeleteDynString(result);
|
DeleteDynString(result);
|
||||||
DeleteDynString(printedData);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1591,6 +1598,56 @@ static int SetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static int UpdateHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
|
int argc, char *argv[]){
|
||||||
|
pHdb targetNode = NULL;
|
||||||
|
hdbValue newValue;
|
||||||
|
pDynString parData = NULL;
|
||||||
|
char error[512];
|
||||||
|
int i, status;
|
||||||
|
|
||||||
|
if(!SCMatchRights(pCon,usUser)){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(argc < 3) {
|
||||||
|
SCWrite(pCon,"ERROR: insufficient number of arguments to UpdateHdbNode",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
targetNode = locateSICSNode(pSics,pCon,argv[1]);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
status = UpdateHipadabaPar(targetNode,newValue,pCon);
|
||||||
|
ReleaseHdbValue(&newValue);
|
||||||
|
if(status == 1){
|
||||||
|
SCSendOK(pCon);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
int argc, char *argv[]){
|
int argc, char *argv[]){
|
||||||
@ -1625,6 +1682,59 @@ static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
static int ZipGetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
|
int argc, char *argv[]){
|
||||||
|
pHdb targetNode = NULL;
|
||||||
|
hdbValue newValue;
|
||||||
|
char error[512], oriPath[512];
|
||||||
|
int i, status;
|
||||||
|
int *iData = NULL;
|
||||||
|
|
||||||
|
if(argc < 2) {
|
||||||
|
SCWrite(pCon,"ERROR: need path to node",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);
|
||||||
|
switch(newValue.dataType){
|
||||||
|
case HIPINTAR:
|
||||||
|
case HIPINTVARAR:
|
||||||
|
for(i = 0; i < newValue.arrayLength; i++){
|
||||||
|
newValue.v.intArray[i] = htonl(newValue.v.intArray[i]);
|
||||||
|
}
|
||||||
|
SCWriteZipped(pCon,oriPath, newValue.v.intArray,
|
||||||
|
newValue.arrayLength*sizeof(int));
|
||||||
|
break;
|
||||||
|
case HIPFLOATAR:
|
||||||
|
case HIPFLOATVARAR:
|
||||||
|
iData = (int *)malloc(newValue.arrayLength*sizeof(int));
|
||||||
|
if(iData == NULL){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory in ZipGetHdbNode",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(iData,0,newValue.arrayLength*sizeof(int));
|
||||||
|
for(i = 0; i < newValue.arrayLength; i++){
|
||||||
|
iData[i] = htonl((int)newValue.v.floatArray[i]*65536.);
|
||||||
|
}
|
||||||
|
SCWriteZipped(pCon,oriPath, iData,
|
||||||
|
newValue.arrayLength*sizeof(int));
|
||||||
|
free(iData);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SCWrite(pCon,"ERROR: zipped writing not supported for this datatype",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ReleaseHdbValue(&newValue);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
static int countChildren(pHdb node){
|
static int countChildren(pHdb node){
|
||||||
pHdb current = NULL;
|
pHdb current = NULL;
|
||||||
@ -2150,7 +2260,9 @@ int InstallSICSHipadaba(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
AddCommand(pSics,"hattach", SICSHdbAdapter, NULL, NULL);
|
AddCommand(pSics,"hattach", SICSHdbAdapter, NULL, NULL);
|
||||||
AddCommand(pSics,"hdel", DeleteHdbNode, NULL, NULL);
|
AddCommand(pSics,"hdel", DeleteHdbNode, NULL, NULL);
|
||||||
AddCommand(pSics,"hset", SetHdbNode, NULL, NULL);
|
AddCommand(pSics,"hset", SetHdbNode, NULL, NULL);
|
||||||
|
AddCommand(pSics,"hupdate", UpdateHdbNode, NULL, NULL);
|
||||||
AddCommand(pSics,"hget", GetHdbNode, NULL, NULL);
|
AddCommand(pSics,"hget", GetHdbNode, NULL, NULL);
|
||||||
|
AddCommand(pSics,"hzipget",ZipGetHdbNode, NULL, NULL);
|
||||||
AddCommand(pSics,"hlist", ListHdbNode, NULL, NULL);
|
AddCommand(pSics,"hlist", ListHdbNode, NULL, NULL);
|
||||||
AddCommand(pSics,"hnotify", AutoNotifyHdbNode, NULL, NULL);
|
AddCommand(pSics,"hnotify", AutoNotifyHdbNode, NULL, NULL);
|
||||||
AddCommand(pSics,"hdelcb", RemoveHdbCallback, NULL, NULL);
|
AddCommand(pSics,"hdelcb", RemoveHdbCallback, NULL, NULL);
|
||||||
|
@ -114,7 +114,7 @@ typedef enum _CharType {eSpace, eNum,eeText,eQuote} CharType;
|
|||||||
{
|
{
|
||||||
TokenList *pList = NULL;
|
TokenList *pList = NULL;
|
||||||
TokenList *pCurrent;
|
TokenList *pCurrent;
|
||||||
char pBueffel[132];
|
char pBueffel[256];
|
||||||
char *pChar;
|
char *pChar;
|
||||||
CharType eWhat;
|
CharType eWhat;
|
||||||
int i, n;
|
int i, n;
|
||||||
@ -141,7 +141,7 @@ typedef enum _CharType {eSpace, eNum,eeText,eQuote} CharType;
|
|||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
pChar++;
|
pChar++;
|
||||||
while( (isEnd(*pChar) != 2) && (CheckSpecial(pChar) != eQuote))
|
while( (isEnd(*pChar) != 2) && (CheckSpecial(pChar) != eQuote) && i < 250)
|
||||||
{
|
{
|
||||||
if (*pChar == '\\') {
|
if (*pChar == '\\') {
|
||||||
pBueffel[i] = Tcl_Backslash(pChar, &n);
|
pBueffel[i] = Tcl_Backslash(pChar, &n);
|
||||||
|
Reference in New Issue
Block a user