- introduced ForEachCommand function

This commit is contained in:
zolliker
2008-02-13 09:47:25 +00:00
parent 4954522ef8
commit 4efc67821d
2 changed files with 25 additions and 2 deletions

View File

@ -1109,3 +1109,19 @@ char *FindAliases(SicsInterp *pSics, char *name)
DeleteDynString(result); DeleteDynString(result);
return charResult; return charResult;
} }
/*---------------------------------------------------------------------*/
void ForEachCommand(int (*scanFunction)(char *name, pDummy object, void *userData)
, void *userData)
{
CommandList *pCurrent;
for(pCurrent = pServ->pSics->pCList;
pCurrent != NULL;
pCurrent = pCurrent->pNext)
{
if(scanFunction(pCurrent->pName, pCurrent->pData, userData) == 0) {
return;
}
}
}

View File

@ -9,6 +9,7 @@
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#ifndef SICSINTERPRETER #ifndef SICSINTERPRETER
#define SICSINTERPRETER #define SICSINTERPRETER
#include "obdes.h"
#include "Scommon.h" #include "Scommon.h"
#include "statistics.h" #include "statistics.h"
#include <tcl.h> #include <tcl.h>
@ -151,10 +152,16 @@ typedef struct __SINTER
pointer to the drivable interface in the case of success, NULL in pointer to the drivable interface in the case of success, NULL in
case of failure. In order to save me fixing header files the pointer must case of failure. In order to save me fixing header files the pointer must
be cast to the drivable interface pointer. be cast to the drivable interface pointer.
------------------------------------------------------------------------*/ */
void *FindDrivable(SicsInterp *pics, char *name); void *FindDrivable(SicsInterp *pics, char *name);
/*------------------------------------------------------------------------
Go through the command list and call scanFunction for every command
until the return value is 0.
*/
void ForEachCommand(int (*scanFunction)(char *name, pDummy object, void *userData)
, void *userData);
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
Get a copy of the Tcl interpreter Get a copy of the Tcl interpreter
------------------------------------------------------------------------*/ ------------------------------------------------------------------------*/