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
This commit is contained in:
gombasg 2006-03-23 13:50:26 +00:00 committed by Adam Visegradi
parent 84e7e61bb4
commit a0782cc09d
1 changed files with 67 additions and 9 deletions

View File

@ -2,6 +2,7 @@
#include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
/* BOINC includes */
@ -15,21 +16,53 @@
#include <graphics_api.h>
#include <dc_client.h>
#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)
{
}