예제 #1
0
DaemonConfig::DaemonConfig(std::string config_file, std::string config_defaults_file) {
  CSimpleIniA ini;
  ini.SetMultiKey();
  ini.LoadFile(config_file.c_str());
  
  CSimpleIniA defaultIni;
  defaultIni.SetMultiKey();
  defaultIni.LoadFile(config_defaults_file.c_str());
  
  // Stream will only be in the user override config, never in the defaults
  CSimpleIniA::TNamesDepend values;
  ini.GetAllValues("daemon", "stream", values);

  // sort the values into the original load order
  values.sort(CSimpleIniA::Entry::LoadOrder());

  // output all of the items
  CSimpleIniA::TNamesDepend::const_iterator i;
  for (i = values.begin(); i != values.end(); ++i) { 
      stream_urls.push_back(i->pItem);
  }

  country = getString(&ini, &defaultIni, "daemon", "country", "us");
  topn = getInt(&ini, &defaultIni, "daemon", "topn", 20);
  
  storePlates = getBoolean(&ini, &defaultIni, "daemon", "store_plates", false);
  imageFolder = getString(&ini, &defaultIni, "daemon", "store_plates_location", "/tmp/");
  uploadData = getBoolean(&ini, &defaultIni, "daemon", "upload_data", false);
  upload_url = getString(&ini, &defaultIni, "daemon", "upload_address", "");
  company_id = getString(&ini, &defaultIni, "daemon", "company_id", "");
  site_id = getString(&ini, &defaultIni, "daemon", "site_id", "");
  pattern = getString(&ini, &defaultIni, "daemon", "pattern", "");
}
예제 #2
0
vector<string> cConfigItem::getValuesFromConfigFile(CSimpleIniA *ini) {
	vector<string> list_values;
	CSimpleIniA::TNamesDepend values;
	if(ini->GetAllValues("general", config_name.c_str(), values)) {
		CSimpleIni::TNamesDepend::const_iterator i = values.begin();
		initBeforeSet();
		for (; i != values.end(); ++i) {
			list_values.push_back(i->pItem);
		}
	}
	return(list_values);
}
예제 #3
0
 inline std::map<std::string,std::string> getMap(const std::string& obj) {
     using namespace std;
     _guard g(m);
     map<std::string,std::string> res;
     CSimpleIniA::TNamesDepend keys;
     ini.GetAllKeys(obj.c_str(), keys);
     CSimpleIniA::TNamesDepend::const_iterator i;
     for(i = keys.begin(); i != keys.end(); ++i) {
         const CSimpleIniA::SI_CHAR_T* _key = i->pItem;
         const CSimpleIniA::SI_CHAR_T* _val = ini.GetValue(obj.c_str(), _key, NULL);
         res[std::string(_key)] = std::string(_val);
     }
     return res;
 }
