// The contents of this file are subject to the BOINC Public License // 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 // http://boinc.berkeley.edu/license_1.0.txt // // 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 // under the License. // // 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. // // Contributor(s): // #ifdef _WIN32 #include "boinc_win.h" #endif #ifndef _WIN32 #include #include #include #include #include #include #include #include #include #include #include #endif #include "parse.h" #include "error_numbers.h" #include "miofile.h" #include "gui_rpc_client.h" using std::string; using std::vector; int GUI_URL::parse(MIOFILE& in) { char buf[256]; while (in.fgets(buf, 256)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", name)) continue; else if (parse_str(buf, "", description)) continue; else if (parse_str(buf, "", url)) continue; } return ERR_XML_PARSE; } void GUI_URL::print() { printf( "GUI URL:\n" " name: %s\n" " description: %s\n" " URL: %s\n", name.c_str(), description.c_str(), url.c_str() ); } PROJECT::PROJECT() { clear(); } PROJECT::~PROJECT() { clear(); } int PROJECT::parse(MIOFILE& in) { char buf[256]; int retval; while (in.fgets(buf, 256)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", master_url)) continue; else if (parse_double(buf, "", resource_share)) continue; else if (parse_str(buf, "", project_name)) continue; else if (parse_str(buf, "", user_name)) continue; else if (parse_str(buf, "", team_name)) continue; else if (parse_double(buf, "", user_total_credit)) continue; else if (parse_double(buf, "", user_expavg_credit)) continue; else if (parse_double(buf, "", host_total_credit)) continue; else if (parse_double(buf, "", host_expavg_credit)) continue; else if (parse_double(buf, "", disk_usage)) continue; else if (parse_int(buf, "", nrpc_failures)) continue; else if (parse_int(buf, "", master_fetch_failures)) continue; else if (parse_int(buf, "", min_rpc_time)) continue; else if (match_tag(buf, "")) { master_url_fetch_pending = true; continue; } else if (match_tag(buf, "")) { sched_rpc_pending = true; continue; } else if (match_tag(buf, "")) { suspended_via_gui = true; continue; } else if (match_tag(buf, "")) { tentative = true; continue; } else if (match_tag(buf, "")) { while (in.fgets(buf, 256)) { if (match_tag(buf, "")) break; else if (match_tag(buf, "")) { GUI_URL gu; retval = gu.parse(in); if (!retval) { gui_urls.push_back(gu); } } } continue; } } return ERR_XML_PARSE; } void PROJECT::print() { unsigned int i; printf(" name: %s\n", project_name.c_str()); printf(" master URL: %s\n", master_url.c_str()); printf(" user_name: %s\n", user_name.c_str()); printf(" team_name: %s\n", team_name.c_str()); printf(" resource share: %f\n", resource_share); printf(" user_total_credit: %f\n", user_total_credit); printf(" user_expavg_credit: %f\n", user_expavg_credit); printf(" host_total_credit: %f\n", host_total_credit); printf(" host_expavg_credit: %f\n", host_expavg_credit); printf(" nrpc_failures: %d\n", nrpc_failures); printf(" master_fetch_failures: %d\n", master_fetch_failures); printf(" master fetch pending: %s\n", master_url_fetch_pending?"yes":"no"); printf(" scheduler RPC pending: %s\n", sched_rpc_pending?"yes":"no"); printf(" tentative: %s\n", tentative?"yes":"no"); printf(" suspended via GUI: %s\n", suspended_via_gui?"yes":"no"); for (i=0; i")) return 0; else if (parse_str(buf, "", name)) continue; } return ERR_XML_PARSE; } void APP::print() { printf(" name: %s\n", name.c_str()); printf(" Project: %s\n", project->project_name.c_str()); } void APP::clear() { name.clear(); project = NULL; } APP_VERSION::APP_VERSION() { clear(); } APP_VERSION::~APP_VERSION() { clear(); } int APP_VERSION::parse(MIOFILE& in) { char buf[256]; while (in.fgets(buf, 256)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", app_name)) continue; else if (parse_int(buf, "", version_num)) continue; } return ERR_XML_PARSE; } void APP_VERSION::print() { printf(" application: %s\n", app->name.c_str()); printf(" version: %.2f\n", version_num/100.0); printf(" project: %s\n", project->project_name.c_str()); } void APP_VERSION::clear() { app_name.clear(); version_num = 0; app = NULL; project = NULL; } WORKUNIT::WORKUNIT() { clear(); } WORKUNIT::~WORKUNIT() { clear(); } int WORKUNIT::parse(MIOFILE& in) { char buf[256]; while (in.fgets(buf, 256)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", name)) continue; else if (parse_str(buf, "", app_name)) continue; else if (parse_int(buf, "", version_num)) continue; else if (parse_double(buf, "", rsc_fpops_est)) continue; else if (parse_double(buf, "", rsc_fpops_bound)) continue; else if (parse_double(buf, "", rsc_memory_bound)) continue; else if (parse_double(buf, "", rsc_disk_bound)) continue; } return ERR_XML_PARSE; } void WORKUNIT::print() { printf(" name: %s\n", name.c_str()); printf(" FP estimate: %f\n", rsc_fpops_est); printf(" FP bound: %f\n", rsc_fpops_bound); printf(" memory bound: %f\n", rsc_memory_bound); printf(" disk bound: %f\n", rsc_disk_bound); } void WORKUNIT::clear() { name.clear(); app_name.clear(); version_num = 0; rsc_fpops_est = 0.0; rsc_fpops_bound = 0.0; rsc_memory_bound = 0.0; rsc_disk_bound = 0.0; project = NULL; app = NULL; avp = NULL; } RESULT::RESULT() { clear(); } RESULT::~RESULT() { clear(); } int RESULT::parse(MIOFILE& in) { char buf[256]; while (in.fgets(buf, 256)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", name)) continue; else if (parse_str(buf, "", wu_name)) continue; else if (parse_str(buf, "", project_url)) continue; else if (parse_int(buf, "", report_deadline)) continue; else if (match_tag(buf, "")) { ready_to_report = true; continue; } else if (match_tag(buf, "")) { got_server_ack = true; continue; } else if (match_tag(buf, "")) { suspended_via_gui = true; continue; } else if (match_tag(buf, "")) { active_task = true; continue; } else if (parse_double(buf, "", final_cpu_time)) continue; else if (parse_int(buf, "", state)) continue; else if (parse_int(buf, "", scheduler_state)) continue; else if (parse_int(buf, "", exit_status)) continue; else if (parse_int(buf, "", signal)) continue; else if (parse_int(buf, "", active_task_state)) continue; else if (match_tag(buf, "")) { copy_element_contents(in, "", stderr_out); } else if (parse_int(buf, "", app_version_num)) continue; else if (parse_double(buf, "", checkpoint_cpu_time)) continue; else if (parse_double(buf, "", current_cpu_time)) continue; else if (parse_double(buf, "", fraction_done)) continue; else if (parse_double(buf, "", estimated_cpu_time_remaining)) continue; } return ERR_XML_PARSE; } void RESULT::print() { printf(" name: %s\n", name.c_str()); printf(" WU name: %s\n", wup->name.c_str()); printf(" ready to report: %s\n", ready_to_report?"yes":"no"); printf(" got server ack: %s\n", got_server_ack?"yes":"no"); printf(" final CPU time: %f\n", final_cpu_time); printf(" state: %d\n", state); printf(" exit_status: %d\n", exit_status); printf(" signal: %d\n", signal); printf(" active_task_state: %d\n", active_task_state); printf(" stderr_out: %s\n", stderr_out.c_str()); printf(" app version num: %d\n", app_version_num); printf(" checkpoint CPU time: %f\n", checkpoint_cpu_time); printf(" current CPU time: %f\n", current_cpu_time); printf(" fraction done: %f\n", fraction_done); } void RESULT::clear() { name.clear(); wu_name.clear(); project_url.clear(); report_deadline = 0; ready_to_report = false; got_server_ack = false; final_cpu_time = 0.0; state = 0; scheduler_state = 0; exit_status = 0; signal = 0; active_task_state = 0; active_task = false; stderr_out.clear(); app_version_num = 0; checkpoint_cpu_time = 0.0; current_cpu_time = 0.0; fraction_done = 0.0; estimated_cpu_time_remaining = 0.0; suspended_via_gui = false; } FILE_TRANSFER::FILE_TRANSFER() { clear(); } FILE_TRANSFER::~FILE_TRANSFER() { clear(); } int FILE_TRANSFER::parse(MIOFILE& in) { char buf[256]; while (in.fgets(buf, 256)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", name)) continue; else if (parse_str(buf, "", project_url)) continue; else if (parse_str(buf, "", project_name)) continue; else if (parse_double(buf, "", nbytes)) continue; else if (match_tag(buf, "")) { generated_locally = true; continue; } else if (match_tag(buf, "")) { uploaded = true; continue; } else if (match_tag(buf, "")) { upload_when_present = true; continue; } else if (match_tag(buf, "")) { sticky = true; continue; } else if (match_tag(buf, "")) { pers_xfer_active = true; continue; } else if (match_tag(buf, "")) { xfer_active = true; continue; } else if (parse_int(buf, "", num_retries)) continue; else if (parse_int(buf, "", first_request_time)) continue; else if (parse_int(buf, "", next_request_time)) continue; else if (parse_int(buf, "", status)) continue; else if (parse_double(buf, "", time_so_far)) continue; else if (parse_double(buf, "", bytes_xferred)) continue; else if (parse_double(buf, "", file_offset)) continue; else if (parse_double(buf, "", xfer_speed)) continue; else if (parse_str(buf, "", hostname)) continue; } return ERR_XML_PARSE; } void FILE_TRANSFER::print() { printf(" name: %s\n", name.c_str()); printf(" generated locally: %s\n", generated_locally?"yes":"no"); printf(" uploaded: %s\n", uploaded?"yes":"no"); printf(" upload when present: %s\n", upload_when_present?"yes":"no"); printf(" sticky: %s\n", sticky?"yes":"no"); printf(" generated locally: %s\n", generated_locally?"yes":"no"); } void FILE_TRANSFER::clear() { name.clear(); project_url.clear(); project_name.clear(); nbytes = 0.0; generated_locally = false; uploaded = false; upload_when_present = false; sticky = false; pers_xfer_active = false; xfer_active = false; num_retries = 0; first_request_time = 0; next_request_time = 0; status = 0; time_so_far = 0.0; bytes_xferred = 0.0; file_offset = 0.0; xfer_speed = 0.0; hostname.clear(); project = NULL; } MESSAGE::MESSAGE() { clear(); } MESSAGE::~MESSAGE() { clear(); } int MESSAGE::parse(MIOFILE& in) { char buf[256]; while (in.fgets(buf, 256)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", project)) continue; else if (match_tag(buf, "" )) { copy_element_contents(in, "", body); continue; } else if (parse_int(buf, "", priority)) continue; else if (parse_int(buf, "