osgToy::OctoStrip::OctoStrip() { osg::Vec3Array* vAry = dynamic_cast<osg::Vec3Array*>( getVertexArray() ); osg::Vec3Array* nAry = dynamic_cast<osg::Vec3Array*>( getNormalArray() ); setNormalBinding( osg::Geometry::BIND_PER_VERTEX ); osg::Vec4Array* cAry = dynamic_cast<osg::Vec4Array*>( getColorArray() ); setColorBinding( osg::Geometry::BIND_PER_VERTEX ); osg::Vec3 xp( 1, 0, 0); osg::Vec4 red(1,0,0,1); osg::Vec3 xn(-1, 0, 0); osg::Vec4 cyan(0,1,1,1); osg::Vec3 yp( 0, 1, 0); osg::Vec4 green(0,1,0,1); osg::Vec3 yn( 0,-1, 0); osg::Vec4 magenta(1,0,1,1); osg::Vec3 zp( 0, 0, 1); osg::Vec4 blue(0,0,1,1); osg::Vec3 zn( 0, 0,-1); osg::Vec4 yellow(1,1,0,1); vAry->push_back(zp); nAry->push_back(zp); cAry->push_back(blue); vAry->push_back(yp); nAry->push_back(yp); cAry->push_back(green); vAry->push_back(xn); nAry->push_back(xn); cAry->push_back(cyan); vAry->push_back(zn); nAry->push_back(zn); cAry->push_back(yellow); vAry->push_back(yn); nAry->push_back(yn); cAry->push_back(magenta); vAry->push_back(xp); nAry->push_back(xp); cAry->push_back(red); vAry->push_back(zp); nAry->push_back(zp); cAry->push_back(blue); vAry->push_back(yp); nAry->push_back(yp); cAry->push_back(green); addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLE_STRIP, 0, vAry->size() ) ); }
void DAILY_XFER_HISTORY::init() { FILE* f = fopen(DAILY_XFER_HISTORY_FILENAME, "r"); if (!f) return; MIOFILE mf; XML_PARSER xp(&mf); mf.init_file(f); bool is_tag; char tag[256]; int d = current_day(); if (!xp.parse_start("daily_xfers")) { fclose(f); return; } while (!xp.get(tag, sizeof(tag), is_tag)) { if (!is_tag) continue; if (!strcmp(tag, "dx")) { DAILY_XFER dx; int retval = dx.parse(xp); if (!retval && d - dx.when < 365) { // discard records after a year daily_xfers.push_back(dx); } } } fclose(f); }
int APP_CONFIGS::parse_file(FILE* f, PROJECT* p) { MIOFILE mf; XML_PARSER xp(&mf); mf.init_file(f); int retval = parse(xp, p); return retval; }
inline void KillRewarder::_RewardXP(Player* player, float rate) { uint32 xp(_xp); if (_group) { // 4.2.1. If player is in group, adjust XP: // * set to 0 if player's level is more than maximum level of not gray member; // * cut XP in half if _isFullXP is false. if (_maxNotGrayMember && player->IsAlive() && _maxNotGrayMember->getLevel() >= player->getLevel()) xp = _isFullXP ? uint32(xp * rate) : // Reward FULL XP if all group members are not gray. uint32(xp * rate / 2) + 1; // Reward only HALF of XP if some of group members are gray. else xp = 0; } if (xp) { // 4.2.2. Apply auras modifying rewarded XP (SPELL_AURA_MOD_XP_PCT). for (auto const& aura : player->GetAuraEffectsByType(SPELL_AURA_MOD_XP_PCT)) AddPct(xp, aura->GetAmount()); // 4.2.3. Give XP to player. player->GiveXP(xp, _victim, _groupRate); if (Pet* pet = player->GetPet()) // 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case). pet->GivePetXP(_group ? xp / 2 : xp); } }
bool ApService::InitApService(std::string ApListenIp, int ApListenPort, int threadPoolNum) { bool status = true; _ApListenIp = ApListenIp; _ApListenPort = ApListenPort; _threadPoolNum = threadPoolNum; SharedPointer<IProcessor> xp( new apapiProcessor( SharedPointer<apapi>( new ApService))); ServiceManager sm; sm.add_service(xp); ThreadPool tp; tp.init(_threadPoolNum); Server* server = new Server(&sm, &tp, _ApListenPort); if (0 != server->serve()) { status = false; } return status; }
void CDlgDiagnosticLogFlags::OnOK(wxCommandEvent& event) { SET_LOCALE sl; char buf[64000]; MIOFILE mf; bool val; unsigned int i; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); mf.init_buf_write(buf, sizeof(buf)); for (i=0; i<m_checkbox_list.size(); ++i) { wxCheckBox* ckbox = m_checkbox_list[i]; val = ckbox->GetValue(); mf.printf(" <%s>%d</%s>\n", (const char*)ckbox->GetLabel().ToAscii(), (int)val, (const char*)ckbox->GetLabel().ToAscii()); } mf.printf(" </log_flags>\n"); XML_PARSER xp(&mf); mf.init_buf_read(buf); log_flags.parse(xp); int retval = pDoc->rpc.set_cc_config(m_cc_config, log_flags); if (!retval) { pDoc->rpc.read_cc_config(); } event.Skip(); }
inline void KillRewarder::_RewardXP(Player* player, float rate) { uint32 xp(_xp); if (_group) { // 4.2.1. If player is in group, adjust XP: // * set to 0 if player's level is more than maximum level of not gray member; // * cut XP in half if _isFullXP is false. if (_maxNotGrayMember && player->IsAlive() && _maxNotGrayMember->getLevel() >= player->getLevel()) xp = _isFullXP ? uint32(xp * rate) : // Reward FULL XP if all group members are not gray. uint32(xp * rate / 2) + 1; // Reward only HALF of XP if some of group members are gray. else xp = 0; } if (xp) { // 4.2.2. Apply auras modifying rewarded XP (SPELL_AURA_MOD_XP_PCT and SPELL_AURA_MOD_XP_FROM_CREATURE_TYPE). xp *= player->GetTotalAuraMultiplier(SPELL_AURA_MOD_XP_PCT); xp *= player->GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_XP_FROM_CREATURE_TYPE, int32(_victim->GetCreatureType())); // 4.2.3. Give XP to player. player->GiveXP(xp, _victim, _groupRate); if (Pet* pet = player->GetPet()) // 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case). pet->GivePetXP(_group ? xp / 2 : xp); } }
int handle_trickle(MSG_FROM_HOST& msg) { double runtime = 0; MIOFILE mf; mf.init_buf_read(msg.xml); XML_PARSER xp(&mf); while (!xp.get_tag()) { if (xp.parse_double("runtime", runtime)) break; log_messages.printf(MSG_NORMAL, "unexpected tag: %s\n", xp.parsed_tag); } if (runtime <= 0) { log_messages.printf(MSG_NORMAL, "unexpected nonpositive runtime: %f\n", runtime ); return ERR_XML_PARSE; } DB_HOST host; int retval = host.lookup_id(msg.hostid); if (retval) return retval; HOST old_host = host; double flops_sec = host.p_fpops; // sanity checks - customize as needed // if (runtime > max_runtime) { log_messages.printf(MSG_NORMAL, "Reported runtime exceeds bound: %f>%f\n", runtime, max_runtime ); runtime = max_runtime; } if (flops_sec < 0) { log_messages.printf(MSG_NORMAL, "host CPU speed %f < 0. Using %f instead\n", flops_sec, flops_50_percentile ); flops_sec = flops_50_percentile; } if (flops_sec > flops_95_percentile) { log_messages.printf(MSG_NORMAL, "host CPU speed %f exceeds %f. Using %f instead\n", flops_sec, flops_95_percentile, flops_95_percentile ); flops_sec = flops_95_percentile; } double credit = cpu_time_to_credit(runtime, flops_sec); grant_credit(host, dtime()-86400, credit); log_messages.printf(MSG_DEBUG, "granting %f credit to host %lu\n", credit, host.id ); // update the host's credit fields // retval = host.update_diff_validator(old_host); return 0; }
int ACCT_MGR_INFO::init() { MIOFILE mf; FILE* p; int retval; clear(); p = fopen(ACCT_MGR_URL_FILENAME, "r"); if (!p) { // if not using acct mgr, make sure projects not flagged, // otherwise won't be able to detach them. // for (unsigned int i=0; i<gstate.projects.size(); i++) { gstate.projects[i]->attached_via_acct_mgr = false; } return 0; } mf.init_file(p); XML_PARSER xp(&mf); if (!xp.parse_start("acct_mgr_login")) { // } while (!xp.get_tag()) { if (!xp.is_tag) { printf("unexpected text: %s\n", xp.parsed_tag); continue; } if (xp.match_tag("/acct_mgr")) break; else if (xp.parse_str("name", project_name, 256)) continue; else if (xp.parse_str("url", master_url, 256)) continue; else if (xp.parse_bool("send_gui_rpc_info", send_gui_rpc_info)) continue; else if (xp.match_tag("signing_key")) { retval = xp.element_contents("</signing_key>", signing_key, sizeof(signing_key)); if (retval) { msg_printf(NULL, MSG_INFO, "error parsing <signing_key> in acct_mgr_url.xml" ); } continue; } else if (xp.parse_bool("cookie_required", cookie_required)) continue; else if (xp.parse_str("cookie_failure_url", cookie_failure_url, 256)) continue; if (log_flags.unparsed_xml) { msg_printf(NULL, MSG_INFO, "[unparsed_xml] ACCT_MGR_INFO::init: unrecognized %s", xp.parsed_tag ); } xp.skip_unexpected(log_flags.unparsed_xml, "ACCT_MGR_INFO::init"); } fclose(p); p = fopen(ACCT_MGR_LOGIN_FILENAME, "r"); if (p) { parse_login_file(p); fclose(p); } return 0; }
vector<P> convexhull(vector<P> v) { // v.SZ >= 2 sort(v.begin(), v.end()); vector<Vect> u; for (int i = 1; i < (int)v.SZ; i++) u.PB(Vect(v[i], v[0])); sort(u.begin(), u.end()); vector<P> w(v.SZ, v[0]); int j = 1; w[1] = u[0].p; for (int i = 1; i < (int)u.SZ; i++) { T t = xp(w[j-1], w[j], u[i].p); for (j--; t < 0 && j > 0; j--) t = xp(w[j-1], w[j], u[i].p); j += t > 0 ? 2 : 1; w[j] = u[i].p; } w.resize(j+1); return w; }
int CERT_SIGS::parse_buffer(char* buf) { MIOFILE mf; int retval; mf.init_buf_read(buf); XML_PARSER xp(&mf); retval = this->parse(xp); return retval; }
dvar_vector posfun(const dvar_vector& x, const double& eps, dvariable& pen) { int i; dvar_vector xp(x.indexmin(),x.indexmax()); for(i=x.indexmin();i<=x.indexmax();i++) { if(x(i)>=eps) { xp(i) = x(i); } else { pen += 0.01*square(x(i)-eps); xp(i) = eps/(2.-x(i)/eps); } } return(xp); }
static void xp(XmlNode *x, int level, int max) { int i; char text[] = "text"; char *name = text; if(level > max)return; if(!x)return; if(x->name)name = x->name; for(i=0; i<level; i++)printf(" "); printf("%s:", name); if(x->name) for(i=0; i<x->nattrib; i++) printf("%s=\"%s\",", x->attrib[i*2], x->attrib[i*2+1]); else printf("%s", x->attrib[0]); printf("\n"); if(x->child)xp(x->child, level+1, max); if(x->next)xp(x->next, level, max); }
int ACCT_MGR_INFO::parse_login_file(FILE* p) { MIOFILE mf; int retval; mf.init_file(p); XML_PARSER xp(&mf); if (!xp.parse_start("acct_mgr_login")) { msg_printf(NULL, MSG_INTERNAL_ERROR, "missing start tag in account manager login file" ); } while (!xp.get_tag()) { if (!xp.is_tag) { printf("unexpected text: %s\n", xp.parsed_tag); continue; } if (xp.match_tag("/acct_mgr_login")) break; else if (xp.parse_str("login", login_name, 256)) continue; else if (xp.parse_str("password_hash", password_hash, 256)) continue; else if (xp.parse_str("previous_host_cpid", previous_host_cpid, sizeof(previous_host_cpid))) continue; else if (xp.parse_double("next_rpc_time", next_rpc_time)) continue; else if (xp.match_tag("opaque")) { retval = xp.element_contents("</opaque>", opaque, sizeof(opaque)); if (retval) { msg_printf(NULL, MSG_INFO, "error parsing <opaque> in acct_mgr_login.xml" ); } continue; } else if (xp.match_tag("sched_req_opaque")) { char buf[65536]; retval = xp.element_contents( "</sched_req_opaque>", buf, sizeof(buf) ); if (retval) { msg_printf(NULL, MSG_INFO, "error parsing <sched_req_opaque> in acct_mgr_login.xml" ); } sched_req_opaque = string(buf); continue; } else if (xp.parse_bool("no_project_notices", no_project_notices)) continue; if (log_flags.unparsed_xml) { msg_printf(NULL, MSG_INFO, "[unparsed_xml] unrecognized %s in acct_mgr_login.xml", xp.parsed_tag ); } xp.skip_unexpected( log_flags.unparsed_xml, "ACCT_MGR_INFO::parse_login_file" ); } return 0; }
// calculate distance line-point double distance2(double x,double y,double z, const double *p) { // distance line point is D= | (xp-x0) cross ux | // where ux is direction of line and x0 is a point in the line (like t = 0) ROOT::Math::XYZVector xp(x,y,z); ROOT::Math::XYZVector x0(p[0], p[2], 0. ); ROOT::Math::XYZVector x1(p[0] + p[1], p[2] + p[3], 1. ); ROOT::Math::XYZVector u = (x1-x0).Unit(); double d2 = ((xp-x0).Cross(u)) .Mag2(); return d2; }
int main(int, char**) { SCHEDULER_REQUEST sreq; FILE* f = fopen("req", "r"); MIOFILE mf; XML_PARSER xp(&mf); mf.init_file(f); for (int i=0; i<10; i++) { sreq.parse(xp); fseek(f, 0, SEEK_SET); } }
data__ operator()(xit__ x, yit__ yb, yit__ ye) const { xit__ xp(x); yit__ y(yb), yp(yb); data__ rtnval(0); for (++x, ++y; y!=ye; ++x, ++xp, ++y, ++yp) rtnval+=((*x)-(*xp))*((*y)+(*yp))/2; return rtnval; }
/// Answer an authorization request sent by the server. /// The answer is the response to the nonce sent as challenge by the server. /// It is the md5sum from the concatenation of the nonce and the /// GUI-RPC password. /// /// \param[in] passwd The GUI-RPC password. /// \return Zero if the authorization was acknowledged by the server, /// nonzero if the server rejected the request or if any other error /// occurred. int RPC_CLIENT::authorize(const char* passwd) { RPC rpc(this); int retval = rpc.do_rpc("<auth1/>\n"); if (retval) { return retval; } XML_PARSER xp(&rpc.fin); char nonce[256]; bool found = false; char chr_buf[256]; bool is_tag; while (!xp.get(chr_buf, sizeof(chr_buf), is_tag)) { if (!is_tag) { continue; } if (xp.parse_str(chr_buf, "nonce", nonce, sizeof(nonce))) { found = true; break; } } if (!found) { //fprintf(stderr, "Nonce not found\n"); return ERR_AUTHENTICATOR; } free(rpc.mbuf); std::ostringstream input; input << nonce << passwd; std::string nonce_hash = md5_string(input.str()); std::ostringstream buf; buf << "<auth2>\n<nonce_hash>" << nonce_hash << "</nonce_hash>\n</auth2>\n"; retval = rpc.do_rpc(buf.str().c_str()); if (retval) { return retval; } while (!xp.get(chr_buf, sizeof(chr_buf), is_tag)) { if (!is_tag) { continue; } bool authorized; if (xp.parse_bool(chr_buf, "authorized", authorized)) { if (authorized) { return 0; } } } return ERR_AUTHENTICATOR; }
void cpp_wrap_test_biotsegment(const int& NumTests) { Eigen::Vector3d xp(0.0,0.0,-1.0); Eigen::Vector3d x1(-0.5,0.0,0.0); Eigen::Vector3d x2(0.5,0.0,0.0); double gam = 1.0; Eigen::Vector3d Result(0.0,0.0,0.0); //call function for (int i = 0; i < NumTests; i++) { Result = BiotSegment(xp,x1,x2,gam); } return; }
// implementation: approximate gradient (if no analytic gradient provided) void eval_grad(const tvector& x, tvector& g) const { // accuracy epsilon as defined in: // see "Numerical optimization", Nocedal & Wright, 2nd edition, p.197 const tscalar dx = std::cbrt(tscalar(10) * std::numeric_limits<tscalar>::epsilon()); const tsize n = size(); tvector xp = x, xn = x; g.resize(n); for (tsize i = 0; i < n; i ++) { if (i > 0) { xp(i - 1) -= dx; xn(i - 1) += dx; } xp(i) += dx; xn(i) -= dx; g(i) = (m_op_fval(xp) - m_op_fval(xn)) / (xp(i) - xn(i)); } }
void move2d_node_t::do_create_params() { std::auto_ptr<transform2_param_t> xp( new transform2_param_t( "xform", "xf")); add_param( xp); create_default_filter_param(); std::auto_ptr<button_param_t> b( new button_param_t( "Apply Track...")); b->set_id( "apply_track"); add_param( b); std::auto_ptr<separator_param_t> sep( new separator_param_t()); add_param( sep); create_motion_blur_param(); }
int ACCT_MGR_INFO::init() { char tag[1024]; bool is_tag; MIOFILE mf; FILE* p; int retval; clear(); p = fopen(ACCT_MGR_URL_FILENAME, "r"); if (!p) return 0; mf.init_file(p); XML_PARSER xp(&mf); if (!xp.parse_start("acct_mgr_login")) { // } while (!xp.get(tag, sizeof(tag), is_tag)) { if (!is_tag) { printf("unexpected text: %s\n", tag); continue; } if (!strcmp(tag, "/acct_mgr")) break; else if (xp.parse_str(tag, "name", acct_mgr_name, 256)) continue; else if (xp.parse_str(tag, "url", acct_mgr_url, 256)) continue; else if (xp.parse_bool(tag, "send_gui_rpc_info", send_gui_rpc_info)) continue; else if (!strcmp(tag, "signing_key")) { retval = xp.element_contents("</signing_key>", signing_key, sizeof(signing_key)); continue; } else if (xp.parse_bool(tag, "cookie_required", cookie_required)) continue; else if (xp.parse_str(tag, "cookie_failure_url", cookie_failure_url, 256)) continue; if (log_flags.unparsed_xml) { msg_printf(NULL, MSG_INFO, "[unparsed_xml] ACCT_MGR_INFO::init: unrecognized %s", tag ); } xp.skip_unexpected(tag, log_flags.unparsed_xml, "ACCT_MGR_INFO::init"); } fclose(p); p = fopen(ACCT_MGR_LOGIN_FILENAME, "r"); if (p) { parse_login_file(p); fclose(p); } return 0; }
double distance2(double px,double py,double pz, double *p) { TVector3 xp(px,py,pz); TVector3 x0(p[0], p[1], p[2]); TVector3 u (TMath::Sin(p[3])*TMath::Cos(p[4]), TMath::Sin(p[3])*TMath::Sin(p[4]), TMath::Cos(p[3])); double coeff = u*(xp-x0); TVector3 n = xp - x0 - coeff * u; double dx = n.x(); double dy = n.y(); double dz = n.z(); double d2_x = TMath::Power(dx/weight[0], 2); double d2_y = TMath::Power(dy/weight[1], 2); double d2_z = TMath::Power(dz/weight[2], 2); double d2 = d2_x + d2_y + d2_z; return d2; }
void DevFindDialog::process() { int i; QTextCursor cur(edit->document()); if ( ww ) { QRegExp xp(QString("\\b")+f+"\\b"); xp.setCaseSensitivity(cs); if ( bw ) i = s.lastIndexOf(xp, pos); else i = s.indexOf(xp, pos); } else { if ( bw ) i = s.lastIndexOf(f, pos, cs); else i = s.indexOf(f, pos, cs); } if ( i==-1 ) return (void)QMessageBox::warning( this, "Search results", "Unable to find : " + f ); //now jump to start of word and select it if ( bw ) cur.setPosition(absPos-s.count()+i, QTextCursor::MoveAnchor); else cur.setPosition(absPos+i, QTextCursor::MoveAnchor); cur.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, f.count()); edit->setTextCursor(cur); //update document cursor color(cur); //update current line highlighting if ( bw ) pos = i - s.count() - f.count(); else pos = i + f.count(); }
void handle_request(FILE* fin, FILE* fout, char* code_sign_key) { SCHEDULER_REQUEST sreq; SCHEDULER_REPLY sreply; char buf[1024]; g_request = &sreq; g_reply = &sreply; g_wreq = &sreply.wreq; sreply.nucleus_only = true; log_messages.set_indent_level(1); MIOFILE mf; XML_PARSER xp(&mf); mf.init_file(fin); const char* p = sreq.parse(xp); double start_time = dtime(); if (!p) { process_request(code_sign_key); if ((config.locality_scheduling || config.locality_scheduler_fraction) && !sreply.nucleus_only) { send_file_deletes(); } } else { sprintf(buf, "Error in request message: %s", p); log_incomplete_request(); sreply.insert_message(buf, "low"); } if (config.debug_user_messages) { log_user_messages(); } sreply.write(fout, sreq); log_messages.printf(MSG_NORMAL, "Scheduler ran %.3f seconds\n", dtime()-start_time ); if (strlen(config.sched_lockfile_dir)) { unlock_sched(); } }
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 (!xp.get_tag()) { if (xp.parse_bool("default_ss_first", periods.Show_default_ss_first)) continue; if (xp.parse_double("default_gfx_duration", periods.GFXDefaultPeriod)) continue; if (xp.parse_double("science_gfx_duration", periods.GFXSciencePeriod)) continue; if (xp.parse_double("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 ); }
int CERT_SIGS::parse_buffer_embed(char* buf) { MIOFILE mf; char tag[4096]; int is_tag; int s_found = false; mf.init_buf_read(buf); XML_PARSER xp(&mf); while (!xp.get(tag, sizeof(tag), (bool&)is_tag)) { if (!strcmp(tag, "signatures")) { s_found = true; break; } } if (s_found) return this->parse(xp); else return false; }
// Parse global prefs file // int GLOBAL_PREFS::parse_file( const char* filename, const char* host_venue, bool& found_venue ) { FILE* f; GLOBAL_PREFS_MASK mask; int retval; #ifndef _USING_FCGI_ f = fopen(filename, "r"); #else f = FCGI::fopen(filename, "r"); #endif if (!f) return ERR_FOPEN; MIOFILE mf; mf.init_file(f); XML_PARSER xp(&mf); retval = parse(xp, host_venue, found_venue, mask); fclose(f); return retval; }
int CERT_SIGS::parse_file(const char* filename) { int retval; #ifndef _USING_FCGI_ FILE *f = fopen(filename, "r"); #else FCGI_FILE *f = FCGI::fopen(filename, "r"); #endif if (!f) return ERR_FOPEN; MIOFILE mf; mf.init_file(f); XML_PARSER xp(&mf); if (!xp.parse_start("signatures")) { return ERR_XML_PARSE; } retval = this->parse(xp); fclose(f); return retval; }
int ACCT_MGR_INFO::parse_login_file(FILE* p) { MIOFILE mf; int retval; mf.init_file(p); XML_PARSER xp(&mf); if (!xp.parse_start("acct_mgr_login")) { // } while (!xp.get_tag()) { if (!xp.is_tag) { printf("unexpected text: %s\n", xp.parsed_tag); continue; } if (xp.match_tag("/acct_mgr_login")) break; else if (xp.parse_str("login", login_name, 256)) continue; else if (xp.parse_str("password_hash", password_hash, 256)) continue; else if (xp.parse_str("previous_host_cpid", previous_host_cpid, sizeof(previous_host_cpid))) continue; else if (xp.parse_double("next_rpc_time", next_rpc_time)) continue; else if (xp.match_tag("opaque")) { retval = xp.element_contents("</opaque>", opaque, sizeof(opaque)); if (retval) { msg_printf(NULL, MSG_INFO, "error parsing <opaque> in acct_mgr_login.xml" ); } continue; } if (log_flags.unparsed_xml) { msg_printf(NULL, MSG_INFO, "[unparsed_xml] unrecognized %s in acct_mgr_login.xml", xp.parsed_tag ); } xp.skip_unexpected( log_flags.unparsed_xml, "ACCT_MGR_INFO::parse_login_file" ); } return 0; }