Пример #1
0
bool GeneralGamlConfig::ReadPossibleModelPartition(ConfigReader &cr){
	string origSection = cr.GetCurrentSection();
	bool foundAnyModels = false;
	for(int modelNum = 0; ;modelNum++){
		char modName[10];
		sprintf(modName, "model%d", modelNum);
		int found = cr.SetSection(modName);
		//models need to appear consecuatively, but can start at 0 (old) or 1 (new)
		if(modelNum == 0 && found < 0){
			continue;
			}
		else if(found < 0){
			cr.SetSection(origSection.c_str());
			return foundAnyModels;
			}
		else{
			foundAnyModels = true;
			ConfigModelSettings configModSet;
			cr.GetStringOption("ratehetmodel", configModSet.rateHetModel, true);
			cr.GetUnsignedOption("numratecats", configModSet.numRateCats, true);	
			cr.GetStringOption("statefrequencies", configModSet.stateFrequencies, true);
			cr.GetStringOption("ratematrix", configModSet.rateMatrix, true);
			cr.GetStringOption("invariantsites", configModSet.proportionInvariant, true);
			cr.GetStringOption("datatype", configModSet.datatype, true);
			cr.GetStringOption("geneticcode", configModSet.geneticCode, true);
			configModelSets.push_back(configModSet);
			}
		}
	//we shouldn't be getting to here
	return false;
	}
Пример #2
0
    CmdResult Handle (const std::vector<std::string> &parameters, User *user)
    {
        ConfigReader *Conf = new ConfigReader(ServerInstance);

        for (int index = 0; index < Conf->Enumerate("vhost"); index++)
        {
            std::string mask = Conf->ReadValue("vhost","host",index);
            std::string username = Conf->ReadValue("vhost","user",index);
            std::string pass = Conf->ReadValue("vhost","pass",index);
            std::string hash = Conf->ReadValue("vhost","hash",index);

            if ((!strcmp(parameters[0].c_str(),username.c_str())) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str()))
            {
                if (!mask.empty())
                {
                    user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
                    user->ChangeDisplayedHost(mask.c_str());
                    delete Conf;
                    return CMD_LOCALONLY;
                }
            }
        }

        user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
        delete Conf;
        return CMD_FAILURE;
    }
