Using new eHdb hipadaba output code.

r1204 | ffr | 2006-10-30 12:58:25 +1100 (Mon, 30 Oct 2006) | 2 lines
This commit is contained in:
Ferdi Franceschini
2006-10-30 12:58:25 +11:00
committed by Douglas Clowes
parent 19fa04ab39
commit eb6b037aac
4 changed files with 20 additions and 107 deletions

View File

@@ -158,7 +158,7 @@ static int SICSNotifyCallback(void *userData, void *callData, pHdb node,
result = CreateDynString(128,128);
if(pPath == NULL || printedData == NULL || result == NULL){
SCWriteInContext(cbInfo->pCon,"ERROR: out of memory formatting data" ,
eEvent,cbInfo->context);
eError,cbInfo->context);
/*
* no need to interrupt something because writing data to a client does
* not work
@@ -182,7 +182,7 @@ static int SICSNotifyCallback(void *userData, void *callData, pHdb node,
}
SCWriteInContext(cbInfo->pCon,GetCharArray(result),
eEvent,cbInfo->context);
eHdb,cbInfo->context);
free(pPath);
DeleteDynString(result);
DeleteDynString(printedData);
@@ -754,7 +754,7 @@ int ProcessSICSHdbPar(pHdb root, SConnection *pCon,
if(printPrefix != NULL){
DynStringInsert(parData,printPrefix,0);
}
SCWrite(pCon,GetCharArray(parData),eValue);
SCWrite(pCon,GetCharArray(parData),eHdb);
DeleteDynString(parData);
ReleaseHdbValue(&input);
return 1;
@@ -1409,30 +1409,18 @@ static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
pDynString parData = NULL;
char error[512], oriPath[512];;
int i, status;
int pathArg = 1, fmtArg=1;
char *usage ="ERROR:valid arguments are [-json] nodepath";
int pathArg = 1;
char *usage ="ERROR: Requires <nodepath> argument";
/*XXX
switch (argc) {
case 2:
pathArg = 1;
currFmtStyle = plain;
break;
case 3:
pathArg = 2;
if(strcmp(argv[1],"-json") == 0){
currFmtStyle = json;
} else {
SCWrite(pCon,usage,eError);
return 0;
}
break;
default:
SCWrite(pCon,usage,eError);
return 0;
break;
}
*/
strncpy(oriPath,argv[pathArg], 511);
targetNode = locateSICSNode(pSics,pCon,argv[pathArg]);
@@ -1441,37 +1429,16 @@ static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
}
memset(&newValue,0,sizeof(hdbValue));
GetHipadabaPar(targetNode, &newValue, pCon);
switch (currFmtStyle) {
case cli:
parData = formatClientValue(oriPath,newValue,0);
break;
case json:
parData = formatJSONValue(oriPath,newValue,0);
break;
case plain:
default:
parData = formatValue(newValue);
}
parData = formatJSONValue(oriPath,newValue,0);
if(parData == NULL){
SCWrite(pCon,"ERROR: out of memory formatting data",eError);
return 0;
}
switch (currFmtStyle) {
case cli:
break;
case json:
DynStringInsert(parData,"{", 0);
DynStringConcat(parData,"}");
break;
case plain:
default:
DynStringInsert(parData," =",0);
DynStringInsert(parData,oriPath,0);
}
SCWrite(pCon,GetCharArray(parData),eValue);
DynStringInsert(parData,"{", 0);
DynStringConcat(parData,"}");
SCWrite(pCon,GetCharArray(parData),eHdb);
DeleteDynString(parData);
ReleaseHdbValue(&newValue);
@@ -1636,70 +1603,32 @@ static int ListHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]){
pHdb node = NULL;
pDynString listData = NULL;
int pathArg = 1, fmtArg=1;
char *usage ="ERROR:valid arguments are [-json] nodepath";
int pathArg = 1;
char *usage ="ERROR: Requires <nodepath> argument";
/*XXX
switch (argc) {
case 2:
pathArg = 1;
currFmtStyle = plain;
break;
case 3:
pathArg = 2;
if(strcmp(argv[1],"-json") == 0){
currFmtStyle = json;
} else {
SCWrite(pCon,usage,eError);
return 0;
}
break;
default:
SCWrite(pCon,usage,eError);
return 0;
break;
}
*/
/*XXX
if(strchr(argv[1],'-') != NULL){
pathArg = 2;
if(argc < 3){
SCWrite(pCon,"ERROR: need path to node to print",eError);
return 0;
}
}
*/
node = locateSICSNode(pSics,pCon,argv[pathArg]);
if(node == NULL){
return 0;
}
strtolower(argv[pathArg]);
/*XXX if (argc == 3) {
if(strcmp(argv[1],"-val") == 0){
listData = formatListWithVal(node);
} else if(strcmp(argv[1],"-cli") == 0 || currFmtStyle == cli){
listData = formatClientList(node);
}
} else { */
switch (currFmtStyle) {
case cli:
listData = formatClientList(node);
break;
case json:
listData = formatJSONList(node);
break;
case plain:
default:
listData = formatPlainList(node);
}
//}
listData = formatJSONList(node);
if(listData == NULL){
SCWrite(pCon,"ERROR: failed to format list",
eError);
return 0;
}
SCWrite(pCon,GetCharArray(listData),eValue);
SCWrite(pCon,GetCharArray(listData),eHdb);
DeleteDynString(listData);
return 1;
}
@@ -1720,23 +1649,12 @@ static int AutoNotifyHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
pHdb node = NULL;
int id, status;
int pathArg = 1, idArg=2;
char *usage ="ERROR:valid arguments are [-json] nodepath id";
char *usage ="ERROR:valid arguments are <nodepath> <id>";
switch (argc) {
case 3:
pathArg = 1;
idArg = 2;
currFmtStyle = json;
break;
case 4:
/* pathArg = 2;
idArg = 3;
if(strcmp(argv[1],"-json") == 0){
currFmtStyle = json;
} else {
SCWrite(pCon,usage,eError);
return 0;
}*/
break;
default:
SCWrite(pCon,usage,eError);
@@ -1744,13 +1662,6 @@ static int AutoNotifyHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
break;
}
/*XXX
if(argc < 3) {
SCWrite(pCon,"ERROR: need path and id in order to add notify",
eError);
return 0;
}
*/
node = locateSICSNode(pSics,pCon,argv[pathArg]);
if(node == NULL){
return 0;