2003-06-14 20:03:10 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2002-09-26 18:11:06 +00:00
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
2003-06-14 20:03:10 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-06-14 20:04:45 +00:00
|
|
|
//
|
2002-09-26 18:11:06 +00:00
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
2003-06-14 20:04:45 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2002-09-26 18:11:06 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
2003-06-14 20:03:10 +00:00
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-06-14 20:04:45 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2002-09-26 18:11:06 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2004-04-07 06:51:42 +00:00
|
|
|
#include "util.h"
|
2003-06-14 20:03:08 +00:00
|
|
|
#include "sched_util.h"
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "sched_msgs.h"
|
2004-03-17 01:26:44 +00:00
|
|
|
#include "validate_util.h"
|
2002-09-25 19:40:19 +00:00
|
|
|
|
2003-08-14 00:02:15 +00:00
|
|
|
// TODO: use md5 hash
|
2002-09-25 19:40:19 +00:00
|
|
|
|
2003-08-14 00:02:15 +00:00
|
|
|
// read file into memory
|
2004-03-17 01:26:44 +00:00
|
|
|
//
|
|
|
|
int init_result_read_file(RESULT const& result, void*& data) {
|
2002-09-25 19:40:19 +00:00
|
|
|
int retval;
|
2003-08-14 00:02:15 +00:00
|
|
|
string path;
|
2002-09-25 19:40:19 +00:00
|
|
|
|
2003-08-14 00:02:15 +00:00
|
|
|
retval = get_output_file_path(result, path);
|
2002-09-25 19:40:19 +00:00
|
|
|
if (retval) {
|
2003-08-07 21:40:17 +00:00
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::CRITICAL,
|
2003-08-14 00:02:15 +00:00
|
|
|
"[RESULT#%d %s] check_set: can't get output filename\n",
|
|
|
|
result.id, result.name
|
2004-03-17 01:26:44 +00:00
|
|
|
);
|
2002-09-25 19:40:19 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2003-08-14 00:02:15 +00:00
|
|
|
|
|
|
|
string* s = new string;
|
|
|
|
data = (void*) s;
|
|
|
|
|
|
|
|
retval = read_file_string(path.c_str(), *s);
|
2002-09-25 19:40:19 +00:00
|
|
|
if (retval) {
|
2003-08-07 21:40:17 +00:00
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::CRITICAL,
|
2003-08-14 00:02:15 +00:00
|
|
|
"[RESULT#%d %s] Couldn't open %s\n",
|
|
|
|
result.id, result.name, path.c_str()
|
2004-03-17 01:26:44 +00:00
|
|
|
);
|
2002-09-25 19:40:19 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2003-08-14 00:02:15 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-09-01 17:11:14 +00:00
|
|
|
int check_pair_initialized_identical(
|
|
|
|
RESULT const& /*r1*/, void* data1,
|
|
|
|
RESULT const& /*r2*/, void* data2,
|
|
|
|
bool& match
|
|
|
|
) {
|
2003-08-14 00:02:15 +00:00
|
|
|
string const* s1 = (string*) data1;
|
|
|
|
string const* s2 = (string*) data2;
|
|
|
|
|
|
|
|
match = (*s1 == *s2);
|
2002-09-25 19:40:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-08-14 00:02:15 +00:00
|
|
|
|
2003-09-01 17:11:14 +00:00
|
|
|
int cleanup_result_string(RESULT const& /*result*/, void* data) {
|
2003-08-14 00:02:15 +00:00
|
|
|
string* s = (string*) data;
|
|
|
|
delete s;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if there's a strict majority under equality.
|
|
|
|
//
|
2003-09-01 17:11:14 +00:00
|
|
|
int check_set(vector<RESULT>& results, int& canonicalid, double& credit) {
|
|
|
|
return generic_check_set_majority(
|
|
|
|
results, canonicalid, credit,
|
|
|
|
init_result_read_file,
|
|
|
|
check_pair_initialized_identical,
|
|
|
|
cleanup_result_string
|
|
|
|
);
|
2003-08-14 00:02:15 +00:00
|
|
|
}
|
|
|
|
|
2003-09-01 17:11:14 +00:00
|
|
|
int check_pair(RESULT const& r1, RESULT const& r2, bool& match) {
|
|
|
|
return generic_check_pair(
|
|
|
|
r1, r2, match,
|
|
|
|
init_result_read_file,
|
|
|
|
check_pair_initialized_identical,
|
|
|
|
cleanup_result_string
|
|
|
|
);
|
2003-08-14 00:02:15 +00:00
|
|
|
}
|
|
|
|
|