From 08d54b1280065906fe372b0f43657317d32a98d6 Mon Sep 17 00:00:00 2001 From: zfarkas Date: Wed, 18 May 2011 06:54:12 +0000 Subject: [PATCH] Fix EDGI Bug #91: add handling the UploadURL configuration variable for output file uploads. Fix workunit description parsing (also read remote files). git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@2506 a7169a2c-3604-0410-bc95-c702d8d87f7a --- dcapi/boinc/dc_boinc.h | 2 ++ dcapi/boinc/wu.C | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/dcapi/boinc/dc_boinc.h b/dcapi/boinc/dc_boinc.h index 5015274d1e..88c07ded4b 100644 --- a/dcapi/boinc/dc_boinc.h +++ b/dcapi/boinc/dc_boinc.h @@ -48,6 +48,8 @@ extern "C" { #define CFG_REGEXPMATCH "InputURLRewriteRegExpMatch" /* Remote file rewrite regexp replace string */ #define CFG_REGEXPREPLACE "InputURLRewriteRegExpReplace" +/* Upload URL configuration option */ +#define CFG_UPLOADURL "UploadURL" /* File types in the working directory */ typedef enum diff --git a/dcapi/boinc/wu.C b/dcapi/boinc/wu.C index fc35bcf468..ec6d4457ca 100644 --- a/dcapi/boinc/wu.C +++ b/dcapi/boinc/wu.C @@ -38,6 +38,7 @@ typedef enum WU_NOTAG = -1, WU_WUDESC, WU_INPUT_LABEL, + WU_REMOTE_IN_LABEL, WU_OUTPUT_LABEL, WU_TAG, WU_CLIENT_NAME, @@ -70,6 +71,9 @@ struct parser_state wu_tag curr_tag; DC_FileMode curr_mode; DC_Workunit *wu; + char *curr_url; + char *curr_md5; + size_t curr_size; }; struct wu_params @@ -117,6 +121,7 @@ static const struct tag_desc tags[] = { { WU_WUDESC, "wudesc" }, { WU_INPUT_LABEL, "input_label" }, + { WU_REMOTE_IN_LABEL, "remote_input_label" }, { WU_OUTPUT_LABEL, "output_label" }, { WU_TAG, "tag" }, { WU_CLIENT_NAME, "client_name" }, @@ -355,6 +360,18 @@ static void wudesc_start(GMarkupParseContext *ctx, const char *element_name, else pctx->curr_mode = DC_FILE_REGULAR; } + else if (tags[i].id == WU_REMOTE_IN_LABEL) + { + int j = 0; + for (; j < 3; j++) { + if (attr_names && attr_names[j] && !strcmp(attr_names[j], "url")) + pctx->curr_url = g_strdup(attr_values[j]); + if (attr_names && attr_names[j] && !strcmp(attr_names[j], "md5")) + pctx->curr_md5 = g_strdup(attr_values[j]); + if (attr_names && attr_names[j] && !strcmp(attr_names[j], "size")) + pctx->curr_size = atoll(attr_values[j]); + } + } else if (attr_names && attr_names[0]) { *error = g_error_new(G_MARKUP_ERROR, @@ -400,6 +417,7 @@ static void wudesc_text(GMarkupParseContext *ctx, const char *text, { struct parser_state *pctx = (struct parser_state *)ptr; DC_PhysicalFile *file; + DC_RemoteFile *rfile; char *tmp, *label; switch (pctx->curr_tag) @@ -415,6 +433,14 @@ static void wudesc_text(GMarkupParseContext *ctx, const char *text, g_list_append(pctx->wu->input_files, file); pctx->wu->num_inputs++; break; + case WU_REMOTE_IN_LABEL: + label = g_strndup(text, text_len); + rfile = _DC_createRemoteFile(label, pctx->curr_url, + pctx->curr_md5, pctx->curr_size); + pctx->wu->remote_input_files = + g_list_append(pctx->wu->remote_input_files, rfile); + pctx->wu->num_remote_inputs++; + break; case WU_OUTPUT_LABEL: label = g_strndup(text, text_len); pctx->wu->output_files = @@ -501,8 +527,8 @@ static int write_wudesc(const DC_Workunit *wu) for (l = wu->remote_input_files; l; l = l->next) { rfile = (DC_RemoteFile *)l->data; - fprintf(f, "\t%s\n", - rfile->label); + fprintf(f, "\t%s\n", + rfile->url, rfile->remotefilehash, rfile->remotefilesize, rfile->label); } for (l = wu->output_files; l; l = l->next) @@ -1238,7 +1264,16 @@ static void append_result_file_info(GString *tmpl, int idx, int auto_upload, if (auto_upload) g_string_append(tmpl, "\t\n"); g_string_append_printf(tmpl, "\t%d\n", max_output); - g_string_append(tmpl, "\t\n"); + + gchar *uploadURL = DC_getCfgStr(CFG_UPLOADURL); + if (!uploadURL) + g_string_append(tmpl, "\t\n"); + else + { + g_string_append_printf(tmpl, "\t%s\n", uploadURL); + free(uploadURL); + } + g_string_append(tmpl, "\n"); }