globle void Dependents( void *theEnv, struct patternEntity *theEntity) { struct patternEntity *entityPtr = NULL; struct patternParser *theParser = NULL; struct dependency *fdPtr; struct partialMatch *theBinds; int found = FALSE; /*=================================*/ /* Loop through every data entity. */ /*=================================*/ for (GetNextPatternEntity(theEnv,&theParser,&entityPtr); entityPtr != NULL; GetNextPatternEntity(theEnv,&theParser,&entityPtr)) { if (EnvGetHaltExecution(theEnv) == TRUE) return; /*====================================*/ /* Loop through every dependency link */ /* associated with the data entity. */ /*====================================*/ for (fdPtr = (struct dependency *) entityPtr->dependents; fdPtr != NULL; fdPtr = fdPtr->next) { if (EnvGetHaltExecution(theEnv) == TRUE) return; /*=====================================================*/ /* If the data entity which was the argument passed to */ /* the dependents command is contained in one of the */ /* partial matches of the data entity currently being */ /* examined, then the data entity being examined is a */ /* dependent. Print the data entity and then move on */ /* to the next data entity. */ /*=====================================================*/ theBinds = (struct partialMatch *) fdPtr->dPtr; if (FindEntityInPartialMatch(theEntity,theBinds) == TRUE) { if (found) EnvPrintRouter(theEnv,WDISPLAY,","); (*entityPtr->theInfo->base.shortPrintFunction)(theEnv,WDISPLAY,entityPtr); found = TRUE; break; } } } /*=================================================*/ /* If no dependents were found, then print "None." */ /* Otherwise print a carriage return after the */ /* list of dependents. */ /*=================================================*/ if (! found) EnvPrintRouter(theEnv,WDISPLAY,"None\n"); else EnvPrintRouter(theEnv,WDISPLAY,"\n"); }
void CommandLoop( void *theEnv) { int inchar; EnvPrintRouter(theEnv,WPROMPT,CommandLineData(theEnv)->BannerString); EnvSetHaltExecution(theEnv,false); EnvSetEvaluationError(theEnv,false); CleanCurrentGarbageFrame(theEnv,NULL); CallPeriodicTasks(theEnv); PrintPrompt(theEnv); RouterData(theEnv)->CommandBufferInputCount = 0; RouterData(theEnv)->AwaitingInput = true; while (true) { /*===================================================*/ /* If a batch file is active, grab the command input */ /* directly from the batch file, otherwise call the */ /* event function. */ /*===================================================*/ if (BatchActive(theEnv) == true) { inchar = LLGetcBatch(theEnv,STDIN,true); if (inchar == EOF) { (*CommandLineData(theEnv)->EventFunction)(theEnv); } else { ExpandCommandString(theEnv,(char) inchar); } } else { (*CommandLineData(theEnv)->EventFunction)(theEnv); } /*=================================================*/ /* If execution was halted, then remove everything */ /* from the command buffer. */ /*=================================================*/ if (EnvGetHaltExecution(theEnv) == true) { EnvSetHaltExecution(theEnv,false); EnvSetEvaluationError(theEnv,false); FlushCommandString(theEnv); #if ! WINDOW_INTERFACE fflush(stdin); #endif EnvPrintRouter(theEnv,WPROMPT,"\n"); PrintPrompt(theEnv); } /*=========================================*/ /* If a complete command is in the command */ /* buffer, then execute it. */ /*=========================================*/ ExecuteIfCommandComplete(theEnv); } }
globle void Dependencies( void *theEnv, struct patternEntity *theEntity) { struct dependency *fdPtr; /*=========================================*/ /* If the data entity has no dependencies, */ /* then print "None" and return. */ /*=========================================*/ if (theEntity->dependents == NULL) { EnvPrintRouter(theEnv,WDISPLAY,"None\n"); return; } /*============================================*/ /* Loop through the list of the data entities */ /* dependencies and print them. */ /*============================================*/ for (fdPtr = (struct dependency *) theEntity->dependents; fdPtr != NULL; fdPtr = fdPtr->next) { if (EnvGetHaltExecution(theEnv) == TRUE) return; PrintPartialMatch(theEnv,WDISPLAY,(struct partialMatch *) fdPtr->dPtr); EnvPrintRouter(theEnv,WDISPLAY,"\n"); } }
void CommandLoopBatchDriver( void *theEnv) { int inchar; while (true) { if (GetHaltCommandLoopBatch(theEnv) == true) { CloseAllBatchSources(theEnv); SetHaltCommandLoopBatch(theEnv,false); } /*===================================================*/ /* If a batch file is active, grab the command input */ /* directly from the batch file, otherwise call the */ /* event function. */ /*===================================================*/ if (BatchActive(theEnv) == true) { inchar = LLGetcBatch(theEnv,STDIN,true); if (inchar == EOF) { return; } else { ExpandCommandString(theEnv,(char) inchar); } } else { return; } /*=================================================*/ /* If execution was halted, then remove everything */ /* from the command buffer. */ /*=================================================*/ if (EnvGetHaltExecution(theEnv) == true) { EnvSetHaltExecution(theEnv,false); EnvSetEvaluationError(theEnv,false); FlushCommandString(theEnv); #if ! WINDOW_INTERFACE fflush(stdin); #endif EnvPrintRouter(theEnv,WPROMPT,"\n"); PrintPrompt(theEnv); } /*=========================================*/ /* If a complete command is in the command */ /* buffer, then execute it. */ /*=========================================*/ ExecuteIfCommandComplete(theEnv); } }
void EnvReset( void *theEnv) { struct callFunctionItem *resetPtr; /*=====================================*/ /* The reset command can't be executed */ /* while a reset is in progress. */ /*=====================================*/ if (ConstructData(theEnv)->ResetInProgress) return; ConstructData(theEnv)->ResetInProgress = true; ConstructData(theEnv)->ResetReadyInProgress = true; /*================================================*/ /* If the reset is performed from the top level */ /* command prompt, reset the halt execution flag. */ /*================================================*/ if (UtilityData(theEnv)->CurrentGarbageFrame->topLevel) EnvSetHaltExecution(theEnv,false); /*=======================================================*/ /* Call the before reset function to determine if the */ /* reset should continue. [Used by the some of the */ /* windowed interfaces to query the user whether a */ /* reset should proceed with activations on the agenda.] */ /*=======================================================*/ if ((ConstructData(theEnv)->BeforeResetFunction != NULL) ? ((*ConstructData(theEnv)->BeforeResetFunction)(theEnv) == false) : false) { ConstructData(theEnv)->ResetReadyInProgress = false; ConstructData(theEnv)->ResetInProgress = false; return; } ConstructData(theEnv)->ResetReadyInProgress = false; /*===========================*/ /* Call each reset function. */ /*===========================*/ for (resetPtr = ConstructData(theEnv)->ListOfResetFunctions; (resetPtr != NULL) && (EnvGetHaltExecution(theEnv) == false); resetPtr = resetPtr->next) { (*resetPtr->func)(theEnv); } /*============================================*/ /* Set the current module to the MAIN module. */ /*============================================*/ EnvSetCurrentModule(theEnv,(void *) EnvFindDefmodule(theEnv,"MAIN")); /*===========================================*/ /* Perform periodic cleanup if the reset was */ /* issued from an embedded controller. */ /*===========================================*/ if ((UtilityData(theEnv)->CurrentGarbageFrame->topLevel) && (! CommandLineData(theEnv)->EvaluatingTopLevelCommand) && (EvaluationData(theEnv)->CurrentExpression == NULL) && (UtilityData(theEnv)->GarbageCollectionLocks == 0)) { CleanCurrentGarbageFrame(theEnv,NULL); CallPeriodicTasks(theEnv); } /*===================================*/ /* A reset is no longer in progress. */ /*===================================*/ ConstructData(theEnv)->ResetInProgress = false; }
globle void EnvFacts( void *theEnv, const 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 (EnvGetHaltExecution(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,"fact","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,"fact","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,"\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,"fact","facts"); /*=============================*/ /* Restore the current module. */ /*=============================*/ EnvSetCurrentModule(theEnv,(void *) oldModule); }