From 4efc67821d50eb3e4abcdfb4dc97fbd513c883b4 Mon Sep 17 00:00:00 2001 From: zolliker Date: Wed, 13 Feb 2008 09:47:25 +0000 Subject: [PATCH] - introduced ForEachCommand function --- SCinter.c | 16 ++++++++++++++++ SCinter.h | 11 +++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/SCinter.c b/SCinter.c index 0ccf8e78..c74ac636 100644 --- a/SCinter.c +++ b/SCinter.c @@ -1109,3 +1109,19 @@ char *FindAliases(SicsInterp *pSics, char *name) DeleteDynString(result); 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; + } + } +} diff --git a/SCinter.h b/SCinter.h index 3c60dea8..411cbdef 100644 --- a/SCinter.h +++ b/SCinter.h @@ -9,6 +9,7 @@ ---------------------------------------------------------------------------*/ #ifndef SICSINTERPRETER #define SICSINTERPRETER +#include "obdes.h" #include "Scommon.h" #include "statistics.h" #include @@ -151,10 +152,16 @@ typedef struct __SINTER 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 be cast to the drivable interface pointer. - ------------------------------------------------------------------------*/ - +*/ 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 ------------------------------------------------------------------------*/