void VMsgLog::runCmd( WString &cmd ) { static char buff[MAX_BUFF+1]; addLine( cmd ); blength = 0; buffer[blength] = '\0'; if( !_batserv ) { #ifdef __WINDOWS__ VxDPut( cmd.gets(), cmd.size() + 1 ); for(;;) { int len = VxDGet( buff, MAX_BUFF ); buff[len] = '\0'; if( streq( buff, TERMINATE_COMMAND_STR ) ) { break; } else if( len > 0 ) { scanLine( buff, len ); } } #endif } else { unsigned maxlen; maxlen = BatchMaxCmdLine(); cmd.truncate( maxlen ); BatchSpawn( cmd ); for( ;; ) { WSystemService::sysYield(); //allow other tasks to run unsigned long stat; int len = BatchCollect( buff, MAX_BUFF, &stat ); if( len < 0 ) { break; } else if( len > 0 ) { scanLine( buff, len ); } } } if( strlen( buffer ) > 0 ) { addLine( buffer ); } }
bool VpeMain::executeOne( const WString& cmd ) { int i = 0; WWindowState wstate = WWinStateShowNormal; WWindowType wtype = WWinTypeDefault; if( strnicmp( cmd, "!FullScreen ", 12 ) == 0 ) { i += 12; wtype = WWinTypeFullScreen; } else if( strnicmp( cmd, "!Windowed ", 10 ) == 0 ) { i += 10; wtype = WWinTypeWindowed; } else if( strnicmp( cmd, "!Hidden ", 8 ) == 0 ) { i += 10; wstate = WWinStateHide; } int ret = WSystemService::sysExec( &cmd[i], wstate, wtype ); stopWait(); #ifdef __OS2__ if( ret == -1 ) { // this is a kludge because the WMessageDialog can only handle // finitely long strings WString cmdmsg; cmdmsg = cmd; cmdmsg.truncate( MAX_CMD_LINE ); // // WARNING - this may stop working if WCLASS modifies errno // WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "Unable to run %s: %s.", (const char*)cmdmsg, strerror( errno ) ); return( false ); } #endif #if defined( __WINDOWS__ ) || defined ( __NT__ ) if( ret <= 32 ) { // this is a kludge because the WMessageDialog can only handle // finitely long strings WString cmdmsg; cmdmsg = cmd; cmdmsg.truncate( MAX_CMD_LINE ); switch( ret ) { case 0: WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "%s: Out of memory.", (const char*)cmdmsg ); break; case 2: WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "%s: Program or one of its components not found.", (const char*)cmdmsg ); break; case 3: WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "%s: Path not found.", (const char*)cmdmsg ); break; case 16: WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "%s: Contains multiple writeable data segments.", (const char*)cmdmsg ); break; default: WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "%s: return code=%d.", (const char*)cmdmsg, ret ); } return( false ); } #endif return( true ); }