From a0782cc09dcd39184cb64e47448a342622f6b46c Mon Sep 17 00:00:00 2001 From: gombasg Date: Thu, 23 Mar 2006 13:50:26 +0000 Subject: [PATCH] Add support for resolving the checkpoint file name git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@391 a7169a2c-3604-0410-bc95-c702d8d87f7a --- dcapi/boinc/client.c | 76 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/dcapi/boinc/client.c b/dcapi/boinc/client.c index 11d79f5de8..1c156508cd 100644 --- a/dcapi/boinc/client.c +++ b/dcapi/boinc/client.c @@ -2,6 +2,7 @@ #include #endif +#include #include /* BOINC includes */ @@ -15,21 +16,53 @@ #include #include +#include "common_defs.h" + +static int ckpt_generation; +static char *last_complete_ckpt; +static char active_ckpt[PATH_MAX]; int DC_init(void) { + char buf[PATH_MAX]; + if (boinc_init_diagnostics(BOINC_DIAG_REDIRECTSTDERR)) return DC_ERR_INTERNAL; if (boinc_init()) return DC_ERR_INTERNAL; + + if (!boinc_resolve_filename(CKPT_LABEL, buf, sizeof(buf))) + last_complete_ckpt = strdup(buf); + return 0; } -/* XXX Add handling for DC_CHECKPOINT_FILE */ char *DC_resolveFileName(DC_Filetype type, const char *logicalFileName) { char buf[PATH_MAX]; + if (!strcmp(logicalFileName, DC_CHECKPOINT_FILE)) + { + if (type == DC_FILE_IN) + { + if (last_complete_ckpt) + return strdup(last_complete_ckpt); + return NULL; + } + else if (type == DC_FILE_OUT) + { + snprintf(active_ckpt, sizeof(active_ckpt), "dc_ckpt_%d", + ++ckpt_generation); + return strdup(active_ckpt); + } + else + return NULL; + } + + /* Temporary files can be created in the current directory */ + if (type == DC_FILE_TMP) + return strdup(logicalFileName); + if (boinc_resolve_filename(logicalFileName, buf, sizeof(buf))) return NULL; return strdup(buf); @@ -51,6 +84,8 @@ DC_Event DC_checkEvent(void **data) void DC_checkpointMade(const char *filename) { boinc_checkpoint_completed(); + free(last_complete_ckpt); + last_complete_ckpt = strdup(filename); } void DC_fractionDone(double fraction) @@ -68,11 +103,34 @@ void DC_finish(int exitcode) * BOINC libraries */ -void app_graphics_init(void) {} -void app_graphics_resize(int width, int height){} -void app_graphics_render(int xs, int ys, double time_of_day) {} -void app_graphics_reread_prefs(void) {} -void boinc_app_mouse_move(int x, int y, bool left, bool middle, bool right ){} -void boinc_app_mouse_button(int x, int y, int which, bool is_down){} -void boinc_app_key_press(int x, int y){} -void boinc_app_key_release(int x, int y){} +void app_graphics_init(void) +{ +} + +void app_graphics_resize(int width, int height) +{ +} + +void app_graphics_render(int xs, int ys, double time_of_day) +{ +} + +void app_graphics_reread_prefs(void) +{ +} + +void boinc_app_mouse_move(int x, int y, bool left, bool middle, bool right) +{ +} + +void boinc_app_mouse_button(int x, int y, int which, bool is_down) +{ +} + +void boinc_app_key_press(int x, int y) +{ +} + +void boinc_app_key_release(int x, int y) +{ +}