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


C++ MIOFILE类代码示例

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


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

示例1: handle_acct_mgr_rpc

static void handle_acct_mgr_rpc(char* buf, MIOFILE& fout) {
    std::string url, name, password;
    std::string password_hash, name_lc;
    bool use_config_file = false;
    bool bad_arg = false;
    if (!parse_bool(buf, "use_config_file", use_config_file)) {
        if (!parse_str(buf, "<url>", url)) bad_arg = true;
        if (!parse_str(buf, "<name>", name)) bad_arg = true;
        if (!parse_str(buf, "<password>", password)) bad_arg = true;
        if (!bad_arg) {
            name_lc = name;
            downcase_string(name_lc);
            if (!starts_with(password, "hash:")) {
                password_hash = md5_string(password+name_lc);
            } else {
                // Remove 'hash:'
                password_hash = password.substr(5);
            }
        }
    } else {
        if (!strlen(gstate.acct_mgr_info.master_url)) {
            bad_arg = true;
            msg_printf(NULL, MSG_INTERNAL_ERROR,
                "Account manager info missing from config file"
            );
        } else {
            url = gstate.acct_mgr_info.master_url;
            name = gstate.acct_mgr_info.login_name;
            password_hash = gstate.acct_mgr_info.password_hash;
        }
    }
    if (bad_arg) {
        fout.printf("<error>bad arg</error>\n");
    } else {
        gstate.acct_mgr_op.do_rpc(url, name, password_hash, true);
        fout.printf("<success/>\n");
    }
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:38,代码来源:gui_rpc_server_ops.cpp

示例2: set_remote_desktop_info

// set remote desktop information if needed
//
void set_remote_desktop_info(APP_INIT_DATA& /* aid */, VBOX_VM& vm) {
    char buf[256];

    if (vm.rd_host_port) {
        // Write info to disk
        //
        MIOFILE mf;
        FILE* f = boinc_fopen(REMOTEDESKTOP_FILENAME, "w");
        mf.init_file(f);

        mf.printf(
            "<remote_desktop>\n"
            "  <host_port>%d</host_port>\n"
            "</remote_desktop>\n",
            vm.rd_host_port
        );

        fclose(f);

        sprintf(buf, "localhost:%d", vm.rd_host_port);
        boinc_remote_desktop_addr(buf);
    }
}
开发者ID:justinlynn,项目名称:boinc-v2,代码行数:25,代码来源:vboxwrapper.cpp

示例3: send_log_after

void send_log_after(const char* filename, double t, MIOFILE& mf) {
    char buf[256];
    double x;

    FILE* f = fopen(filename, "r");
    if (!f) return;
    while (fgets(buf, 256, f)) {
        int n = sscanf(buf, "%lf", &x);
        if (n != 1) continue;
        if (x < t) continue;
        mf.printf("%s", buf);
    }
    fclose(f);
}
开发者ID:DanAurea,项目名称:boinc,代码行数:14,代码来源:time_stats.cpp

示例4: clear

int PROJECT_INIT::init() {
    clear();
    FILE* f = fopen(PROJECT_INIT_FILENAME, "r");
    if (!f) return 0;

    MIOFILE mf;
    mf.init_file(f);
    XML_PARSER xp(&mf);
    while (!xp.get_tag()) {
        if (xp.match_tag("/project_init")) break;
        else if (xp.parse_str("name", name, 256)) continue;
        else if (xp.parse_str("team_name", team_name, 256)) continue;
        else if (xp.parse_str("url", url, 256)) {
            canonicalize_master_url(url);
            continue;
        } else if (xp.parse_str("account_key", account_key, 256)) {
            continue;
        }
    }
    fclose(f);
    msg_printf(0, MSG_INFO, "Found project_init.xml for %s", url);
    return 0;
}
开发者ID:FpgaAtHome,项目名称:seti_fpga,代码行数:23,代码来源:acct_setup.cpp

示例5: parse

int COPROC_REQ::parse(MIOFILE& fin) {
    char buf[1024];
    strcpy(type, "");
    count = 0;
    while (fin.fgets(buf, sizeof(buf))) {
        if (match_tag(buf, "</coproc>")) {
            if (!strlen(type)) return ERR_XML_PARSE;
            return 0;
        }
        if (parse_str(buf, "<type>", type, sizeof(type))) continue;
        if (parse_double(buf, "<count>", count)) continue;
    }
    return ERR_XML_PARSE;
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:14,代码来源:coproc.cpp

示例6: write_xml

void COPROCS::write_xml(MIOFILE& mf, bool scheduler_rpc) {
#ifndef _USING_FCGI_
    mf.printf("    <coprocs>\n");
    
    for (int i=1; i<n_rsc; i++) {
        switch (coproc_type_name_to_num(coprocs[i].type)) {
        case PROC_TYPE_NVIDIA_GPU:
            nvidia.write_xml(mf, scheduler_rpc);
            break;
        case PROC_TYPE_AMD_GPU:
            ati.write_xml(mf, scheduler_rpc);
            break;
        case PROC_TYPE_INTEL_GPU:
            intel_gpu.write_xml(mf, scheduler_rpc);
            break;
        default:
            coprocs[i].write_xml(mf, scheduler_rpc);
        }
    }
    
    mf.printf("    </coprocs>\n");
#endif
}
开发者ID:xavierdingdev,项目名称:boinc,代码行数:23,代码来源:coproc.cpp

示例7: handle_update_projects_apps

static void handle_update_projects_apps(char* buf, bool is_local, MIOFILE& fout) {
    if (!is_local) {
        fout.printf("<failed/>\n");
        return;
    }
    
    string url;
    if (!parse_str(buf, "<project_url>", url)) {
        fout.printf("<error>Missing URL</error>\n");
        return;
    }
    
    for (unsigned int i=0;i<gstate.projects.size();i++) {
        PROJECT* project = gstate.projects[i];
        if (!strcmp(project->master_url,url.c_str())) {
            if (log_flags.update_apps_debug)
                msg_printf(project, MSG_INFO, "init process");
            gstate.init_update_project_apps(project);
            fout.printf("<success/>");
        }
    }
    fout.printf("<error>Project not attached</error>\n");
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:23,代码来源:gui_rpc_server_ops.cpp

示例8: handle_acct_mgr_info

static void handle_acct_mgr_info(char*, MIOFILE& fout) {
    fout.printf(
        "<acct_mgr_info>\n"
        "   <acct_mgr_url>%s</acct_mgr_url>\n"
        "   <acct_mgr_name>%s</acct_mgr_name>\n",
        gstate.acct_mgr_info.master_url,
        gstate.acct_mgr_info.project_name
    );

    if (strlen(gstate.acct_mgr_info.login_name)) {
        fout.printf("   <have_credentials/>\n");
    }

    if (gstate.acct_mgr_info.cookie_required) {
        fout.printf("   <cookie_required/>\n");
        fout.printf(
            "   <cookie_failure_url>%s</cookie_failure_url>\n",
            gstate.acct_mgr_info.cookie_failure_url
        );
    }

    fout.printf("</acct_mgr_info>\n");
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:23,代码来源:gui_rpc_server_ops.cpp

示例9: write_coproc_info_file

int COPROCS::write_coproc_info_file(vector<string> &warnings) {
    MIOFILE mf;
    unsigned int i, temp;
    FILE* f;
    
    f = boinc_fopen(COPROC_INFO_FILENAME, "wb");
    if (!f) return ERR_FOPEN;
    mf.init_file(f);
    
    mf.printf("    <coprocs>\n");

    if (nvidia.have_cuda) {
        mf.printf("    <have_cuda>1</have_cuda>\n");
        mf.printf("    <cuda_version>%d</cuda_version>\n", nvidia.cuda_version);
    }
    
    for (i=0; i<ati_gpus.size(); ++i) {
       ati_gpus[i].write_xml(mf, false);
    }
    for (i=0; i<nvidia_gpus.size(); ++i) {
        temp = nvidia_gpus[i].count;
        nvidia_gpus[i].count = 1;
        nvidia_gpus[i].pci_infos[0] = nvidia_gpus[i].pci_info;
        nvidia_gpus[i].write_xml(mf, false);
        nvidia_gpus[i].count = temp;
    }
    for (i=0; i<intel_gpus.size(); ++i) {
        intel_gpus[i].write_xml(mf, false);
    }
    for (i=0; i<ati_opencls.size(); ++i) {
        ati_opencls[i].write_xml(mf, "ati_opencl", true);
    }
    for (i=0; i<nvidia_opencls.size(); ++i) {
        nvidia_opencls[i].write_xml(mf, "nvidia_opencl", true);
    }
    for (i=0; i<intel_gpu_opencls.size(); ++i) {
        intel_gpu_opencls[i].write_xml(mf, "intel_gpu_opencl", true);
    }
    for (i=0; i<other_opencls.size(); i++) {
        other_opencls[i].write_xml(mf, "other_opencl", true);
    }
    for (i=0; i<cpu_opencls.size(); i++) {
        cpu_opencls[i].write_xml(mf);
    }
    for (i=0; i<warnings.size(); ++i) {
        mf.printf("<warning>%s</warning>\n", warnings[i].c_str());
    }

    mf.printf("    </coprocs>\n");
    fclose(f);
    return 0;
}
开发者ID:Ocode,项目名称:boinc,代码行数:52,代码来源:gpu_detect.cpp

示例10: parse_job_file

int parse_job_file() {
    MIOFILE mf;
    char tag[1024], buf[256], buf2[256];
    bool is_tag;

    boinc_resolve_filename(JOB_FILENAME, buf, 1024);
    FILE* f = boinc_fopen(buf, "r");
    if (!f) {
        fprintf(stderr,
            "%s can't open job file %s\n",
            boinc_msg_prefix(buf2, sizeof(buf2)), buf
        );
        return ERR_FOPEN;
    }
    mf.init_file(f);
    XML_PARSER xp(&mf);

    if (!xp.parse_start("job_desc")) return ERR_XML_PARSE;
    while (!xp.get(tag, sizeof(tag), is_tag)) {
        if (!is_tag) {
            fprintf(stderr,
                "%s SCHED_CONFIG::parse(): unexpected text %s\n",
                boinc_msg_prefix(buf2, sizeof(buf2)), tag
            );
            continue;
        }
        if (!strcmp(tag, "/job_desc")) {
            fclose(f);
            return 0;
        }
        if (!strcmp(tag, "vm")) {
            vm.parse(xp);
        }
    }
    fclose(f);
    return ERR_XML_PARSE;
}
开发者ID:BME-IK,项目名称:gridbee-nacl-framework,代码行数:37,代码来源:vboxwrapper.cpp

示例11: parse

void parse(FILE* f) {
    char tag[256];
    bool is_tag, flag;
    MIOFILE mf;
    XML_PARSER xp(&mf);
    char name[256];
    int val;
    double x;

    mf.init_file(f);
    if (!xp.parse_start("blah")) {
        printf("missing start tag\n");
        return;
    }
    while (!xp.get(tag, sizeof(tag), is_tag)) {
        if (!is_tag) {
            printf("unexpected text: %s\n", tag);
            continue;
        }
        if (!strcmp(tag, "/blah")) {
            printf("success\n");
            return;
        } else if (xp.parse_str(tag, "str", name, sizeof(name))) {
            printf("got str: %s\n", name);
        } else if (xp.parse_int(tag, "int", val)) {
            printf("got int: %d\n", val);
        } else if (xp.parse_double(tag, "double", x)) {
            printf("got double: %f\n", x);
        } else if (xp.parse_bool(tag, "bool", flag)) {
            printf("got bool: %d\n", flag);
        } else {
            printf("unparsed tag: %s\n", tag);
            xp.skip_unexpected(tag, true, "xml test");
        }
    }
    printf("unexpected EOF\n");
}
开发者ID:freehal,项目名称:boinc-freehal,代码行数:37,代码来源:parse.cpp

示例12: write

// <active_task_state> is here for the benefit of 3rd-party software
// that reads the client state file
//
int ACTIVE_TASK::write(MIOFILE& fout) {
    fout.printf(
        "<active_task>\n"
        "    <project_master_url>%s</project_master_url>\n"
        "    <result_name>%s</result_name>\n"
        "    <active_task_state>%d</active_task_state>\n"
        "    <app_version_num>%d</app_version_num>\n"
        "    <slot>%d</slot>\n"
        "    <checkpoint_cpu_time>%f</checkpoint_cpu_time>\n"
        "    <checkpoint_elapsed_time>%f</checkpoint_elapsed_time>\n"
        "    <checkpoint_fraction_done>%f</checkpoint_fraction_done>\n"
        "    <checkpoint_fraction_done_elapsed_time>%f</checkpoint_fraction_done_elapsed_time>\n"
        "    <current_cpu_time>%f</current_cpu_time>\n"
        "    <once_ran_edf>%d</once_ran_edf>\n"
        "    <swap_size>%f</swap_size>\n"
        "    <working_set_size>%f</working_set_size>\n"
        "    <working_set_size_smoothed>%f</working_set_size_smoothed>\n"
        "    <page_fault_rate>%f</page_fault_rate>\n",
        result->project->master_url,
        result->name,
        task_state(),
        app_version->version_num,
        slot,
        checkpoint_cpu_time,
        checkpoint_elapsed_time,
        checkpoint_fraction_done,
        checkpoint_fraction_done_elapsed_time,
        current_cpu_time,
        once_ran_edf?1:0,
        procinfo.swap_size,
        procinfo.working_set_size,
        procinfo.working_set_size_smoothed,
        procinfo.page_fault_rate
    );
    fout.printf("</active_task>\n");
    return 0;
}
开发者ID:asimonov-im,项目名称:boinc,代码行数:40,代码来源:app.cpp

示例13: write

int WORKUNIT::write(MIOFILE& out) {
    unsigned int i;

    out.printf(
        "<workunit>\n"
        "    <name>%s</name>\n"
        "    <app_name>%s</app_name>\n"
        "    <version_num>%d</version_num>\n"
        //"    <env_vars>%s</env_vars>\n"
        "    <rsc_fpops_est>%f</rsc_fpops_est>\n"
        "    <rsc_fpops_bound>%f</rsc_fpops_bound>\n"
        "    <rsc_memory_bound>%f</rsc_memory_bound>\n"
        "    <rsc_disk_bound>%f</rsc_disk_bound>\n",
        name,
        app_name,
        version_num,
        //env_vars,
        rsc_fpops_est,
        rsc_fpops_bound,
        rsc_memory_bound,
        rsc_disk_bound
    );
    if (command_line.size()) {
        out.printf(
            "    <command_line>\n"
            "%s\n"
            "    </command_line>\n",
            command_line.c_str()
        );
    }
    for (i=0; i<input_files.size(); i++) {
        input_files[i].write(out);
    }
    out.printf("</workunit>\n");
    return 0;
}
开发者ID:nicolas17,项目名称:boincgit-test,代码行数:36,代码来源:client_types.cpp

示例14: ReloadSkin

bool CSkinManager::ReloadSkin(wxString strSkin) {
    int      retval = ERR_XML_PARSE;
    FILE*    p;
    MIOFILE  mf;

    // This fixes a (rare) crash bug
    if (strSkin.IsEmpty()) {
        strSkin = GetDefaultSkinName();
    }
    
    // Clear out all the old stuff 
    Clear();

    // Set the default skin back to Default
    m_strSelectedSkin = strSkin;

    // TODO: Eliminate the <en> tags: localization is no longer in skin files.
    p = fopen((const char*)ConstructSkinFileName().mb_str(wxConvUTF8), "r");
    if (p) {
        mf.init_file(p);
        retval = Parse(mf, wxT("en"));
        fclose(p);
    }

    if (retval && show_error_msgs) {
        fprintf(stderr, "Skin Manager: Failed to load skin '%s'.\n", (const char *)ConstructSkinFileName().mb_str(wxConvUTF8));
    }

    InitializeDelayedValidation();

    // Tell whichever UI elements that are loaded to reload the
    //   skinable resources they use.
    wxGetApp().FireReloadSkin();

    return true;
}
开发者ID:AltroCoin,项目名称:altrocoin,代码行数:36,代码来源:SkinManager.cpp

示例15: write

// Write XML information about a persistent file transfer
//
int PERS_FILE_XFER::write(MIOFILE& fout) {
    fout.printf(
        "    <persistent_file_xfer>\n"
        "        <num_retries>%d</num_retries>\n"
        "        <first_request_time>%f</first_request_time>\n"
        "        <next_request_time>%f</next_request_time>\n"
        "        <time_so_far>%f</time_so_far>\n"
        "        <last_bytes_xferred>%f</last_bytes_xferred>\n"
        "        <is_upload>%d</is_upload>\n"
        "    </persistent_file_xfer>\n",
        nretry,
        first_request_time,
        next_request_time,
        time_so_far,
        last_bytes_xferred,
        is_upload?1:0
    );

    // the following is for GUI RPCs
    //
    if (fxp) {
        fout.printf(
            "    <file_xfer>\n"
            "        <bytes_xferred>%f</bytes_xferred>\n"
            "        <file_offset>%f</file_offset>\n"
            "        <xfer_speed>%f</xfer_speed>\n"
            "        <url>%s</url>\n"
            "    </file_xfer>\n",
            fxp->bytes_xferred,
            fxp->file_offset,
            fxp->xfer_speed,
            fxp->m_url
        );
    }
    return 0;
}
开发者ID:Gspohu,项目名称:Crowdcomputing,代码行数:38,代码来源:pers_file_xfer.cpp


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