int CONFIG::parse(FILE* f) { char tag[256]; MIOFILE mf; XML_PARSER xp(&mf); bool is_tag; mf.init_file(f); if (!xp.parse_start("cc_config")) { msg_printf(NULL, MSG_USER_ALERT, "Missing start tag in %s", CONFIG_FILE); return ERR_XML_PARSE; } while (!xp.get(tag, sizeof(tag), is_tag)) { if (!is_tag) { msg_printf(NULL, MSG_USER_ALERT, "Unexpected text %s in %s", tag, CONFIG_FILE ); continue; } if (!strcmp(tag, "/cc_config")) return 0; if (!strcmp(tag, "log_flags")) { log_flags.parse(xp); continue; } if (!strcmp(tag, "options")) { parse_options(xp); continue; } msg_printf(NULL, MSG_USER_ALERT, "Unparsed tag in %s: <%s>\n", CONFIG_FILE, tag ); xp.skip_unexpected(tag, true, "CONFIG.parse"); } msg_printf(NULL, MSG_USER_ALERT, "Missing end tag in %s", CONFIG_FILE); return ERR_XML_PARSE; }
// read config file, e.g. cc_config.xml // Called on startup and in response to GUI RPC requesting reread // int read_config_file(bool init, const char* fname) { if (!init) { msg_printf(NULL, MSG_INFO, "Re-reading %s", fname); cc_config.defaults(); log_flags.init(); } FILE* f = boinc_fopen(fname, "r"); if (!f) { msg_printf(NULL, MSG_INFO, "cc_config.xml not found - using defaults"); return ERR_FOPEN; } cc_config.parse_client(f); fclose(f); #ifndef SIM diagnostics_set_max_file_sizes( cc_config.max_stdout_file_size, cc_config.max_stderr_file_size ); #endif config_proxy_info = cc_config.proxy_info; if (init) { coprocs = cc_config.config_coprocs; } else { select_proxy_info(); // in case added or removed proxy info } return 0; }
int read_config_file(bool init, const char* fname) { if (!init) { msg_printf(NULL, MSG_INFO, "Re-reading %s", fname); config.defaults(); log_flags.init(); } FILE* f = boinc_fopen(fname, "r"); if (!f) { msg_printf(NULL, MSG_INFO, "No config file found - using defaults"); return ERR_FOPEN; } config.parse_client(f); fclose(f); #ifndef SIM diagnostics_set_max_file_sizes( config.max_stdout_file_size, config.max_stderr_file_size ); #endif if (init) { coprocs = config.config_coprocs; config_proxy_info = config.proxy_info; if (strlen(config.data_dir)) { #ifdef _WIN32 _chdir(config.data_dir); #else chdir(config.data_dir); #endif } } return 0; }
int CC_CONFIG::parse_client(FILE* f) { MIOFILE mf; XML_PARSER xp(&mf); mf.init_file(f); if (!xp.parse_start("cc_config")) { msg_printf_notice(NULL, false, "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", "%s", _("Missing start tag in cc_config.xml") ); return ERR_XML_PARSE; } while (!xp.get_tag()) { if (!xp.is_tag) { msg_printf_notice(NULL, false, "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", "%s: %s", _("Unexpected text in cc_config.xml"), xp.parsed_tag ); continue; } if (xp.match_tag("/cc_config")) { notices.remove_notices(NULL, REMOVE_CONFIG_MSG); return 0; } if (xp.match_tag("log_flags")) { log_flags.parse(xp); continue; } if (xp.match_tag("options")) { int retval = parse_options_client(xp); if (retval) { msg_printf_notice(NULL, false, "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", "%s", _("Error in cc_config.xml options") ); } continue; } if (xp.match_tag("options/")) continue; if (xp.match_tag("log_flags/")) continue; msg_printf_notice(NULL, false, "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", "%s: <%s>", _("Unrecognized tag in cc_config.xml"), xp.parsed_tag ); xp.skip_unexpected(true, "CC_CONFIG.parse"); } msg_printf_notice(NULL, false, "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", "%s", _("Missing end tag in cc_config.xml") ); return ERR_XML_PARSE; }
int CONFIG::parse(XML_PARSER& xp, LOG_FLAGS& log_flags) { while (!xp.get_tag()) { if (!xp.is_tag) { continue; } if (xp.match_tag("/cc_config")) return 0; if (xp.match_tag("log_flags")) { log_flags.parse(xp); continue; } if (xp.match_tag("options")) { parse_options(xp); continue; } if (xp.match_tag("options/")) continue; if (xp.match_tag("log_flags/")) continue; } return ERR_XML_PARSE; }
int CONFIG::write(MIOFILE& out, LOG_FLAGS& log_flags) { int j; unsigned int i; out.printf("<set_cc_config>\n"); out.printf("<cc_config>\n"); log_flags.write(out); out.printf( " <options>\n" " <abort_jobs_on_exit>%d</abort_jobs_on_exit>\n" " <allow_multiple_clients>%d</allow_multiple_clients>\n" " <allow_remote_gui_rpc>%d</allow_remote_gui_rpc>\n", abort_jobs_on_exit ? 1 : 0, allow_multiple_clients ? 1 : 0, allow_remote_gui_rpc ? 1 : 0 ); for (i=0; i<alt_platforms.size(); ++i) { out.printf( " <alt_platform>%s</alt_platform>\n", alt_platforms[i].c_str() ); } out.printf( " <client_version_check_url>%s</client_version_check_url>\n" " <client_download_url>%s</client_download_url>\n", client_version_check_url.c_str(), client_download_url.c_str() ); for (int k=1; k<config_coprocs.n_rsc; k++) { if (!config_coprocs.coprocs[k].specified_in_config) continue; out.printf( " <coproc>\n" " <type>%s</type>\n" " <count>%d</count>\n" " <peak_flops>%f</peak_flops>\n" " <device_nums>", config_coprocs.coprocs[k].type, config_coprocs.coprocs[k].count, config_coprocs.coprocs[k].peak_flops ); for (j=0; j<config_coprocs.coprocs[k].count; j++) { out.printf("%d", config_coprocs.coprocs[k].device_nums[j]); if (j < (config_coprocs.coprocs[k].count - 1)) { out.printf(" "); } } out.printf( "</device_nums>\n" " </coproc>\n" ); } // Older versions of BOINC choke on empty data_dir string if (strlen(data_dir)) { out.printf(" <data_dir>%s</data_dir>\n", data_dir); } out.printf( " <disallow_attach>%d</disallow_attach>\n" " <dont_check_file_sizes>%d</dont_check_file_sizes>\n" " <dont_contact_ref_site>%d</dont_contact_ref_site>\n", disallow_attach, dont_check_file_sizes, dont_contact_ref_site ); for (i=0; i<exclusive_apps.size(); ++i) { out.printf( " <exclusive_app>%s</exclusive_app>\n", exclusive_apps[i].c_str() ); } for (i=0; i<exclusive_gpu_apps.size(); ++i) { out.printf( " <exclusive_gpu_app>%s</exclusive_gpu_app>\n", exclusive_gpu_apps[i].c_str() ); } out.printf( " <exit_after_finish>%d</exit_after_finish>\n" " <exit_before_start>%d</exit_before_start>\n" " <exit_when_idle>%d</exit_when_idle>\n" " <fetch_minimal_work>%d</fetch_minimal_work>\n" " <fetch_on_update>%d</fetch_on_update>\n" " <force_auth>%s</force_auth>\n" " <http_1_0>%d</http_1_0>\n" " <http_transfer_timeout>%d</http_transfer_timeout>\n" " <http_transfer_timeout_bps>%d</http_transfer_timeout_bps>\n", exit_after_finish, exit_before_start, exit_when_idle, fetch_minimal_work, fetch_on_update, force_auth.c_str(), http_1_0, http_transfer_timeout, http_transfer_timeout_bps ); for (i=0; i<ignore_gpu_instance[PROC_TYPE_NVIDIA_GPU].size(); ++i) { out.printf( " <ignore_nvidia_dev>%d</ignore_nvidia_dev>\n", ignore_gpu_instance[PROC_TYPE_NVIDIA_GPU][i] ); } for (i=0; i<ignore_gpu_instance[PROC_TYPE_AMD_GPU].size(); ++i) { out.printf( " <ignore_ati_dev>%d</ignore_ati_dev>\n", ignore_gpu_instance[PROC_TYPE_AMD_GPU][i] ); } for (i=0; i<ignore_gpu_instance[PROC_TYPE_INTEL_GPU].size(); ++i) { out.printf( " <ignore_intel_gpu_dev>%d</ignore_intel_gpu_dev>\n", ignore_gpu_instance[PROC_TYPE_INTEL_GPU][i] ); } out.printf( " <max_file_xfers>%d</max_file_xfers>\n" " <max_file_xfers_per_project>%d</max_file_xfers_per_project>\n" " <max_stderr_file_size>%d</max_stderr_file_size>\n" " <max_stdout_file_size>%d</max_stdout_file_size>\n" " <max_tasks_reported>%d</max_tasks_reported>\n" " <ncpus>%d</ncpus>\n" " <network_test_url>%s</network_test_url>\n" " <no_alt_platform>%d</no_alt_platform>\n" " <no_gpus>%d</no_gpus>\n" " <no_info_fetch>%d</no_info_fetch>\n" " <no_priority_change>%d</no_priority_change>\n" " <os_random_only>%d</os_random_only>\n", max_file_xfers, max_file_xfers_per_project, max_stderr_file_size, max_stdout_file_size, max_tasks_reported, ncpus, network_test_url.c_str(), no_alt_platform, no_gpus, no_info_fetch, no_priority_change, os_random_only ); proxy_info.write(out); out.printf( " <rec_half_life_days>%f</rec_half_life_days>\n" " <report_results_immediately>%d</report_results_immediately>\n" " <run_apps_manually>%d</run_apps_manually>\n" " <save_stats_days>%d</save_stats_days>\n" " <skip_cpu_benchmarks>%d</skip_cpu_benchmarks>\n" " <simple_gui_only>%d</simple_gui_only>\n" " <start_delay>%d</start_delay>\n" " <stderr_head>%d</stderr_head>\n" " <suppress_net_info>%d</suppress_net_info>\n" " <unsigned_apps_ok>%d</unsigned_apps_ok>\n" " <use_all_gpus>%d</use_all_gpus>\n" " <use_certs>%d</use_certs>\n" " <use_certs_only>%d</use_certs_only>\n" " <vbox_window>%d</vbox_window>\n", rec_half_life/86400, report_results_immediately, run_apps_manually, save_stats_days, skip_cpu_benchmarks, simple_gui_only, start_delay, stderr_head, suppress_net_info, unsigned_apps_ok, use_all_gpus, use_certs, use_certs_only, vbox_window ); out.printf(" </options>\n</cc_config>\n"); out.printf("</set_cc_config>\n"); return 0; }