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 CommandLoop( void *theEnv) { int inchar; EnvPrintRouter(theEnv,WPROMPT,CommandLineData(theEnv)->BannerString); SetHaltExecution(theEnv,FALSE); SetEvaluationError(theEnv,FALSE); PeriodicCleanup(theEnv,TRUE,FALSE); PrintPrompt(theEnv); RouterData(theEnv)->CommandBufferInputCount = 0; 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 (GetHaltExecution(theEnv) == TRUE) { SetHaltExecution(theEnv,FALSE); SetEvaluationError(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 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); } }
HDDEDATA CALLBACK DDECallBack( UINT uType, UINT uFmt, HCONV hconv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, DWORD dwData1, DWORD dwData2) { #if MAC_MCW || WIN_MCW || MAC_XCD #pragma unused(hconv) #pragma unused(dwData1) #pragma unused(dwData2) #endif extern HSZ hszService; extern char CompleteString[255]; DWORD size; HWND hWnd; char *TheData; char *Data; char *theString; void *theEnv = GetCurrentEnvironment(); /* char theBuffer[100]; DWORD cb; PSTR pszTopicName; */ switch (uType) { case XTYP_ADVDATA: case XTYP_POKE: return ((HDDEDATA) DDE_FNOTPROCESSED); case XTYP_ADVREQ: case XTYP_WILDCONNECT: return ((HDDEDATA) NULL); case XTYP_ADVSTART: case XTYP_ADVSTOP: case XTYP_CONNECT_CONFIRM: case XTYP_DISCONNECT: case XTYP_ERROR: case XTYP_REGISTER: case XTYP_UNREGISTER: case XTYP_XACT_COMPLETE: return ((HDDEDATA) FALSE); case XTYP_MONITOR: return ((HDDEDATA) TRUE); case XTYP_CONNECT: /* cb = DdeQueryString(idInst,hsz1,(LPSTR) NULL, 0,CP_WINANSI) + 1; pszTopicName = (PSTR) LocalAlloc(LPTR, (UINT) cb); DdeQueryString(idInst,hsz1, pszTopicName,cb,CP_WINANSI); cb = DdeQueryString(idInst,hsz2,(LPSTR) NULL, 0,CP_WINANSI) + 1; pszTopicName = (PSTR) LocalAlloc(LPTR, (UINT) cb); DdeQueryString(idInst,hsz2, pszTopicName,cb,CP_WINANSI); */ DDE_RV.type = RVOID; if (hsz2 != hszService) { return ((HDDEDATA) FALSE); } return((HDDEDATA) TRUE); /*--------------------------------------------------+ | Get completed command and return result to client | +--------------------------------------------------*/ case XTYP_REQUEST: if (uFmt != CF_TEXT) { return(NULL); } /* sprintf(theBuffer,"XTYP_REQUEST uFmt = %d\n",(int) uFmt); PrintRouter(WDISPLAY,theBuffer); */ hData = NULL; if (hsz1 == hszCommand) { theString = DataObjectToString(GetCurrentEnvironment(),&DDE_RV); hData = DdeCreateDataHandle (idInst, (unsigned char *) theString, strlen(theString)+1, 0L, hsz2,CF_TEXT,0); } return (hData); case XTYP_EXECUTE: SetFocus(DialogWindow); if (CommandLineData(GetCurrentEnvironment())->EvaluatingTopLevelCommand || BatchActive(GetCurrentEnvironment()) ) { return ((HDDEDATA) DDE_FBUSY ); } Data = (char *) DdeAccessData ( hData, NULL); size = strlen((char *) Data) + 1; TheData = (char *) genalloc ( GetCurrentEnvironment(),(unsigned) size ); DdeGetData ( hData, (LPBYTE)TheData, size, 0L ); EnvPrintRouter(theEnv,WPROMPT,TheData); EnvPrintRouter(theEnv,WPROMPT,"\n"); EnvEval(theEnv,TheData,&DDE_RV); if (DDE_RV.type != RVOID) { PrintDataObject(GetCurrentEnvironment(),"stdout",&DDE_RV); EnvPrintRouter(theEnv,"stdout","\n"); } PrintPrompt(theEnv); DdeUnaccessData(hData); hWnd = FindWindow("ClipsEditWClass", NULL); SetFocus (hWnd); return ((HDDEDATA) DDE_FACK); } return ( (HDDEDATA) TRUE ); }