From ed40388c622efc74260ff9db305d2bcc517c2ce0 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Wed, 11 Sep 2002 21:56:20 +0000 Subject: [PATCH] Stupid DOS carriage returns svn path=/trunk/boinc/; revision=414 --- api/boinc_api.C | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ api/boinc_api.h | 1 + 2 files changed, 56 insertions(+) diff --git a/api/boinc_api.C b/api/boinc_api.C index 7cc343ae03..92c1d770fa 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -17,6 +17,10 @@ // Contributor(s): // +// API_IGNORE_CLIENT will make the app ignore the core client +// this is useful for debugging just the application +#define API_IGNORE_CLIENT + #include #include #include @@ -39,10 +43,12 @@ #include "parse.h" #include "error_numbers.h" +#include "graphics_api.h" #include "boinc_api.h" static APP_INIT_DATA aid; +static GRAPHICS_INFO gi; static double timer_period = 0.1; static double time_until_checkpoint; static double time_until_fraction_done_update; @@ -50,6 +56,10 @@ static double fraction_done; static bool ready_to_checkpoint = false; static bool this_process_active; +#ifdef _WIN32 +DWORD WINAPI graphics_main( LPVOID duff ); +#endif + // read the INIT_DATA and FD_INIT files // int boinc_init() { @@ -61,6 +71,7 @@ int boinc_init() { fprintf(stderr, "in boinc_init()\n"); #endif +#ifndef API_IGNORE_CLIENT f = fopen(INIT_DATA_FILE, "r"); if (!f) { fprintf(stderr, "boinc_init(): can't open init data file\n"); @@ -73,15 +84,59 @@ int boinc_init() { } fclose(f); + f = fopen(GRAPHICS_DATA_FILE, "r"); + if (!f) { + fprintf(stderr, "boinc_init(): can't open graphics data file\n"); + return ERR_FOPEN; + } + retval = parse_graphics_file(f, gi); + if (retval) { + fprintf(stderr, "boinc_init(): can't parse graphics data file\n"); + return retval; + } + fclose(f); + f = fopen(FD_INIT_FILE, "r"); if (f) { parse_fd_init_file(f); fclose(f); } +#else + strcpy(aid.app_preferences, ""); + strcpy(aid.user_name, "John Smith"); + strcpy(aid.team_name, "The A-Team"); + aid.wu_cpu_time = 1000; + aid.total_cobblestones = 1000; + aid.recent_avg_cobblestones = 500; + aid.checkpoint_period = DEFAULT_CHECKPOINT_PERIOD; + aid.fraction_done_update_period = DEFAULT_FRACTION_DONE_UPDATE_PERIOD; + + gi.graphics_mode = MODE_WINDOW; + gi.refresh_period = 0.1; // 1/10th of a second + gi.xsize = 640; + gi.ysize = 480; +#endif time_until_checkpoint = aid.checkpoint_period; time_until_fraction_done_update = aid.fraction_done_update_period; this_process_active = true; set_timer(timer_period); + +#ifdef BOINC_APP_GRAPHICS +#ifdef _WIN32 + DWORD threadId; + HANDLE hThread; + + // Create the graphics thread, passing it the graphics info + hThread = CreateThread( NULL, 0, graphics_main, 0, CREATE_SUSPENDED, &threadId ); + + // Set it to idle priority + SetThreadPriority (hThread, THREAD_PRIORITY_IDLE); + + // Start the graphics thread + ResumeThread( hThread ); +#endif +#endif + return 0; } diff --git a/api/boinc_api.h b/api/boinc_api.h index d6c5d89114..85643ef3b1 100755 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -87,6 +87,7 @@ int write_fraction_done_file(FILE*, double, double); int parse_fraction_done_file(FILE*, double&, double&); #define INIT_DATA_FILE "init_data.xml" +#define GRAPHICS_DATA_FILE "graphics_data.xml" #define FD_INIT_FILE "fd_init.xml" #define CHECKPOINT_CPU_FILE "checkpoint_cpu.xml" #define FRACTION_DONE_FILE "fraction_done.xml"