/******************************************************************* NAME : ListDefmessageHandlers DESCRIPTION : Lists message-handlers for a class INPUTS : 1) The logical name of the output 2) Class name (NULL to display all handlers) 3) A flag indicating whether to list inherited handlers or not RETURNS : Nothing useful SIDE EFFECTS : None NOTES : None *******************************************************************/ globle void ListDefmessageHandlers( char *log, void *vptr, int inhp) { DEFCLASS *cls; long cnt; PACKED_CLASS_LINKS plinks; if (vptr != NULL) { cls = (DEFCLASS *) vptr; if (inhp) cnt = DisplayHandlersInLinks(log,&cls->allSuperclasses,0); else { plinks.classCount = 1; plinks.classArray = &cls; cnt = DisplayHandlersInLinks(log,&plinks,0); } } else { plinks.classCount = 1; cnt = 0L; for (cls = (DEFCLASS *) GetNextDefclass(NULL) ; cls != NULL ; cls = (DEFCLASS *) GetNextDefclass((void *) cls)) { plinks.classArray = &cls; cnt += DisplayHandlersInLinks(log,&plinks,0); } } PrintTally(log,cnt,"message-handler","message-handlers"); }
globle void EnvListDefmodules( void *theEnv, char *logicalName) { void *theModule; int count = 0; for (theModule = EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = EnvGetNextDefmodule(theEnv,theModule)) { EnvPrintRouter(theEnv,logicalName,EnvGetDefmoduleName(theEnv,theModule)); EnvPrintRouter(theEnv,logicalName,"\n"); count++; } PrintTally(theEnv,logicalName,count,"defmodule","defmodules"); }
globle void EnvFacts( void *theEnv, char *logicalName, void *vTheModule, long long start, long long end, long long max) { struct fact *factPtr; long count = 0; struct defmodule *oldModule, *theModule = (struct defmodule *) vTheModule; int allModules = FALSE; /*==========================*/ /* Save the current module. */ /*==========================*/ oldModule = ((struct defmodule *) EnvGetCurrentModule(theEnv)); /*=========================================================*/ /* Determine if facts from all modules are to be displayed */ /* or just facts from the current module. */ /*=========================================================*/ if (theModule == NULL) allModules = TRUE; else EnvSetCurrentModule(theEnv,(void *) theModule); /*=====================================*/ /* Get the first fact to be displayed. */ /*=====================================*/ if (allModules) factPtr = (struct fact *) EnvGetNextFact(theEnv,NULL); else factPtr = (struct fact *) GetNextFactInScope(theEnv,NULL); /*===============================*/ /* Display facts until there are */ /* no more facts to display. */ /*===============================*/ while (factPtr != NULL) { /*==================================================*/ /* Abort the display of facts if the Halt Execution */ /* flag has been set (normally by user action). */ /*==================================================*/ if (GetHaltExecution(theEnv) == TRUE) { EnvSetCurrentModule(theEnv,(void *) oldModule); return; } /*===============================================*/ /* If the maximum fact index of facts to display */ /* has been reached, then stop displaying facts. */ /*===============================================*/ if ((factPtr->factIndex > end) && (end != UNSPECIFIED)) { PrintTally(theEnv,logicalName,count,(char*)"fact",(char*)"facts"); EnvSetCurrentModule(theEnv,(void *) oldModule); return; } /*================================================*/ /* If the maximum number of facts to be displayed */ /* has been reached, then stop displaying facts. */ /*================================================*/ if (max == 0) { PrintTally(theEnv,logicalName,count,(char*)"fact",(char*)"facts"); EnvSetCurrentModule(theEnv,(void *) oldModule); return; } /*======================================================*/ /* If the index of the fact is greater than the minimum */ /* starting fact index, then display the fact. */ /*======================================================*/ if (factPtr->factIndex >= start) { PrintFactWithIdentifier(theEnv,logicalName,factPtr); EnvPrintRouter(theEnv,logicalName,(char*)"\n"); count++; if (max > 0) max--; } /*========================================*/ /* Proceed to the next fact to be listed. */ /*========================================*/ if (allModules) factPtr = (struct fact *) EnvGetNextFact(theEnv,factPtr); else factPtr = (struct fact *) GetNextFactInScope(theEnv,factPtr); } /*===================================================*/ /* Print the total of the number of facts displayed. */ /*===================================================*/ PrintTally(theEnv,logicalName,count,(char*)"fact",(char*)"facts"); /*=============================*/ /* Restore the current module. */ /*=============================*/ EnvSetCurrentModule(theEnv,(void *) oldModule); }
globle void ListItemsDriver( void *theEnv, EXEC_STATUS, char *logicalName, struct defmodule *theModule, char *singleName, char *pluralName, void *(*nextFunction)(void *,EXEC_STATUS,void *), char *(*nameFunction)(void *,EXEC_STATUS), void (*printFunction)(void *,EXEC_STATUS,char *,void *), int (*doItFunction)(void *,EXEC_STATUS,void *)) { void *constructPtr; char *constructName; long count = 0; int allModules = FALSE; int doIt; /*==========================*/ /* Save the current module. */ /*==========================*/ SaveCurrentModule(theEnv,execStatus); /*======================*/ /* Print out the items. */ /*======================*/ if (theModule == NULL) { theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,NULL); allModules = TRUE; } while (theModule != NULL) { if (allModules) { EnvPrintRouter(theEnv,execStatus,logicalName,EnvGetDefmoduleName(theEnv,execStatus,theModule)); EnvPrintRouter(theEnv,execStatus,logicalName,":\n"); } EnvSetCurrentModule(theEnv,execStatus,(void *) theModule); constructPtr = (*nextFunction)(theEnv,execStatus,NULL); while (constructPtr != NULL) { if (execStatus->HaltExecution == TRUE) return; if (doItFunction == NULL) doIt = TRUE; else doIt = (*doItFunction)(theEnv,execStatus,constructPtr); if (! doIt) {} else if (nameFunction != NULL) { constructName = (*nameFunction)(constructPtr,execStatus); if (constructName != NULL) { if (allModules) EnvPrintRouter(theEnv,execStatus,logicalName," "); EnvPrintRouter(theEnv,execStatus,logicalName,constructName); EnvPrintRouter(theEnv,execStatus,logicalName,"\n"); } } else if (printFunction != NULL) { if (allModules) EnvPrintRouter(theEnv,execStatus,logicalName," "); (*printFunction)(theEnv,execStatus,logicalName,constructPtr); EnvPrintRouter(theEnv,execStatus,logicalName,"\n"); } constructPtr = (*nextFunction)(theEnv,execStatus,constructPtr); count++; } if (allModules) theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,theModule); else theModule = NULL; } /*=================================================*/ /* Print the tally and restore the current module. */ /*=================================================*/ if (singleName != NULL) PrintTally(theEnv,execStatus,logicalName,count,singleName,pluralName); RestoreCurrentModule(theEnv,execStatus); }