median_mean_credit(results)
.
If credit is specified in the workunit,
call get_credit_from_wu()
.
You must link these functions with the files validator.C, validate_util.C, and validate_util2.C. The result is your custom validator.
This example uses utility functions
get_output_file_path() and try_fopen(),
which are documented here.
"; block_start(); echo "
struct DATA {
int i;
double x;
};
int init_result(RESULT const & result, void*& data) {
FILE* f;
string path;
int i, n, retval;
double x;
retval = get_output_file_path(result, path);
if (retval) return retval;
retval = try_fopen(path.c_str(), f, \"r\");
if (retval) return retval;
n = fscanf(f, \"%d %f\", &i, &x);
if (n != 2) return ERR_XML_PARSE;
DATA* dp = new DATA;
dp->i = i;
dp->x = x;
data = (void*) dp;
return 0;
}
int compare_results(
RESULT& r1, void* _data1, RESULT const& r2, void* _data2, bool& match
) {
DATA* data1 = (DATA*)_data1;
DATA* data2 = (DATA*)_data2;
match = true;
if (data1->i != data2->i) match = false;
if (fabs(data1->x - data2->x) > 0.01) match = false;
return 0;
}
int cleanup_result(RESULT& r, void* data) {
if (data) delete (DATA*) data;
return 0;
}
double compute_granted_credit(WORKUNIT&, vector