static bool QueryRouter( void *theEnv, const char *logicalName, struct router *currentPtr) { /*===================================================*/ /* If the router is inactive, then it can't respond. */ /*===================================================*/ if (currentPtr->active == false) { return(false); } /*=============================================================*/ /* If the router has no query function, then it can't respond. */ /*=============================================================*/ if (currentPtr->query == NULL) return(false); /*=========================================*/ /* Call the router's query function to see */ /* if it recognizes the logical name. */ /*=========================================*/ SetEnvironmentRouterContext(theEnv,currentPtr->context); if ((*currentPtr->query)(theEnv,logicalName) == true) { return(true); } return(false); }
globle void EnvExitRouter( void *theEnv, int num) { struct router *currentPtr, *nextPtr; RouterData(theEnv)->Abort = FALSE; currentPtr = RouterData(theEnv)->ListOfRouters; while (currentPtr != NULL) { nextPtr = currentPtr->next; if (currentPtr->active == TRUE) { if (currentPtr->exiter != NULL) { SetEnvironmentRouterContext(theEnv,currentPtr->context); if (currentPtr->environmentAware) { (*currentPtr->exiter)(theEnv,num); } else { ((int (*)(int))(*currentPtr->exiter))(num); } } } currentPtr = nextPtr; } if (RouterData(theEnv)->Abort) return; genexit(theEnv,num); }
void EnvExitRouter( void *theEnv, int num) { struct router *currentPtr, *nextPtr; RouterData(theEnv)->Abort = false; currentPtr = RouterData(theEnv)->ListOfRouters; while (currentPtr != NULL) { nextPtr = currentPtr->next; if (currentPtr->active == true) { if (currentPtr->exiter != NULL) { SetEnvironmentRouterContext(theEnv,currentPtr->context); (*currentPtr->exiter)(theEnv,num); } } currentPtr = nextPtr; } if (RouterData(theEnv)->Abort) return; genexit(theEnv,num); }
globle int EnvPrintRouter( void *theEnv, EXEC_STATUS, char *logicalName, char *str) { struct router *currentPtr; /*===================================================*/ /* If the "fast save" option is being used, then the */ /* logical name is actually a pointer to a file and */ /* fprintf can be called directly to bypass querying */ /* all of the routers. */ /*===================================================*/ if (((char *) RouterData(theEnv,execStatus)->FastSaveFilePtr) == logicalName) { fprintf(RouterData(theEnv,execStatus)->FastSaveFilePtr,"%s",str); return(2); } /*==============================================*/ /* Search through the list of routers until one */ /* is found that will handle the print request. */ /*==============================================*/ currentPtr = RouterData(theEnv,execStatus)->ListOfRouters; while (currentPtr != NULL) { if ((currentPtr->printer != NULL) ? QueryRouter(theEnv,execStatus,logicalName,currentPtr) : FALSE) { SetEnvironmentRouterContext(theEnv,execStatus,currentPtr->context); if (currentPtr->environmentAware) { (*currentPtr->printer)(theEnv,execStatus,logicalName,str); } else { ((int (*)(char *,char *)) (*currentPtr->printer))(logicalName,str); } return(1); } currentPtr = currentPtr->next; } /*=====================================================*/ /* The logical name was not recognized by any routers. */ /*=====================================================*/ if (strcmp(WERROR,logicalName) != 0) UnrecognizedRouterMessage(theEnv,execStatus,logicalName); return(0); }
static int QueryRouter( void *theEnv, EXEC_STATUS, char *logicalName, struct router *currentPtr) { /*===================================================*/ /* If the router is inactive, then it can't respond. */ /*===================================================*/ if (currentPtr->active == FALSE) { return(FALSE); } /*=============================================================*/ /* If the router has no query function, then it can't respond. */ /*=============================================================*/ if (currentPtr->query == NULL) return(FALSE); /*=========================================*/ /* Call the router's query function to see */ /* if it recognizes the logical name. */ /*=========================================*/ SetEnvironmentRouterContext(theEnv,execStatus,currentPtr->context); if (currentPtr->environmentAware) { if ((*currentPtr->query)(theEnv,execStatus,logicalName) == TRUE) { return(TRUE); } } else { if (((int (*)(char *)) (*currentPtr->query))(logicalName) == TRUE) { return(TRUE); } } return(FALSE); }
globle int EnvUngetcRouter( void *theEnv, int ch, char *logicalName) { struct router *currentPtr; /*===================================================*/ /* If the "fast load" option is being used, then the */ /* logical name is actually a pointer to a file and */ /* ungetc can be called directly to bypass querying */ /* all of the routers. */ /*===================================================*/ if (((char *) RouterData(theEnv)->FastLoadFilePtr) == logicalName) { if ((ch == '\r') || (ch == '\n')) { if (((char *) RouterData(theEnv)->FastLoadFilePtr) == RouterData(theEnv)->LineCountRouter) { DecrementLineCount(theEnv); } } return(ungetc(ch,RouterData(theEnv)->FastLoadFilePtr)); } /*===============================================*/ /* If the "fast string get" option is being used */ /* for the specified logical name, then bypass */ /* the router system and unget the character */ /* directly from the fast get string. */ /*===============================================*/ if (RouterData(theEnv)->FastCharGetRouter == logicalName) { if ((ch == '\r') || (ch == '\n')) { if (RouterData(theEnv)->FastCharGetRouter == RouterData(theEnv)->LineCountRouter) { DecrementLineCount(theEnv); } } if (RouterData(theEnv)->FastCharGetIndex > 0) RouterData(theEnv)->FastCharGetIndex--; return(ch); } /*===============================================*/ /* Search through the list of routers until one */ /* is found that will handle the ungetc request. */ /*===============================================*/ currentPtr = RouterData(theEnv)->ListOfRouters; while (currentPtr != NULL) { if ((currentPtr->charunget != NULL) ? QueryRouter(theEnv,logicalName,currentPtr) : FALSE) { if ((ch == '\r') || (ch == '\n')) { if ((RouterData(theEnv)->LineCountRouter != NULL) && (strcmp(logicalName,RouterData(theEnv)->LineCountRouter) == 0)) { DecrementLineCount(theEnv); } } SetEnvironmentRouterContext(theEnv,currentPtr->context); if (currentPtr->environmentAware) { return((*currentPtr->charunget)(theEnv,ch,logicalName)); } else { return(((int (*)(int,char *)) (*currentPtr->charunget))(ch,logicalName)); } } currentPtr = currentPtr->next; } /*=====================================================*/ /* The logical name was not recognized by any routers. */ /*=====================================================*/ UnrecognizedRouterMessage(theEnv,logicalName); return(-1); }
int EnvGetcRouter( void *theEnv, const char *logicalName) { struct router *currentPtr; int inchar; /*===================================================*/ /* If the "fast load" option is being used, then the */ /* logical name is actually a pointer to a file and */ /* getc can be called directly to bypass querying */ /* all of the routers. */ /*===================================================*/ if (((char *) RouterData(theEnv)->FastLoadFilePtr) == logicalName) { inchar = getc(RouterData(theEnv)->FastLoadFilePtr); if ((inchar == '\r') || (inchar == '\n')) { if (((char *) RouterData(theEnv)->FastLoadFilePtr) == RouterData(theEnv)->LineCountRouter) { IncrementLineCount(theEnv); } } /* if (inchar == '\r') return('\n'); */ return(inchar); } /*===============================================*/ /* If the "fast string get" option is being used */ /* for the specified logical name, then bypass */ /* the router system and extract the character */ /* directly from the fast get string. */ /*===============================================*/ if (RouterData(theEnv)->FastCharGetRouter == logicalName) { inchar = (unsigned char) RouterData(theEnv)->FastCharGetString[RouterData(theEnv)->FastCharGetIndex]; RouterData(theEnv)->FastCharGetIndex++; if (inchar == '\0') return(EOF); if ((inchar == '\r') || (inchar == '\n')) { if (RouterData(theEnv)->FastCharGetRouter == RouterData(theEnv)->LineCountRouter) { IncrementLineCount(theEnv); } } return(inchar); } /*==============================================*/ /* Search through the list of routers until one */ /* is found that will handle the getc request. */ /*==============================================*/ currentPtr = RouterData(theEnv)->ListOfRouters; while (currentPtr != NULL) { if ((currentPtr->charget != NULL) ? QueryRouter(theEnv,logicalName,currentPtr) : false) { SetEnvironmentRouterContext(theEnv,currentPtr->context); inchar = (*currentPtr->charget)(theEnv,logicalName); if ((inchar == '\r') || (inchar == '\n')) { if ((RouterData(theEnv)->LineCountRouter != NULL) && (strcmp(logicalName,RouterData(theEnv)->LineCountRouter) == 0)) { IncrementLineCount(theEnv); } } return(inchar); } currentPtr = currentPtr->next; } /*=====================================================*/ /* The logical name was not recognized by any routers. */ /*=====================================================*/ UnrecognizedRouterMessage(theEnv,logicalName); return(-1); }