int get_output_file_info(RESULT& result, FILE_INFO& fi) { char path[1024]; string name; MIOFILE mf; mf.init_buf_read(result.xml_doc_in); XML_PARSER xp(&mf); while (!xp.get_tag()) { if (!xp.is_tag) continue; if (xp.match_tag("file_ref")) { int retval = fi.parse(xp); if (retval) return retval; dir_hier_path( fi.name.c_str(), config.upload_dir, config.uldl_dir_fanout, path ); fi.path = path; return 0; } } return ERR_XML_PARSE; }
int get_output_file_infos(RESULT& result, vector<FILE_INFO>& fis) { char path[1024]; MIOFILE mf; string name; mf.init_buf_read(result.xml_doc_in); XML_PARSER xp(&mf); fis.clear(); while (!xp.get_tag()) { if (!xp.is_tag) continue; if (xp.match_tag("file_ref")) { FILE_INFO fi; int retval = fi.parse(xp); if (retval) return retval; dir_hier_path( fi.name.c_str(), config.upload_dir, config.uldl_dir_fanout, path ); fi.path = path; fis.push_back(fi); } } return 0; }
// return an error message or NULL // const char* SCHEDULER_REQUEST::parse(XML_PARSER& xp) { SCHED_DB_RESULT result; int retval; strcpy(authenticator, ""); strcpy(platform.name, ""); strcpy(cross_project_id, ""); hostid = 0; core_client_major_version = 0; core_client_minor_version = 0; core_client_release = 0; core_client_version = 0; rpc_seqno = 0; work_req_seconds = 0; cpu_req_secs = 0; cpu_req_instances = 0; resource_share_fraction = 1.0; rrs_fraction = 1.0; prrs_fraction = 1.0; cpu_estimated_delay = 0; strcpy(global_prefs_xml, ""); strcpy(working_global_prefs_xml, ""); strcpy(code_sign_key, ""); memset(&global_prefs, 0, sizeof(global_prefs)); memset(&host, 0, sizeof(host)); have_other_results_list = false; have_ip_results_list = false; have_time_stats_log = false; client_cap_plan_class = false; sandbox = -1; allow_multiple_clients = -1; if (xp.get_tag()) { return "xp.get_tag() failed"; } if (xp.match_tag("?xml")) { xp.get_tag(); } if (!xp.match_tag("scheduler_request")) return "no start tag"; while (!xp.get_tag()) { if (xp.match_tag("/scheduler_request")) { core_client_version = 10000*core_client_major_version + 100*core_client_minor_version + core_client_release; return NULL; } if (xp.parse_str("authenticator", authenticator, sizeof(authenticator))) { remove_quotes(authenticator); continue; } if (xp.parse_str("cross_project_id", cross_project_id, sizeof(cross_project_id))) continue; if (xp.parse_int("hostid", hostid)) continue; if (xp.parse_int("rpc_seqno", rpc_seqno)) continue; if (xp.parse_str("platform_name", platform.name, sizeof(platform.name))) continue; if (xp.match_tag("alt_platform")) { CLIENT_PLATFORM cp; retval = cp.parse(xp); if (!retval) { alt_platforms.push_back(cp); } continue; } if (xp.match_tag("app_versions")) { while (!xp.get_tag()) { if (xp.match_tag("/app_versions")) break; if (xp.match_tag("app_version")) { CLIENT_APP_VERSION cav; retval = cav.parse(xp); if (retval) { if (!strcmp(platform.name, "anonymous")) { if (retval == ERR_NOT_FOUND) { g_reply->insert_message( _("Unknown app name in app_info.xml"), "notice" ); } else { g_reply->insert_message( _("Syntax error in app_info.xml"), "notice" ); } } else { // this case happens if the app version // refers to a deprecated app } cav.app = 0; } // store the CLIENT_APP_VERSION even if it didn't parse. // This is necessary to maintain the correspondence // with result.app_version // client_app_versions.push_back(cav); } } continue; } if (xp.parse_int("core_client_major_version", core_client_major_version)) continue; if (xp.parse_int("core_client_minor_version", core_client_minor_version)) continue; if (xp.parse_int("core_client_release", core_client_release)) continue; if (xp.parse_double("work_req_seconds", work_req_seconds)) continue; if (xp.parse_double("cpu_req_secs", cpu_req_secs)) continue; if (xp.parse_double("cpu_req_instances", cpu_req_instances)) continue; if (xp.parse_double("resource_share_fraction", resource_share_fraction)) continue; if (xp.parse_double("rrs_fraction", rrs_fraction)) continue; if (xp.parse_double("prrs_fraction", prrs_fraction)) continue; if (xp.parse_double("estimated_delay", cpu_estimated_delay)) continue; if (xp.parse_double("duration_correction_factor", host.duration_correction_factor)) continue; if (xp.match_tag("global_preferences")) { strcpy(global_prefs_xml, "<global_preferences>\n"); char buf[BLOB_SIZE]; retval = xp.element_contents( "</global_preferences>", buf, sizeof(buf) ); if (retval) return "error copying global prefs"; safe_strcat(global_prefs_xml, buf); safe_strcat(global_prefs_xml, "</global_preferences>\n"); continue; } if (xp.match_tag("working_global_preferences")) { retval = xp.element_contents( "</working_global_preferences>", working_global_prefs_xml, sizeof(working_global_prefs_xml) ); if (retval) return "error copying working global prefs"; continue; } if (xp.parse_str("global_prefs_source_email_hash", global_prefs_source_email_hash, sizeof(global_prefs_source_email_hash))) continue; if (xp.match_tag("host_info")) { host.parse(xp); continue; } if (xp.match_tag("time_stats")) { host.parse_time_stats(xp); continue; } if (xp.match_tag("time_stats_log")) { handle_time_stats_log(xp.f->f); have_time_stats_log = true; continue; } if (xp.match_tag("net_stats")) { host.parse_net_stats(xp); continue; } if (xp.match_tag("disk_usage")) { host.parse_disk_usage(xp); continue; } if (xp.match_tag("result")) { retval = result.parse_from_client(xp); if (retval) continue; if (strstr(result.name, "download") || strstr(result.name, "upload")) { file_xfer_results.push_back(result); continue; } #if 0 // enable if you need to limit CGI memory size if (results.size() >= 1024) { continue; } #endif // check if client is sending the same result twice. // Shouldn't happen, but if it does bad things will happen // bool found = false; for (unsigned int i=0; i<results.size(); i++) { if (!strcmp(results[i].name, result.name)) { found = true; break; } } if (!found) { results.push_back(result); } continue; } if (xp.match_tag("code_sign_key")) { copy_element_contents(xp.f->f, "</code_sign_key>", code_sign_key, sizeof(code_sign_key)); strip_whitespace(code_sign_key); continue; } if (xp.match_tag("msg_from_host")) { MSG_FROM_HOST_DESC md; retval = md.parse(xp); if (!retval) { msgs_from_host.push_back(md); } continue; } if (xp.match_tag("file_info")) { FILE_INFO fi; retval = fi.parse(xp); if (!retval) { file_infos.push_back(fi); } continue; } if (xp.match_tag("host_venue")) { continue; } if (xp.match_tag("other_results")) { have_other_results_list = true; while (!xp.get_tag()) { if (xp.match_tag("/other_results")) break; if (xp.match_tag("other_result")) { OTHER_RESULT o_r; retval = o_r.parse(xp); if (!retval) { other_results.push_back(o_r); } } } continue; } if (xp.match_tag("in_progress_results")) { have_ip_results_list = true; int i = 0; double now = time(0); while (!xp.get_tag()) { if (xp.match_tag("/in_progress_results")) break; if (xp.match_tag("ip_result")) { IP_RESULT ir; retval = ir.parse(xp); if (!retval) { if (!strlen(ir.name)) { sprintf(ir.name, "ip%d", i++); } ir.report_deadline -= now; ip_results.push_back(ir); } } } continue; } if (xp.match_tag("coprocs")) { coprocs.parse(xp); continue; } if (xp.parse_bool("client_cap_plan_class", client_cap_plan_class)) continue; if (xp.parse_int("sandbox", sandbox)) continue; if (xp.parse_int("allow_multiple_clients", allow_multiple_clients)) continue; if (xp.parse_string("client_opaque", client_opaque)) continue; if (xp.match_tag("active_task_set")) continue; if (xp.match_tag("app")) continue; if (xp.match_tag("app_version")) continue; if (xp.match_tag("duration_variability")) continue; if (xp.match_tag("new_version_check_time")) continue; if (xp.match_tag("newer_version")) continue; if (xp.match_tag("project")) continue; if (xp.match_tag("project_files")) continue; if (xp.match_tag("proxy_info")) continue; if (xp.match_tag("user_network_request")) continue; if (xp.match_tag("user_run_request")) continue; if (xp.match_tag("master_url")) continue; if (xp.match_tag("project_name")) continue; if (xp.match_tag("user_name")) continue; if (xp.match_tag("team_name")) continue; if (xp.match_tag("email_hash")) continue; if (xp.match_tag("user_total_credit")) continue; if (xp.match_tag("user_expavg_credit")) continue; if (xp.match_tag("user_create_time")) continue; if (xp.match_tag("host_total_credit")) continue; if (xp.match_tag("host_expavg_credit")) continue; if (xp.match_tag("host_create_time")) continue; if (xp.match_tag("nrpc_failures")) continue; if (xp.match_tag("master_fetch_failures")) continue; if (xp.match_tag("min_rpc_time")) continue; if (xp.match_tag("short_term_debt")) continue; if (xp.match_tag("long_term_debt")) continue; if (xp.match_tag("resource_share")) continue; if (xp.match_tag("scheduler_url")) continue; if (xp.match_tag("/project")) continue; if (xp.match_tag("?xml")) continue; log_messages.printf(MSG_NORMAL, "SCHEDULER_REQUEST::parse(): unexpected: %s\n", xp.parsed_tag ); xp.skip_unexpected(); } return "no end tag"; }
// return an error message or NULL // const char* SCHEDULER_REQUEST::parse(FILE* fin) { char buf[256]; RESULT result; int retval; strcpy(authenticator, ""); strcpy(platform.name, ""); strcpy(cross_project_id, ""); hostid = 0; core_client_major_version = 0; core_client_minor_version = 0; core_client_release = 0; rpc_seqno = 0; work_req_seconds = 0; cpu_req_secs = 0; cpu_req_instances = 0; resource_share_fraction = 1.0; rrs_fraction = 1.0; prrs_fraction = 1.0; cpu_estimated_delay = 0; strcpy(global_prefs_xml, ""); strcpy(working_global_prefs_xml, ""); strcpy(code_sign_key, ""); memset(&global_prefs, 0, sizeof(global_prefs)); memset(&host, 0, sizeof(host)); have_other_results_list = false; have_ip_results_list = false; have_time_stats_log = false; client_cap_plan_class = false; sandbox = -1; coproc_cuda = 0; coproc_ati = 0; fgets(buf, sizeof(buf), fin); if (!match_tag(buf, "<scheduler_request>")) return "no start tag"; while (fgets(buf, sizeof(buf), fin)) { // If a line is too long, ignore it. // This can happen e.g. if the client has bad global_prefs.xml // This won't be necessary if we rewrite this using XML_PARSER // if (!strchr(buf, '\n')) { while (fgets(buf, sizeof(buf), fin)) { if (strchr(buf, '\n')) break; } continue; } if (match_tag(buf, "</scheduler_request>")) { core_client_version = 10000*core_client_major_version + 100*core_client_minor_version + core_client_release; return NULL; } if (parse_str(buf, "<authenticator>", authenticator, sizeof(authenticator))) { remove_quotes(authenticator); continue; } if (parse_str(buf, "<cross_project_id>", cross_project_id, sizeof(cross_project_id))) continue; if (parse_int(buf, "<hostid>", hostid)) continue; if (parse_int(buf, "<rpc_seqno>", rpc_seqno)) continue; if (parse_str(buf, "<platform_name>", platform.name, sizeof(platform.name))) continue; if (match_tag(buf, "<alt_platform>")) { CLIENT_PLATFORM cp; retval = cp.parse(fin); if (!retval) { alt_platforms.push_back(cp); } continue; } if (match_tag(buf, "<app_versions>")) { while (fgets(buf, sizeof(buf), fin)) { if (match_tag(buf, "</app_versions>")) break; if (match_tag(buf, "<app_version>")) { CLIENT_APP_VERSION cav; retval = cav.parse(fin); if (retval) { g_reply->insert_message( "Invalid app version description", "high" ); } else { client_app_versions.push_back(cav); } } } continue; } if (parse_int(buf, "<core_client_major_version>", core_client_major_version)) continue; if (parse_int(buf, "<core_client_minor_version>", core_client_minor_version)) continue; if (parse_int(buf, "<core_client_release>", core_client_release)) continue; if (parse_double(buf, "<work_req_seconds>", work_req_seconds)) continue; if (parse_double(buf, "<cpu_req_secs>", cpu_req_secs)) continue; if (parse_double(buf, "<cpu_req_instances>", cpu_req_instances)) continue; if (parse_double(buf, "<resource_share_fraction>", resource_share_fraction)) continue; if (parse_double(buf, "<rrs_fraction>", rrs_fraction)) continue; if (parse_double(buf, "<prrs_fraction>", prrs_fraction)) continue; if (parse_double(buf, "<estimated_delay>", cpu_estimated_delay)) continue; if (parse_double(buf, "<duration_correction_factor>", host.duration_correction_factor)) continue; if (match_tag(buf, "<global_preferences>")) { strcpy(global_prefs_xml, "<global_preferences>\n"); while (fgets(buf, sizeof(buf), fin)) { if (strstr(buf, "</global_preferences>")) break; safe_strcat(global_prefs_xml, buf); } safe_strcat(global_prefs_xml, "</global_preferences>\n"); continue; } if (match_tag(buf, "<working_global_preferences>")) { while (fgets(buf, sizeof(buf), fin)) { if (strstr(buf, "</working_global_preferences>")) break; safe_strcat(working_global_prefs_xml, buf); } continue; } if (parse_str(buf, "<global_prefs_source_email_hash>", global_prefs_source_email_hash, sizeof(global_prefs_source_email_hash))) continue; if (match_tag(buf, "<host_info>")) { host.parse(fin); continue; } if (match_tag(buf, "<time_stats>")) { host.parse_time_stats(fin); continue; } if (match_tag(buf, "<time_stats_log>")) { handle_time_stats_log(fin); have_time_stats_log = true; continue; } if (match_tag(buf, "<net_stats>")) { host.parse_net_stats(fin); continue; } if (match_tag(buf, "<disk_usage>")) { host.parse_disk_usage(fin); continue; } if (match_tag(buf, "<result>")) { result.parse_from_client(fin); static int max_results = 200; --max_results; if (max_results >= 0) results.push_back(result); continue; } if (match_tag(buf, "<code_sign_key>")) { copy_element_contents(fin, "</code_sign_key>", code_sign_key, sizeof(code_sign_key)); continue; } if (match_tag(buf, "<msg_from_host>")) { MSG_FROM_HOST_DESC md; retval = md.parse(fin); if (!retval) { msgs_from_host.push_back(md); } continue; } if (match_tag(buf, "<file_info>")) { FILE_INFO fi; retval = fi.parse(fin); if (!retval) { file_infos.push_back(fi); } continue; } if (match_tag(buf, "<host_venue>")) { continue; } if (match_tag(buf, "<other_results>")) { have_other_results_list = true; while (fgets(buf, sizeof(buf), fin)) { if (match_tag(buf, "</other_results>")) break; if (match_tag(buf, "<other_result>")) { OTHER_RESULT o_r; retval = o_r.parse(fin); if (!retval) { other_results.push_back(o_r); } } } continue; } if (match_tag(buf, "<in_progress_results>")) { have_ip_results_list = true; int i = 0; double now = time(0); while (fgets(buf, sizeof(buf), fin)) { if (match_tag(buf, "</in_progress_results>")) break; if (match_tag(buf, "<ip_result>")) { IP_RESULT ir; retval = ir.parse(fin); if (!retval) { if (!strlen(ir.name)) { sprintf(ir.name, "ip%d", i++); } ir.report_deadline -= now; ip_results.push_back(ir); } } } continue; } if (match_tag(buf, "coprocs")) { MIOFILE mf; mf.init_file(fin); coprocs.parse(mf); coproc_cuda = (COPROC_CUDA*)coprocs.lookup("CUDA"); coproc_ati = (COPROC_ATI*)coprocs.lookup("ATI"); continue; } if (parse_bool(buf, "client_cap_plan_class", client_cap_plan_class)) continue; if (parse_int(buf, "<sandbox>", sandbox)) continue; if (match_tag(buf, "<active_task_set>")) continue; if (match_tag(buf, "<app>")) continue; if (match_tag(buf, "<app_version>")) continue; if (match_tag(buf, "<duration_variability>")) continue; if (match_tag(buf, "<new_version_check_time>")) continue; if (match_tag(buf, "<newer_version>")) continue; if (match_tag(buf, "<project>")) continue; if (match_tag(buf, "<project_files>")) continue; if (match_tag(buf, "<proxy_info>")) continue; if (match_tag(buf, "<user_network_request>")) continue; if (match_tag(buf, "<user_run_request>")) continue; if (match_tag(buf, "<master_url>")) continue; if (match_tag(buf, "<project_name>")) continue; if (match_tag(buf, "<user_name>")) continue; if (match_tag(buf, "<team_name>")) continue; if (match_tag(buf, "<email_hash>")) continue; if (match_tag(buf, "<user_total_credit>")) continue; if (match_tag(buf, "<user_expavg_credit>")) continue; if (match_tag(buf, "<user_create_time>")) continue; if (match_tag(buf, "<host_total_credit>")) continue; if (match_tag(buf, "<host_expavg_credit>")) continue; if (match_tag(buf, "<host_create_time>")) continue; if (match_tag(buf, "<nrpc_failures>")) continue; if (match_tag(buf, "<master_fetch_failures>")) continue; if (match_tag(buf, "<min_rpc_time>")) continue; if (match_tag(buf, "<short_term_debt>")) continue; if (match_tag(buf, "<long_term_debt>")) continue; if (match_tag(buf, "<resource_share>")) continue; if (match_tag(buf, "<scheduler_url>")) continue; if (match_tag(buf, "</project>")) continue; if (match_tag(buf, "<?xml")) continue; strip_whitespace(buf); if (!strlen(buf)) continue; log_messages.printf(MSG_NORMAL, "SCHEDULER_REQUEST::parse(): unrecognized: %s\n", buf ); MIOFILE mf; mf.init_file(fin); retval = skip_unrecognized(buf, mf); if (retval) return "unterminated unrecognized XML"; } return "no end tag"; }
// parse a project's app_info.xml (anonymous platform) file // int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) { char buf[256], path[MAXPATHLEN]; MIOFILE mf; mf.init_file(in); XML_PARSER xp(&mf); while (!xp.get_tag()) { if (xp.match_tag("app_info")) continue; if (xp.match_tag("/app_info")) { notices.remove_notices(p, REMOVE_APP_INFO_MSG); return 0; } if (xp.match_tag("file_info") || xp.match_tag("file")) { FILE_INFO* fip = new FILE_INFO; if (fip->parse(xp)) { delete fip; continue; } if (!fip->download_urls.empty() || !fip->upload_urls.empty()) { msg_printf(p, MSG_INFO, "Can't specify URLs in app_info.xml" ); delete fip; continue; } if (link_file_info(p, fip)) { delete fip; continue; } // check that the file is actually there // get_pathname(fip, path, sizeof(path)); if (!boinc_file_exists(path)) { safe_strcpy(buf, _("File referenced in app_info.xml does not exist: ") ); strcat(buf, fip->name); msg_printf(p, MSG_USER_ALERT, "%s", buf); delete fip; continue; } fip->status = FILE_PRESENT; fip->anonymous_platform_file = true; file_infos.push_back(fip); continue; } if (xp.match_tag("app")) { APP* app = new APP; if (app->parse(xp)) { delete app; continue; } if (lookup_app(p, app->name)) { delete app; continue; } link_app(p, app); apps.push_back(app); continue; } if (xp.match_tag("app_version")) { APP_VERSION* avp = new APP_VERSION; if (avp->parse(xp)) { delete avp; continue; } if (cc_config.dont_use_vbox && strstr(avp->plan_class, "vbox")) { msg_printf(p, MSG_INFO, "skipping vbox app in app_info.xml; vbox disabled in cc_config.xml" ); delete avp; continue; } if (strlen(avp->platform) == 0) { safe_strcpy(avp->platform, get_primary_platform()); } if (link_app_version(p, avp)) { delete avp; continue; } app_versions.push_back(avp); continue; } if (log_flags.unparsed_xml) { msg_printf(p, MSG_INFO, "Unparsed line in app_info.xml: %s", xp.parsed_tag ); } } return ERR_XML_PARSE; }
int CLIENT_STATE::parse_state_file_aux(const char* fname) { PROJECT *project=NULL; int retval=0; string stemp; FILE* f = fopen(fname, "r"); if (!f) return ERR_FOPEN; MIOFILE mf; XML_PARSER xp(&mf); mf.init_file(f); while (!xp.get_tag()) { if (xp.match_tag("/client_state")) { break; } if (xp.match_tag("client_state")) { continue; } if (xp.match_tag("project")) { PROJECT temp_project; retval = temp_project.parse_state(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse project in state file"); } else { #ifdef SIM project = new PROJECT; *project = temp_project; projects.push_back(project); #else project = lookup_project(temp_project.master_url); if (project) { project->copy_state_fields(temp_project); } else { msg_printf(&temp_project, MSG_INTERNAL_ERROR, "Project %s is in state file but no account file found", temp_project.get_project_name() ); } #endif } continue; } if (xp.match_tag("app")) { APP* app = new APP; retval = app->parse(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Application %s outside project in state file", app->name ); delete app; continue; } if (project->anonymous_platform) { delete app; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse application in state file" ); delete app; continue; } retval = link_app(project, app); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't handle application %s in state file", app->name ); delete app; continue; } apps.push_back(app); continue; } if (xp.match_tag("file_info") || xp.match_tag("file")) { FILE_INFO* fip = new FILE_INFO; retval = fip->parse(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "File info outside project in state file" ); delete fip; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't handle file info in state file" ); delete fip; continue; } retval = link_file_info(project, fip); if (project->anonymous_platform && retval == ERR_NOT_UNIQUE) { delete fip; continue; } if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't handle file info %s in state file", fip->name ); delete fip; continue; } file_infos.push_back(fip); #ifndef SIM // If the file had a failure before, // don't start another file transfer // int failnum; if (fip->had_failure(failnum)) { if (fip->pers_file_xfer) { delete fip->pers_file_xfer; fip->pers_file_xfer = NULL; } } if (fip->pers_file_xfer) { retval = fip->pers_file_xfer->init(fip, fip->pers_file_xfer->is_upload); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't initialize file transfer for %s", fip->name ); } retval = pers_file_xfers->insert(fip->pers_file_xfer); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't start persistent file transfer for %s", fip->name ); } } #endif continue; } if (xp.match_tag("app_version")) { APP_VERSION* avp = new APP_VERSION; retval = avp->parse(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Application version outside project in state file" ); delete avp; continue; } if (project->anonymous_platform) { delete avp; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse application version in state file" ); delete avp; continue; } if (strlen(avp->platform) == 0) { safe_strcpy(avp->platform, get_primary_platform()); } else { if (!is_supported_platform(avp->platform)) { // if it's a platform we haven't heard of, // must be that the user tried out a 64 bit client // and then reverted to a 32-bit client. // Let's not throw away the app version and its WUs // #ifndef SIM msg_printf(project, MSG_INTERNAL_ERROR, "App version has unsupported platform %s; changing to %s", avp->platform, get_primary_platform() ); #endif safe_strcpy(avp->platform, get_primary_platform()); } } if (avp->missing_coproc) { msg_printf(project, MSG_INFO, "Application uses missing %s GPU", avp->missing_coproc_name ); } retval = link_app_version(project, avp); if (retval) { delete avp; continue; } app_versions.push_back(avp); continue; } if (xp.match_tag("workunit")) { WORKUNIT* wup = new WORKUNIT; retval = wup->parse(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Workunit outside project in state file" ); delete wup; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse workunit in state file" ); delete wup; continue; } retval = link_workunit(project, wup); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't handle workunit in state file" ); delete wup; continue; } workunits.push_back(wup); continue; } if (xp.match_tag("result")) { RESULT* rp = new RESULT; retval = rp->parse_state(xp); if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Task %s outside project in state file", rp->name ); delete rp; continue; } if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse task in state file" ); delete rp; continue; } retval = link_result(project, rp); if (retval) { msg_printf(project, MSG_INTERNAL_ERROR, "Can't link task %s in state file", rp->name ); delete rp; continue; } // handle transition from old clients which didn't store result.platform; // skip for anon platform if (!project->anonymous_platform) { if (!strlen(rp->platform) || !is_supported_platform(rp->platform)) { safe_strcpy(rp->platform, get_primary_platform()); rp->version_num = latest_version(rp->wup->app, rp->platform); } } rp->avp = lookup_app_version( rp->wup->app, rp->platform, rp->version_num, rp->plan_class ); if (!rp->avp) { msg_printf(project, MSG_INTERNAL_ERROR, "No application found for task: %s %d %s; discarding", rp->platform, rp->version_num, rp->plan_class ); delete rp; continue; } if (rp->avp->missing_coproc) { msg_printf(project, MSG_INFO, "Missing coprocessor for task %s", rp->name ); rp->coproc_missing = true; } rp->wup->version_num = rp->version_num; results.push_back(rp); continue; } if (xp.match_tag("project_files")) { if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Project files outside project in state file" ); xp.skip_unexpected(); continue; } parse_project_files(xp, project->project_files); project->link_project_files(); continue; } if (xp.match_tag("host_info")) { #ifdef SIM retval = host_info.parse(xp, false); coprocs = host_info.coprocs; coprocs.bound_counts(); #else retval = host_info.parse(xp, true); #endif if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse host info in state file" ); } continue; } if (xp.match_tag("time_stats")) { retval = time_stats.parse(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse time stats in state file" ); } continue; } if (xp.match_tag("net_stats")) { retval = net_stats.parse(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse network stats in state file" ); } continue; } if (xp.match_tag("active_task_set")) { retval = active_tasks.parse(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse active tasks in state file" ); } continue; } if (xp.parse_string("platform_name", statefile_platform_name)) { continue; } if (xp.parse_string("alt_platform", stemp)) { continue; } if (xp.parse_int("user_run_request", retval)) { cpu_run_mode.set(retval, 0); continue; } if (xp.parse_int("user_run_prev_request", retval)) { cpu_run_mode.set_prev(retval); continue; } if (xp.parse_int("user_gpu_request", retval)) { gpu_run_mode.set(retval, 0); continue; } if (xp.parse_int("user_gpu_prev_request", retval)) { gpu_run_mode.set_prev(retval); continue; } if (xp.parse_int("user_network_request", retval)) { network_run_mode.set(retval, 0); continue; } if (xp.parse_int("core_client_major_version", old_major_version)) { continue; } if (xp.parse_int("core_client_minor_version", old_minor_version)) { continue; } if (xp.parse_int("core_client_release", old_release)) { continue; } if (xp.parse_str("language", language, sizeof(language))) { continue; } if (xp.match_tag("proxy_info")) { retval = gui_proxy_info.parse(xp); if (retval) { msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse proxy info in state file" ); } continue; } if (xp.parse_str("host_venue", main_host_venue, sizeof(main_host_venue))) { continue; } if (xp.parse_double("new_version_check_time", new_version_check_time)) { continue; } if (xp.parse_double("all_projects_list_check_time", all_projects_list_check_time)) { continue; } if (xp.parse_string("newer_version", newer_version)) { continue; } #ifdef ENABLE_AUTO_UPDATE if (xp.match_tag("auto_update")) { if (!project) { msg_printf(NULL, MSG_INTERNAL_ERROR, "auto update outside project in state file" ); xp.skip_unexpected(); continue; } if (!auto_update.parse(xp) && !auto_update.validate_and_link(project)) { auto_update.present = true; } continue; } #endif if (log_flags.unparsed_xml) { msg_printf(0, MSG_INFO, "[unparsed_xml] state_file: unrecognized: %s", xp.parsed_tag ); } xp.skip_unexpected(); } sort_results(); fclose(f); // if total resource share is zero, set all shares to 1 // if (projects.size()) { unsigned int i; double x=0; for (i=0; i<projects.size(); i++) { x += projects[i]->resource_share; } if (!x) { msg_printf(NULL, MSG_INFO, "All projects have zero resource share; setting to 100" ); for (i=0; i<projects.size(); i++) { projects[i]->resource_share = 100; } } } return 0; }