예제 #4
0
////////////////////////////////////////////////////////////
/// Load & apply some settings
////////////////////////////////////////////////////////////
void MainClient::_loadGameSettings(void)
{
	CSimpleIniA ini;
	if(	ini.LoadFile("settings.ini") < 0 ){
		throw "Could not open the settings file!";
	}

	//Input .ini file settings
	info.debug			= ini.GetBoolValue("Settings", "debug");
	info.mapfile 		= ini.GetValue("Settings", "map");
	info.demoFile		= ini.GetValue("Settings", "demo");
	info.demoPlay		= ini.GetBoolValue("Settings", "play");
	info.demoRecord		= ini.GetBoolValue("Settings", "record");
	info.texturefile	= ini.GetValue("Settings", "textures");

	info.fullscreen 	= ini.GetBoolValue("Window", "fullscreen");
	info.window_width	= ini.GetLongValue("Window", "width");
	info.window_height	= ini.GetLongValue("Window", "height");
	info.cursorfile 	= ini.GetValue("Window", "cursor");

	info.fpslimit 		= ini.GetLongValue("Graphics", "fpslimit");
	info.frameskip 		= ini.GetLongValue("Graphics", "frameskip");

	/* Load the weapon list */
	CSimpleIniA weaponlist;
	weaponlist.LoadFile("assets/weaponlist.ini");

	CSimpleIniA::TNamesDepend keys;
	weaponlist.GetAllKeys("Weapons", keys);

	//Build Weapon definitions
	CSimpleIniA::TNamesDepend::const_iterator i;
	for(i = keys.begin(); i != keys.end(); ++i){
		//corresponds to the weapon select menu
		WeaponList.push_back(weaponlist.GetValue("Weapons", i->pItem));

		{
			//Push back a weapon info
			object::Weapon::Info winfo;
			std::string	path = WeaponList.back() + "/weapon.ini";

			object::Weapon::Info::Load(path.c_str(), &winfo);

			WeaponInfo.push_back(winfo);
		}
	}

} //void MainClient::_loadGameSettings(void)
예제 #5
0
파일: ini.cpp 프로젝트: nszhsl/pylon
    ClassList<std::string> * Ini::keysinsection(std::string sec)
    {
        if(!hasSection(sec))
            return NULL;

        CSimpleIniA::TNamesDepend keys;
        ini.GetAllKeys(sec.c_str(), keys);

        ClassList<std::string> * ret = new ClassList<std::string>();

        CSimpleIniA::TNamesDepend::iterator it;
        for ( it = keys.begin(); it != keys.end(); it++ )
            ret->add(std::string(it->pItem));

        return ret;
    }
