本文整理汇总了C++中MIOFILE::init_file方法的典型用法代码示例。如果您正苦于以下问题:C++ MIOFILE::init_file方法的具体用法?C++ MIOFILE::init_file怎么用?C++ MIOFILE::init_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MIOFILE
的用法示例。
在下文中一共展示了MIOFILE::init_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
int SCHED_CONFIG::parse(FILE* f) {
char buf[256];
MIOFILE mf;
XML_PARSER xp(&mf);
int retval, itemp;
regex_t re;
double x;
mf.init_file(f);
memset(this, 0, sizeof(*this));
ban_os = new vector<regex_t>;
ban_cpu = new vector<regex_t>;
locality_scheduling_workunit_file = new vector<regex_t>;
locality_scheduling_sticky_file = new vector<regex_t>;
max_wus_to_send = 10;
default_disk_max_used_gb = 100.;
default_disk_max_used_pct = 50.;
default_disk_min_free_gb = .001;
sched_debug_level = MSG_NORMAL;
fuh_debug_level = MSG_NORMAL;
strcpy(httpd_user, "apache");
max_ncpus = MAX_NCPUS;
scheduler_log_buffer = 32768;
version_select_random_factor = .1;
if (!xp.parse_start("boinc")) return ERR_XML_PARSE;
if (!xp.parse_start("config")) return ERR_XML_PARSE;
while (!xp.get_tag()) {
if (!xp.is_tag) {
fprintf(stderr,
"SCHED_CONFIG::parse(): unexpected text %s\n",
xp.parsed_tag
);
continue;
}
if (xp.match_tag("/config")) {
char hostname[256];
gethostname(hostname, 256);
if (!strcmp(hostname, db_host)) strcpy(db_host, "localhost");
if (!strlen(replica_db_host)) {
strcpy(replica_db_host, db_host);
}
if (!strlen(replica_db_name)) {
strcpy(replica_db_name, db_name);
}
if (!strlen(replica_db_user)) {
strcpy(replica_db_user, db_user);
}
if (!strlen(replica_db_passwd)) {
strcpy(replica_db_passwd, db_passwd);
}
return 0;
}
if (xp.parse_str("master_url", master_url, sizeof(master_url))) continue;
if (xp.parse_str("long_name", long_name, sizeof(long_name))) continue;
if (xp.parse_str("db_name", db_name, sizeof(db_name))) continue;
if (xp.parse_str("db_user", db_user, sizeof(db_user))) continue;
if (xp.parse_str("db_passwd", db_passwd, sizeof(db_passwd))) continue;
if (xp.parse_str("db_host", db_host, sizeof(db_host))) continue;
if (xp.parse_str("replica_db_name", replica_db_name, sizeof(replica_db_name))) continue;
if (xp.parse_str("replica_db_user", replica_db_user, sizeof(replica_db_user))) continue;
if (xp.parse_str("replica_db_passwd", replica_db_passwd, sizeof(replica_db_passwd))) continue;
if (xp.parse_str("replica_db_host", replica_db_host, sizeof(replica_db_host))) continue;
if (xp.parse_str("project_dir", project_dir, sizeof(project_dir))) continue;
if (xp.parse_int("shmem_key", shmem_key)) continue;
if (xp.parse_str("key_dir", key_dir, sizeof(key_dir))) continue;
if (xp.parse_str("download_url", download_url, sizeof(download_url))) continue;
if (xp.parse_str("download_dir", download_dir, sizeof(download_dir))) continue;
if (xp.parse_str("upload_url", upload_url, sizeof(upload_url))) continue;
if (xp.parse_str("upload_dir", upload_dir, sizeof(upload_dir))) continue;
if (xp.parse_bool("non_cpu_intensive", non_cpu_intensive)) continue;
if (xp.parse_bool("verify_files_on_app_start", verify_files_on_app_start)) continue;
if (xp.parse_int("homogeneous_redundancy", homogeneous_redundancy)) continue;
if (xp.parse_bool("hr_allocate_slots", hr_allocate_slots)) continue;
if (xp.parse_bool("msg_to_host", msg_to_host)) continue;
if (xp.parse_bool("ignore_upload_certificates", ignore_upload_certificates)) continue;
if (xp.parse_bool("dont_generate_upload_certificates", dont_generate_upload_certificates)) continue;
if (xp.parse_int("uldl_dir_fanout", uldl_dir_fanout)) continue;
if (xp.parse_bool("cache_md5_info", cache_md5_info)) continue;
if (xp.parse_int("fuh_debug_level", fuh_debug_level)) continue;
if (xp.parse_int("reliable_priority_on_over", reliable_priority_on_over)) continue;
if (xp.parse_int("reliable_priority_on_over_except_error", reliable_priority_on_over_except_error)) continue;
if (xp.parse_int("reliable_on_priority", reliable_on_priority)) continue;
if (xp.parse_double("grace_period_hours", x)) {
report_grace_period = (int)(x*3600);
continue;
}
if (xp.parse_int("report_grace_period", report_grace_period)) continue;
if (xp.parse_double("delete_delay_hours", x)) {
delete_delay = x*3600;
continue;
}
if (xp.parse_bool("distinct_beta_apps", distinct_beta_apps)) continue;
if (xp.parse_bool("ended", ended)) continue;
if (xp.parse_int("shmem_work_items", shmem_work_items)) continue;
if (xp.parse_int("feeder_query_size", feeder_query_size)) continue;
if (xp.parse_str("httpd_user", httpd_user, sizeof(httpd_user))) continue;
if (xp.parse_bool("enable_vda", enable_vda)) continue;
if (xp.parse_double("vda_host_timeout", vda_host_timeout)) continue;
//.........这里部分代码省略.........
示例2: make_scheduler_request
// Write a scheduler request to a disk file,
// to be sent to a scheduling server
//
int CLIENT_STATE::make_scheduler_request(PROJECT* p) {
char buf[1024];
MIOFILE mf;
unsigned int i;
RESULT* rp;
get_sched_request_filename(*p, buf, sizeof(buf));
FILE* f = boinc_fopen(buf, "wb");
if (!f) return ERR_FOPEN;
double trs = total_resource_share();
double rrs = runnable_resource_share(RSC_TYPE_ANY);
double prrs = potentially_runnable_resource_share();
double resource_share_fraction, rrs_fraction, prrs_fraction;
if (trs) {
resource_share_fraction = p->resource_share / trs;
} else {
resource_share_fraction = 1;
}
if (rrs) {
rrs_fraction = p->resource_share / rrs;
} else {
rrs_fraction = 1;
}
if (prrs) {
prrs_fraction = p->resource_share / prrs;
} else {
prrs_fraction = 1;
}
// if hostid is zero, rpc_seqno better be also
//
if (!p->hostid) {
p->rpc_seqno = 0;
}
mf.init_file(f);
fprintf(f,
"<scheduler_request>\n"
" <authenticator>%s</authenticator>\n"
" <hostid>%d</hostid>\n"
" <rpc_seqno>%d</rpc_seqno>\n"
" <core_client_major_version>%d</core_client_major_version>\n"
" <core_client_minor_version>%d</core_client_minor_version>\n"
" <core_client_release>%d</core_client_release>\n"
" <resource_share_fraction>%f</resource_share_fraction>\n"
" <rrs_fraction>%f</rrs_fraction>\n"
" <prrs_fraction>%f</prrs_fraction>\n"
" <duration_correction_factor>%f</duration_correction_factor>\n"
" <allow_multiple_clients>%d</allow_multiple_clients>\n"
" <sandbox>%d</sandbox>\n",
p->authenticator,
p->hostid,
p->rpc_seqno,
core_client_version.major,
core_client_version.minor,
core_client_version.release,
resource_share_fraction,
rrs_fraction,
prrs_fraction,
p->duration_correction_factor,
config.allow_multiple_clients?1:0,
g_use_sandbox?1:0
);
work_fetch.write_request(f, p);
// write client capabilities
//
fprintf(f,
" <client_cap_plan_class>1</client_cap_plan_class>\n"
);
write_platforms(p, mf);
if (strlen(p->code_sign_key)) {
fprintf(f, " <code_sign_key>\n%s\n</code_sign_key>\n", p->code_sign_key);
}
// send working prefs
//
fprintf(f, "<working_global_preferences>\n");
global_prefs.write(mf);
fprintf(f, "</working_global_preferences>\n");
// send master global preferences if present and not host-specific
//
if (!global_prefs.host_specific && boinc_file_exists(GLOBAL_PREFS_FILE_NAME)) {
FILE* fprefs = fopen(GLOBAL_PREFS_FILE_NAME, "r");
if (fprefs) {
copy_stream(fprefs, f);
fclose(fprefs);
}
PROJECT* pp = lookup_project(global_prefs.source_project);
if (pp && strlen(pp->email_hash)) {
fprintf(f,
"<global_prefs_source_email_hash>%s</global_prefs_source_email_hash>\n",
pp->email_hash
//.........这里部分代码省略.........
示例3: do_client_simulation
void do_client_simulation() {
char buf[256], buf2[256];
int retval;
FILE* f;
sprintf(buf, "%s%s", infile_prefix, CONFIG_FILE);
cc_config.defaults();
read_config_file(true, buf);
log_flags.init();
sprintf(buf, "%s%s", outfile_prefix, "log_flags.xml");
f = fopen(buf, "r");
if (f) {
MIOFILE mf;
mf.init_file(f);
XML_PARSER xp(&mf);
xp.get_tag(); // skip open tag
log_flags.parse(xp);
fclose(f);
}
gstate.add_platform("client simulator");
sprintf(buf, "%s%s", infile_prefix, STATE_FILE_NAME);
if (!boinc_file_exists(buf)) {
fprintf(stderr, "No client state file\n");
exit(1);
}
retval = gstate.parse_state_file_aux(buf);
if (retval) {
fprintf(stderr, "state file parse error %d\n", retval);
exit(1);
}
// if tasks have pending transfers, mark as completed
//
for (unsigned int i=0; i<gstate.results.size(); i++) {
RESULT* rp = gstate.results[i];
if (rp->state() < RESULT_FILES_DOWNLOADED) {
rp->set_state(RESULT_FILES_DOWNLOADED, "init");
} else if (rp->state() == RESULT_FILES_UPLOADING) {
rp->set_state(RESULT_FILES_UPLOADED, "init");
}
}
check_app_config(infile_prefix);
show_app_config();
cc_config.show();
log_flags.show();
sprintf(buf, "%s%s", infile_prefix, GLOBAL_PREFS_FILE_NAME);
sprintf(buf2, "%s%s", infile_prefix, GLOBAL_PREFS_OVERRIDE_FILE);
gstate.read_global_prefs(buf, buf2);
fprintf(index_file,
"<h3>Output files</h3>\n"
"<a href=%s>Summary</a>\n"
"<br><a href=%s>Log file</a>\n",
SUMMARY_FNAME, LOG_FNAME
);
// fill in GPU device nums and OpenCL flags
//
for (int i=0; i<coprocs.n_rsc; i++) {
COPROC& cp = coprocs.coprocs[i];
for (int j=0; j<cp.count; j++) {
cp.device_nums[j] = j;
if (cp.have_opencl) {
cp.instance_has_opencl[j] = true;
}
}
}
set_no_rsc_config();
process_gpu_exclusions();
get_app_params();
if (!include_empty_projects) {
cull_projects();
}
fprintf(summary_file, "--------------------------\n");
int j=0;
for (unsigned int i=0; i<gstate.projects.size(); i++) {
gstate.projects[i]->index = j++;
}
clear_backoff();
gstate.log_show_projects();
gstate.set_ncpus();
work_fetch.init();
//set_initial_rec();
rec_adjust_period = delta;
gstate.request_work_fetch("init");
simulate();
sim_results.compute_figures_of_merit();
sprintf(buf, "%s%s", outfile_prefix, RESULTS_DAT_FNAME);
//.........这里部分代码省略.........
示例4: diagnostics_init
//.........这里部分代码省略.........
_CrtMemCheckpoint(&start_snapshot);
}
}
#endif // defined(_DEBUG)
// Initialize the thread list structure
// The data for this structure should be set by
// boinc_init or boinc_init_graphics.
diagnostics_init_thread_list();
diagnostics_init_unhandled_exception_monitor();
diagnostics_init_message_monitor();
#endif // defined(_WIN32)
// Install unhandled exception filters and signal traps.
if (BOINC_SUCCESS != boinc_install_signal_handlers()) {
return ERR_SIGNAL_OP;
}
// Store various pieces of inforation for future use.
if (flags & BOINC_DIAG_BOINCAPPLICATION) {
char buf[256];
char proxy_address[256];
int proxy_port;
MIOFILE mf;
FILE* p;
#ifdef _WIN32
LONG lReturnValue;
HKEY hkSetupHive;
DWORD dwSize = 0;
#endif
strcpy(buf, "");
strcpy(proxy_address, "");
proxy_port = 0;
#ifndef _USING_FCGI_
p = fopen(INIT_DATA_FILE, "r");
#else
p = FCGI::fopen(INIT_DATA_FILE, "r");
#endif
if (p) {
mf.init_file(p);
while(mf.fgets(buf, sizeof(buf))) {
if (match_tag(buf, "</app_init_data>")) break;
else if (parse_str(buf, "<boinc_dir>", boinc_dir, 256)) continue;
else if (parse_str(buf, "<symstore>", symstore, 256)) continue;
else if (match_tag(buf, "<use_http_proxy/>")) {
boinc_proxy_enabled = true;
continue;
}
else if (parse_str(buf, "<http_server_name>", proxy_address, 256)) continue;
else if (parse_int(buf, "<http_server_port>", proxy_port)) continue;
}
fclose(p);
}
if (boinc_proxy_enabled) {
int buffer_used = snprintf(boinc_proxy, sizeof(boinc_proxy), "%s:%d", proxy_address, proxy_port);
if ((sizeof(boinc_proxy) == buffer_used) || (-1 == buffer_used)) {
boinc_proxy[sizeof(boinc_proxy)-1] = '\0';
}
}
#ifdef _WIN32
// Lookup the location of where BOINC was installed to and store
// that for future use.
lReturnValue = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Space Sciences Laboratory, U.C. Berkeley\\BOINC Setup"),
0,
KEY_READ,
&hkSetupHive
);
if (lReturnValue == ERROR_SUCCESS) {
// How large does our buffer need to be?
dwSize = sizeof(boinc_install_dir);
lReturnValue = RegQueryValueEx(
hkSetupHive,
_T("INSTALLDIR"),
NULL,
NULL,
(LPBYTE)&boinc_install_dir,
&dwSize
);
}
if (hkSetupHive) RegCloseKey(hkSetupHive);
#endif
}
return BOINC_SUCCESS;
}
示例5: parse
int VBOX_JOB::parse() {
MIOFILE mf;
std::string str;
char buf[1024];
boinc_resolve_filename(JOB_FILENAME, buf, sizeof(buf));
FILE* f = boinc_fopen(buf, "r");
if (!f) {
vboxlog_msg("VBOX_JOB::parse(): can't open job file %s", buf);
return ERR_FOPEN;
}
mf.init_file(f);
XML_PARSER xp(&mf);
if (!xp.parse_start("vbox_job")) return ERR_XML_PARSE;
while (!xp.get_tag()) {
if (!xp.is_tag) {
vboxlog_msg("VBOX_JOB::parse(): unexpected text %s", xp.parsed_tag);
continue;
}
if (xp.match_tag("/vbox_job")) {
fclose(f);
return 0;
}
else if (xp.parse_string("vm_disk_controller_type", vm_disk_controller_type)) continue;
else if (xp.parse_string("vm_disk_controller_model", vm_disk_controller_model)) continue;
else if (xp.parse_string("os_name", os_name)) continue;
else if (xp.parse_double("memory_size_mb", memory_size_mb)) continue;
else if (xp.parse_double("job_duration", job_duration)) continue;
else if (xp.parse_double("minimum_checkpoint_interval", minimum_checkpoint_interval)) continue;
else if (xp.parse_double("minimum_heartbeat_interval", minimum_heartbeat_interval)) continue;
else if (xp.parse_string("fraction_done_filename", fraction_done_filename)) continue;
else if (xp.parse_string("heartbeat_filename", heartbeat_filename)) continue;
else if (xp.parse_string("completion_trigger_file", completion_trigger_file)) continue;
else if (xp.parse_string("temporary_exit_trigger_file", temporary_exit_trigger_file)) continue;
else if (xp.parse_bool("enable_cern_dataformat", enable_cern_dataformat)) continue;
else if (xp.parse_bool("enable_network", enable_network)) continue;
else if (xp.parse_bool("network_bridged_mode", network_bridged_mode)) continue;
else if (xp.parse_bool("enable_shared_directory", enable_shared_directory)) continue;
else if (xp.parse_bool("enable_scratch_directory", enable_scratch_directory)) continue;
else if (xp.parse_bool("enable_floppyio", enable_floppyio)) continue;
else if (xp.parse_bool("enable_cache_disk", enable_cache_disk)) continue;
else if (xp.parse_bool("enable_isocontextualization", enable_isocontextualization)) continue;
else if (xp.parse_bool("enable_remotedesktop", enable_remotedesktop)) continue;
else if (xp.parse_bool("enable_gbac", enable_gbac)) continue;
else if (xp.parse_bool("enable_screenshots_on_error", enable_screenshots_on_error)) continue;
else if (xp.parse_bool("enable_graphics_support", enable_graphics_support)) continue;
else if (xp.parse_bool("enable_vm_savestate_usage", enable_vm_savestate_usage)) continue;
else if (xp.parse_bool("disable_automatic_checkpoints", disable_automatic_checkpoints)) continue;
else if (xp.parse_bool("boot_iso", boot_iso)) continue;
else if (xp.parse_int("pf_guest_port", pf_guest_port)) continue;
else if (xp.parse_int("pf_host_port", pf_host_port)) continue;
else if (xp.parse_string("copy_to_shared", str)) {
copy_to_shared.push_back(str);
continue;
}
else if (xp.parse_string("trickle_trigger_file", str)) {
trickle_trigger_files.push_back(str);
continue;
}
else if (xp.parse_string("intermediate_upload_file", str)) {
VBOX_INTERMEDIATE_UPLOAD iu;
iu.clear();
iu.file = str;
intermediate_upload_files.push_back(iu);
continue;
}
else if (xp.match_tag("port_forward")) {
VBOX_PORT_FORWARD pf;
pf.clear();
pf.parse(xp);
if (pf.nports) {
VBOX_PORT_FORWARD pf_range;
pf_range = pf;
pf_range.nports = 0;
for (int i = 0; i < pf.nports; ++i) {
port_forwards.push_back(pf_range);
pf_range.host_port++;
pf_range.guest_port++;
}
} else {
port_forwards.push_back(pf);
}
}
vboxlog_msg("VBOX_JOB::parse(): unexpected text %s", xp.parsed_tag);
}
fclose(f);
return ERR_XML_PARSE;
}
示例6: parse_account
// parse an account_*.xml file, ignoring <venue> elements
// (since we don't know the host venue yet)
//
int PROJECT::parse_account(FILE* in) {
char buf2[256];
int retval;
bool in_project_prefs = false, btemp;
double dtemp;
for (int i=0; i<coprocs.n_rsc; i++) {
no_rsc_pref[i] = false;
}
MIOFILE mf;
XML_PARSER xp(&mf);
mf.init_file(in);
strcpy(master_url, "");
strcpy(authenticator, "");
while (!xp.get_tag()) {
if (xp.match_tag("account")) continue;
if (xp.match_tag("project_preferences")) {
in_project_prefs = true;
continue;
}
if (xp.match_tag("/project_preferences")) {
in_project_prefs = false;
continue;
}
if (xp.match_tag("/account")) {
return 0;
} else if (xp.match_tag("venue")) {
std::string devnull;
retval = copy_element_contents(xp.f->f, "</venue>", devnull);
if (retval) return retval;
continue;
} else if (xp.parse_str("master_url", master_url, sizeof(master_url))) {
canonicalize_master_url(master_url, sizeof(master_url));
continue;
} else if (xp.parse_str("authenticator", authenticator, sizeof(authenticator))) continue;
else if (xp.parse_double("resource_share", dtemp)) {
if (ams_resource_share < 0) {
resource_share = dtemp;
}
continue;
}
else if (xp.parse_bool("no_cpu", btemp)) {
if (btemp) handle_no_rsc_pref(this, "CPU");
continue;
}
// deprecated
else if (xp.parse_bool("no_cuda", btemp)) {
if (btemp) handle_no_rsc_pref(this, GPU_TYPE_NVIDIA);
continue;
}
else if (xp.parse_bool("no_ati", btemp)) {
if (btemp) handle_no_rsc_pref(this, GPU_TYPE_ATI);
continue;
}
else if (xp.parse_bool("no_intel_gpu", btemp)) {
if (btemp) handle_no_rsc_pref(this, GPU_TYPE_INTEL);
continue;
}
else if (xp.parse_str("no_rsc", buf2, sizeof(buf2))) {
handle_no_rsc_pref(this, buf2);
continue;
}
else if (xp.parse_str("project_name", project_name, sizeof(project_name))) continue;
else if (xp.match_tag("gui_urls")) {
string foo;
retval = copy_element_contents(xp.f->f, "</gui_urls>", foo);
if (retval) return retval;
gui_urls = "<gui_urls>\n"+foo+"</gui_urls>\n";
continue;
} else if (xp.match_tag("project_specific")) {
retval = copy_element_contents(
xp.f->f,
"</project_specific>",
project_specific_prefs
);
if (retval) return retval;
continue;
} else {
// don't show unparsed XML errors if we're in project prefs
//
if (!in_project_prefs && log_flags.unparsed_xml) {
msg_printf(0, MSG_INFO,
"[unparsed_xml] PROJECT::parse_account(): unrecognized: %s\n",
xp.parsed_tag
);
}
}
}
return ERR_XML_PARSE;
}
示例7: do_rpc
//.........这里部分代码省略.........
" <dont_request_more_work>%d</dont_request_more_work>\n"
" <detach_when_done>%d</detach_when_done>\n"
" <ended>%d</ended>\n"
" <resource_share>%f</resource_share>\n"
" <disk_usage>%f</disk_usage>\n"
" <disk_share>%f</disk_share>\n",
p->master_url,
p->project_name,
p->suspended_via_gui?1:0,
p->hostid,
not_started_dur,
in_progress_dur,
p->attached_via_acct_mgr?1:0,
p->dont_request_more_work?1:0,
p->detach_when_done?1:0,
p->ended?1:0,
p->resource_share,
p->disk_usage,
p->disk_share
);
// send work and starvation-related info
//
if (ami.dynamic) {
fprintf(f,
" <nrpc_failures>%d</nrpc_failures>\n"
" <cpu_ec>%f</cpu_ec>\n"
" <cpu_time>%f</cpu_time>\n"
" <gpu_ec>%f</gpu_ec>\n"
" <gpu_time>%f</gpu_time>\n"
" <njobs_success>%d</njobs_success>\n"
" <njobs_error>%d</njobs_error>\n",
p->nrpc_failures,
p->cpu_ec,
p->cpu_time,
p->gpu_ec,
p->gpu_time,
p->njobs_success,
p->njobs_error
);
for (int j=0; j<coprocs.n_rsc; j++) {
if (p->sched_req_no_work[j]) {
fprintf(f,
" <sched_req_no_work>%s</sched_req_no_work>\n",
coprocs.coprocs[j].type
);
}
}
}
if (p->attached_via_acct_mgr) {
fprintf(f,
" <account_key>%s</account_key>\n",
p->authenticator
);
}
fprintf(f,
" </project>\n"
);
}
MIOFILE mf;
mf.init_file(f);
// send working prefs
//
fprintf(f, "<working_global_preferences>\n");
gstate.global_prefs.write(mf);
fprintf(f, "</working_global_preferences>\n");
if (boinc_file_exists(GLOBAL_PREFS_FILE_NAME)) {
FILE* fprefs = fopen(GLOBAL_PREFS_FILE_NAME, "r");
if (fprefs) {
copy_stream(fprefs, f);
fclose(fprefs);
}
}
gstate.host_info.write(mf, !cc_config.suppress_net_info, true);
if (strlen(gstate.acct_mgr_info.opaque)) {
fprintf(f,
" <opaque>\n%s\n"
" </opaque>\n",
gstate.acct_mgr_info.opaque
);
}
gstate.time_stats.write(mf, true);
gstate.net_stats.write(mf);
fprintf(f, "</acct_mgr_request>\n");
fclose(f);
snprintf(buf, sizeof(buf), "%srpc.php", ami.master_url);
retval = gui_http->do_rpc_post(
this, buf, ACCT_MGR_REQUEST_FILENAME, ACCT_MGR_REPLY_FILENAME, true
);
if (retval) {
error_num = retval;
return retval;
}
msg_printf(NULL, MSG_INFO, "Contacting account manager at %s", ami.master_url);
return 0;
}
示例8: parse_init_data_file
int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) {
int retval;
bool flag;
MIOFILE mf;
mf.init_file(f);
XML_PARSER xp(&mf);
if (!xp.parse_start("app_init_data")) {
fprintf(stderr, "%s: no start tag in app init data\n",
time_to_string(dtime())
);
return ERR_XML_PARSE;
}
if (ai.project_preferences) {
free(ai.project_preferences);
ai.project_preferences = 0;
}
ai.clear();
ai.fraction_done_start = 0;
ai.fraction_done_end = 1;
while (!xp.get_tag()) {
if (!xp.is_tag) {
fprintf(stderr,
"%s: unexpected text in init_data.xml: %s\n",
time_to_string(dtime()), xp.parsed_tag
);
continue;
}
if (xp.match_tag("/app_init_data")) return 0;
if (xp.match_tag("project_preferences")) {
retval = dup_element(f, "project_preferences", &ai.project_preferences);
if (retval) return retval;
continue;
}
if (xp.match_tag("global_preferences")) {
GLOBAL_PREFS_MASK mask;
retval = ai.global_prefs.parse(xp, "", flag, mask);
if (retval) return retval;
continue;
}
if (xp.match_tag("host_info")) {
ai.host_info.parse(xp);
continue;
}
if (xp.match_tag("proxy_info")) {
ai.proxy_info.parse(xp);
continue;
}
if (xp.parse_int("major_version", ai.major_version)) continue;
if (xp.parse_int("minor_version", ai.minor_version)) continue;
if (xp.parse_int("release", ai.release)) continue;
if (xp.parse_int("app_version", ai.app_version)) continue;
if (xp.parse_str("app_name", ai.app_name, sizeof(ai.app_name))) continue;
if (xp.parse_str("symstore", ai.symstore, sizeof(ai.symstore))) continue;
if (xp.parse_str("acct_mgr_url", ai.acct_mgr_url, sizeof(ai.acct_mgr_url))) continue;
if (xp.parse_int("userid", ai.userid)) continue;
if (xp.parse_int("teamid", ai.teamid)) continue;
if (xp.parse_int("hostid", ai.hostid)) continue;
if (xp.parse_str("user_name", ai.user_name, sizeof(ai.user_name))) {
xml_unescape(ai.user_name);
continue;
}
if (xp.parse_str("team_name", ai.team_name, sizeof(ai.team_name))) {
xml_unescape(ai.team_name);
continue;
}
if (xp.parse_str("project_dir", ai.project_dir, sizeof(ai.project_dir))) continue;
if (xp.parse_str("boinc_dir", ai.boinc_dir, sizeof(ai.boinc_dir))) continue;
if (xp.parse_str("authenticator", ai.authenticator, sizeof(ai.authenticator))) continue;
if (xp.parse_str("wu_name", ai.wu_name, sizeof(ai.wu_name))) continue;
if (xp.parse_str("result_name", ai.result_name, sizeof(ai.result_name))) continue;
#ifdef _WIN32
if (xp.parse_str("comm_obj_name", ai.shmem_seg_name, sizeof(ai.shmem_seg_name))) continue;
#else
if (xp.parse_int("shm_key", ai.shmem_seg_name)) continue;
#endif
if (xp.parse_int("slot", ai.slot)) continue;
if (xp.parse_int("client_pid", ai.client_pid)) continue;
if (xp.parse_double("user_total_credit", ai.user_total_credit)) continue;
if (xp.parse_double("user_expavg_credit", ai.user_expavg_credit)) continue;
if (xp.parse_double("host_total_credit", ai.host_total_credit)) continue;
if (xp.parse_double("host_expavg_credit", ai.host_expavg_credit)) continue;
if (xp.parse_double("resource_share_fraction", ai.resource_share_fraction)) continue;
if (xp.parse_double("rsc_fpops_est", ai.rsc_fpops_est)) continue;
if (xp.parse_double("rsc_fpops_bound", ai.rsc_fpops_bound)) continue;
if (xp.parse_double("rsc_memory_bound", ai.rsc_memory_bound)) continue;
if (xp.parse_double("rsc_disk_bound", ai.rsc_disk_bound)) continue;
if (xp.parse_double("computation_deadline", ai.computation_deadline)) continue;
if (xp.parse_double("wu_cpu_time", ai.wu_cpu_time)) continue;
if (xp.parse_double("starting_elapsed_time", ai.starting_elapsed_time)) continue;
if (xp.parse_bool("using_sandbox", ai.using_sandbox)) continue;
if (xp.parse_bool("vm_extensions_disabled", ai.vm_extensions_disabled)) continue;
if (xp.parse_double("checkpoint_period", ai.checkpoint_period)) continue;
if (xp.parse_str("gpu_type", ai.gpu_type, sizeof(ai.gpu_type))) continue;
if (xp.parse_int("gpu_device_num", ai.gpu_device_num)) continue;
if (xp.parse_int("gpu_opencl_dev_index", ai.gpu_opencl_dev_index)) continue;
if (xp.parse_double("gpu_usage", ai.gpu_usage)) continue;
//.........这里部分代码省略.........
示例9: init
// called at client startup.
// If currently using an AM, read its URL and login files
//
int ACCT_MGR_INFO::init() {
MIOFILE mf;
FILE* p;
int retval;
clear();
p = fopen(ACCT_MGR_URL_FILENAME, "r");
if (!p) {
// if not using acct mgr, make sure projects not flagged,
// otherwise won't be able to detach them.
//
for (unsigned int i=0; i<gstate.projects.size(); i++) {
gstate.projects[i]->attached_via_acct_mgr = false;
}
return 0;
}
mf.init_file(p);
XML_PARSER xp(&mf);
if (!xp.parse_start("acct_mgr")) {
//
}
while (!xp.get_tag()) {
if (!xp.is_tag) {
printf("unexpected text: %s\n", xp.parsed_tag);
continue;
}
if (xp.match_tag("/acct_mgr")) break;
else if (xp.parse_str("name", project_name, 256)) continue;
else if (xp.parse_str("url", master_url, 256)) continue;
else if (xp.parse_bool("send_gui_rpc_info", send_gui_rpc_info)) continue;
else if (xp.match_tag("signing_key")) {
retval = xp.element_contents("</signing_key>", signing_key, sizeof(signing_key));
if (retval) {
msg_printf(NULL, MSG_INFO,
"error parsing <signing_key> in acct_mgr_url.xml"
);
}
continue;
}
else if (xp.parse_bool("cookie_required", cookie_required)) continue;
else if (xp.parse_str("cookie_failure_url", cookie_failure_url, 256)) continue;
if (log_flags.unparsed_xml) {
msg_printf(NULL, MSG_INFO,
"[unparsed_xml] ACCT_MGR_INFO::init: unrecognized %s",
xp.parsed_tag
);
}
xp.skip_unexpected(log_flags.unparsed_xml, "ACCT_MGR_INFO::init");
}
fclose(p);
p = fopen(ACCT_MGR_LOGIN_FILENAME, "r");
if (p) {
parse_login_file(p);
fclose(p);
}
if (using_am()) {
msg_printf(NULL, MSG_INFO, "Using account manager %s", project_name);
if (strlen(user_name)) {
msg_printf(NULL, MSG_INFO, "Account manager login: %s", user_name);
}
}
return 0;
}
示例10: parse
// parse RPC reply from account manager
//
int ACCT_MGR_OP::parse(FILE* f) {
string message;
int retval;
MIOFILE mf;
mf.init_file(f);
XML_PARSER xp(&mf);
accounts.clear();
error_str = "";
error_num = 0;
repeat_sec = 0;
safe_strcpy(host_venue, "");
safe_strcpy(ami.opaque, "");
ami.no_project_notices = false;
ami.dynamic = false;
rss_feeds.clear();
if (!xp.parse_start("acct_mgr_reply")) return ERR_XML_PARSE;
while (!xp.get_tag()) {
if (!xp.is_tag) {
if (log_flags.unparsed_xml) {
msg_printf(0, MSG_INFO,
"[unparsed_xml] ACCT_MGR_OP::parse: unexpected text %s",
xp.parsed_tag
);
}
continue;
}
if (xp.match_tag("/acct_mgr_reply")) return 0;
if (xp.parse_str("name", ami.project_name, 256)) continue;
if (xp.parse_str("user_name", ami.user_name, sizeof(ami.user_name))) {
xml_unescape(ami.user_name);
continue;
}
if (xp.parse_str("team_name", ami.team_name, sizeof(ami.team_name))) {
xml_unescape(ami.team_name);
continue;
}
if (xp.parse_str("authenticator", ami.authenticator, 256)) continue;
if (xp.parse_int("error_num", error_num)) continue;
if (xp.parse_string("error", error_str)) continue;
if (xp.parse_string("error_msg", error_str)) continue;
if (xp.parse_double("repeat_sec", repeat_sec)) continue;
if (xp.parse_bool("dynamic", ami.dynamic)) continue;
if (xp.parse_string("message", message)) {
msg_printf(NULL, MSG_INFO, "Account manager: %s", message.c_str());
continue;
}
if (xp.match_tag("opaque")) {
retval = xp.element_contents("</opaque>", ami.opaque, sizeof(ami.opaque));
if (retval) return retval;
continue;
}
if (xp.match_tag("signing_key")) {
retval = xp.element_contents("</signing_key>", ami.signing_key, sizeof(ami.signing_key));
if (retval) return retval;
continue;
}
if (xp.match_tag("account")) {
AM_ACCOUNT account;
retval = account.parse(xp);
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Can't parse account in account manager reply: %s",
boincerror(retval)
);
} else {
accounts.push_back(account);
}
continue;
}
if (xp.match_tag("global_preferences")) {
retval = copy_element_contents(
f,
"</global_preferences>",
global_prefs_xml
);
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Can't parse global prefs in account manager reply: %s",
boincerror(retval)
);
return retval;
}
continue;
}
if (xp.parse_str("host_venue", host_venue, sizeof(host_venue))) {
continue;
}
if (xp.match_tag("rss_feeds")) {
got_rss_feeds = true;
parse_rss_feed_descs(xp, rss_feeds);
continue;
}
if (xp.parse_bool("no_project_notices", ami.no_project_notices)) {
continue;
}
if (xp.match_tag("user_keywords")) {
retval = ami.user_keywords.parse(xp);
//.........这里部分代码省略.........
示例11: do_rpc
//.........这里部分代码省略.........
fprintf(f,
" <previous_host_cpid>%s</previous_host_cpid>\n",
gstate.acct_mgr_info.previous_host_cpid
);
}
// If the AMS requested it, send GUI RPC port and password hash.
// This is for the "farm" account manager so it
// can know where to send GUI RPC requests to
// without having to configure each host
//
if (gstate.acct_mgr_info.send_gui_rpc_info) {
if (gstate.cmdline_gui_rpc_port) {
fprintf(f," <gui_rpc_port>%d</gui_rpc_port>\n", gstate.cmdline_gui_rpc_port);
} else {
fprintf(f," <gui_rpc_port>%d</gui_rpc_port>\n", GUI_RPC_PORT);
}
if (boinc_file_exists(GUI_RPC_PASSWD_FILE)) {
strcpy(password, "");
pwdf = fopen(GUI_RPC_PASSWD_FILE, "r");
if (pwdf) {
if (fgets(password, 256, pwdf)) {
strip_whitespace(password);
}
fclose(pwdf);
}
fprintf(f," <gui_rpc_password>%s</gui_rpc_password>\n", password);
}
}
for (i=0; i<gstate.projects.size(); i++) {
PROJECT* p = gstate.projects[i];
double not_started_dur, in_progress_dur;
p->get_task_durs(not_started_dur, in_progress_dur);
fprintf(f,
" <project>\n"
" <url>%s</url>\n"
" <project_name>%s</project_name>\n"
" <suspended_via_gui>%d</suspended_via_gui>\n"
" <account_key>%s</account_key>\n"
" <hostid>%d</hostid>\n"
" <not_started_dur>%f</not_started_dur>\n"
" <in_progress_dur>%f</in_progress_dur>\n"
" <attached_via_acct_mgr>%d</attached_via_acct_mgr>\n"
" <dont_request_more_work>%d</dont_request_more_work>\n"
" <detach_when_done>%d</detach_when_done>\n"
" <ended>%d</ended>\n"
" </project>\n",
p->master_url,
p->project_name,
p->suspended_via_gui?1:0,
p->authenticator,
p->hostid,
not_started_dur,
in_progress_dur,
p->attached_via_acct_mgr?1:0,
p->dont_request_more_work?1:0,
p->detach_when_done?1:0,
p->ended?1:0
);
}
MIOFILE mf;
mf.init_file(f);
// send working prefs
//
fprintf(f, "<working_global_preferences>\n");
gstate.global_prefs.write(mf);
fprintf(f, "</working_global_preferences>\n");
if (boinc_file_exists(GLOBAL_PREFS_FILE_NAME)) {
FILE* fprefs = fopen(GLOBAL_PREFS_FILE_NAME, "r");
if (fprefs) {
copy_stream(fprefs, f);
fclose(fprefs);
}
}
gstate.host_info.write(mf, !config.suppress_net_info, true);
if (strlen(gstate.acct_mgr_info.opaque)) {
fprintf(f,
" <opaque>\n%s\n"
" </opaque>\n",
gstate.acct_mgr_info.opaque
);
}
gstate.time_stats.write(mf, true);
gstate.net_stats.write(mf);
fprintf(f, "</acct_mgr_request>\n");
fclose(f);
sprintf(buf, "%srpc.php", url);
retval = gui_http->do_rpc_post(
this, buf, ACCT_MGR_REQUEST_FILENAME, ACCT_MGR_REPLY_FILENAME, true
);
if (retval) {
error_num = retval;
return retval;
}
msg_printf(NULL, MSG_INFO, "Contacting account manager at %s", url);
return 0;
}
示例12: wu_is_infeasible_custom
bool wu_is_infeasible_custom(WORKUNIT& wu, APP& app, BEST_APP_VERSION& bav) {
#if 0
// example: if WU name contains "_v1", don't use GPU apps.
// Note: this is slightly suboptimal.
// If the host is able to accept both GPU and CPU jobs,
// we'll skip this job rather than send it for the CPU.
// Fixing this would require a big architectural change.
//
if (strstr(wu.name, "_v1") && bav.host_usage.uses_gpu()) {
return true;
}
#endif
#if 0
// example: for NVIDIA GPU app,
// wu.batch is the minimum number of GPU processors.
// Don't send if #procs is less than this.
//
if (!strcmp(app.name, "foobar") && bav.host_usage.proc_type == PROC_TYPE_NVIDIA_GPU) {
int n = g_request->coprocs.nvidia.prop.multiProcessorCount;
if (n < wu.batch) {
return true;
}
}
#endif
#if defined(SETIATHOME)
bool infeasible=false;
static bool send_vlar_to_gpu=false;
static bool sah_config_checked=false;
char buff[256];
// check the projects app config whether to send vlar wus to gpus
if (!sah_config_checked) {
MIOFILE mf;
XML_PARSER xp(&mf);
#ifndef _USING_FCGI_
FILE *f=fopen(config.project_path("sah_config.xml"),"r");
#else
FCGI_FILE *f=FCGI::fopen(config.project_path("sah_config.xml"),"r");
#endif
if (f) {
mf.init_file(f);
if (xp.parse_start("sah") && xp.parse_start("config")) {
while (!xp.get_tag()) {
if (!xp.is_tag) continue;
if (xp.parse_bool("send_vlar_to_gpu",send_vlar_to_gpu)) continue;
if (xp.match_tag("/config")) break;
xp.skip_unexpected(false, "wu_is_infeasible_custom");
}
}
fclose(f);
}
sah_config_checked=true;
}
// example: if CUDA app and WU name contains ".vlar", don't send
// to NVIDIA, INTEL or older ATI cards
//
if (bav.host_usage.uses_gpu() && strstr(wu.name, ".vlar")) {
if (send_vlar_to_gpu) {
if (bav.host_usage.proc_type == PROC_TYPE_AMD_GPU) {
// ATI GPUs older than HD7870
COPROC_ATI &cp = g_request->coprocs.ati;
if (cp.count && (cp.attribs.target < 15)) {
infeasible=true;
}
} else if (bav.host_usage.proc_type == PROC_TYPE_NVIDIA_GPU) {
COPROC_NVIDIA &cp = g_request->coprocs.nvidia;
if (cp.count) {
int v = (cp.prop.major)*100 + cp.prop.minor;
if (v < 300) {
infeasible=true;
}
}
} else {
// all other GPUS
infeasible=true;
}
} else {
infeasible=true;
}
}
if (infeasible && config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] [setiathome] VLAR workunit is infeasible on this GPU\n"
);
}
return infeasible;
#endif
return false;
}
示例13: read_coproc_info_file
int COPROCS::read_coproc_info_file(vector<string> &warnings) {
MIOFILE mf;
int retval;
FILE* f;
string s;
COPROC_ATI my_ati_gpu;
COPROC_NVIDIA my_nvidia_gpu;
COPROC_INTEL my_intel_gpu;
OPENCL_DEVICE_PROP ati_opencl;
OPENCL_DEVICE_PROP nvidia_opencl;
OPENCL_DEVICE_PROP intel_gpu_opencl;
OPENCL_DEVICE_PROP other_opencl;
OPENCL_CPU_PROP cpu_opencl;
ati_gpus.clear();
nvidia_gpus.clear();
intel_gpus.clear();
ati_opencls.clear();
nvidia_opencls.clear();
intel_gpu_opencls.clear();
other_opencls.clear();
cpu_opencls.clear();
f = boinc_fopen(COPROC_INFO_FILENAME, "r");
if (!f) return ERR_FOPEN;
XML_PARSER xp(&mf);
mf.init_file(f);
if (!xp.parse_start("coprocs")) {
fclose(f);
return ERR_XML_PARSE;
}
while (!xp.get_tag()) {
if (xp.match_tag("/coprocs")) {
fclose(f);
return 0;
}
if (xp.parse_bool("have_cuda", nvidia.have_cuda)) continue;
if (xp.parse_int("cuda_version", nvidia.cuda_version)) {
continue;
}
if (xp.match_tag("coproc_ati")) {
retval = my_ati_gpu.parse(xp);
if (retval) {
my_ati_gpu.clear();
} else {
my_ati_gpu.device_num = (int)ati_gpus.size();
ati_gpus.push_back(my_ati_gpu);
}
continue;
}
if (xp.match_tag("coproc_cuda")) {
retval = my_nvidia_gpu.parse(xp);
if (retval) {
my_nvidia_gpu.clear();
} else {
my_nvidia_gpu.device_num = (int)nvidia_gpus.size();
my_nvidia_gpu.pci_info = my_nvidia_gpu.pci_infos[0];
memset(&my_nvidia_gpu.pci_infos[0], 0, sizeof(struct PCI_INFO));
nvidia_gpus.push_back(my_nvidia_gpu);
}
continue;
}
if (xp.match_tag("coproc_intel_gpu")) {
retval = my_intel_gpu.parse(xp);
if (retval) {
my_intel_gpu.clear();
} else {
my_intel_gpu.device_num = (int)intel_gpus.size();
intel_gpus.push_back(my_intel_gpu);
}
continue;
}
if (xp.match_tag("ati_opencl")) {
memset(&ati_opencl, 0, sizeof(ati_opencl));
retval = ati_opencl.parse(xp, "/ati_opencl");
if (retval) {
memset(&ati_opencl, 0, sizeof(ati_opencl));
} else {
ati_opencl.is_used = COPROC_IGNORED;
ati_opencls.push_back(ati_opencl);
}
continue;
}
if (xp.match_tag("nvidia_opencl")) {
memset(&nvidia_opencl, 0, sizeof(nvidia_opencl));
retval = nvidia_opencl.parse(xp, "/nvidia_opencl");
if (retval) {
memset(&nvidia_opencl, 0, sizeof(nvidia_opencl));
} else {
nvidia_opencl.is_used = COPROC_IGNORED;
nvidia_opencls.push_back(nvidia_opencl);
}
continue;
}
//.........这里部分代码省略.........
示例14: get_firefox_profile_root
// traverse the profiles and determine which profile to use.
// this should be compatible with firefox2, firefox3, firefox4, seamonkey, and netscape.
//
bool get_firefox_profile_root( std::string& profile_root ) {
bool retval = false;
FILE* pf = NULL;
MIOFILE pmf;
MOZILLA_PROFILES mps;
MOZILLA_PROFILE* mp = NULL;
std::string cookies_root;
std::string tmp;
unsigned int i = 0;
unsigned int default_index = 0;
get_home_dir_path( profile_root );
#ifdef _WIN32
profile_root += std::string("Mozilla\\Firefox\\");
#elif defined(__APPLE__)
profile_root += std::string("Library/Application Support/Firefox/");
#else
profile_root += std::string(".mozilla/firefox/");
#endif
// lets see if we can open the profiles configuration file
tmp = profile_root + "profiles.ini";
pf = fopen(tmp.c_str(), "r");
// if profiles configuration file exists, parse it.
if (pf) {
pmf.init_file(pf);
mps.parse(pmf);
}
// we need to know which cookie file to look at, so if only
// one profile exists, use it.
//
// if more than one profile exists, look through all the
// profiles until we find the default profile. even when the
// user selects a different profile at startup the default
// profile flag is changed at startup to the new profile.
if (mps.profiles.size() == 0) {
if (pf) fclose(pf);
return retval; // something is very wrong, don't
// risk a crash
}
if (mps.profiles.size() == 1) {
default_index = 0;
} else {
for (i=0; i < mps.profiles.size(); i++) {
if (mps.profiles[i]->is_default) {
default_index = i;
break;
}
}
}
// should the path be treated as an absolute path or a relative
// path?
mp = mps.profiles[default_index];
if (mp->is_relative) {
cookies_root = profile_root + mp->path + "/";
} else {
cookies_root = mp->path + "/";
}
profile_root = cookies_root;
retval = true;
// cleanup
if (pf) fclose(pf);
return retval;
}
示例15: parse_login_file
int ACCT_MGR_INFO::parse_login_file(FILE* p) {
MIOFILE mf;
int retval;
mf.init_file(p);
XML_PARSER xp(&mf);
if (!xp.parse_start("acct_mgr_login")) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"missing start tag in account manager login file"
);
}
while (!xp.get_tag()) {
if (!xp.is_tag) {
printf("unexpected text: %s\n", xp.parsed_tag);
continue;
}
if (xp.match_tag("/acct_mgr_login")) break;
if (xp.parse_str("login", login_name, 256)) continue;
if (xp.parse_str("password_hash", password_hash, 256)) continue;
if (xp.parse_str("authenticator", authenticator, 256)) continue;
if (xp.parse_str("previous_host_cpid", previous_host_cpid, sizeof(previous_host_cpid))) continue;
if (xp.parse_double("next_rpc_time", next_rpc_time)) continue;
if (xp.match_tag("opaque")) {
retval = xp.element_contents("</opaque>", opaque, sizeof(opaque));
if (retval) {
msg_printf(NULL, MSG_INFO,
"error parsing <opaque> in acct_mgr_login.xml"
);
}
continue;
}
if (xp.parse_str("user_name", user_name, sizeof(user_name))) {
xml_unescape(user_name);
continue;
}
if (xp.parse_str("team_name", team_name, sizeof(team_name))) {
xml_unescape(team_name);
continue;
}
if (xp.parse_bool("no_project_notices", no_project_notices)) continue;
if (xp.parse_bool("dynamic", dynamic)) continue;
if (xp.match_tag("user_keywords")) {
retval = user_keywords.parse(xp);
if (retval) {
msg_printf(NULL, MSG_INFO,
"error parsing user keywords in acct_mgr_login.xml"
);
}
continue;
}
if (log_flags.unparsed_xml) {
msg_printf(NULL, MSG_INFO,
"[unparsed_xml] unrecognized %s in acct_mgr_login.xml",
xp.parsed_tag
);
}
xp.skip_unexpected(
log_flags.unparsed_xml, "ACCT_MGR_INFO::parse_login_file"
);
}
return 0;
}