本文整理汇总了C++中MIOFILE::fgets方法的典型用法代码示例。如果您正苦于以下问题:C++ MIOFILE::fgets方法的具体用法?C++ MIOFILE::fgets怎么用?C++ MIOFILE::fgets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MIOFILE
的用法示例。
在下文中一共展示了MIOFILE::fgets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
/// Parse XML information about an active task set
int ACTIVE_TASK_SET::parse(MIOFILE& fin) {
ACTIVE_TASK* atp;
char buf[256];
int retval;
while (fin.fgets(buf, 256)) {
if (match_tag(buf, "</active_task_set>")) return 0;
else if (match_tag(buf, "<active_task>")) {
atp = new ACTIVE_TASK;
retval = atp->parse(fin);
if (!retval) {
if (slot_taken(atp->slot)) {
msg_printf(atp->result->project, MSG_INTERNAL_ERROR,
"slot %d in use; discarding result %s",
atp->slot, atp->result->name
);
retval = ERR_XML_PARSE;
}
}
if (!retval) active_tasks.push_back(atp);
else delete atp;
} else {
handle_unparsed_xml_warning("ACTIVE_TASK_SET::parse", buf);
}
}
return ERR_XML_PARSE;
}
示例2: parse
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;
}
示例3: skip_unrecognized
// we got an unrecognized line.
// If it has two <'s (e.g. <foo>xx</foo>) return 0.
// If it's of the form <foo/> return 0.
// If it's of the form <foo> then scan for </foo> and return 0.
// Otherwise return ERR_XML_PARSE
//
int skip_unrecognized(char* buf, MIOFILE& fin) {
char* p, *q, buf2[256];
std::string close_tag;
p = strchr(buf, '<');
if (!p) {
return ERR_XML_PARSE;
}
if (strchr(p+1, '<')) {
return 0;
}
q = strchr(p+1, '>');
if (!q) {
return ERR_XML_PARSE;
}
if (q[-1] == '/') return 0;
*q = 0;
close_tag = string("</") + string(p+1) + string(">");
while (fin.fgets(buf2, 256)) {
if (strstr(buf2, close_tag.c_str())) {
return 0;
}
}
return ERR_XML_PARSE;
}
示例4: init
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;
}
示例5: skip_unrecognized
// we got an unrecognized line.
// If it has two <'s (e.g. <foo>xx</foo>) return 0.
// If it's of the form <foo/> return 0.
// If it's of the form <foo> then scan for </foo> and return 0.
// Otherwise return ERR_XML_PARSE
//
int skip_unrecognized(wxChar* buf, MIOFILE& fin) {
wxChar* p, *q, buf2[256];
std::wstring close_tag;
p = _tcschr(buf, wxT('<'));
if (!p) {
return -112;
}
if (_tcschr(p+1, wxT('<'))) {
return 0;
}
q = _tcschr(p+1, wxT('>'));
if (!q) {
return -112;
}
if (q[-1] == '/') return 0;
*q = 0;
close_tag = std::wstring(wxT("</")) + std::wstring(p+1) + std::wstring(wxT(">"));
while (fin.fgets(buf2, 256)) {
if (_tcsstr(buf2, close_tag.c_str())) {
return 0;
}
}
return -112;
}
示例6: Parse
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;
}
示例7: copy_element_contents
int copy_element_contents(MIOFILE& in, const char* end_tag, string& str) {
char buf[256];
str.clear();
while (in.fgets(buf, 256)) {
if (strstr(buf, end_tag)) {
return 0;
}
str += buf;
}
fprintf(stderr, "copy_element_contents(): no end tag\n");
return ERR_XML_PARSE;
}
示例8: 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;
}
示例9: parse
int MOZILLA_PROFILE::parse(MIOFILE& in) {
char buf[512];
std::string sn;
std::string sv;
while (in.fgets(buf, 512)) {
if (starts_with(buf, "\n")) return 0;
if (starts_with(buf, "\r\n")) return 0;
if (!parse_name_value_pair(buf, sn, sv)) continue;
if ("Name" == sn) name = sv;
if ("Path" == sn) path = sv;
if (("IsRelative" == sn) && ("1" == sv)) is_relative = true;
if (("Default" == sn) && ("1" == sv)) is_default = true;
}
return ERR_FREAD;
}
示例10: parse
int NET_STATS::parse(MIOFILE& in) {
char buf[256];
up.clear();
down.clear();
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</net_stats>")) return 0;
if (parse_double(buf, "<bwup>", up.max_rate)) continue;
if (parse_double(buf, "<avg_up>", up.avg_rate)) continue;
if (parse_double(buf, "<avg_time_up>", up.avg_time)) continue;
if (parse_double(buf, "<bwdown>", down.max_rate)) continue;
if (parse_double(buf, "<avg_down>", down.avg_rate)) continue;
if (parse_double(buf, "<avg_time_down>", down.avg_time)) continue;
handle_unparsed_xml_warning("NET_STATS::parse", buf);
}
return ERR_XML_PARSE;
}
示例11: 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;
}
示例12: parse
int NET_STATS::parse(MIOFILE& in) {
char buf[256];
memset(this, 0, sizeof(NET_STATS));
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</net_stats>")) return 0;
if (parse_double(buf, "<bwup>", up.max_rate)) continue;
if (parse_double(buf, "<avg_up>", up.avg_rate)) continue;
if (parse_double(buf, "<avg_time_up>", up.avg_time)) continue;
if (parse_double(buf, "<bwdown>", down.max_rate)) continue;
if (parse_double(buf, "<avg_down>", down.avg_rate)) continue;
if (parse_double(buf, "<avg_time_down>", down.avg_time)) continue;
if (log_flags.unparsed_xml) {
msg_printf(NULL, MSG_INFO,
"[unparsed_xml] Unrecognized network statistics line: %s", buf
);
}
}
return ERR_XML_PARSE;
}
示例13: GetDefaultDisplayPeriods
void CScreensaver::GetDefaultDisplayPeriods(struct ss_periods &periods)
{
char* default_data_dir_path = NULL;
char buf[1024];
FILE* f;
MIOFILE mf;
periods.GFXDefaultPeriod = GFX_DEFAULT_PERIOD;
periods.GFXSciencePeriod = GFX_SCIENCE_PERIOD;
periods.GFXChangePeriod = GFX_CHANGE_PERIOD;
periods.Show_default_ss_first = false;
#ifdef __APPLE__
default_data_dir_path = "/Library/Application Support/BOINC Data";
#else
default_data_dir_path = (char*)m_strBOINCDataDirectory.c_str();
#endif
strlcpy(buf, default_data_dir_path, sizeof(buf));
strlcat(buf, PATH_SEPARATOR, sizeof(buf));
strlcat(buf, THE_SS_CONFIG_FILE, sizeof(buf));
f = boinc_fopen(buf, "r");
if (!f) return;
mf.init_file(f);
XML_PARSER xp(&mf);
while (mf.fgets(buf, sizeof(buf))) {
if (parse_bool(buf, "default_ss_first", periods.Show_default_ss_first)) continue;
if (parse_double(buf, "<default_gfx_duration>", periods.GFXDefaultPeriod)) continue;
if (parse_double(buf, "<science_gfx_duration>", periods.GFXSciencePeriod)) continue;
if (parse_double(buf, "<science_gfx_change_interval>", periods.GFXChangePeriod)) continue;
}
fclose(f);
BOINCTRACE(_T("CScreensaver::GetDefaultDisplayPeriods: m_bShow_default_ss_first=%d, m_fGFXDefaultPeriod=%f, m_fGFXSciencePeriod=%f, m_fGFXChangePeriod=%f\n"),
(int)periods.Show_default_ss_first, periods.GFXDefaultPeriod, periods.GFXSciencePeriod, periods.GFXChangePeriod);
}
示例14: parse
// Parse XML information about a persistent file transfer
//
int PERS_FILE_XFER::parse(MIOFILE& fin) {
char buf[256];
while (fin.fgets(buf, 256)) {
if (match_tag(buf, "</persistent_file_xfer>")) return 0;
else if (parse_int(buf, "<num_retries>", nretry)) continue;
else if (parse_double(buf, "<first_request_time>", first_request_time)) {
continue;
}
else if (parse_double(buf, "<next_request_time>", next_request_time)) {
continue;
}
else if (parse_double(buf, "<time_so_far>", time_so_far)) continue;
else if (parse_double(buf, "<last_bytes_xferred>", last_bytes_xferred)) continue;
else {
if (log_flags.unparsed_xml) {
msg_printf(NULL, MSG_INFO,
"[unparsed_xml] Unparsed line in file transfer info: %s", buf
);
}
}
}
return ERR_XML_PARSE;
}
示例15: Parse
int CSkinImage::Parse(MIOFILE& in) {
char buf[256];
std::string strBuffer;
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</image>")) break;
else if (parse_str(buf, "<imagesrc>", strBuffer)) {
if (strBuffer.length()) {
m_strDesiredBitmap = wxString(
wxGetApp().GetSkinManager()->ConstructSkinPath() +
wxString(strBuffer.c_str(), wxConvUTF8)
);
}
continue;
} else if (parse_str(buf, "<background_color>", strBuffer)) {
if (strBuffer.length()) {
m_strDesiredBackgroundColor = wxString(strBuffer.c_str(), wxConvUTF8);
}
continue;
} else if (match_tag(buf, "<anchor_horizontal_left>")) {
m_iAnchorHorizontal = BKGD_ANCHOR_HORIZ_LEFT;
} else if (match_tag(buf, "<anchor_horizontal_center>")) {
m_iAnchorHorizontal = BKGD_ANCHOR_HORIZ_CENTER;
} else if (match_tag(buf, "<anchor_horizontal_right>")) {
m_iAnchorHorizontal = BKGD_ANCHOR_HORIZ_RIGHT;
} else if (match_tag(buf, "<anchor_vertical_top>")) {
m_iAnchorVertical = BKGD_ANCHOR_VERT_TOP;;
} else if (match_tag(buf, "<anchor_vertical_center>")) {
m_iAnchorVertical = BKGD_ANCHOR_VERT_CENTER;;
} else if (match_tag(buf, "<anchor_vertical_bottom>")) {
m_iAnchorVertical = BKGD_ANCHOR_VERT_BOTTOM;;
}
}
return BOINC_SUCCESS;
}