예제 #6
0
void Configuration::GetConfigListS(std::string Name, std::map<std::string, std::filesystem::path> &Out, std::string DefaultKeyName)
{
    CSimpleIniA::TNamesDepend List;
	if (!Config) throw CfgNotLoaded;

    Config->GetAllKeys(Name.c_str(), List);

    if (!List.size() && DefaultKeyName != "")
        Config->SetValue(Name.c_str(), DefaultKeyName.c_str(), "");

    for (CSimpleIniA::TNamesDepend::iterator i = List.begin();
    i != List.end();
        ++i)
    {
        if (Config->GetValue(Name.c_str(), i->pItem))
            Out[std::string(i->pItem)] = Config->GetValue(Name.c_str(), i->pItem);
    }
}
예제 #7
0
std::vector<float> getAllFloats(CSimpleIniA* ini, string section, string key)
{
    CSimpleIniA::TNamesDepend values;

    ini->GetAllValues(section.c_str(), key.c_str(), values);

    // sort the values into the original load order
    values.sort(CSimpleIniA::Entry::LoadOrder());

    std::vector<float> response;

    // output all of the items
    CSimpleIniA::TNamesDepend::const_iterator i;
    for (i = values.begin(); i != values.end(); ++i) {
        response.push_back(atof(i->pItem));
    }

    return response;
}
예제 #8
0
파일: zgw.cpp 프로젝트: zhangnian/zgw
void ZGWServer::createPushSocks()
{
    assert( NULL != zmqContext_ );

    CSimpleIniA::TNamesDepend keys;
    ini_.GetAllKeys("backend", keys);
    CSimpleIni::TNamesDepend::const_iterator iter = keys.begin();
    for (; iter != keys.end(); ++iter )
    {
        std::string key = iter->pItem;
        size_t pos = key.find("push_service_");
        if( pos == std::string::npos )
            continue;

        std::string str_type = key.substr(pos + 13);
        assert( str_type.size() > 0 );
        int service_type = atoi(str_type.c_str());

        std::string service_endpoint = ini_.GetValue("backend", key.c_str(), "");
        if( service_endpoint.size() == 0 )
        {
            LOG_INFO << "类型为: " << service_type << "的进程组未设置地址";
            continue;
        }

        void* pushSocket = zmq_socket(zmqContext_, ZMQ_PUSH);
        assert( NULL != pushSocket );

        // 注意,PUSH端调用bind,如果PULL端没有connect上来,send调用会阻塞.
        // 为了让这种情况下send调用不阻塞并直接丢弃消息,需要在send时指定:ZMQ_DONTWAIT.
        int rc = zmq_bind(pushSocket, service_endpoint.c_str());
        assert( rc == 0 );

        pushSocks_[service_type] = pushSocket;
        LOG_INFO << "绑定PUSH Socket成功,类型: " << service_type << ", 地址: " << service_endpoint;
    }
}
예제 #9
0
파일: daemon.cpp 프로젝트: Simage/openalpr
int main( int argc, const char** argv )
{
  daemon_active = true;

  bool noDaemon = false;
  bool clockOn = false;
  std::string logFile;
  int topn;
  
  std::string configFile;
  std::string country;

  TCLAP::CmdLine cmd("OpenAlpr Daemon", ' ', Alpr::getVersion());

  TCLAP::ValueArg<std::string> countryCodeArg("c","country","Country code to identify (either us for USA or eu for Europe).  Default=us",false, "us" ,"country_code");
  TCLAP::ValueArg<std::string> configFileArg("","config","Path to the openalpr.conf file.",false, "" ,"config_file");
  TCLAP::ValueArg<int> topNArg("n","topn","Max number of possible plate numbers to return.  Default=25",false, 25 ,"topN");
  TCLAP::ValueArg<std::string> logFileArg("l","log","Log file to write to.  Default=" + DEFAULT_LOG_FILE_PATH,false, DEFAULT_LOG_FILE_PATH ,"topN");

  TCLAP::SwitchArg daemonOffSwitch("f","foreground","Set this flag for debugging.  Disables forking the process as a daemon and runs in the foreground.  Default=off", cmd, false);
  TCLAP::SwitchArg clockSwitch("","clock","Display timing information to log.  Default=off", cmd, false);

  try
  {
    
    cmd.add( countryCodeArg );
    cmd.add( topNArg );
    cmd.add( configFileArg );
    cmd.add( logFileArg );

    
    if (cmd.parse( argc, argv ) == false)
    {
      // Error occured while parsing.  Exit now.
      return 1;
    }

    country = countryCodeArg.getValue();
    configFile = configFileArg.getValue();
    logFile = logFileArg.getValue();
    topn = topNArg.getValue();
    noDaemon = daemonOffSwitch.getValue();
    clockOn = clockSwitch.getValue();
  }
  catch (TCLAP::ArgException &e)    // catch any exceptions
  {
    std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
    return 1;
  }
  
  log4cplus::BasicConfigurator config;
  config.configure();
    
  if (noDaemon == false)
  {
    // Fork off into a separate daemon
    daemon(0, 0);
    
    
    log4cplus::SharedAppenderPtr myAppender(new log4cplus::RollingFileAppender(logFile));
    myAppender->setName("alprd_appender");
    // Redirect std out to log file
    logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("alprd"));
    logger.addAppender(myAppender);
    
    
    LOG4CPLUS_INFO(logger, "Running OpenALPR daemon in daemon mode.");
  }
  else
  {
    //log4cplus::SharedAppenderPtr myAppender(new log4cplus::ConsoleAppender());
    //myAppender->setName("alprd_appender");
    // Redirect std out to log file
    logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("alprd"));
    //logger.addAppender(myAppender);
    
    LOG4CPLUS_INFO(logger, "Running OpenALPR daemon in the foreground.");
  }
  
  CSimpleIniA ini;
  ini.SetMultiKey();
  
  ini.LoadFile(DAEMON_CONFIG_FILE_PATH.c_str());
  
  std::vector<std::string> stream_urls;
  
  
  CSimpleIniA::TNamesDepend values;
  ini.GetAllValues("daemon", "stream", values);

  // sort the values into the original load order
  values.sort(CSimpleIniA::Entry::LoadOrder());

  // output all of the items
  CSimpleIniA::TNamesDepend::const_iterator i;
  for (i = values.begin(); i != values.end(); ++i) { 
      stream_urls.push_back(i->pItem);
  }
  
  
  if (stream_urls.size() == 0)
  {
    LOG4CPLUS_FATAL(logger, "No video streams defined in the configuration.");
    return 1;
  }
  
  bool storePlates = ini.GetBoolValue("daemon", "store_plates", false);
  std::string imageFolder = ini.GetValue("daemon", "store_plates_location", "/tmp/");
  bool uploadData = ini.GetBoolValue("daemon", "upload_data", false);
  std::string upload_url = ini.GetValue("daemon", "upload_address", "");
  std::string site_id = ini.GetValue("daemon", "site_id", "");
  
  LOG4CPLUS_INFO(logger, "Using: " << imageFolder << " for storing valid plate images");
  
  pid_t pid;
  
  for (int i = 0; i < stream_urls.size(); i++)
  {
    pid = fork();
    if (pid == (pid_t) 0)
    {
      // This is the child process, kick off the capture data and upload threads
      CaptureThreadData* tdata = new CaptureThreadData();
      tdata->stream_url = stream_urls[i];
      tdata->camera_id = i + 1;
      tdata->config_file = configFile;
      tdata->output_images = storePlates;
      tdata->output_image_folder = imageFolder;
      tdata->country_code = country;
      tdata->site_id = site_id;
      tdata->top_n = topn;
      tdata->clock_on = clockOn;
      
      tthread::thread* thread_recognize = new tthread::thread(streamRecognitionThread, (void*) tdata);
      
      if (uploadData)
      {
	// Kick off the data upload thread
	UploadThreadData* udata = new UploadThreadData();
	udata->upload_url = upload_url;
	tthread::thread* thread_upload = new tthread::thread(dataUploadThread, (void*) udata );
      }
      
      break;
    }

    // Parent process will continue and spawn more children
  }



  while (daemon_active)
  {
    usleep(30000);
  }

}
예제 #10
0
bool
snippets(
    const char *    a_pszFile,
    bool            a_bIsUtf8,
    bool            a_bUseMultiKey,
    bool            a_bUseMultiLine
    )
{
    // LOADING DATA

    // load from a data file
    CSimpleIniA ini(a_bIsUtf8, a_bUseMultiKey, a_bUseMultiLine);
    SI_Error rc = ini.LoadFile(a_pszFile);
    if (rc < 0) return false;

    // load from a string
    std::string strData;
    rc = ini.LoadData(strData.c_str(), strData.size());
    if (rc < 0) return false;

    // GETTING SECTIONS AND KEYS

    // get all sections
    CSimpleIniA::TNamesDepend sections;
    ini.GetAllSections(sections);

    // get all keys in a section
    CSimpleIniA::TNamesDepend keys;
    ini.GetAllKeys("section-name", keys);

    // GETTING VALUES

    // get the value of a key
    const char * pszValue = ini.GetValue("section-name",
        "key-name", NULL /*default*/);

    // get the value of a key which may have multiple
    // values. If bHasMultipleValues is true, then just
    // one value has been returned
    bool bHasMultipleValues;
    pszValue = ini.GetValue("section-name", "key-name",
        NULL /*default*/, &bHasMultipleValues);

    // get all values of a key with multiple values
    CSimpleIniA::TNamesDepend values;
    ini.GetAllValues("section-name", "key-name", values);

    // sort the values into the original load order
#if defined(_MSC_VER) && _MSC_VER <= 1200
    /** STL of VC6 doesn't allow me to specify my own comparator for list::sort() */
    values.sort();
#else
    values.sort(CSimpleIniA::Entry::LoadOrder());
#endif

    // output all of the items
    CSimpleIniA::TNamesDepend::const_iterator i;
    for (i = values.begin(); i != values.end(); ++i) {
        printf("key-name = '%s'\n", i->pItem);
    }

    // MODIFYING DATA

    // adding a new section
    rc = ini.SetValue("new-section", NULL, NULL);
    if (rc < 0) return false;
    printf("section: %s\n", rc == SI_INSERTED ?
        "inserted" : "updated");

    // adding a new key ("new-section" will be added
    // automatically if it doesn't already exist.
    rc = ini.SetValue("new-section", "new-key", "value");
    if (rc < 0) return false;
    printf("key: %s\n", rc == SI_INSERTED ?
        "inserted" : "updated");

    // changing the value of a key
    rc = ini.SetValue("section", "key", "updated-value");
    if (rc < 0) return false;
    printf("key: %s\n", rc == SI_INSERTED ?
        "inserted" : "updated");

    // DELETING DATA

    // deleting a key from a section. Optionally the entire
    // section may be deleted if it is now empty.
    ini.Delete("section-name", "key-name",
        true /*delete the section if empty*/);

    // deleting an entire section and all keys in it
    ini.Delete("section-name", NULL);

    // SAVING DATA

    // save the data to a string
    rc = ini.Save(strData);
    if (rc < 0) return false;

    // save the data back to the file
    rc = ini.SaveFile(a_pszFile);
    if (rc < 0) return false;

    return true;
}
예제 #11
0
//-------------------------------------------------------------------------------------
// Name: main()
// Desc: The application's entry point
//-------------------------------------------------------------------------------------
void __cdecl main()
{
	CSimpleIniA ini(true, true, true);
	std::map<std::string, bool> Settings;

	Utilities u;
	// Try mounting the game directory; at console startup it's not mounted
	u.MountGameDirectory();
	if (ini.LoadFile("g:\\settings.ini") < 0)
	{
		ini.Reset();

		std::string IniText(
			" LaunchCode was created by CLK.\n\n"			\
			" What can this app do?\n"									\
			"    - Remove console signature checks\n"					\
			"    - Remove RSA signature checks\n"						\
			"    - Set RoL LEDs\n"										\
			"    - Remove profile breakpoints (freezing when viewing some profiles)\n"\
			"    - Remove XampHeapAllocExplicit breakpoints (some bullshit)\n"	\
			"    - Enable hidden partitions for Xbox 360 Neighborhood\n"		\
			"    - Add additional, customizable partitions to Neighborhood\n"	\
			"    - Set the default account password for PartnerNet accounts\n"	\
			"    - Set the display gamertag\n"							\
			"    - Make the console think you have a gold membership\n" \
			" -> Instructions/Limitations:\n"							\
			" - Account password length must not exceed 11 characters.\n"\
			" - Each Neighborhood partition should match the following"	\
			    "criteria, otherwise it will not be mounted:\n"			\
			" ~ NeighborhoodName must not exceed 35 characters\n"		\
			" ~ DevicePath must not exceed 61 characters\n"				\
			" ~ DevicePath must be formatted as so:\n"					\
			"  - \"\\Device\\Harddisk0\\Partition1\\Devikit\"\n"		\
			"    - The following are all valid basic paths:\n"			\
			"      - \\Device\n"										\
			"      - \\Device\\Harddisk0\\SystemPartition\n"			\
			"      - \\Device\\Harddisk0\\Partition1\n"					\
			"      - \\Device\\Flash\n"									\
			"      - \\Device\\Mu0System\n"								\
			"      - \\Device\\Mu1System\n"								\
			"      - \\Device\\Mass0\n"									\
			"      - \\Device\\Mass1\n"									\
			"      - \\Device\\Mass2\n"									\
			"      - \\Device\\BuiltInMuSfcSystem\n"					\
			"      - \\Device\\Harddisk\\SystemExtPartition\n"			\
			"      - \\Device\\Harddisk\\SystemAuxPartition\n"			\
			"      - \\Device\\BuiltInMuUsb\\Storage\n"					\
			"      - \\Device\\BuiltInMuUsb\\StorageSystem\n"			\
			"      - \\Device\\BuiltInMuUsb\\SystemExtPartition\n"		\
			"      - \\Device\\BuiltInMuUsb\\SystemAuxPartition\n"		\
			"      - \\Device\\BuiltInMuMmc\\Storage\n"					\
			"      - \\Device\\BuiltInMuMmc\\StorageSystem\n"			\
			"      - \\Device\\BuiltInMuMmc\\SystemExtPartition\n"		\
			"      - \\Device\\BuiltInMuMmc\\SystemAuxPartition\n"		\
			"      - \\Device\\HdDvdRom\n"								\
			"      - \\Device\\HdDvdStorage\n"							\
			"      - \\Device\\HdDvdPlayer\n"							\
			"      - \\Device\\TransferCable\n"							\
			"      - \\Device\\Mass0PartitionFile\\Storage\n"			\
			"      - \\Device\\Mass1PartitionFile\\Storage\n"			\
			"      - \\Device\\Mass0PartitionFile\\StorageSystem\n"		\
			"      - \\Device\\Mass1PartitionFile\\StorageSystem\n"		\
			"      - \\Device\\Harddisk0\\Cache0\n"						\
			"      - \\Device\\Harddisk0\\Cache1\n"						\
			"      - \\Device\\NetworkStorageCache\n"					\
			"      - \\Device\\UpdateStorage\n"							\
			"      - \\Device\\Harddisk0\\TitleURLCachePartition\n"		\
			"      - \\Device\\DeviceAuth\n"							\
			"      - \\Device\\BuiltInMuUsb\\ReservationPartition\n"	\
			"      - \\Device\\LauncherData\n"							\
			"\n\n\n\nGreets to the following people:\n"					\
			"gabe_k, Xenon.7 (Xenomega), paul (British dude), rickshaw, skitzo, kiwi, dual\n" \
			"yolo."
			);

		std::fstream readme("g:\\readme.txt", std::ios::trunc | std::ios::in | std::ios::out);
		readme << IniText;
		readme.close();

		ini.SetBoolValue("settings", "SetLeds", true);
		ini.SetBoolValue("settings", "PatchRsaPubCrypt", true);
		ini.SetBoolValue("settings", "RemoveConsoleSignatureChecks", true);
		ini.SetBoolValue("settings", "RemovePackageRsaChecks", true);
		ini.SetBoolValue("settings", "RemoveProfileBreakpoints", true);
		ini.SetBoolValue("settings", "RemoveXampHeapAllocExplicitBreakpoints", true);
		ini.SetBoolValue("settings", "SetAsStartupApplication", true);
		ini.SetBoolValue("settings", "EnableHiddenPartitions", true);
		ini.SetBoolValue("settings", "EnableExtraNeighborhoodDrives", true);

		ini.SetBoolValue("settings", "SetGamertag", true);
		ini.SetBoolValue("settings", "SetGoldMembership", true);
		ini.SetBoolValue("settings", "EnableXamWatsonOutput", true);

		ini.SetValue("Network", "AccountCreatePassword", "meth=friend");
		ini.SetValue("Network", "OnlineGamertag", "[test]DRUG DEALER"); // MODIFY THIS LINE TO YOUR DEFAULT GAMERTAG
		//ini.SetBoolValue("xshell", "WriteCustomBackground", false);
		//ini.SetValue("xshell", "DevKitBackground", "bg_image_blue.png");
		//ini.SetValue("xshell", "TestKitBackground", "bg_image_gray.png");

		ini.SetValue("LEDs", "TopLeft", "Inverted");
		ini.SetValue("LEDs", "TopRight", "Normal");
		ini.SetValue("LEDs", "BottomLeft", "Mix");
		ini.SetValue("LEDs", "BottomRight", "Off");
		
		ini.SetValue("NeighborhoodDrive1", "DevicePath", "");
		ini.SetValue("NeighborhoodDrive1", "NeighborhoodName", "");

		ini.SetValue("NeighborhoodDrive2", "DevicePath", "");
		ini.SetValue("NeighborhoodDrive2", "NeighborhoodName", "");

		ini.SetValue("NeighborhoodDrive3", "DevicePath", "");
		ini.SetValue("NeighborhoodDrive3", "NeighborhoodName", "");

		ini.SetValue("NeighborhoodDrive4", "DevicePath", "");
		ini.SetValue("NeighborhoodDrive4", "NeighborhoodName", "");
		
		ini.SaveFile("g:\\settings.ini");
		ini.LoadFile("g:\\settings.ini");
	}
	CSimpleIniA::TNamesDepend keys;
	ini.GetAllKeys("settings", keys);
	CSimpleIniA::TNamesDepend::iterator it;
	for (it = keys.begin(); it != keys.end(); it++)
	{
		const char *key = ((*it).pItem);
		bool Enabled = ini.GetBoolValue("settings", key, NULL);
		Settings[std::string(key)] = Enabled;
	}

	keys.clear();
	ini.GetAllKeys("Network", keys);
	NetworkSettings ns;
	for (it = keys.begin(); it != keys.end(); it++)
	{
		std::string key((*it).pItem);
		std::string value = ini.GetValue("Network", key.c_str(), NULL);
		if (key == "AccountCreatePassword")
			ns.AccountCreationPassword = value;
		else if (key == "OnlineGamertag")
			ns.Gamertag = value;
	}

	std::vector<Utilities::Drive> drl;
	char Section[20] = {0};
	for (int i = 1; i < 5; i++)
	{
		keys.clear();
		sprintf(Section, "NeighborhoodDrive%d", i);
		ini.GetAllKeys(Section, keys);
		Utilities::Drive d;
		for (it = keys.begin(); it != keys.end(); it++)
		{
			std::string key  = ((*it).pItem);
			std::string value = ini.GetValue(Section, key.c_str(), NULL);
			if (key == "NeighborhoodName")
				d.NeighborhoodName = value;
			else if(key == "DevicePath")
				d.Path = value;
		}
		if (!d.NeighborhoodName.size() || !d.Path.size())
			continue;
		else
			drl.push_back(d);
	}

	if (Settings[std::string("SetLeds")])
	{
		LEDState TL = LEDState::ORANGE, TR = LEDState::RED, BL = LEDState::ORANGE, BR = LEDState::RED;
		keys.clear();
		ini.GetAllKeys("LEDs", keys);
		for (it = keys.begin(); it != keys.end(); it++)
		{
			std::string key(((*it).pItem));
			std::string value(ini.GetValue("LEDs", key.c_str(), NULL));
			LEDState *CurrentLed = nullptr;
			if (key == "TopLeft")
				CurrentLed = &TL;
			else if (key == "TopRight")
				CurrentLed = &TR;
			else if (key == "BottomLeft")
				CurrentLed = &BL;
			else if (key == "BottomRight")
				CurrentLed = &BR;

			if (CurrentLed == nullptr)
				continue;

			if (value == "Inverted")
				*CurrentLed = LEDState::RED;
			else if (value == "Normal")
				*CurrentLed = LEDState::GREEN;
			else if (value == "Mix")
				*CurrentLed = LEDState::ORANGE;
			else if (value == "Off")
				*CurrentLed = LEDState::OFF;
		}
		u.SetLeds(TL, TR, BL, BR);
	}
	if (Settings[std::string("PatchRsaPubCrypt")])
		u.PatchRsaPubCrypt();
	if (Settings[std::string("RemoveConsoleSignatureChecks")])
		u.RemoveConsoleSignatureChecks();
	if (Settings[std::string("RemovePackageRsaChecks")])
		u.RemovePackageRsaChecks();
	if (Settings[std::string("RemoveProfileBreakpoints")])
		u.RemoveProfileBreakpoints();
	if (Settings[std::string("RemoveXampHeapAllocExplicitBreakpoints")])
		u.RemoveXampHeapAllocExplicitBreakpoints();
	if (Settings[std::string("EnableXamWatsonOutput")])
		u.EnableXamWatsonOutput();

	if (ns.AccountCreationPassword != "")
		u.SetDefaultAccountPassword(ns.AccountCreationPassword);
	if (Settings[std::string("SetGamertag")] && ns.Gamertag != "")
		u.SetGamertag(ns.Gamertag);
	if (Settings[std::string("SetGoldMembership")])
		u.SetGold();
	if (Settings[std::string("EnableExtraNeighborhoodDrives")])
		u.AddExtraDrives(drl);
	else if (Settings[std::string("EnableHiddenPartitions")])
		u.EnableHiddenDrives();
	if (Settings[std::string("SetAsStartupApplication")])
		u.EnableApplicationStartup();
	u.PatchControllerDisconnect();

	// Return to launcher
	u.LaunchXshell();
}
예제 #12
0
파일: Main.cpp 프로젝트: iSLC/VCMP-Announce
// ------------------------------------------------------------------------------------------------
SMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallbacks* callbacks, PluginInfo* info)
{
    using namespace SMod;
    // Output plug-in header
    puts("");
    OutputMessage("------------------------------------------------------------------");
    OutputMessage("Plug-in: %s", SMOD_NAME);
    OutputMessage("Author: %s", SMOD_AUTHOR);
    OutputMessage("Legal: %s", SMOD_COPYRIGHT);
    OutputMessage("------------------------------------------------------------------");
    puts("");
    // Store server proxies
    _Func = functions;
    _Clbk = callbacks;
    _Info = info;
    // Assign plug-in version
    _Info->pluginVersion = SMOD_VERSION;
    _Info->apiMajorVersion = PLUGIN_API_MAJOR;
    _Info->apiMinorVersion = PLUGIN_API_MINOR;
    // Assign the plug-in name
    snprintf(_Info->name, sizeof(_Info->name), "%s", SMOD_HOST_NAME);
    // Create the configuration loader
    CSimpleIniA conf(false, true, true);
    // Attempt to load the configurations from disk
    const SI_Error ini_ret = conf.LoadFile("announce.ini");
    // See if the configurations could be loaded
    if (ini_ret < 0)
    {
        switch (ini_ret)
        {
            case SI_FAIL:   OutputError("Failed to load the configuration file. Probably invalid");
            case SI_NOMEM:  OutputError("Run out of memory while loading the configuration file");
            case SI_FILE:   OutputError("Failed to load the configuration file: announce.ini");
            default:        OutputError("Failed to load the configuration file for some unforeseen reason");
        }
        // Plug-in failed to load configurations
        return SMOD_FAILURE;
    }
    // See if the plug-in should output verbose information
    g_Verbose = conf.GetBoolValue("Options", "Verbose", false);
    // Attempt to retrieve the list of specified master-servers
    CSimpleIniA::TNamesDepend servers;
    conf.GetAllValues("Servers", "Address", servers);
    // See if any server address was specified
    if (servers.size() <= 0)
    {
        VerboseError("No master-servers specified. No reason to load the plug-in.");
        // No point in loading the plug-in
        return SMOD_FAILURE;
    }
    // Sort the list in it's original order
    servers.sort(CSimpleIniA::Entry::LoadOrder());
    // Process each specified server addresses
    for (const auto & elem : servers)
    {
        // See if there's even something that could resemble a server address
        if (!elem.pItem)
        {
            continue;
        }
        // Attempt to extract URI information from the currently processed address
        URI addr(elem.pItem);
        // See if a valid host could be extracted
        if (addr.mHost.empty())
        {
            VerboseError("Master-server '%s' is an ill formed address", elem.pItem);
        }
        // Construct a server instance using this address
        else
        {
            // Show which master-server is added to the list
            VerboseMessage("Master-server '%s' added to the announce list", addr.Full());
            // Create the server instance
            g_Servers.emplace_back(std::move(addr));
        }
    }
    // See if any server was valid
    if (g_Servers.size() <= 0)
    {
        VerboseError("No master-servers specified. No reason to load the plug-in.");
        // No point in loading the plug-in
        return SMOD_FAILURE;
    }
    // Bind to the server callbacks
    _Clbk->OnServerInitialise       = OnServerInitialise;
    _Clbk->OnServerShutdown         = OnServerShutdown;
    _Clbk->OnServerFrame            = OnServerFrame;
    // Notify that the plug-in was successfully loaded
    VerboseMessage("Successfully loaded %s", SMOD_NAME);
    // Done!
    return SMOD_SUCCESS;
}