file sizes

svn path=/trunk/boinc/; revision=734
This commit is contained in:
David Anderson 2002-12-12 01:07:24 +00:00
parent 92eb972df2
commit f276290458
7 changed files with 79 additions and 80 deletions

View File

@ -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

View File

@ -27,16 +27,17 @@ create_work
infile_1 ... infile_m // input files
</pre>
<p>
The workunit template file is macro-substituted as follows:
The workunit template file is processed as follows:
<ul>
<li>
&lt;INFILE_n/> is replaced with the name of the nth input
Within a &lt;file_info> element,
&lt;number>x&lt;/number> identifies the order of the file.
It is replaced with elements giving
the filename, download URL, MD5 checksum, and size.
file.
<li>
&lt;MD5_n/> is replaced with the MD5 checksum of the nth
input file.
<li>
&lt;DOWNLOAD_URL/> is replaced with the download URL.
Within a &lt;file_ref> element,
&lt;file_number>x&lt;/number> is replaced with the filename.
</ul>
<p>
The result file template is macro-substituted as follows:

View File

@ -1,20 +1,16 @@
<file_info>
<name><INFILE_0/></name>
<url><DOWNLOAD_URL/>0/<INFILE_0/></url>
<md5_cksum><MD5_0/></md5_cksum>
<number>0</number>
</file_info>
<file_info>
<name><INFILE_1/></name>
<url><DOWNLOAD_URL/>/<INFILE_1/></url>
<md5_cksum><MD5_1/></md5_cksum>
<number>1</number>
</file_info>
<workunit>
<file_ref>
<file_name><INFILE_0/></file_name>
<file_number>0</file_number>
<open_name>in1</open_name>
</file_ref>
<file_ref>
<file_name><INFILE_1/></file_name>
<file_number>1</file_number>
<open_name>in2</open_name>
</file_ref>
<command_line>in1 in2 out</command_line>

View File

@ -1,11 +1,9 @@
<file_info>
<name><INFILE_0/></name>
<url><DOWNLOAD_URL/><INFILE_0/></url>
<md5_cksum><MD5_0/></md5_cksum>
<number>0</number>
</file_info>
<workunit>
<input_file>
<file_name><INFILE_0/></file_name>
<file_number>0</file_number>
<open_name>work_unit.sah</open_name>
</input_file>
<command_line>work_unit.sah</command_line>

View File

@ -1,11 +1,9 @@
<file_info>
<name><INFILE_0/></name>
<url><DOWNLOAD_URL/>/<INFILE_0/></url>
<md5_cksum><MD5_0/></md5_cksum>
<number>0</number>
</file_info>
<workunit>
<file_ref>
<file_name><INFILE_0/></file_name>
<file_number>0</file_number>
<open_name>in</open_name>
</file_ref>
</workunit>

View File

@ -1,11 +1,9 @@
<file_info>
<name><INFILE_0/></name>
<url><DOWNLOAD_URL/><INFILE_0/></url>
<md5_cksum><MD5_0/></md5_cksum>
<number>0</number>
</file_info>
<workunit>
<file_ref>
<file_name><INFILE_0/></file_name>
<file_number>0</file_number>
<open_name>in</open_name>
</file_ref>
<command_line>-run_slow</command_line>

View File

@ -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 "<INFILE_"
#define MD5_MACRO "<MD5_"
#define OUTFILE_MACRO "<OUTFILE_"
#define UPLOAD_URL_MACRO "<UPLOAD_URL/>"
#define DOWNLOAD_URL_MACRO "<DOWNLOAD_URL/>"
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, "<file_info>")) {
} else if (parse_int(p, "<number>", file_number)) {
} else if (match_tag(p, "</file_info>")) {
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,
"<file_info>\n"
" <name>%s</name>\n"
" <url>%s/%s</url>\n"
" <md5_cksum>%s</md5_cksum>\n"
" <nbytes>%.0f</nbytes>\n"
"</file_info>\n",
infiles[file_number],
download_url, infiles[file_number],
md5,
nbytes
);
strcat(out, buf);
} else if (match_tag(p, "<workunit>")) {
strcat(out, "<workunit>\n");
} else if (match_tag(p, "</workunit>")) {
strcat(out, "</workunit>\n");
} else if (match_tag(p, "<file_ref>")) {
} else if (parse_int(p, "<file_number>", file_number)) {
} else if (parse_str(p, "<open_name>", open_name, sizeof(open_name))) {
} else if (match_tag(p, "</file_ref>")) {
sprintf(buf,
"<file_ref>\n"
" <file_name>%s</file_name>\n"
" <open_name>%s</open_name>\n"
"</file_ref>\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;
}