From c1506abe39d2ebac56a174f5b395aeacfea30195 Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Thu, 21 Aug 2003 23:44:57 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2164 --- api/boinc_api.C | 51 +++++++++++++++++++++++--------------------- api/boinc_api.h | 7 ++---- api/windows_opengl.C | 17 ++++++++------- checkin_notes | 11 ++++++++++ 4 files changed, 49 insertions(+), 37 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index f16f75cc80..63cef40d1a 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -2,18 +2,18 @@ // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://boinc.berkeley.edu/license_1.0.txt -// +// // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is the Berkeley Open Infrastructure for Network Computing. -// +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 -// University of California at Berkeley. All Rights Reserved. -// +// University of California at Berkeley. All Rights Reserved. +// // Contributor(s): // @@ -83,12 +83,17 @@ static bool write_frac_done = false; static bool this_process_active; static bool time_to_quit = false; bool using_opengl = false; +bool standalone = false; APP_CLIENT_SHM *app_client_shm; +bool boinc_is_standalone() +{ + return standalone; +} + // read the INIT_DATA and FD_INIT files // -int boinc_init() { - bool standalone = false; +int boinc_init(bool standalone_ /* = false */) { FILE* f; int retval; @@ -96,9 +101,7 @@ int boinc_init() { freopen(STDERR_FILE, "a", stderr); #endif -#ifdef API_STANDALONE - standalone = true; -#endif + standalone = standalone_; // If in standalone mode, use init files if they're there, // but don't demand that they exist @@ -154,7 +157,7 @@ int boinc_init() { time_until_checkpoint = aid.checkpoint_period; time_until_fraction_done_update = aid.fraction_done_update_period; this_process_active = true; - + boinc_install_signal_handlers(); set_timer(timer_period); setup_shared_mem(); @@ -193,7 +196,7 @@ LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *ExceptionInfo) { // If we've been in this procedure before, something went wrong so we immediately exit if (already_caught_signal) _exit(ERR_SIGNAL_CATCH); already_caught_signal = 1; - + switch (exceptionCode) { case STATUS_WAIT_0: safe_strncpy(status,"Wait 0",sizeof(status)); break; case STATUS_ABANDONED_WAIT_0: safe_strncpy(status,"Abandoned Wait 0",sizeof(status)); break; @@ -294,7 +297,7 @@ bool boinc_time_to_checkpoint() { DWORD eventState; // Check if core client has requested us to exit eventState = WaitForSingleObject(hQuitRequest, 0L); - + switch (eventState) { case WAIT_OBJECT_0: case WAIT_ABANDONED: @@ -313,7 +316,7 @@ bool boinc_time_to_checkpoint() { } // If the application has received a quit request it should checkpoint - // + // if (time_to_quit) { return true; } @@ -470,7 +473,7 @@ int set_timer(double period) { // Create the event object used to signal between the // worker and event threads - hQuitEvent = CreateEvent( + hQuitEvent = CreateEvent( NULL, // no security attributes TRUE, // manual reset event TRUE, // initial state is signaled @@ -503,11 +506,11 @@ int set_timer(double period) { void setup_shared_mem(void) { app_client_shm = new APP_CLIENT_SHM; -#ifdef API_STANDALONE - app_client_shm->shm = NULL; - fprintf( stderr, "Standalone mode, so not attaching to shared memory.\n" ); - return; -#endif + if (standalone) { + app_client_shm->shm = NULL; + fprintf( stderr, "Standalone mode, so not attaching to shared memory.\n" ); + return; + } #ifdef _WIN32 char buf[256]; @@ -528,7 +531,7 @@ void setup_shared_mem(void) { void cleanup_shared_mem(void) { if (!app_client_shm) return; - + #ifdef _WIN32 if (app_client_shm->shm != NULL) detach_shmem(hSharedMem, app_client_shm->shm); @@ -545,7 +548,7 @@ void cleanup_shared_mem(void) { int update_app_progress(double frac_done, double cpu_t, double cp_cpu_t, double ws_t) { char msg_buf[SHM_SEG_SIZE]; - + sprintf( msg_buf, "%2.8f\n" "%10.4f\n" diff --git a/api/boinc_api.h b/api/boinc_api.h index 743586537e..ca23266273 100755 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -20,10 +20,6 @@ #ifndef _BOINC_API_ #define _BOINC_API_ -// API_STANDALONE will allow the app to function without the core client. -// this is useful for debugging just the application -//#define API_STANDALONE - #include #ifdef HAVE_SYS_TIME_H #include @@ -55,7 +51,7 @@ public: long tell() const; }; -extern int boinc_init(); +extern int boinc_init(bool standalone = false); extern int boinc_get_init_data(APP_INIT_DATA&); extern int boinc_finish(int); extern int boinc_resolve_filename(char*, char*, int len); @@ -64,6 +60,7 @@ extern int boinc_checkpoint_completed(); extern int boinc_fraction_done(double); extern int boinc_child_start(); extern int boinc_child_done(double); +bool boinc_is_standalone(); /////////// API ENDS HERE - IMPLEMENTATION STUFF FOLLOWS diff --git a/api/windows_opengl.C b/api/windows_opengl.C index 969071c124..4606d2d174 100755 --- a/api/windows_opengl.C +++ b/api/windows_opengl.C @@ -31,6 +31,7 @@ static UINT m_uEndSSMsg; BOOL win_loop_done; extern bool using_opengl; +extern bool standalone; extern HANDLE hQuitEvent; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc @@ -96,7 +97,7 @@ void SetMode(int mode) { while(ShowCursor(true) < 0); } - // Do not do AdjustWindowRectEx here, this will + // Do not do AdjustWindowRectEx here, this will // cause the window to creep upwards hWnd = CreateWindowEx(dwExStyle, "BOINC_OpenGL", "BOINC Graphics", @@ -122,7 +123,7 @@ void SetMode(int mode) { 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored - 16, // 16Bit Z-Buffer (Depth Buffer) + 16, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer @@ -240,11 +241,11 @@ DWORD WINAPI win_graphics_event_loop( LPVOID gi ) { // Register window class and graphics mode message reg_win_class(); -#ifdef API_STANDALONE - SetMode(MODE_WINDOW); -#else - SetMode(MODE_HIDE_GRAPHICS); -#endif + if (standalone) { + SetMode(MODE_WINDOW); + } else { + SetMode(MODE_HIDE_GRAPHICS); + } win_loop_done = false; using_opengl = true; @@ -277,7 +278,7 @@ BOOL VerifyPassword(HWND hwnd) VerifyScreenSavePwd= (VERIFYSCREENSAVEPWD)GetProcAddress(hpwdcpl,"VerifyScreenSavePwd"); if (VerifyScreenSavePwd==NULL) - { + { FreeLibrary(hpwdcpl);return TRUE; } BOOL bres=VerifyScreenSavePwd(hwnd); FreeLibrary(hpwdcpl); diff --git a/checkin_notes b/checkin_notes index 5ba84d38fb..c2f3c69215 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5887,3 +5887,14 @@ Karl 2003/08/20 fake_php.py (added) miniserv.pl (removed) testbase.py + +Karl 2003/08/21 + - changed 'standalone' mode from a compile-time option to a run-time + option + - boinc_init() takes optional bool parameter which is true if + standalone (app has to parse this from argv or however it wants) + + api/ + boinc_api.C + boinc_api.h + windows_opengl.C