void ConsoleController::EvaluateCommand(std::string command) { if(command.length()) { if (command.substr(0, 6) == "!load ") CloseConsole(); int returnCode = commandInterface->Command(command); consoleModel->AddLastCommand(ConsoleCommand(command, returnCode, commandInterface->GetLastError())); } else CloseConsole(); }
//--------------------------------------------------------------------------- WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { if(CONSOLE) OpenConsole(); try { Application->Initialize(); Application->CreateForm(__classid(TMainCaptureForm), &MainCaptureForm); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { Application->ShowException(&exception); } } if(CONSOLE) CloseConsole(); return 0; }
//int ExitFunction( char *message, FireFlyUSB *FireFly, Authenticate* X15Authenticate, int retCode ) int ExitFunction( const char message[], FireFlyUSB *FireFly, Authenticate* X15Authenticate, int retCode ) { printf( "%s\n", message ); if ( FireFly->GetLastError( ) != USB_MESSAGE_EXECUTION_SUCCESS ) { printf( "X10 Error Code: %d\n", (int)FireFly->GetLastError( ) ); } // Clean up the authentication thread if ( X15Authenticate ) { X15Authenticate->KillThread( ); } // Close device. if ( !FireFly->close( ) ) { printf( "\nError closing device - %d.\n\n", (int)FireFly->GetLastError( ) ); } #ifdef X10_LINUX_BUILD CloseConsole( ); #endif // return( retCode ); exit( retCode ); }
void cleanup() { if(OpenedConsole) CloseConsole(writeReq); if(readReq) DeleteExtIO(readReq); if(readPort) DeletePort(readPort); if(writeReq) DeleteExtIO(writeReq); if(writePort) DeletePort(writePort); if(win) CloseWindow(win); if(IntuitionBase) CloseLibrary(IntuitionBase); }
void CApplication::ToggleConsole() { if (!Get()) return; CConsole* pConsole = Get()->GetConsole(); if (IsConsoleOpen()) CloseConsole(); else OpenConsole(); }
void CloseIO(void) { if(consoleyes) CloseConsole(); if(conreadreq) DeleteExtIO((struct IORequest *)conreadreq); if(conreadport) DeleteMsgPort(conreadport); if(conwritereq) DeleteExtIO((struct IORequest *)conwritereq); if(conwriteport) DeleteMsgPort(conwriteport); if(timeryes) CloseTimer(timerreq); if(timerreq) DeleteExtIO((struct IORequest *)timerreq); if(timerport) DeleteMsgPort(timerport); }
//アプリケーションの解放 void Application::Release() { //デバッグビルド時にビープ音を鳴らす #if defined (DEBUG) | defined(_DEBUG) MessageBeep(MB_OK); #endif //コンソールを閉じる CloseConsole(); //モデルのテンプレートを破棄する SafeRelease(d3dDevice); SafeRelease(direct3d); SafeRelease(directInput); }
void Log::RemoveOutput(int output) { Lock lock(this); if (output & LOG_OUTPUT) { _logoutput = false; } if (output & LOG_FILE) { CloseFile(); } if (output & LOG_CONSOLE) { CloseConsole(); } if (output & LOG_TIME) { _logtime = false; } }
static Boolean ConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type, XtPointer *value, unsigned long *length, int *format) { Display* d = XtDisplay(w); XSelectionRequestEvent* req = XtGetSelectionRequest(w, *selection, (XtRequestId)NULL); if (*target == XA_TARGETS(d)) { Atom* targetP; Atom* std_targets; unsigned long std_length; XmuConvertStandardSelection(w, req->time, selection, target, type, (XPointer *)&std_targets, &std_length, format); *value = (XtPointer)XtMalloc(sizeof(Atom)*(std_length + 5)); targetP = *(Atom**)value; *targetP++ = XA_STRING; *targetP++ = XA_TEXT(d); *targetP++ = XA_LENGTH(d); *targetP++ = XA_LIST_LENGTH(d); *targetP++ = XA_CHARACTER_POSITION(d); *length = std_length + (targetP - (*(Atom **) value)); memmove( (char*)targetP, (char*)std_targets, sizeof(Atom)*std_length); XtFree((char*)std_targets); *type = XA_ATOM; *format = 32; return True; } if (*target == XA_LIST_LENGTH(d) || *target == XA_LENGTH(d)) { long * temp; temp = (long *) XtMalloc(sizeof(long)); if (*target == XA_LIST_LENGTH(d)) *temp = 1L; else /* *target == XA_LENGTH(d) */ *temp = (long) TextLength (text); *value = (XtPointer) temp; *type = XA_INTEGER; *length = 1L; *format = 32; return True; } if (*target == XA_CHARACTER_POSITION(d)) { long * temp; temp = (long *) XtMalloc(2 * sizeof(long)); temp[0] = (long) 0; temp[1] = TextLength (text); *value = (XtPointer) temp; *type = XA_SPAN(d); *length = 2L; *format = 32; return True; } if (*target == XA_STRING || *target == XA_TEXT(d) || *target == XA_COMPOUND_TEXT(d)) { if (*target == XA_COMPOUND_TEXT(d)) *type = *target; else *type = XA_STRING; *length = TextLength (text); *value = (XtPointer)_XawTextGetSTRING((TextWidget) text, 0, *length); *format = 8; /* * Drop our connection to the file; the new console program * will open as soon as it receives the selection contents; there * is a small window where console output will not be redirected, * but I see no way of avoiding that without having two programs * attempt to redirect console output at the same time, which seems * worse */ CloseConsole (); return True; } if (XmuConvertStandardSelection(w, req->time, selection, target, type, (XPointer *)value, length, format)) return True; return False; }
static int MainProcess( const wchar_t *lpwszEditName, const wchar_t *lpwszViewName, const wchar_t *lpwszDestName1, const wchar_t *lpwszDestName2, int StartLine, int StartChar ) { { ChangePriority ChPriority(ChangePriority::NORMAL); ControlObject CtrlObj; WORD InitAttributes=0; Console.GetTextAttributes(InitAttributes); SetRealColor(COL_COMMANDLINEUSERSCREEN); if (*lpwszEditName || *lpwszViewName) { Opt.OnlyEditorViewerUsed=1; Panel *DummyPanel=new Panel; _tran(SysLog(L"create dummy panels")); CtrlObj.CreateFilePanels(); CtrlObj.Cp()->LeftPanel=CtrlObj.Cp()->RightPanel=CtrlObj.Cp()->ActivePanel=DummyPanel; CtrlObj.Plugins.LoadPlugins(); CtrlObj.Macro.LoadMacros(TRUE,FALSE); if (*lpwszEditName) { FileEditor *ShellEditor=new FileEditor(lpwszEditName,CP_AUTODETECT,FFILEEDIT_CANNEWFILE|FFILEEDIT_ENABLEF6,StartLine,StartChar); _tran(SysLog(L"make shelleditor %p",ShellEditor)); if (!ShellEditor->GetExitCode()) // ???????????? { FrameManager->ExitMainLoop(0); } } // TODO: Этот else убрать только после разборок с возможностью задавать несколько /e и /v в ком.строке else if (*lpwszViewName) { FileViewer *ShellViewer=new FileViewer(lpwszViewName,FALSE); if (!ShellViewer->GetExitCode()) { FrameManager->ExitMainLoop(0); } _tran(SysLog(L"make shellviewer, %p",ShellViewer)); } FrameManager->EnterMainLoop(); CtrlObj.Cp()->LeftPanel=CtrlObj.Cp()->RightPanel=CtrlObj.Cp()->ActivePanel=nullptr; delete DummyPanel; _tran(SysLog(L"editor/viewer closed, delete dummy panels")); } else { Opt.OnlyEditorViewerUsed=0; Opt.SetupArgv=0; FARString strPath; // воспользуемся тем, что ControlObject::Init() создает панели // юзая Opt.* if (*lpwszDestName1) // актиная панель { Opt.SetupArgv++; strPath = lpwszDestName1; CutToNameUNC(strPath); DeleteEndSlash(strPath); //BUGBUG!! если конечный слешь не убрать - получаем забавный эффект - отсутствует ".." // if ((strPath.At(1)==L':' && !strPath.At(2)) || (HasPathPrefix(strPath) && strPath.At(5)==L':' && !strPath.At(6))) // AddEndSlash(strPath); // Та панель, которая имеет фокус - активна (начнем по традиции с Левой Панели ;-) if (Opt.LeftPanel.Focus) { Opt.LeftPanel.Type=FILE_PANEL; // сменим моду панели Opt.LeftPanel.Visible=TRUE; // и включим ее Opt.strLeftFolder = strPath; } else { Opt.RightPanel.Type=FILE_PANEL; Opt.RightPanel.Visible=TRUE; Opt.strRightFolder = strPath; } if (*lpwszDestName2) // пассивная панель { Opt.SetupArgv++; strPath = lpwszDestName2; CutToNameUNC(strPath); DeleteEndSlash(strPath); //BUGBUG!! если конечный слешь не убрать - получаем забавный эффект - отсутствует ".." // if ((strPath.At(1)==L':' && !strPath.At(2)) || (HasPathPrefix(strPath) && strPath.At(5)==L':' && !strPath.At(6))) // AddEndSlash(strPath); // а здесь с точнотью наоборот - обрабатываем пассивную панель if (Opt.LeftPanel.Focus) { Opt.RightPanel.Type=FILE_PANEL; // сменим моду панели Opt.RightPanel.Visible=TRUE; // и включим ее Opt.strRightFolder = strPath; } else { Opt.LeftPanel.Type=FILE_PANEL; Opt.LeftPanel.Visible=TRUE; Opt.strLeftFolder = strPath; } } } // теперь все готово - создаем панели! CtrlObj.Init(); // а теперь "провалимся" в каталог или хост-файл (если получится ;-) if (*lpwszDestName1) // актиная панель { FARString strCurDir; Panel *ActivePanel=CtrlObject->Cp()->ActivePanel; Panel *AnotherPanel=CtrlObject->Cp()->GetAnotherPanel(ActivePanel); if (*lpwszDestName2) // пассивная панель { AnotherPanel->GetCurDir(strCurDir); FarChDir(strCurDir); if (IsPluginPrefixPath(lpwszDestName2)) { AnotherPanel->SetFocus(); CtrlObject->CmdLine->ExecString(lpwszDestName2,0); ActivePanel->SetFocus(); } else { strPath = PointToNameUNC(lpwszDestName2); if (!strPath.IsEmpty()) { if (AnotherPanel->GoToFile(strPath)) AnotherPanel->ProcessKey(KEY_CTRLPGDN); } } } ActivePanel->GetCurDir(strCurDir); FarChDir(strCurDir); if (IsPluginPrefixPath(lpwszDestName1)) { CtrlObject->CmdLine->ExecString(lpwszDestName1,0); } else { strPath = PointToNameUNC(lpwszDestName1); if (!strPath.IsEmpty()) { if (ActivePanel->GoToFile(strPath)) ActivePanel->ProcessKey(KEY_CTRLPGDN); } } // !!! ВНИМАНИЕ !!! // Сначала редравим пассивную панель, а потом активную! AnotherPanel->Redraw(); ActivePanel->Redraw(); } FrameManager->EnterMainLoop(); } // очистим за собой! SetScreen(0,0,ScrX,ScrY,L' ',COL_COMMANDLINEUSERSCREEN); Console.SetTextAttributes(InitAttributes); ScrBuf.ResetShadow(); ScrBuf.Flush(); MoveRealCursor(0,0); } CloseConsole(); return 0; }
Log::~Log() { CloseFile(); CloseConsole(); }
void main(int argc,char *argv[]) { int going=TRUE,forsok=2,car=1,x,connectbps, i, tmp; struct NodeType *nt; char *tmppscreen,commandstring[100], configname[50] = "NiKom:DatoCfg/SerNode.cfg"; FILE *fil; if(argc>1) for(x=1; x<argc; x++) { if(argv[x][0]=='-') { if(argv[x][1]=='G') getty=TRUE; else if(argv[x][1]=='B') gettybps=atoi(&argv[x][2]); else if(argv[x][1]=='C') connectbps = atoi(&argv[x][2]); } else strcpy(configname,argv[x]); } if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(ERROR,"Kunde inte öppna utility.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(ERROR,"Kunde inte öppna nikom.library\n"); if(!initnode(NODSER)) cleanup(ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomPreRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(ERROR,"Kunde inte öppna rexxsyslib.library\n"); getnodeconfig(configname); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=openmywindow(tmppscreen))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); if(getty) dtespeed = gettybps; else dtespeed = highbaud; if(!OpenIO(NiKwind)) cleanup(ERROR,"Couldn't setup IO"); strcpy(Servermem->nodid[nodnr],nodid); conreqtkn(); serreqtkn(); Delay(50); for(;;) { inloggad=-1; Servermem->idletime[nodnr] = time(NULL); Servermem->inloggad[nodnr]=-1; if(getty) Servermem->connectbps[nodnr] = connectbps; else waitconnect(); Servermem->idletime[nodnr] = time(NULL); Servermem->inloggad[nodnr]=-2; /* Sätt till <Uppringd> för att även hantera -getty-fallet */ reloginspec: updateinactive(); Servermem->inne[nodnr].flaggor = Servermem->cfg.defaultflags; if(!getty) Delay(100); Servermem->inne[nodnr].rader=0; Servermem->inne[nodnr].chrset = CHRS_LATIN1; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendrexx(Servermem->cfg.ar.preinlogg); car=TRUE; Servermem->inne[nodnr].chrset = 0; memset(commandhistory,0,1000); going=1; while(going && going<=Servermem->cfg.logintries) { putstring("\r\nNamn: ",-1,0); if(getstring(EKO,40,NULL)) { car=FALSE; break; } if(!stricmp(inmat,Servermem->cfg.ny) && !(Servermem->cfg.cfgflags & NICFG_CLOSEDBBS)) { tmp = RegisterNewUser(); if(tmp == 2) { goto panik; } car = tmp ? 0 : 1; going=FALSE; } else if((inloggad=parsenamn(inmat))>=0) { if(readuser(inloggad,&Servermem->inne[nodnr])) { puttekn("Error reading user data.\r\n", -1); goto panik; } // TODO: Extract password loop. Should be identical to in NiKomCon.c forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) { if(getstring(STAREKO,15,NULL)) { car=FALSE; break; } } else { if(getstring(EJEKO,15,NULL)) { car=FALSE; break; } } if(CheckPassword(inmat, Servermem->inne[nodnr].losen)) { forsok=FALSE; going=FALSE; } else forsok--; } if(going && (Servermem->cfg.logmask & LOG_FAILINLOGG)) { LogEvent(USAGE_LOG, WARN, "Nod %d, %s angivet som namn, fel lösen.", nodnr, getusername(inloggad)); } if(going) going++; } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } if(!car) { if(getty) cleanup(OK,""); disconnect(); continue; } if(going) { putstring("\n\n\rTyvärr. Du har försökt maximalt antal gånger att logga in. Kopplar ned.\n\r",-1,0); goto panik; /* Urrk vad fult. :-) */ } Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if((nt = selectNodeType()) == NULL) { goto panik; } abortinactive(); abortserial(); sprintf(commandstring,"%s -N%d -B%d %s",nt->path,nodnr,dtespeed,configname); CloseConsole(); CloseWindow(NiKwind); NiKwind = NULL; RemPort(nikomnodeport); i = 0; if(Servermem->connectbps[nodnr] > 0) { while(Servermem->info.bps[i] != Servermem->connectbps[nodnr] && Servermem->info.bps[i] > 0 && i<49) i++; if(i<49) { if(Servermem->info.bps[i] == Servermem->connectbps[nodnr]) Servermem->info.antbps[i]++; else { Servermem->info.bps[i] = Servermem->connectbps[nodnr]; Servermem->info.antbps[i]++; } } if(!(fil = fopen("NiKom:datocfg/sysinfo.dat","w"))) { /* putstring("Kunde inte spara nya sysinfo.dat..\n",-1,0); */ } if(fwrite((void *)&Servermem->info,sizeof(Servermem->info),1,fil) != 1) { /* putstring("Kunde inte skriva till nya sysinfo.dat....\n",-1,0); */ } fclose(fil); } nodestate = SystemTags(commandstring, SYS_UserShell, TRUE, TAG_DONE); AddPort(nikomnodeport); if(!getty || (nodestate & NIKSTATE_RELOGIN)) { if(!(NiKwind = openmywindow(tmppscreen))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); OpenConsole(NiKwind); } serreqtkn(); if(nodestate & NIKSTATE_RELOGIN) goto reloginspec; panik: Delay(hangupdelay); if(getty) cleanup(OK,""); disconnect(); } }
bool tTVPApplication::StartApplication( int argc, char* argv[] ) { _set_se_translator(se_translator_function); ArgC = argc; ArgV = argv; for( int i = 0; i < argc; i++ ) { if(!strcmp(argv[i], "-@processohmlog")) { has_map_report_process_ = true; } } TVPTerminateCode = 0; CheckConsole(); // try starting the program! bool engine_init = false; try { if(TVPCheckProcessLog()) return true; // sub-process for processing object hash map log TVPInitScriptEngine(); engine_init = true; // banner TVPAddImportantLog( TVPFormatMessage(TVPProgramStartedOn, TVPGetOSName(), TVPGetPlatformName()) ); // TVPInitializeBaseSystems TVPInitializeBaseSystems(); Initialize(); if(TVPCheckPrintDataPath()) return true; if(TVPExecuteUserConfig()) return true; image_load_thread_ = new tTVPAsyncImageLoader(); TVPSystemInit(); if(TVPCheckAbout()) return true; // version information dialog box; SetTitle( std::wstring(TVPKirikiri) ); TVPSystemControl = new tTVPSystemControl(); #ifndef TVP_IGNORE_LOAD_TPM_PLUGIN TVPLoadPluigins(); // load plugin module *.tpm #endif // Check digitizer CheckDigitizer(); // start image load thread image_load_thread_->Resume(); if(TVPProjectDirSelected) TVPInitializeStartupScript(); Run(); try { // image_load_thread_->ExitRequest(); delete image_load_thread_; image_load_thread_ = NULL; } catch(...) { // ignore errors } try { TVPSystemUninit(); } catch(...) { // ignore errors } } catch( const EAbort & ) { // nothing to do } catch( const Exception &exception ) { TVPOnError(); if(!TVPSystemUninitCalled) ShowException(exception.what()); } catch( const TJS::eTJSScriptError &e ) { TVPOnError(); if(!TVPSystemUninitCalled) ShowException( e.GetMessage().c_str() ); } catch( const TJS::eTJS &e) { TVPOnError(); if(!TVPSystemUninitCalled) ShowException( e.GetMessage().c_str() ); } catch( const std::exception &e ) { ShowException( ttstr(e.what()).c_str() ); } catch( const char* e ) { ShowException( ttstr(e).c_str() ); } catch( const wchar_t* e ) { ShowException( e ); } catch( const SEHException& e ) { PEXCEPTION_RECORD rec = e.ExceptionPointers->ExceptionRecord; std::wstring text(SECodeToMessage(e.Code)); ttstr result = TJSGetStackTraceString( 10 ); PrintConsole( result.c_str(), result.length(), true ); TVPDumpHWException(); ShowException( text.c_str() ); } catch(...) { ShowException( (const tjs_char*)TVPUnknownError ); } if(engine_init) TVPUninitScriptEngine(); if(TVPSystemControl) delete TVPSystemControl; TVPSystemControl = NULL; CloseConsole(); return false; }