- Fixed a bug with hlist -val
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
*
|
||||
* Added property functions, Mark Koennecke, January 2007
|
||||
*
|
||||
* Added hmatchprop function. Mark Koennecke, February 2008
|
||||
*
|
||||
* TODO: separate this into two modules: sicshipadaba proper and sicshipadabaint for the
|
||||
* interpreter interface.
|
||||
*/
|
||||
@@ -2353,7 +2355,7 @@ static int ListHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(strchr(argv[1],'-') != NULL){
|
||||
if(argv[1][0] == '-'){
|
||||
pathArg = 2;
|
||||
if(argc < 3){
|
||||
SCWrite(pCon,"ERROR: need path to node to print",eError);
|
||||
@@ -2789,6 +2791,61 @@ static int ListSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData
|
||||
DeleteDynString(data);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static pHdb matchHdbProp(pHdb root, char *propname, char *buffer){
|
||||
char value[1024];
|
||||
pHdb current = NULL, search;
|
||||
|
||||
memset(value,0,1024);
|
||||
if(GetHdbProperty(root,propname,value,1023) == 1){
|
||||
if(strstr(buffer,value) != NULL){
|
||||
return root;
|
||||
}
|
||||
}
|
||||
current = root->child;
|
||||
while(current != NULL){
|
||||
search = matchHdbProp(current,propname,buffer);
|
||||
if(search != NULL){
|
||||
return search;
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int MatchHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]){
|
||||
pHdb root = NULL;
|
||||
pHdb foundNode = NULL;
|
||||
char buffer[1024], *path = NULL;
|
||||
|
||||
if(argc < 4){
|
||||
SCWrite(pCon,"ERROR: need root, property name and target string for search",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
memset(buffer,0,1024);
|
||||
Arg2Text(argc-3,&argv[3],buffer,1023);
|
||||
root = GetHipadabaNode(GetHipadabaRoot(), argv[1]);
|
||||
if(root == NULL){
|
||||
SCWrite(pCon,"ERROR: start node for search not found",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strtolower(argv[2]);
|
||||
strtolower(buffer);
|
||||
foundNode = matchHdbProp(root,argv[2],buffer);
|
||||
|
||||
if(foundNode == NULL){
|
||||
SCWrite(pCon,"NONE", eValue);
|
||||
} else {
|
||||
path = GetHipadabaPath(foundNode);
|
||||
SCWrite(pCon,path,eValue);
|
||||
free(path);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*======================= Factory Functions =================================*/
|
||||
void killSICSHipadaba(){
|
||||
if(root != NULL){
|
||||
@@ -2820,7 +2877,8 @@ 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,"hgetprop",GetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hmatchprop",MatchHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hlistprop",ListSICSHdbProperty, NULL, NULL);
|
||||
|
||||
InstallSICSPoll(pCon,pSics,pData,argc,argv);
|
||||
|
||||
Reference in New Issue
Block a user