From f276290458d1e10d2dec06f5f33809e2e95b02b2 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 12 Dec 2002 01:07:24 +0000 Subject: [PATCH] file sizes svn path=/trunk/boinc/; revision=734 --- checkin_notes | 15 +++++++ doc/tools_work.html | 13 +++--- test/concat_wu | 12 ++---- test/sah_wu | 6 +-- test/uc_wu | 6 +-- test/ucs_wu | 6 +-- tools/backend_lib.C | 101 +++++++++++++++++++++----------------------- 7 files changed, 79 insertions(+), 80 deletions(-) diff --git a/checkin_notes b/checkin_notes index bbd84a4b23..c346a8fa9e 100755 --- a/checkin_notes +++ b/checkin_notes @@ -2610,3 +2610,18 @@ Seth Dec 9, 2002 hostinfo.C,h client/win/ hostinfo_win.cpp + +David Dec 11 2002 + - Have process_wu_template() fill in the file size as well as the MD5. + This necessitated changing the format of WU templates, + and the way they are processed. + + NOTE: this breaks the multiple-data-server test. + Need to figure out another way to do that. + + tools/ + backend_lib.C + doc/ + tools_work.html + test/ + *wu diff --git a/doc/tools_work.html b/doc/tools_work.html index 5a83547919..058d07518b 100644 --- a/doc/tools_work.html +++ b/doc/tools_work.html @@ -27,16 +27,17 @@ create_work infile_1 ... infile_m // input files

-The workunit template file is macro-substituted as follows: +The workunit template file is processed as follows:

The result file template is macro-substituted as follows: diff --git a/test/concat_wu b/test/concat_wu index 26b47ec3cd..c053e26009 100644 --- a/test/concat_wu +++ b/test/concat_wu @@ -1,20 +1,16 @@ - - 0/ - + 0 - - / - + 1 - + 0 in1 - + 1 in2 in1 in2 out diff --git a/test/sah_wu b/test/sah_wu index be2af74fb0..adedbd1b18 100644 --- a/test/sah_wu +++ b/test/sah_wu @@ -1,11 +1,9 @@ - - - + 0 - + 0 work_unit.sah work_unit.sah diff --git a/test/uc_wu b/test/uc_wu index 68acd4c795..f92f1d5469 100644 --- a/test/uc_wu +++ b/test/uc_wu @@ -1,11 +1,9 @@ - - / - + 0 - + 0 in diff --git a/test/ucs_wu b/test/ucs_wu index 63a0a1f20c..165e9f54cd 100644 --- a/test/ucs_wu +++ b/test/ucs_wu @@ -1,11 +1,9 @@ - - - + 0 - + 0 in -run_slow diff --git a/tools/backend_lib.C b/tools/backend_lib.C index 17d727ad84..52c72e8c43 100644 --- a/tools/backend_lib.C +++ b/tools/backend_lib.C @@ -8,8 +8,7 @@ // License for the specific language governing rights and limitations // under the License. // -// The Original Code is the Berkeley Open Infrastructure for Network Computing. -// +// 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. @@ -25,15 +24,10 @@ #include "db.h" #include "crypt.h" #include "md5_file.h" +#include "parse.h" #include "backend_lib.h" -#define INFILE_MACRO "" -#define DOWNLOAD_URL_MACRO "" - int read_file(FILE* f, char* buf) { assert(f); assert(buf); @@ -69,8 +63,8 @@ int read_key_file(char* keyfile, R_RSA_PRIVATE_KEY& key) { return 0; } -// replace INFILE_x with filename from array, -// MD5_x with checksum of file, + +// process WU template // static int process_wu_template( char* wu_name, char* tmplate, char* out, @@ -79,9 +73,9 @@ static int process_wu_template( ) { char* p; char buf[MAX_BLOB_SIZE], md5[33], path[256]; - bool found; - int i, retval; + int retval, file_number; double nbytes; + char open_name[256]; assert(wu_name!=NULL); assert(tmplate!=NULL); @@ -90,54 +84,53 @@ static int process_wu_template( assert(infiles!=NULL); assert(n>=0); - strcpy(out, tmplate); - while (1) { - found = false; - p = strstr(out, INFILE_MACRO); - if (p) { - found = true; - i = atoi(p+strlen(INFILE_MACRO)); - if (i >= n) { - fprintf(stderr, "process_wu_template: invalid file number\n"); - return 1; - } - strcpy(buf, p+strlen(INFILE_MACRO)+1+2); // assume <= 10 files - strcpy(p, infiles[i]); - strcat(p, buf); - } - p = strstr(out, UPLOAD_URL_MACRO); - if (p) { - found = true; - strcpy(buf, p+strlen(UPLOAD_URL_MACRO)); - strcpy(p, upload_url); - strcat(p, buf); - } - p = strstr(out, DOWNLOAD_URL_MACRO); - if (p) { - found = true; - strcpy(buf, p+strlen(DOWNLOAD_URL_MACRO)); - strcpy(p, download_url); - strcat(p, buf); - } - p = strstr(out, MD5_MACRO); - if (p) { - found = true; - i = atoi(p+strlen(MD5_MACRO)); - if (i >= n) { - fprintf(stderr, "process_wu_template: invalid file number\n"); - return 1; - } - sprintf(path, "%s/%s", dirpath, infiles[i]); + strcpy(out, ""); + p = strtok(tmplate, "\n"); + while (p) { + if (match_tag(p, "")) { + } else if (parse_int(p, "", file_number)) { + } else if (match_tag(p, "")) { + sprintf(path, "%s/%s", dirpath, infiles[file_number]); retval = md5_file(path, md5, nbytes); if (retval) { fprintf(stderr, "process_wu_template: md5_file %d\n", retval); return 1; } - strcpy(buf, p+strlen(MD5_MACRO)+1+2); // assume <= 10 files - strcpy(p, md5); - strcat(p, buf); + sprintf(buf, + "\n" + " %s\n" + " %s/%s\n" + " %s\n" + " %.0f\n" + "\n", + infiles[file_number], + download_url, infiles[file_number], + md5, + nbytes + ); + strcat(out, buf); + } else if (match_tag(p, "")) { + strcat(out, "\n"); + } else if (match_tag(p, "")) { + strcat(out, "\n"); + } else if (match_tag(p, "")) { + } else if (parse_int(p, "", file_number)) { + } else if (parse_str(p, "", open_name, sizeof(open_name))) { + } else if (match_tag(p, "")) { + sprintf(buf, + "\n" + " %s\n" + " %s\n" + "\n", + infiles[file_number], + open_name + ); + strcat(out, buf); + } else { + strcat(out, p); + strcat(out, "\n"); } - if (!found) break; + p = strtok(0, "\n"); } return 0; }