Added -space option to hlist command. This is useful for processing hlist outpu in Tcl.
r1691 | ffr | 2007-03-20 16:06:24 +1100 (Tue, 20 Mar 2007) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
efb997cd16
commit
78905ca695
@@ -33,6 +33,12 @@ typedef enum {
|
||||
normal_protocol,
|
||||
json_protocol,
|
||||
} Protocol;
|
||||
|
||||
typedef enum {
|
||||
linefeed,
|
||||
space,
|
||||
} RecSep;
|
||||
|
||||
char *trim(char *str);
|
||||
/*=============== common callback functions used for SICS ===========================*/
|
||||
static int SICSCheckPermissionCallback(void *userData, void *callData, pHdb node,
|
||||
@@ -1943,7 +1949,7 @@ int isSICSHdbRO(pHdb node){
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static pDynString formatPlainList(pHdb node){
|
||||
static pDynString formatPlainList(pHdb node, RecSep recsep){
|
||||
pHdb current;
|
||||
pDynString result = NULL;
|
||||
|
||||
@@ -1955,7 +1961,14 @@ static pDynString formatPlainList(pHdb node){
|
||||
current = node->child;
|
||||
while(current != NULL){
|
||||
DynStringConcat(result,current->name);
|
||||
DynStringConcat(result,"\n");
|
||||
switch (recsep) {
|
||||
case space:
|
||||
DynStringConcat(result," ");
|
||||
break;
|
||||
case linefeed:
|
||||
default:
|
||||
DynStringConcat(result,"\n");
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
return result;
|
||||
@@ -2132,12 +2145,16 @@ static int ListHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
listData = formatListWithVal(node);
|
||||
} else if(strcmp(argv[1],"-cli") == 0){
|
||||
listData = formatClientList(node);
|
||||
} else if(strcmp(argv[1],"-space") == 0){
|
||||
listData = formatPlainList(node, space);
|
||||
} else if(strcmp(argv[1],"-linefeed") == 0){
|
||||
listData = formatPlainList(node, linefeed);
|
||||
} else {
|
||||
if ((protocol = isJSON(pCon)) == 1) {
|
||||
listData = formatJSONList(node);
|
||||
outCode = eHdbEvent;
|
||||
} else {
|
||||
listData = formatPlainList(node);
|
||||
listData = formatPlainList(node, linefeed);
|
||||
outCode = eEvent;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user