LOCAL ushort CheckSignature(void) { if (link_read (exefile, Signature, 4) == 4) { if ((Signature[0] != 'N') || (Signature[1] != 'B')) { ErrorExit(ERR_RELINK, NULL, NULL); } if (Signature[2] == '0') { if (Signature[3] == '5') { return(SIG05); } } if ((Signature[2] == '0' && Signature[3] == '9') || (Signature[2] == '1' && Signature[3] == '0')) { // Just return a zero here when stripping. // They just have to match until we strip if (strip) { return(0); } Warn(WARN_PACKED, NULL, NULL); AppExit(0); } ErrorExit(ERR_RELINK, NULL, NULL); } ErrorExit(ERR_INVALIDEXE, NULL, NULL); }
void AppCleanup() { StopReplay(); WaveLogStop(); AppExit(); }
void ErrorExit(unsigned error, const char *s1, const char *s2) { char *szPrefix; int cch = 0; char szError[ERROR_LEN]; if (logo && NeedsBanner) { Banner(); } if (error != ERR_USAGE) { szPrefix = get_err(MSG_ERROR); if (szPrefix == NULL) { szPrefix = (char *) szErrorPrefix; } cch = sprintf(szError, szPrefix, error, ' '); } sprintf(szError + cch, get_err(error), s1, s2); puts(szError); AppExit(1); }
static int SetReflProfCoef(Fprec Q, int h, int k, int l, Fprec F2, Fprec *Angle, Fprec *Intensity, Fprec *FWHM, Fprec *Asym) { Fprec tanT; *Angle = TwoThetaDeg(Q); if (*Angle == 0.) return -1; *Intensity = CalcIrel(*Angle, h, k, l, F2); tanT = AppTan(*Angle * .5 * PIover180); *FWHM = CalcFWHM(tanT); if (*FWHM < 0.) { Fprintf(stderr, "%s: Error: Illegal half width function parameters\n", progn); AppExit(1); } if (ProfileAsym.Valid) *Asym = ProfileAsym.a1 + (ProfileAsym.a2 + ProfileAsym.a3 / tanT) / tanT; else *Asym = 0.; return 0; }
void AppMain() { AppInit(1280, 720, "silver-winner"); for (;;) { MSG msg; while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); } if (g_App.bShouldClose) { break; } ImGui_ImplDX11_NewFrame(); RendererPaint(); } AppExit(); }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CommandLine()->CreateCmdLine( Plat_GetCommandLine() ); // TODO: Place code here. SpewOutputFunc( D3DAppSpewFunc ); MathLib_Init( true, true, true, 2.2f, 2.2f, 0.0f, 2.0f ); MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); strcpy( szWindowClass, "d3dapp" ); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TERRAINBLEND); InvalidateRect( g_hWnd, NULL, FALSE ); // Main message loop: while(1) { while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) break; if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } if(msg.message == WM_QUIT) break; CallAppRender( false ); } AppExit(); return msg.wParam; }
static void CatchSignal(int sig) { #if SIGINT >= 0 (void) signal(SIGINT, SIG_IGN); #endif #if SIGHUP >= 0 (void) signal(SIGHUP, SIG_IGN); #endif #if SIGQUIT >= 0 (void) signal(SIGQUIT, SIG_IGN); #endif #if SIGALRM >= 0 (void) signal(SIGALRM, SIG_IGN); #endif #if SIGTERM >= 0 (void) signal(SIGTERM, SIG_IGN); #endif switch (sig) { case SIGHUP: case SIGALRM: Fflush(stdout); AppSignal(); break; case SIGINT: case SIGQUIT: case SIGTERM: default: Fprintf(stdout, "\n\n# Signal #%d: %s\n\n", sig, NameOfSignal(sig)); if (sig == SIGINT) { QuitProgram = 1; NoSIGINT = 1; AppSignal(); } else AppExit(2); break; } }
/*----------------------------------------------------------------------------*\ | WinMain( hInst, hPrev, lpszCmdLine, cmdShow ) | | | | Description: | | The main procedure for the App. After initializing, it just goes | | into a message-processing loop until it gets a WM_QUIT message | | (meaning the app was closed). | | | | Arguments: | | hInst instance handle of this instance of the app | | hPrev instance handle of previous instance, NULL if first | | szCmdLine ->null-terminated command line | | cmdShow specifies how the window is initially displayed | | | | Returns: | | The exit code as specified in the WM_QUIT message. | | | \*----------------------------------------------------------------------------*/ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { MSG msg; DWORD dw=0; /* Call initialization procedure */ if (!AppInit(hInst,hPrev,sw,szCmdLine)) return FALSE; #ifdef WIN32 CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)IdleThread, 0, 0, &dw); #endif /* * Polling messages from event queue */ for (;;) { if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE)) { if (msg.message == WM_QUIT) break; if (hAccelApp && TranslateAccelerator(hwndApp, hAccelApp, &msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); } else { if (dw!=0 || AppIdle()) WaitMessage(); } } AppExit(); return msg.wParam; }
I32 main(I32 argc, CHAR** argv) { if(argc < 2) { NAssert(VA("%s : requires server argument.",argv[0])); return -1; } // init the application AppInit(argc-1, &argv[1]); // run the application while(s_exit == FALSE) { AppRun(); } // exit the application AppExit(); return 0; }
void CheckSignalFile(void) { int c; FILE *fpsig; if (F_SignalFileName) { fpsig = fopen(F_SignalFileName, "r"); if (fpsig != NULL) { c = fgetc(fpsig); Fclose(fpsig); Fprintf(stdout, "\n\n# Signal file \"%s\" detected\n\n", F_SignalFileName); QuitProgram = 2; if (c == '!') AppExit(2); } } }
/*----------------------------------------------------------------------------*\ | WinMain( hInst, hPrev, lpszCmdLine, cmdShow ) | | | | Description: | | The main procedure for the App. After initializing, it just goes | | into a message-processing loop until it gets a WM_QUIT message | | (meaning the app was closed). | | | | Arguments: | | hInst instance handle of this instance of the app | | hPrev instance handle of previous instance, NULL if first | | szCmdLine ->null-terminated command line | | cmdShow specifies how the window is initially displayed | | | | Returns: | | The exit code as specified in the WM_QUIT message. | | | \*----------------------------------------------------------------------------*/ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { MSG msg; if (!WinG.Load()) { //link to WinG DLL. MessageBox(0,"Can't find WING32.DLL","WTWIN Error!",MB_OK); return FALSE; } /* Call initialization procedure */ if (!AppInit(hInst,hPrev,sw,szCmdLine)) return FALSE; /* * Polling messages from event queue */ for (;;) { if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else { if (AppIdle()) WaitMessage(); } } AppExit(); WinG.Free(); //terminate WinG DLL link. return msg.wParam; }