本文整理汇总了C++中PROJECT::parse_account方法的典型用法代码示例。如果您正苦于以下问题:C++ PROJECT::parse_account方法的具体用法?C++ PROJECT::parse_account怎么用?C++ PROJECT::parse_account使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PROJECT
的用法示例。
在下文中一共展示了PROJECT::parse_account方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_account_files
int CLIENT_STATE::parse_account_files() {
string name;
PROJECT* project;
FILE* f;
int retval;
DirScanner dir(".");
while (dir.scan(name)) {
if (!is_file(name.c_str())) continue;
if (!is_account_file(name.c_str())) continue;
f = boinc_fopen(name.c_str(), "r");
if (!f) continue;
project = new PROJECT;
// Assume master_url_fetch_pending, sched_rpc_pending are
// true until we read client_state.xml
//
project->master_url_fetch_pending = true;
project->sched_rpc_pending = RPC_REASON_INIT;
retval = project->parse_account(f);
fclose(f);
if (retval) {
msg_printf(project, MSG_INTERNAL_ERROR,
"Couldn't parse account file %s", name.c_str()
);
delete project;
} else {
if (lookup_project(project->master_url)) {
msg_printf(project, MSG_INFO,
"Duplicate account file %s - ignoring", name.c_str()
);
delete project;
} else {
projects.push_back(project);
}
}
}
sort_projects();
return 0;
}
示例2: add_project
int CLIENT_STATE::add_project(
const char* master_url, const char* _auth, const char* project_name,
bool attached_via_acct_mgr
) {
char path[MAXPATHLEN], canonical_master_url[256], auth[256];
PROJECT* project;
FILE* f;
int retval;
if (cc_config.disallow_attach) {
return ERR_USER_PERMISSION;
}
safe_strcpy(canonical_master_url, master_url);
strip_whitespace(canonical_master_url);
canonicalize_master_url(canonical_master_url, sizeof(canonical_master_url));
if (!valid_master_url(canonical_master_url)) {
msg_printf(0, MSG_INFO, "Invalid URL: %s", canonical_master_url);
return ERR_INVALID_URL;
}
safe_strcpy(auth, _auth);
strip_whitespace(auth);
if (!strlen(auth)) {
msg_printf(0, MSG_INFO, "Missing account key");
return ERR_AUTHENTICATOR;
}
// check if we're already attached to this project
//
if (lookup_project(canonical_master_url)) {
msg_printf(0, MSG_INFO, "Already attached to %s", canonical_master_url);
return ERR_ALREADY_ATTACHED;
}
// create project state
//
project = new PROJECT;
safe_strcpy(project->master_url, canonical_master_url);
safe_strcpy(project->authenticator, auth);
safe_strcpy(project->project_name, project_name);
project->attached_via_acct_mgr = attached_via_acct_mgr;
retval = project->write_account_file();
if (retval) {
delete project;
return retval;
}
get_account_filename(canonical_master_url, path, sizeof(path));
f = boinc_fopen(path, "r");
if (!f) {
delete project;
return ERR_FOPEN;
}
retval = project->parse_account(f);
fclose(f);
if (retval) {
delete project;
return retval;
}
// remove any old files
// (unless PROJECT/app_info.xml is found, so that
// people using anonymous platform don't have to get apps again)
//
sprintf(path, "%s/%s", project->project_dir(), APP_INFO_FILE_NAME);
if (boinc_file_exists(path)) {
project->anonymous_platform = true;
f = fopen(path, "r");
if (f) {
parse_app_info(project, f);
fclose(f);
}
} else {
retval = remove_project_dir(*project);
}
retval = make_project_dir(*project);
if (retval) {
delete project;
return retval;
}
projects.push_back(project);
sort_projects_by_name();
project->sched_rpc_pending = RPC_REASON_INIT;
set_client_state_dirty("Add project");
return 0;
}