From 0945912d40646cfb78a1a3e17b1dc987674be82b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 9 Jan 2003 21:48:33 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=807 --- db/db_mysql.C | 2 +- db/mysql_util.C | 44 ++++++++++++++++++++++---------------------- doc/tools_work.html | 37 +++++++++++++++++++++++++++---------- sched/make_work.C | 2 +- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/db/db_mysql.C b/db/db_mysql.C index b75c2c77d4..22e1123952 100644 --- a/db/db_mysql.C +++ b/db/db_mysql.C @@ -50,7 +50,7 @@ static char* boinc_table_name[] = { "workseq", }; -class BOINC_MYSQL_DB : virtual public MYSQL_DB { +class BOINC_MYSQL_DB : public MYSQL_DB { public: BOINC_MYSQL_DB(); void struct_to_str(void* vp, char* q, int type); diff --git a/db/mysql_util.C b/db/mysql_util.C index 7528942911..e30840821b 100644 --- a/db/mysql_util.C +++ b/db/mysql_util.C @@ -129,9 +129,9 @@ int MYSQL_DB::db_update(void* vp, int type) { char buf[MAX_QUERY_LEN], sbuf[MAX_QUERY_LEN]; struct_to_str(vp, sbuf, type); sprintf( - buf, - "update %s set %s where id=%d", - table_name[type], sbuf, *id(vp, type) + buf, + "update %s set %s where id=%d", + table_name[type], sbuf, *id(vp, type) ); return mysql_query(mp, buf); } @@ -139,43 +139,43 @@ int MYSQL_DB::db_update(void* vp, int type) { int MYSQL_DB::db_enum(ENUM& e, void* p, int type, char* clause, int limit) { char buf[MAX_QUERY_LEN], buf2[256]; if (!e.active) { - e.active = 1; - sprintf(buf, "select * from %s %s", table_name[type], clause?clause:""); + e.active = 1; + sprintf(buf, "select * from %s %s", table_name[type], clause?clause:""); if (limit) { sprintf(buf2, " limit %d", limit); strcat(buf, buf2); } - mysql_query(mp, buf); - e.rp = mysql_store_result(mp); - if (!e.rp) return -1; + mysql_query(mp, buf); + e.rp = mysql_store_result(mp); + if (!e.rp) return -1; } row = mysql_fetch_row(e.rp); if (!row) { - mysql_free_result(e.rp); - e.active = 0; - return 1; + mysql_free_result(e.rp); + e.active = 0; + return 1; } else { - row_to_struct(row, p, type); - return 0; + row_to_struct(row, p, type); + return 0; } } int MYSQL_DB::db_enum_field(ENUM& e, int type, char* field, char* clause) { char buf[MAX_QUERY_LEN]; if (!e.active) { - e.active = 1; - sprintf(buf, "select %s from %s %s", field, table_name[type], clause); - mysql_query(mp, buf); - e.rp = mysql_store_result(mp); - if (!e.rp) return -1; + e.active = 1; + sprintf(buf, "select %s from %s %s", field, table_name[type], clause); + mysql_query(mp, buf); + e.rp = mysql_store_result(mp); + if (!e.rp) return -1; } row = mysql_fetch_row(e.rp); if (!row) { - mysql_free_result(e.rp); - e.active = 0; - return 1; + mysql_free_result(e.rp); + e.active = 0; + return 1; } else { - return 0; + return 0; } } diff --git a/doc/tools_work.html b/doc/tools_work.html index 058d07518b..a18a640e92 100644 --- a/doc/tools_work.html +++ b/doc/tools_work.html @@ -4,7 +4,9 @@

Workunits and results can be created using either a utility program or a C++ function. -

+In either case you must first generate a key pair +for file upload authentication. +


The utility program is
 create_work
@@ -37,7 +39,7 @@ the filename, download URL, MD5 checksum, and size.
 file.
 
  • Within a <file_ref> element, -<file_number>x</number> is replaced with the filename. +<file_number>x</file_number> is replaced with the filename.

    The result file template is macro-substituted as follows: @@ -52,22 +54,37 @@ the ordinal number of the result (0, 1, ...).


    -The C++ library (backend_lib.C,h) provides the function: +The C++ library (backend_lib.C,h) provides the functions:

    +int read_key_file(char* path, R_RSA_PRIVATE_KEY& key);
    +
     int create_work(
         WORKUNIT&,
    -    char* wu_template,
    -    char* result_template_filename,
    +    char* wu_template,                  // contents, not path
    +    char* result_template_filename,     // path
         int nresults,
    -    char* infile_dir,
    -    char** infiles,
    +    char* infile_dir,                   // where input files are
    +    char** infiles,                     // array of input file names
         int ninfiles
    -    R_RSA_PRIVATE_KEY& key,
    +    R_RSA_PRIVATE_KEY& key,             // upload authentication key
         char* upload_url,
         char* download_url
     );
     

    -This creates a workunit and one or more results. +read_key_file() reads a private key from a file. +Use this to read the file upload authentication key. +

    +create_work() +creates a workunit and one or more results. The arguments are similar to those of the utility program; -some of the information is passed in the WORKUNIT structure. +some of the information is passed in the WORKUNIT structure, +namely the following fields: +

    +name
    +rsc_fpops
    +rsc_iops
    +rsc_memory
    +rsc_disk
    +delay_bound
    +
    diff --git a/sched/make_work.C b/sched/make_work.C index 89080b760b..ac8c7e7827 100644 --- a/sched/make_work.C +++ b/sched/make_work.C @@ -162,7 +162,7 @@ void make_work() { while (p) { if (parse_str(p, "", file_name, sizeof(file_name))) { sprintf( - new_file_name, "%s_%d_%d", file_name, start_time, seqno++ + new_file_name, "%s__%d_%d", file_name, start_time, seqno++ ); sprintf(pathname, "%s/%s", config.download_dir, file_name); sprintf(