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:
committed by
Douglas Clowes
parent
19fa04ab39
commit
eb6b037aac
@@ -50,7 +50,8 @@ typedef enum {
|
|||||||
eFinish,
|
eFinish,
|
||||||
eEvent,
|
eEvent,
|
||||||
eWarning,
|
eWarning,
|
||||||
eError
|
eError,
|
||||||
|
eHdb
|
||||||
} OutCode;
|
} OutCode;
|
||||||
|
|
||||||
#include "interrupt.h"
|
#include "interrupt.h"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"event",
|
"event",
|
||||||
"warning",
|
"warning",
|
||||||
"error",
|
"error",
|
||||||
|
"hdb",
|
||||||
NULL };
|
NULL };
|
||||||
static int iNoCodes = 10;
|
static int iNoCodes = 11;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -632,7 +632,7 @@ struct json_object *mkJSON_Object(SConnection *pCon, char *pBuffer, int iOut)
|
|||||||
json_object_object_add(msg_json, "flag", json_object_new_string(pCode[iOut]));
|
json_object_object_add(msg_json, "flag", json_object_new_string(pCode[iOut]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (iOut == eValue || iOut == eEvent) {
|
if (iOut == eHdb) {
|
||||||
tmp_json = json_tokener_parse(pBuffer);
|
tmp_json = json_tokener_parse(pBuffer);
|
||||||
if (is_error(msg_json)) { linenum = __LINE__; goto reporterr; }
|
if (is_error(msg_json)) { linenum = __LINE__; goto reporterr; }
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
119
sicshipadaba.c
119
sicshipadaba.c
@@ -158,7 +158,7 @@ static int SICSNotifyCallback(void *userData, void *callData, pHdb node,
|
|||||||
result = CreateDynString(128,128);
|
result = CreateDynString(128,128);
|
||||||
if(pPath == NULL || printedData == NULL || result == NULL){
|
if(pPath == NULL || printedData == NULL || result == NULL){
|
||||||
SCWriteInContext(cbInfo->pCon,"ERROR: out of memory formatting data" ,
|
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
|
* no need to interrupt something because writing data to a client does
|
||||||
* not work
|
* not work
|
||||||
@@ -182,7 +182,7 @@ static int SICSNotifyCallback(void *userData, void *callData, pHdb node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SCWriteInContext(cbInfo->pCon,GetCharArray(result),
|
SCWriteInContext(cbInfo->pCon,GetCharArray(result),
|
||||||
eEvent,cbInfo->context);
|
eHdb,cbInfo->context);
|
||||||
free(pPath);
|
free(pPath);
|
||||||
DeleteDynString(result);
|
DeleteDynString(result);
|
||||||
DeleteDynString(printedData);
|
DeleteDynString(printedData);
|
||||||
@@ -754,7 +754,7 @@ int ProcessSICSHdbPar(pHdb root, SConnection *pCon,
|
|||||||
if(printPrefix != NULL){
|
if(printPrefix != NULL){
|
||||||
DynStringInsert(parData,printPrefix,0);
|
DynStringInsert(parData,printPrefix,0);
|
||||||
}
|
}
|
||||||
SCWrite(pCon,GetCharArray(parData),eValue);
|
SCWrite(pCon,GetCharArray(parData),eHdb);
|
||||||
DeleteDynString(parData);
|
DeleteDynString(parData);
|
||||||
ReleaseHdbValue(&input);
|
ReleaseHdbValue(&input);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1409,30 +1409,18 @@ static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
pDynString parData = NULL;
|
pDynString parData = NULL;
|
||||||
char error[512], oriPath[512];;
|
char error[512], oriPath[512];;
|
||||||
int i, status;
|
int i, status;
|
||||||
int pathArg = 1, fmtArg=1;
|
int pathArg = 1;
|
||||||
char *usage ="ERROR:valid arguments are [-json] nodepath";
|
char *usage ="ERROR: Requires <nodepath> argument";
|
||||||
|
|
||||||
/*XXX
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 2:
|
case 2:
|
||||||
pathArg = 1;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
SCWrite(pCon,usage,eError);
|
SCWrite(pCon,usage,eError);
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
strncpy(oriPath,argv[pathArg], 511);
|
strncpy(oriPath,argv[pathArg], 511);
|
||||||
targetNode = locateSICSNode(pSics,pCon,argv[pathArg]);
|
targetNode = locateSICSNode(pSics,pCon,argv[pathArg]);
|
||||||
@@ -1441,37 +1429,16 @@ static int GetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
}
|
}
|
||||||
memset(&newValue,0,sizeof(hdbValue));
|
memset(&newValue,0,sizeof(hdbValue));
|
||||||
GetHipadabaPar(targetNode, &newValue, pCon);
|
GetHipadabaPar(targetNode, &newValue, pCon);
|
||||||
|
parData = formatJSONValue(oriPath,newValue,0);
|
||||||
switch (currFmtStyle) {
|
|
||||||
case cli:
|
|
||||||
parData = formatClientValue(oriPath,newValue,0);
|
|
||||||
break;
|
|
||||||
case json:
|
|
||||||
parData = formatJSONValue(oriPath,newValue,0);
|
|
||||||
break;
|
|
||||||
case plain:
|
|
||||||
default:
|
|
||||||
parData = formatValue(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(parData == NULL){
|
if(parData == NULL){
|
||||||
SCWrite(pCon,"ERROR: out of memory formatting data",eError);
|
SCWrite(pCon,"ERROR: out of memory formatting data",eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (currFmtStyle) {
|
DynStringInsert(parData,"{", 0);
|
||||||
case cli:
|
DynStringConcat(parData,"}");
|
||||||
break;
|
SCWrite(pCon,GetCharArray(parData),eHdb);
|
||||||
case json:
|
|
||||||
DynStringInsert(parData,"{", 0);
|
|
||||||
DynStringConcat(parData,"}");
|
|
||||||
break;
|
|
||||||
case plain:
|
|
||||||
default:
|
|
||||||
DynStringInsert(parData," =",0);
|
|
||||||
DynStringInsert(parData,oriPath,0);
|
|
||||||
}
|
|
||||||
SCWrite(pCon,GetCharArray(parData),eValue);
|
|
||||||
DeleteDynString(parData);
|
DeleteDynString(parData);
|
||||||
ReleaseHdbValue(&newValue);
|
ReleaseHdbValue(&newValue);
|
||||||
|
|
||||||
@@ -1636,70 +1603,32 @@ static int ListHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
int argc, char *argv[]){
|
int argc, char *argv[]){
|
||||||
pHdb node = NULL;
|
pHdb node = NULL;
|
||||||
pDynString listData = NULL;
|
pDynString listData = NULL;
|
||||||
int pathArg = 1, fmtArg=1;
|
int pathArg = 1;
|
||||||
char *usage ="ERROR:valid arguments are [-json] nodepath";
|
char *usage ="ERROR: Requires <nodepath> argument";
|
||||||
|
|
||||||
/*XXX
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 2:
|
case 2:
|
||||||
pathArg = 1;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
SCWrite(pCon,usage,eError);
|
SCWrite(pCon,usage,eError);
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
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]);
|
node = locateSICSNode(pSics,pCon,argv[pathArg]);
|
||||||
if(node == NULL){
|
if(node == NULL){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
strtolower(argv[pathArg]);
|
strtolower(argv[pathArg]);
|
||||||
/*XXX if (argc == 3) {
|
listData = formatJSONList(node);
|
||||||
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);
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
if(listData == NULL){
|
if(listData == NULL){
|
||||||
SCWrite(pCon,"ERROR: failed to format list",
|
SCWrite(pCon,"ERROR: failed to format list",
|
||||||
eError);
|
eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SCWrite(pCon,GetCharArray(listData),eValue);
|
SCWrite(pCon,GetCharArray(listData),eHdb);
|
||||||
DeleteDynString(listData);
|
DeleteDynString(listData);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1720,23 +1649,12 @@ static int AutoNotifyHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
pHdb node = NULL;
|
pHdb node = NULL;
|
||||||
int id, status;
|
int id, status;
|
||||||
int pathArg = 1, idArg=2;
|
int pathArg = 1, idArg=2;
|
||||||
char *usage ="ERROR:valid arguments are [-json] nodepath id";
|
char *usage ="ERROR:valid arguments are <nodepath> <id>";
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 3:
|
case 3:
|
||||||
pathArg = 1;
|
pathArg = 1;
|
||||||
idArg = 2;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
SCWrite(pCon,usage,eError);
|
SCWrite(pCon,usage,eError);
|
||||||
@@ -1744,13 +1662,6 @@ static int AutoNotifyHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
break;
|
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]);
|
node = locateSICSNode(pSics,pCon,argv[pathArg]);
|
||||||
if(node == NULL){
|
if(node == NULL){
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user