int CLIENT_APP_VERSION::parse(FILE* f) { char buf[256]; memset(this, 0, sizeof(CLIENT_APP_VERSION)); while (fgets(buf, sizeof(buf), f)) { if (match_tag(buf, "</app_version>")) { app = ssp->lookup_app_name(app_name); if (!app) return ERR_NOT_FOUND; return 0; } if (parse_str(buf, "<app_name>", app_name, 256)) continue; if (parse_str(buf, "<platform>", platform, 256)) continue; if (parse_str(buf, "<plan_class>", plan_class, 256)) continue; if (parse_int(buf, "<version_num>", version_num)) continue; if (parse_double(buf, "<flops>", host_usage.projected_flops)) { host_usage.peak_flops = host_usage.projected_flops; continue; } if (match_tag(buf, "<coproc>")) { COPROC_REQ coproc_req; MIOFILE mf; mf.init_file(f); int retval = coproc_req.parse(mf); if (!retval && !strcmp(coproc_req.type, "CUDA")) { host_usage.ncudas = coproc_req.count; } if (!retval && !strcmp(coproc_req.type, "ATI")) { host_usage.natis = coproc_req.count; } } } return ERR_XML_PARSE; }
int wu_delete_files(WORKUNIT& wu) { char* p; char filename[256], pathname[256], buf[BLOB_SIZE]; bool no_delete=false; int count_deleted = 0, retval, mthd_retval = 0; if (strstr(wu.name, "nodelete")) return 0; safe_strcpy(buf, wu.xml_doc); p = strtok(buf, "\n"); strcpy(filename, ""); while (p) { if (parse_str(p, "<name>", filename, sizeof(filename))) { } else if (match_tag(p, "<file_info>")) { no_delete = false; strcpy(filename, ""); } else if (match_tag(p, "<no_delete/>")) { no_delete = true; } else if (match_tag(p, "</file_info>")) { if (!no_delete) { retval = get_file_path( filename, config.download_dir, config.uldl_dir_fanout, pathname ); if (retval == ERR_OPENDIR) { log_messages.printf(MSG_CRITICAL, "[WU#%d] missing dir for %s\n", wu.id, filename ); mthd_retval = ERR_UNLINK; } else if (retval) { log_messages.printf(MSG_CRITICAL, "[WU#%d] get_file_path: %s: %d\n", wu.id, filename, retval ); } else { log_messages.printf(MSG_NORMAL, "[WU#%d] deleting %s\n", wu.id, filename ); retval = unlink(pathname); if (retval) { log_messages.printf(MSG_CRITICAL, "[WU#%d] unlink %s failed: %d\n", wu.id, filename, retval ); mthd_retval = ERR_UNLINK; } else { count_deleted++; } } } } p = strtok(0, "\n"); } log_messages.printf(MSG_DEBUG, "[WU#%d] deleted %d file(s)\n", wu.id, count_deleted ); return mthd_retval; }
// Parse a boolean; tag is of form "foobar" // Accept either <foobar/>, <foobar />, or <foobar>0|1</foobar> // (possibly with leading/trailing white space) // bool parse_bool(wxChar* buf, const wxChar* tag, bool& result) { wxChar tag2[256], tag3[256]; int x; // quick check to reject most cases // if (!_tcsstr(buf, tag)) { return false; } _stprintf(tag2, sizeof(tag2), wxT("<%s/>"), tag); _stprintf(tag3, sizeof(tag3), wxT("<%s />"), tag); if (match_tag(buf, tag2) || match_tag(buf, tag3)) { result = true; return true; } _stprintf(tag2, sizeof(tag2), wxT("<%s>"), tag); if (parse_int(buf, tag2, x)) { result = (x != 0); return true; } return false; }
void __init prom_setup_cmdline(void) { char cmd_line[CL_SIZE]; char *cp, *board; int prom_argc; char **prom_argv, **prom_envp; int i; prom_argc = fw_arg0; prom_argv = (char **) fw_arg1; prom_envp = (char **) fw_arg2; cp = cmd_line; /* Note: it is common that parameters start * at argv[1] and not argv[0], * however, our elf loader starts at [0] */ for (i = 0; i < prom_argc; i++) { if (match_tag(prom_argv[i], FREQ_TAG)) { idt_cpu_freq = tag2ul(prom_argv[i], FREQ_TAG); continue; } #ifdef IGNORE_CMDLINE_MEM /* parses out the "mem=xx" arg */ if (match_tag(prom_argv[i], MEM_TAG)) continue; #endif if (i > 0) *(cp++) = ' '; if (match_tag(prom_argv[i], BOARD_TAG)) { board = prom_argv[i] + strlen(BOARD_TAG); if (match_tag(board, BOARD_RB532A)) mips_machtype = MACH_MIKROTIK_RB532A; else mips_machtype = MACH_MIKROTIK_RB532; } if (match_tag(prom_argv[i], GPIO_TAG)) gpio_bootup_state = tag2ul(prom_argv[i], GPIO_TAG); strcpy(cp, prom_argv[i]); cp += strlen(prom_argv[i]); } *(cp++) = ' '; i = strlen(arcs_cmdline); if (i > 0) { *(cp++) = ' '; strcpy(cp, arcs_cmdline); cp += strlen(arcs_cmdline); } if (gpio_bootup_state & 0x02) strcpy(cp, GPIO_INIT_NOBUTTON); else strcpy(cp, GPIO_INIT_BUTTON); cmd_line[CL_SIZE-1] = '\0'; strcpy(arcs_cmdline, cmd_line); }
int rda_is_filter(const uschar *s) { while (isspace(*s)) s++; /* Skips initial blank lines */ if (match_tag(s, CUS"# exim filter")) return FILTER_EXIM; else if (match_tag(s, CUS"# sieve filter")) return FILTER_SIEVE; else return FILTER_FORWARD; }
int CSkinAdvanced::Parse(MIOFILE& in) { char buf[256]; std::string strBuffer; while (in.fgets(buf, 256)) { if (match_tag(buf, "</advanced>")) break; else if (parse_bool(buf, "is_branded", m_bIsBranded)) continue; else if (parse_str(buf, "<application_name>", strBuffer)) { m_strApplicationName = wxString(strBuffer.c_str(), wxConvUTF8); continue; } else if (parse_str(buf, "<application_short_name>", strBuffer)) { m_strApplicationShortName = wxString(strBuffer.c_str(), wxConvUTF8); continue; } else if (match_tag(buf, "<application_icon>")) { m_iconApplicationIcon.Parse(in); continue; } else if (match_tag(buf, "<application_icon32>")) { m_iconApplicationIcon32.Parse(in); continue; } else if (match_tag(buf, "<application_disconnected_icon>")) { m_iconApplicationDisconnectedIcon.Parse(in); continue; } else if (match_tag(buf, "<application_snooze_icon>")) { m_iconApplicationSnoozeIcon.Parse(in); continue; } else if (parse_str(buf, "<application_logo>", strBuffer)) { if(strBuffer.length()) { wxString str = wxString( wxGetApp().GetSkinManager()->ConstructSkinPath() + wxString(strBuffer.c_str(), wxConvUTF8) ); if (boinc_file_exists(str.c_str())) { m_bitmapApplicationLogo = wxBitmap(wxImage(str.c_str(), wxBITMAP_TYPE_ANY)); } } continue; } else if (parse_str(buf, "<organization_name>", strBuffer)) { m_strOrganizationName = wxString(strBuffer.c_str(), wxConvUTF8); continue; } else if (parse_str(buf, "<organization_website>", strBuffer)) { m_strOrganizationWebsite = wxString(strBuffer.c_str(), wxConvUTF8); continue; } else if (parse_str(buf, "<organization_help_url>", strBuffer)) { m_strOrganizationHelpUrl = wxString(strBuffer.c_str(), wxConvUTF8); continue; } else if (parse_int(buf, "<open_tab>", m_iDefaultTab)) { m_bDefaultTabSpecified = true; continue; } else if (parse_str(buf, "<exit_message>", strBuffer)) { m_strExitMessage = wxString(strBuffer.c_str(), wxConvUTF8); continue; } } InitializeDelayedValidation(); return 0; }
// always generates an HTML reply // int handle_request(FILE* in, R_RSA_PUBLIC_KEY& key) { char buf[256]; char file_name[256]; int major, minor, release, retval=0; bool got_version = true; bool did_something = false; double start_time = dtime(); #ifdef _USING_FCGI_ log_messages.set_indent_level(1); #endif while (fgets(buf, 256, in)) { log_messages.printf(MSG_DEBUG, "handle_request: %s", buf); if (parse_int(buf, "<core_client_major_version>", major)) { continue; } else if (parse_int(buf, "<core_client_minor_version>", minor)) { continue; } else if (parse_int(buf, "<core_client_release>", release)) { continue; } else if (match_tag(buf, "<file_upload>")) { if (!got_version) { retval = return_error(ERR_PERMANENT, "Missing version"); } else { retval = handle_file_upload(in, key); } did_something = true; break; } else if (parse_str(buf, "<get_file_size>", file_name, sizeof(file_name))) { if (strstr(file_name, "..")) { return return_error(ERR_PERMANENT, "Bad filename"); } if (!got_version) { retval = return_error(ERR_PERMANENT, "Missing version"); } else { retval = handle_get_file_size(file_name); } did_something = true; break; } else if (match_tag(buf, "<data_server_request>")) { // DO NOTHING } else { log_messages.printf(MSG_DEBUG, "handle_request: unrecognized %s\n", buf); } } if (!did_something) { log_messages.printf(MSG_CRITICAL, "handle_request: no command\n"); return return_error(ERR_TRANSIENT, "no command"); } log_messages.printf(MSG_DEBUG, "elapsed time %f seconds\n", dtime()-start_time); return retval; }
static ERL_NIF_TERM unescape_cdata(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) { ErlNifBinary input; ERL_NIF_TERM output; struct buf *rbuf; int i; if (argc != 1) { return enif_make_badarg(env); } // CData should be iolist() or binary() if (enif_is_binary(env, argv[0])) { if (!enif_inspect_binary(env, argv[0], &input)) { return enif_make_badarg(env); } } else { if (!enif_inspect_iolist_as_binary(env, argv[0], &input)) { return enif_make_badarg(env); } } rbuf = init_buf(env, EXML_CDATA_BUF_SIZE); for (i = 0; i < input.size; i++) { if (input.data[i] == '&') { if (match_tag(input, i+1, "amp;", 4)) { buf_add_char(env, EXML_CDATA_BUF_SIZE, rbuf, '&'); i += 4; } else if (match_tag(input, i+1, "lt;", 3)) { buf_add_char(env, EXML_CDATA_BUF_SIZE, rbuf, '<'); i += 3; } else if (match_tag(input, i+1, "gt;", 3)) { buf_add_char(env, EXML_CDATA_BUF_SIZE, rbuf, '>'); i += 3; } else { buf_add_char(env, EXML_CDATA_BUF_SIZE, rbuf, input.data[i]); } } else { buf_add_char(env, EXML_CDATA_BUF_SIZE, rbuf, input.data[i]); } } unsigned char *data = enif_make_new_binary(env, rbuf->len, &output); memcpy(data, rbuf->b, rbuf->len); destroy_buf(env, rbuf); return output; }
void __init prom_setup_cmdline(void) { char *cp; int prom_argc; char **prom_argv; int i; prom_argc = fw_arg0; prom_argv = (char **)KSEG0ADDR(fw_arg1); cp = &(arcs_cmdline[0]); for (i = 1; i < prom_argc; i++) { prom_argv[i] = (char *)KSEG0ADDR(prom_argv[i]); /* default bootargs has "console=/dev/ttyS0" yet console won't * show up at all if you include the '/dev/' nowadays ... */ if (match_tag(prom_argv[i], "console=/dev/")) { char *ptr = prom_argv[i] + strlen("console=/dev/"); strcpy(cp, "console="); cp += strlen("console="); strcpy(cp, ptr); cp += strlen(ptr); *cp++ = ' '; continue; } strcpy(cp, prom_argv[i]); cp += strlen(prom_argv[i]); *cp++ = ' '; } if (prom_argc > 1) --cp; /* trailing space */ *cp = '\0'; }
int PROXY_INFO::parse(MIOFILE& in) { char buf[1024]; memset(this, 0, sizeof(PROXY_INFO)); while (in.fgets(buf, 256)) { if (match_tag(buf, "</proxy_info>")) { present = false; if (strlen(http_server_name)) present = true; if (strlen(socks_server_name)) present = true; return 0; } else if (parse_bool(buf, "use_http_proxy", use_http_proxy)) continue; else if (parse_bool(buf, "use_socks_proxy", use_socks_proxy)) continue; else if (parse_bool(buf, "use_http_auth", use_http_auth)) continue; else if (parse_str(buf, "<socks_server_name>", socks_server_name, sizeof(socks_server_name))) continue; else if (parse_int(buf, "<socks_server_port>", socks_server_port)) continue; else if (parse_str(buf, "<http_server_name>", http_server_name, sizeof(http_server_name))) continue; else if (parse_int(buf, "<http_server_port>", http_server_port)) continue; else if (parse_str(buf, "<socks5_user_name>", socks5_user_name,sizeof(socks5_user_name))) continue; else if (parse_str(buf, "<socks5_user_passwd>", socks5_user_passwd,sizeof(socks5_user_passwd))) continue; else if (parse_str(buf, "<http_user_name>", http_user_name,sizeof(http_user_name))) continue; else if (parse_str(buf, "<http_user_passwd>", http_user_passwd,sizeof(http_user_passwd))) continue; else if (parse_str(buf, "<no_proxy>", noproxy_hosts, sizeof(noproxy_hosts))) continue; } return ERR_XML_PARSE; }
void GET_CURRENT_VERSION_OP::handle_reply(int http_op_retval) { char buf[256], new_version[256]; if (http_op_retval) { error_num = http_op_retval; return; } gstate.new_version_check_time = gstate.now; FILE* f = boinc_fopen(GET_CURRENT_VERSION_FILENAME, "r"); if (!f) return; while (fgets(buf, 256, f)) { if (match_tag(buf, "<version>")) { if (parse_version(f, new_version)) { msg_printf(0, MSG_USER_ALERT, "A new version of BOINC (%s) is available", new_version ); msg_printf(0, MSG_USER_ALERT, "Visit %s to download it", config.client_download_url.c_str() ); gstate.newer_version = string(new_version); break; } } } fclose(f); }
int PROJECT_INIT::init() { char buf[256]; MIOFILE mf; FILE* p; clear(); p = fopen(PROJECT_INIT_FILENAME, "r"); if (p) { mf.init_file(p); while(mf.fgets(buf, sizeof(buf))) { if (match_tag(buf, "</project_init>")) break; else if (parse_str(buf, "<name>", name, 256)) continue; else if (parse_str(buf, "<team_name>", team_name, 256)) continue; else if (parse_str(buf, "<url>", url, 256)) { canonicalize_master_url(url); continue; } else if (parse_str(buf, "<account_key>", account_key, 256)) { continue; } } fclose(p); msg_printf(0, MSG_INFO, "Found project_init.xml for %s", url); } return 0; }
// CPU benchmarks are run in a separate process, // which communicates its result via a file. // The following functions read and write this file. // int HOST_INFO::parse_cpu_benchmarks(FILE* in) { char buf[256]; char* p = fgets(buf, 256, in); if (!p) return 0; // Fixes compiler warning while (fgets(buf, 256, in)) { if (match_tag(buf, "<cpu_benchmarks>")); else if (match_tag(buf, "</cpu_benchmarks>")) return 0; else if (parse_double(buf, "<p_fpops>", p_fpops)) continue; else if (parse_double(buf, "<p_iops>", p_iops)) continue; else if (parse_double(buf, "<p_membw>", p_membw)) continue; else if (parse_double(buf, "<p_calculated>", p_calculated)) continue; else if (parse_double(buf, "<m_cache>", m_cache)) continue; } return 0; }
static ERL_NIF_TERM unescape_attr(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) { ErlNifBinary input; ERL_NIF_TERM output; struct buf *rbuf; int i; if (argc != 1) { return enif_make_badarg(env); } if (!enif_inspect_binary(env, argv[0], &input)) { return enif_make_badarg(env); } rbuf = init_buf(env, EXML_ATTR_BUF_SIZE); for (i = 0; i < input.size; i++) { if (input.data[i] == '&') { if (match_tag(input, i+1, "amp;", 4)) { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, '&'); i += 4; } else if (match_tag(input, i+1, "apos;", 5)) { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, '\''); i += 5; } else if (match_tag(input, i+1, "lt;", 3)) { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, '<'); i += 3; } else if (match_tag(input, i+1, "gt;", 3)) { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, '>'); i += 3; } else if (match_tag(input, i+1, "quot;", 5)) { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, '"'); i += 5; } else if (match_tag(input, i+1, "#x9;", 4)) { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, '\t'); i += 4; } else if (match_tag(input, i+1, "#xA;", 4)) { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, '\n'); i += 4; } else if (match_tag(input, i+1, "#xD;", 4)) { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, '\r'); i += 4; } else { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, input.data[i]); } } else { buf_add_char(env, EXML_ATTR_BUF_SIZE, rbuf, input.data[i]); } } unsigned char* data = enif_make_new_binary(env, rbuf->len, &output); memcpy((char*)data, rbuf->b, rbuf->len); destroy_buf(env, rbuf); return output; }
int CSkinWizards::Parse(MIOFILE& in) { char buf[256]; while (in.fgets(buf, 256)) { if (match_tag(buf, "</wizards>")) break; else if (match_tag(buf, "<attach_to_project>")) { m_AttachToProjectWizard.Parse(in); continue; } else if (match_tag(buf, "<attach_to_account_manager>")) { m_AttachToAccountManagerWizard.Parse(in); continue; } } InitializeDelayedValidation(); return 0; }
int CLIENT_PLATFORM::parse(FILE* fin) { char buf[256]; strcpy(name, ""); while (fgets(buf, sizeof(buf), fin)) { if (match_tag(buf, "</alt_platform>")) return 0; if (parse_str(buf, "<name>", name, sizeof(name))) continue; } return ERR_XML_PARSE; }
int HOST_INFO::parse(MIOFILE& in, bool benchmarks_only) { char buf[1024]; while (in.fgets(buf, sizeof(buf))) { if (match_tag(buf, "</host_info>")) return 0; else if (parse_double(buf, "<p_fpops>", p_fpops)) { // fix foolishness that could result in negative value here // if (p_fpops < 0) p_fpops = -p_fpops; continue; } else if (parse_double(buf, "<p_iops>", p_iops)) { if (p_iops < 0) p_iops = -p_iops; continue; } else if (parse_double(buf, "<p_membw>", p_membw)) { if (p_membw < 0) p_membw = -p_membw; continue; } else if (parse_double(buf, "<p_calculated>", p_calculated)) continue; if (benchmarks_only) continue; if (parse_int(buf, "<timezone>", timezone)) continue; else if (parse_str(buf, "<domain_name>", domain_name, sizeof(domain_name))) continue; else if (parse_str(buf, "<ip_addr>", ip_addr, sizeof(ip_addr))) continue; else if (parse_str(buf, "<host_cpid>", host_cpid, sizeof(host_cpid))) continue; else if (parse_int(buf, "<p_ncpus>", p_ncpus)) continue; else if (parse_str(buf, "<p_vendor>", p_vendor, sizeof(p_vendor))) continue; else if (parse_str(buf, "<p_model>", p_model, sizeof(p_model))) continue; else if (parse_str(buf, "<p_features>", p_features, sizeof(p_features))) continue; else if (parse_double(buf, "<m_nbytes>", m_nbytes)) continue; else if (parse_double(buf, "<m_cache>", m_cache)) continue; else if (parse_double(buf, "<m_swap>", m_swap)) continue; else if (parse_double(buf, "<d_total>", d_total)) continue; else if (parse_double(buf, "<d_free>", d_free)) continue; else if (parse_str(buf, "<os_name>", os_name, sizeof(os_name))) continue; else if (parse_str(buf, "<os_version>", os_version, sizeof(os_version))) continue; else if (match_tag(buf, "<coprocs>")) { coprocs.parse(in); } } return ERR_XML_PARSE; }
int MSG_FROM_HOST_DESC::parse(FILE* fin) { char buf[256]; msg_text = ""; while (fgets(buf, sizeof(buf), fin)) { if (match_tag(buf, "</msg_from_host>")) return 0; if (parse_str(buf, "<variety>", variety, sizeof(variety))) continue; msg_text += buf; } return ERR_XML_PARSE; }
int HOST::parse_time_stats(FILE* fin) { char buf[256]; while (fgets(buf, sizeof(buf), fin)) { if (match_tag(buf, "</time_stats>")) return 0; if (parse_double(buf, "<on_frac>", on_frac)) continue; if (parse_double(buf, "<connected_frac>", connected_frac)) continue; if (parse_double(buf, "<active_frac>", active_frac)) continue; #if 0 if (match_tag(buf, "<outages>")) continue; if (match_tag(buf, "<outage>")) continue; if (match_tag(buf, "<start>")) continue; if (match_tag(buf, "<end>")) continue; log_messages.printf(MSG_NORMAL, "HOST::parse_time_stats(): unrecognized: %s\n", buf ); #endif } return ERR_XML_PARSE; }
static bool valid_state_file(const char* fname) { char buf[256]; FILE* f = boinc_fopen(fname, "r"); if (!f) return false; if (!fgets(buf, 256, f)) { fclose(f); return false; } if (!match_tag(buf, "<client_state>")) { fclose(f); return false; } while (fgets(buf, 256, f)) { if (match_tag(buf, "</client_state>")) { fclose(f); return true; } } fclose(f); return false; }
int FILE_INFO::parse(FILE* in) { char buf[256]; int retval; memset(this, 0, sizeof(FILE_INFO)); signed_xml = strdup(""); while (fgets(buf, 256, in)) { //log_messages.printf(MSG_DEBUG, buf, "FILE_INFO::parse: "); if (match_tag(buf, "</file_info>")) return 0; if (match_tag(buf, "<xml_signature>")) { retval = dup_element_contents(in, "</xml_signature>", &xml_signature); if (retval) return retval; continue; } retval = strcatdup(signed_xml, buf); if (retval) return retval; if (parse_str(buf, "<name>", name, sizeof(name))) { strcpy(this_filename, name); continue; } if (parse_double(buf, "<max_nbytes>", max_nbytes)) continue; if (match_tag(buf, "<generated_locally/>")) continue; if (match_tag(buf, "<upload_when_present/>")) continue; if (match_tag(buf, "<url>")) continue; if (match_tag(buf, "<gzip_when_done")) continue; log_messages.printf(MSG_NORMAL, "FILE_INFO::parse: unrecognized: %s \n", buf ); } return ERR_XML_PARSE; }
int CSkinManager::Parse(MIOFILE& in, wxString strDesiredLocale) { char buf[256]; wxString strLocaleStartTag; wxString strLocaleEndTag; bool bLocaleFound = false; // Construct the start and end tags for the locale we want. strLocaleStartTag.Printf(wxT("<%s>"), strDesiredLocale.c_str()); strLocaleEndTag.Printf(wxT("</%s>"), strDesiredLocale.c_str()); // TODO: Eliminate the <en> tags: localization is no longer in skin files. // Look for the begining of the desired locale. while (in.fgets(buf, 256)) { if (match_tag(buf, (const char*)strLocaleStartTag.mb_str(wxConvUTF8))) { bLocaleFound = true; break; } } if (!bLocaleFound) return ERR_XML_PARSE; while (in.fgets(buf, 256)) { if (match_tag(buf, (const char*)strLocaleStartTag.mb_str(wxConvUTF8))) break; else if (match_tag(buf, "<simple>")) { m_SimpleSkin.Parse(in); continue; } else if (match_tag(buf, "<advanced>")) { m_AdvancedSkin.Parse(in); continue; } else if (match_tag(buf, "<wizards>")) { m_WizardsSkin.Parse(in); continue; } } InitializeDelayedValidation(); return 0; }
int FILE_INFO::parse(FILE* f) { char buf[256]; memset(this, 0, sizeof(FILE_INFO)); while (fgets(buf, sizeof(buf), f)) { if (match_tag(buf, "</file_info>")) { if (!strlen(name)) return ERR_XML_PARSE; return 0; } if (parse_str(buf, "<name>", name, 256)) continue; } return ERR_XML_PARSE; }
int HOST::parse_net_stats(FILE* fin) { char buf[256]; while (fgets(buf, sizeof(buf), fin)) { if (match_tag(buf, "</net_stats>")) return 0; if (parse_double(buf, "<bwup>", n_bwup)) continue; if (parse_double(buf, "<bwdown>", n_bwdown)) continue; // items reported by 5.10+ clients, not currently used // if (match_tag(buf, "<avg_time_up>")) continue; if (match_tag(buf, "<avg_up>")) continue; if (match_tag(buf, "<avg_time_down>")) continue; if (match_tag(buf, "<avg_down>")) continue; log_messages.printf(MSG_NORMAL, "HOST::parse_net_stats(): unrecognized: %s\n", buf ); } return ERR_XML_PARSE; }
int APP_CONFIG::parse(char* buf) { memset(this, 0, sizeof(APP_CONFIG)); parse_str(buf, "<scidb_name>", scidb_name, sizeof(scidb_name)); parse_int(buf, "<max_wus_ondisk>", max_wus_ondisk); parse_int(buf, "<min_quorum>", min_quorum ); parse_int(buf, "<target_nresults>", target_nresults); parse_int(buf, "<max_error_results>", max_error_results); parse_int(buf, "<max_success_results>", max_success_results); parse_int(buf, "<max_total_results>", max_total_results); if (match_tag(buf, "</config>")) return 0; return ERR_XML_PARSE; }
int IP_RESULT::parse(FILE* f) { char buf[256]; report_deadline = 0; cpu_time_remaining = 0; strcpy(name, ""); while (fgets(buf, sizeof(buf), f)) { if (match_tag(buf, "</ip_result>")) return 0; if (parse_str(buf, "<name>", name, sizeof(name))) continue; if (parse_double(buf, "<report_deadline>", report_deadline)) continue; if (parse_double(buf, "<cpu_time_remaining>", cpu_time_remaining)) continue; } return ERR_XML_PARSE; }
int HOST::parse_disk_usage(FILE* fin) { char buf[256]; while (fgets(buf, sizeof(buf), fin)) { if (match_tag(buf, "</disk_usage>")) return 0; if (parse_double(buf, "<d_boinc_used_total>", d_boinc_used_total)) continue; if (parse_double(buf, "<d_boinc_used_project>", d_boinc_used_project)) continue; log_messages.printf(MSG_NORMAL, "HOST::parse_disk_usage(): unrecognized: %s\n", buf ); } return ERR_XML_PARSE; }
static void parse_game( pr_state_t* parser ) { match_tag( parser, "game" ); pr_node_t* node = (pr_node_t*)malloc( sizeof( pr_node_t ) ); if ( node == NULL ) longjmp( parser->env, PR_OUT_OF_MEMORY ); node->count = 0; parser->node = node; *parser->prev = node; parser->prev = &node->next; parse_map( parser, 0, 0 ); }
int match_tagged_match(struct mail_ctx *mctx, struct expritem *ei) { struct match_tagged_data *data = ei->data; struct mail *m = mctx->mail; char *tag; tag = replacestr(&data->tag, m->tags, m, &m->rml); if (match_tag(m->tags, tag) != NULL) { xfree(tag); return (MATCH_TRUE); } xfree(tag); return (MATCH_FALSE); }
int CSkinWizardATAM::Parse(MIOFILE& in) { char buf[256]; std::string strBuffer; while (in.fgets(buf, 256)) { if (match_tag(buf, "</attach_to_account_manager>")) break; else if (parse_str(buf, "<account_info_message>", strBuffer)) { m_strAccountInfoMessage = wxString(strBuffer.c_str(), wxConvUTF8); continue; } } InitializeDelayedValidation(); return 0; }