Пример #3
0
	ModuleRandQuote(InspIRCd* Me)
		: Module(Me)
	{
		
		conf = new ConfigReader(ServerInstance);
		// Sort the Randomizer thingie..
		srand(time(NULL));

		q_file = conf->ReadValue("randquote","file",0);
		prefix = conf->ReadValue("randquote","prefix",0);
		suffix = conf->ReadValue("randquote","suffix",0);

		mycommand = NULL;

		if (q_file.empty())
		{
			RandquoteException e("m_randquote: Quotefile not specified - Please check your config.");
			throw(e);
		}

		quotes = new FileReader(ServerInstance, q_file);
		if(!quotes->Exists())
		{
			RandquoteException e("m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
			throw(e);
		}
		else
		{
			/* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
			mycommand = new cmd_randquote(ServerInstance);
			ServerInstance->AddCommand(mycommand);
		}
	}
Пример #4
0
		virtual void ReadConfig()
		{
			ConfigReader *MyConf = new ConfigReader(ServerInstance);

			helpop_map.clear();

			for (int i = 0; i < MyConf->Enumerate("helpop"); i++)
			{
				irc::string key = assign(MyConf->ReadValue("helpop", "key", i));
				std::string value = MyConf->ReadValue("helpop", "value", i, true); /* Linefeeds allowed! */

				if (key == "index")
				{
					throw ModuleException("m_helpop: The key 'index' is reserved for internal purposes. Please remove it.");
				}

				helpop_map[key] = value;
			}

			if (helpop_map.find("start") == helpop_map.end())
			{
				// error!
				throw ModuleException("m_helpop: Helpop file is missing important entries. Please check the example conf.");
			}
			else if (helpop_map.find("nohelp") == helpop_map.end())
			{
				// error!
				throw ModuleException("m_helpop: Helpop file is missing important entries. Please check the example conf.");
			}

		}
Пример #5
0
bool jets_RA5(EasyChain* tree,vector<int>& goodJets){

	static ConfigReader config;
	// static since we read only once
	static float jet_pt_min  = config.getFloat("jet_pt_min",   30);
	static float jet_eta_max = config.getDouble("jet_eta_max",2.4);
	static bool  quick       = config.getBool("quick");

	// static to get the cut flow for all events
	static CutSet jetFlow("good jet selection");
	// print at end of program and dump into histogram file
	jetFlow.autoprint=true;
	jetFlow.autodump=true;

	vector<int>&       JetID = tree->Get(&JetID,"ak5JetPFPFJetIDloosePat");
	vector<LorentzM>&   Jets = tree->Get(&Jets, "ak5JetPFCorrectedP4Pat");
	int cntJets=0;

	for(int k = 0; k<Jets.size(); k++){
		if( !jetFlow.keepIf("pt>=jet_min",              Jets[k].pt()   >= jet_pt_min  ) && quick) continue;
		if( !jetFlow.keepIf("eta<=eta_max",        fabs(Jets[k].eta()) <= jet_eta_max ) && quick) continue;
		if( !jetFlow.keepIf("ak5JetPFPFJetIDloosePat", JetID[k]!=0 )                    && quick) continue;
		goodJets.push_back(k);
	}

	return goodJets.size() >= 2;
}
Пример #6
0
std::string getLocaleValue(const ConfigReader &config, const std::string &group, const std::string &key, const std::string &language)
{
	lang wanted(language);
	std::vector<std::string> localeKeys;

	if (wanted.country.size() > 0 && wanted.modifier.size() > 0)
	{
		localeKeys.push_back(wanted.language + "_" + wanted.country + "@" + wanted.modifier);
	}

	if (wanted.country.size() > 0)
	{
		localeKeys.push_back(wanted.language + "_" + wanted.country);
	}

	if (wanted.modifier.size() > 0)
	{
		localeKeys.push_back(wanted.language + "@" + wanted.modifier);
	}

	localeKeys.push_back(wanted.language);

	for (std::vector<std::string>::size_type i = 0; i < localeKeys.size(); ++i)
	{
		std::string localeKey = key + "[" + localeKeys[i] + "]";

		if (config.hasKey(group, localeKey))
		{
			return config.value(group, localeKey);
		}
	}

	return config.value(group, key);
}
Пример #7
0
PoseGrabber::PoseGrabber(const ConfigReader &reader, const std::string &output_dir) : BasePoseGrabber(output_dir) {

  self_name_ = "pose-grabber";
  checkSelfName(reader.get_element("name"));

  try{
    model_.LoadData(reader.get_element("model-file"));
  }
  catch (std::runtime_error){
    //e.g. no model
  }
  
  
  ifs_.open(reader.get_element("pose-file"));

  if (!ifs_.is_open()){
    throw std::runtime_error("Error, could not open file: " + reader.get_element("pose-file"));
  }

  ifs_.exceptions(std::ifstream::eofbit);

  save_dir_ = output_dir;

  ofs_file_ = save_dir_ + "/" + reader.get_element("output-pose-file");

}
Пример #8
0
bool cleaningFilters::METconsistency( LorentzM& caloMET, LorentzM& pfMET){

  ConfigReader config;
  static float DPhi_Max = config.getFloat( "METconsistency_DPhiMax", 1.5);

  return fabs( DeltaPhi( caloMET, pfMET)) < DPhi_Max;
};
Пример #9
0
bool readV4Config( const char *configFile, 
    EncfsConfig &config, ConfigInfo *)
{
  bool ok = false;

  // use Config to parse the file and query it..
  ConfigReader cfgRdr;
  if(cfgRdr.load( configFile ))
  {
    try
    {
      cfgRdr["cipher"] >> (*config.mutable_cipher());
      int blockSize;
      cfgRdr["blockSize"] >> blockSize;
      config.set_block_size(blockSize);

      EncryptedKey *key = config.mutable_key();
      cfgRdr["keyData"] >> (*key->mutable_ciphertext());

      // fill in default for V4
      config.mutable_naming()->MergeFrom( makeInterface("nameio/stream", 1, 0, 0) );
      config.set_creator( "EncFS 1.0.x" );

      ok = true;
    } catch( Error &err)
    {
      LOG(WARNING) << "Error parsing config file " << configFile
        << ": " << err.what();
      ok = false;
    }
  }

  return ok;
}
Пример #10
0
// Read a v5 archive, which is a proprietary binary format.
bool readV5Config( const char *configFile, 
    EncfsConfig &config, ConfigInfo *)
{
  bool ok = false;

  // use Config to parse the file and query it..
  ConfigReader cfgRdr;
  if(cfgRdr.load( configFile ))
  {
    try
    {
      config.set_revision(cfgRdr["subVersion"].readInt(0));
      if(config.revision() > V5Latest)
      {
        /* config file specifies a version outside our supported
           range..   */
        LOG(ERROR) << "Config subversion " << config.revision()
          << " found, but this version of encfs only supports up to version "
          << V5Latest;
        return false;
      }
      if( config.revision() < V5Latest )
      {
        LOG(ERROR) << "This version of EncFS doesn't support "
          << "filesystems created with EncFS releases before 2004-08-13";
        return false;
      }

      cfgRdr["creator"] >> (*config.mutable_creator());
      cfgRdr["cipher"] >> (*config.mutable_cipher());
      cfgRdr["naming"] >> (*config.mutable_naming());

      int blockSize;
      cfgRdr["blockSize"] >> blockSize;
      config.set_block_size(blockSize);

      EncryptedKey *encryptedKey = config.mutable_key();
      int keySize;
      cfgRdr["keySize"] >> keySize;
      encryptedKey->set_size(keySize / 8);
      cfgRdr["keyData"] >> (*encryptedKey->mutable_ciphertext());

      config.set_unique_iv( cfgRdr["uniqueIV"].readBool( false ) );
      config.set_chained_iv( cfgRdr["chainedIV"].readBool( false ) );
      config.set_external_iv( cfgRdr["externalIV"].readBool( false ) );
      config.set_block_mac_bytes( cfgRdr["blockMACBytes"].readInt(0) );
      config.set_block_mac_rand_bytes( cfgRdr["blockMACRandBytes"].readInt(0) );

      ok = true;
    } catch( Error &err)
    {
      LOG(WARNING) << "Error parsing data in config file " << configFile
        << "; " << err.what();
      ok = false;
    }
  }

  return ok;
}
Пример #11
0
	virtual void OnRehash(User* user)
	{
		ConfigReader* conf = new ConfigReader(ServerInstance);
		deaf_bypasschars = conf->ReadValue("deaf", "bypasschars", 0);
		deaf_bypasschars_uline = conf->ReadValue("deaf", "bypasscharsuline", 0);

		delete conf;
	}
Пример #12
0
bool cleaningFilters::anomalousRho( EasyChain* tree){

  ConfigReader config;
  static float rho_Max = config.getFloat( "Rho_Max", 40.);

  float rho = tree->Get( rho, "rho");
  return rho <= rho_Max;
};
Пример #13
0
	void ReadSettings()
	{
		Conf = new ConfigReader(ServerInstance);
		IdentTimeout = Conf->ReadInteger("ident", "timeout", 0, true);
		PortBind = Conf->ReadValue("ident", "bind", 0);
		if (!IdentTimeout)
			IdentTimeout = 1;
		DELETE(Conf);
	}
Пример #14
0
		virtual void OnRehash(User* user)
		{
			ConfigReader* conf = new ConfigReader(ServerInstance);
			JoinChan = conf->ReadValue("autojoin", "channel", 0);
			Joinchans.clear();
			if (!JoinChan.empty())
				tokenize(JoinChan,Joinchans);
			delete conf;
		}
Пример #15
0
int main()
{
	string configFileName("difex.dat");
	ConfigReader *configReader = new ConfigReader(configFileName);
	configReader->readConfig();

	FTCSSchemeSolver *solver = new FTCSSchemeSolver(configReader);
	solver->run();

	return EXIT_SUCCESS;
}
Пример #16
0
    virtual void OnRehash(userrec* user, const std::string &parameter)
    {
        ConfigReader* conf = new ConfigReader(ServerInstance);

        operChan = conf->ReadValue("operjoin", "channel", 0);
        operChans.clear();
        if (!operChan.empty())
            tokenize(operChan,operChans);

        DELETE(conf);
    }
Пример #17
0
/**
* @brief Save all values and prepare xml configuration for writing
*/
void ParameterStructure::UpdateConfig() const
{
	ConfigReader conf = m_configReader.Find("parameters");

	for(const auto & elem : m_list)
	{
		if(m_writeAllParamsToConfig || (elem)->GetConfigurationSource() != PARAMCONF_DEF)
		{
			conf.FindRef("param[name=\"" +(elem)->GetName() + "\"]", true).SetValue((elem)->GetValueString());
		}
	}
}
Пример #18
0
	void ReadConfig()
	{
		ConfigReader* MyConf = new ConfigReader(ServerInstance);
		allowchans.clear();
		for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
		{
			std::string txt;
			txt = MyConf->ReadValue("allowchannel", "name", i);
			irc::string channel = txt.c_str();
			allowchans[channel] = 1;
		}
		DELETE(MyConf);
	}
Пример #19
0
	void LoadOperMOTD()
	{
		ConfigReader* conf = new ConfigReader(ServerInstance);
		std::string filename;
		filename = conf->ReadValue("opermotd","file",0);
		if (opermotd)
		{
			delete opermotd;
			opermotd = NULL;
		}
		opermotd = new FileReader(ServerInstance, filename);
		DELETE(conf);
	}
int add_all_devices(ConfigReader &cfg, DeviceFilter &dev_filt)
{
	int rc = 0;
	list<__u32> lst;

	cfg.get_unique_mms(lst);
	for (list<__u32>::const_iterator i = lst.begin();
	      i != lst.end(); ++i) {
		dev_filt.add_device(*i, cfg.get_ident_by_mm_internal(*i, &rc));
		assert(rc == 0);
	}

	return 0;
}
Пример #21
0
	virtual void OnRehash(const std::string &parameter)
	{
		// reload our config file on rehash - we must destroy and re-allocate the classes
		// to call the constructor again and re-read our data.
		ConfigReader* Conf = new ConfigReader(ServerInstance);
		std::string filterfile = Conf->ReadValue("filter","file",0);
		// this automatically re-reads the configuration file into the class
		ConfigReader* MyConf = new ConfigReader(ServerInstance, filterfile);
		if ((filterfile == "") || (!MyConf->Verify()))
		{
			// bail if the user forgot to create a config file
			FilterException e;
			throw(e);
		}
		for (filter_t::iterator n = filters.begin(); n != filters.end(); n++)
		{
			DELETE(n->second);
		}
		filters.clear();
		for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
		{
			std::string pattern = MyConf->ReadValue("keyword","pattern",index);
			std::string reason = MyConf->ReadValue("keyword","reason",index);
			std::string do_action = MyConf->ReadValue("keyword","action",index);
			if (do_action == "")
				do_action = "none";
			Filter* x = new Filter;
			x->reason = reason;
			x->action = do_action;
			filters[pattern] = x;
		}
		ServerInstance->Log(DEFAULT,"m_filter: read configuration from "+filterfile);
		DELETE(Conf);
		DELETE(MyConf);
	}
Пример #22
0
	void OnReload()
	{
		ConfigReader config;

		this->binddn = config.ReadValue("m_ldap_oper", "binddn", "", 0);
		this->password = config.ReadValue("m_ldap_oper", "password", "", 0);
		this->basedn = config.ReadValue("m_ldap_oper", "basedn", "", 0);
		this->filter = config.ReadValue("m_ldap_oper", "filter", "", 0);
		opertype_attribute = config.ReadValue("m_ldap_oper", "opertype_attribute", "", 0);

		for (std::set<Oper *>::iterator it = my_opers.begin(), it_end = my_opers.end(); it != it_end; ++it)
			delete *it;
		my_opers.clear();
	}
Пример #23
0
	void LoadOperMOTD()
	{
		ConfigReader* conf = new ConfigReader(ServerInstance);
		std::string filename;
		filename = conf->ReadValue("opermotd","file",0);
		if (opermotd)
		{
			delete opermotd;
			opermotd = NULL;
		}
		opermotd = new FileReader(ServerInstance, filename);
		onoper = conf->ReadFlag("opermotd","onoper","yes",0);
		delete conf;
	}
Пример #24
0
	void InitConf()
	{
		/* read configuration variables */
		conf = new ConfigReader(ServerInstance);
		/* throttle configuration */
		seconds = conf->ReadInteger("connflood", "seconds", 0, true);
		maxconns = conf->ReadInteger("connflood", "maxconns", 0, true);
		timeout = conf->ReadInteger("connflood", "timeout", 0, true);
		quitmsg = conf->ReadValue("connflood", "quitmsg", 0);

		/* seconds to wait when the server just booted */
		boot_wait = conf->ReadInteger("connflood", "bootwait", 0, true);

		first = ServerInstance->Time();
	}
Пример #25
0
/**
* @brief Print the results of timings
*/
void Manager::PrintStatistics()
{
	double fps = m_frameCount / m_timerProcessable.GetSecDouble();
	LOG_INFO(m_logger, "Manager: " << m_frameCount << " frames processed in " << m_timerProcessable.GetSecDouble() * 1000 << " ms, " << fps << " fps");
	// LOG_INFO("input convertion "                  <<m_timerConvertion<<" ms ("<<(1000.0 * m_frameCount) / m_timerConvertion<<" frames/s)");
	// LOG_INFO("Total time "<< m_timerProcessable + m_timerConvertion<<" ms ("<<     (1000.0 * m_frameCount) /(m_timerProcessable + m_timerConvertion)<<" frames/s)");

	// Create an XML file to summarize CPU usage
	//     if output dir is empty, write to /tmp
	string benchFileName = ((IsContextSet() && !GetContext().IsOutputDirEmpty()) ? GetContext().GetOutputDir() : "/tmp") + "/benchmark.xml";
	ConfigFile benchSummary(benchFileName, true);
	ConfigReader conf = benchSummary.FindRef("benchmark", true);


	// Write perf to output XML
	ConfigReader perfModule = conf.FindRef("manager", true);
	perfModule.FindRef("nb_frames", true).SetValue(m_frameCount);
	perfModule.FindRef("timer[name=\"processable\"]", true).SetValue(m_timerProcessable.GetSecDouble()*1000);
	perfModule.FindRef("timer[name=\"processing\"]", true).SetValue(m_timerProcessable.GetSecDouble()*1000); // note: this line is kept for backward compatibility
	perfModule.FindRef("fps", true).SetValue(fps);

	// Call for each module
	for(const auto& module : m_modules)
	{
		// LOG_INFO(cpt<<": ");
		module->PrintStatistics(conf);
	}
	benchSummary.SaveToFile(benchFileName);
}
Пример #26
0
void Game::readObjectHeight(int &objectHeight, const ConfigReader reader, bool &parseOk, const std::string name, bool &successful)
{
    objectHeight = QString(reader.get(name, "Height").c_str()).toInt(&parseOk);
    if (!parseOk || objectHeight < 0) {
        std::cerr << "error: [" << name << "]: height was not an integer." << std::endl;
        objectHeight = 1;
        successful = false;
    }
}
Пример #27
0
void Game::readObjectPath(std::string &objectSprite, const ConfigReader reader, const std::string name, bool &successful)
{
    objectSprite = reader.get(name, "Sprite");
    if (objectSprite == "") {
        std::cerr << "error: [" << name << "]: Sprite was not set." << std::endl;
        objectSprite = ":/resources/block_brown.png";
        successful = false;
    }
}
Пример #28
0
	virtual void OnRehash(User* user)
	{
		/*
		 * reload our config file on rehash - we must destroy and re-allocate the classes
		 * to call the constructor again and re-read our data.
		 */
		ConfigReader* MyConf = new ConfigReader(ServerInstance);
		censors.clear();

		for (int index = 0; index < MyConf->Enumerate("badword"); index++)
		{
			irc::string pattern = (MyConf->ReadValue("badword","text",index)).c_str();
			irc::string replace = (MyConf->ReadValue("badword","replace",index)).c_str();
			censors[pattern] = replace;
		}

		delete MyConf;
	}
   bool OperatorEnergyChannels::initialize(ConfigReader& cr,Simulation& sim,SimulationClasses& simClasses) {
      initialized = true;
      simClasses.logger << "(SEP OP ENERGY CHANNELS) Starting initialization" << endl << write;
      
      // Init base class:
      if (OperatorAccumulationBase::initialize(cr,sim,simClasses) == false) {
	 simClasses.logger << "(SEP OP ENERGY CHANNELS) ERROR: OperatorAccumulationBase failed to initialize!" << endl << write;
	 initialized = false;
      }

      // Create a profiler section name for this DataOperator:
      #if PROFILE_LEVEL > 0
         stringstream ss;
         ss << "Energy Channels" << OperatorAccumulationBase::getOrder();
         profileName = ss.str();
         OperatorAccumulationBase::setProfileName(ss.str());
      #endif
      
      // Get names of instruments:
      vector<string> instrumentNames;
      cr.addComposed(PREFIX+".instrument_names","Names of energy instruments (string).");
      cr.parse();
      cr.get(PREFIX+".instrument_names",instrumentNames);

      //instrumentIndices.push_back(make_pair<size_t,size_t>(0,0));
      for (size_t i=0; i<instrumentNames.size(); ++i) {
	 // Skip empty lines
	 if (instrumentNames[i].size() == 0) continue;

	 // Read config file items for instrument and create it:
	 if (createInstrument(simClasses,cr,instrumentNames[i]) == false) {
	    simClasses.logger << "(SEP OP ENERGY CHANNELS) ERROR: Failed to read required config file items for ";
	    simClasses.logger << "instrument '" << instrumentNames[i] << "'" << endl << write;
	    initialized = false;
	 }
      }

      // Write init status and exit:
      simClasses.logger << "(SEP OP ENERGY CHANNELS) Initialization complete, status is ";
      if (initialized == true) simClasses.logger << "SUCCESS" << endl << write;
      else simClasses.logger << "FAILURE" << endl << write;
      
      return initialized;
   }
Пример #30
0
BaseDaVinciPoseGrabber::BaseDaVinciPoseGrabber(const ConfigReader &reader, const std::string &output_dir) : BasePoseGrabber(output_dir) {
  
  try{
    model_.LoadData(reader.get_element("model-file"));
  }
  catch (std::runtime_error){
    //no model (e.g. tracking camera)
  }

}