- Fixed a bug with hlist -val
This commit is contained in:
19
alias.c
19
alias.c
@ -212,3 +212,22 @@
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
int LocateAliasAction(SConnection *pCon, SicsInterp *pSics,
|
||||
void *pData, int argc, char *argv[]){
|
||||
char *aliases = NULL;
|
||||
|
||||
if(argc < 2){
|
||||
SCWrite(pCon,"ERROR: missing argument aliasname for locating aliases",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strtolower(argv[1]);
|
||||
aliases = FindAliases(pSics,argv[1]);
|
||||
if(aliases == NULL){
|
||||
SCWrite(pCon,"NONE", eValue);
|
||||
} else {
|
||||
SCPrintf(pCon,eValue,"%s = %s",argv[1], aliases);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
2
alias.h
2
alias.h
@ -16,5 +16,7 @@
|
||||
int argc, char *argv[]);
|
||||
int MakeAlias(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]);
|
||||
int LocateAliasAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
|
5
exeman.c
5
exeman.c
@ -1068,11 +1068,14 @@ static int printBuffer(pExeMan self, SConnection *pCon,
|
||||
DeleteDynString(filePath);
|
||||
return 0;
|
||||
}
|
||||
DeleteDynString(filePath);
|
||||
SCStartBuffering(pCon);
|
||||
while(fgets(pLine,511,fd) != NULL){
|
||||
SCWrite(pCon,pLine,eValue);
|
||||
}
|
||||
fclose(fd);
|
||||
DeleteDynString(filePath);
|
||||
filePath = SCEndBuffering(pCon);
|
||||
SCWrite(pCon,GetCharArray(filePath),eValue);
|
||||
return 1;
|
||||
}
|
||||
/*========================== run stack ===============================*/
|
||||
|
@ -324,7 +324,7 @@ int SetHipadabaPar(pHdb node, hdbValue v, void *callData);
|
||||
*/
|
||||
int UpdateHipadabaPar(pHdb node, hdbValue v, void *callData);
|
||||
/**
|
||||
* notify any update listeners that this node has been internally modidifed.
|
||||
* notify any update listeners that this node has been internally modifed.
|
||||
* @param node The node modified
|
||||
* @param callData Addtional data for the callback
|
||||
* @return 1 on success, 0 on failure
|
||||
|
1
ofac.c
1
ofac.c
@ -247,6 +247,7 @@
|
||||
AddCommand(pInter,"commandlog",CommandLog,CommandLogClose,NULL);
|
||||
AddCommand(pInter,"udpquieck",QuieckAction,KillQuieck,NULL);
|
||||
AddCommand(pInter,"alias",MakeAlias,NULL,NULL);
|
||||
AddCommand(pInter,"findalias",LocateAliasAction,NULL,NULL);
|
||||
AddCommand(pInter,"sicscron",MakeCron,NULL,NULL);
|
||||
AddCommand(pInter,"dolater",MakeCron,NULL,NULL);
|
||||
AddCommand(pInter,"sicsdatafactory",SICSDataFactory,NULL,NULL);
|
||||
|
@ -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