当前位置: 首页>>代码示例>>C++>>正文


C++ PROJECT::write_account_file方法代码示例

本文整理汇总了C++中PROJECT::write_account_file方法的典型用法代码示例。如果您正苦于以下问题:C++ PROJECT::write_account_file方法的具体用法?C++ PROJECT::write_account_file怎么用?C++ PROJECT::write_account_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PROJECT的用法示例。


在下文中一共展示了PROJECT::write_account_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:FoxKyong,项目名称:boinc,代码行数:89,代码来源:cs_account.cpp


注:本文中的PROJECT::write_account_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。