work in progress
This commit is contained in:
47
sicslist.c
47
sicslist.c
@ -25,9 +25,9 @@ static void listAllObjects(SConnection * pCon, SicsInterp * pSics)
|
||||
while (pCom != NULL) {
|
||||
Tcl_DStringAppend(&lst, pCom->pName, -1);
|
||||
pCom = pCom->pNext;
|
||||
Tcl_DStringAppend(&lst, ",", -1);
|
||||
Tcl_DStringAppend(&lst, " ", -1); //ffr "," -> " "
|
||||
}
|
||||
Tcl_DStringAppend(&lst, "ENDLIST", -1);
|
||||
Tcl_DStringAppend(&lst, " ", -1);
|
||||
SCWrite(pCon, Tcl_DStringValue(&lst), eValue);
|
||||
Tcl_DStringFree(&lst);
|
||||
}
|
||||
@ -79,7 +79,7 @@ static void listAllObjectData(SConnection * pCon, char *name, pDummy data)
|
||||
prop = prop->pNext;
|
||||
}
|
||||
}
|
||||
Tcl_DStringAppend(&lst, "ENDLIST", -1);
|
||||
Tcl_DStringAppend(&lst, " ", -1);
|
||||
SCWrite(pCon, Tcl_DStringValue(&lst), eValue);
|
||||
Tcl_DStringFree(&lst);
|
||||
}
|
||||
@ -169,6 +169,18 @@ static int printObjectData(SConnection * pCon, pDummy obj, char *key)
|
||||
}
|
||||
}
|
||||
|
||||
static int existsObjectData(SConnection * pCon, pDummy obj, char *key)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
ptr = IFindOption(obj->pDescriptor->pKeys, key);
|
||||
if (ptr != NULL)
|
||||
SCPrintf(pCon, eValue, "%s", "true");
|
||||
else
|
||||
SCPrintf(pCon, eValue, "%s", "false");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* this function implements a set on top of a list. This means that
|
||||
* the list is first searched for the occurence of name. name is only
|
||||
@ -203,7 +215,7 @@ static void listToString(int list, Tcl_DString * txt)
|
||||
pPtr = (char *) LLDnodePtr(list);
|
||||
if (pPtr != NULL) {
|
||||
Tcl_DStringAppend(txt, pPtr, -1);
|
||||
Tcl_DStringAppend(txt, ",", -1);
|
||||
Tcl_DStringAppend(txt, " ", -1); //ffr "," -> " "
|
||||
}
|
||||
status = LLDnodePtr2Next(list);
|
||||
}
|
||||
@ -234,7 +246,7 @@ static void printKeyTypes(SicsInterp * pSics, SConnection * pCon,
|
||||
}
|
||||
pCom = pCom->pNext;
|
||||
}
|
||||
LLDstringAppend(list, "ENDLIST");
|
||||
LLDstringAppend(list, " ");
|
||||
|
||||
listToString(list, &result);
|
||||
SCWrite(pCon, Tcl_DStringValue(&result), eValue);
|
||||
@ -271,11 +283,11 @@ static void printObjectsMatchingKeyVal(SicsInterp * pSics,
|
||||
}
|
||||
if (status == 1) {
|
||||
Tcl_DStringAppend(&result, pCom->pName, -1);
|
||||
Tcl_DStringAppend(&result, ",", -1);
|
||||
Tcl_DStringAppend(&result, " ", -1); //ffr "," -> " "
|
||||
}
|
||||
pCom = pCom->pNext;
|
||||
}
|
||||
Tcl_DStringAppend(&result, "ENDLIST", -1);
|
||||
Tcl_DStringAppend(&result, " ", -1);
|
||||
SCWrite(pCon, Tcl_DStringValue(&result), eValue);
|
||||
Tcl_DStringFree(&result);
|
||||
}
|
||||
@ -395,7 +407,7 @@ static int printServer(SConnection * pCon)
|
||||
Tcl_DStringAppend(&txt, buffer, -1);
|
||||
current = current->pNext;
|
||||
}
|
||||
Tcl_DStringAppend(&txt, "ENDLIST", -1);
|
||||
Tcl_DStringAppend(&txt, " ", -1);
|
||||
SCWrite(pCon, Tcl_DStringValue(&txt), eValue);
|
||||
Tcl_DStringFree(&txt);
|
||||
return 1;
|
||||
@ -465,11 +477,11 @@ static void printMatch(SConnection * pCon, SicsInterp * pSics, char *mask)
|
||||
while (current != NULL) {
|
||||
if (!match(mask, current->pName)) {
|
||||
Tcl_DStringAppend(&txt, current->pName, -1);
|
||||
Tcl_DStringAppend(&txt, ",", -1);
|
||||
Tcl_DStringAppend(&txt, " ", -1); //ffr "," -> " "
|
||||
}
|
||||
current = current->pNext;
|
||||
}
|
||||
Tcl_DStringAppend(&txt, "ENDLIST", -1);
|
||||
Tcl_DStringAppend(&txt, " ", -1);
|
||||
SCWrite(pCon, Tcl_DStringValue(&txt), eValue);
|
||||
Tcl_DStringFree(&txt);
|
||||
}
|
||||
@ -518,6 +530,21 @@ int SicsList(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "exists") == 0) {
|
||||
if (argc < 4) {
|
||||
SCWrite(pCon, "ERROR: not enough arguments", eError);
|
||||
return 0;
|
||||
} else {
|
||||
pCom = FindCommand(pSics, argv[2]);
|
||||
if (pCom == NULL) {
|
||||
SCWrite(pCon, "ERROR: Object doesn't exist", eError);
|
||||
return 0;
|
||||
} else
|
||||
return existsObjectData(pCon, (pDummy) pCom->pData, argv[3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* object properties
|
||||
*/
|
||||
|
Reference in New Issue
Block a user