Ejemplo n.º 1
0
void set_config_path(libconfig::Config& configuration, const char* config_path)
{
    // Ignore error if unable to read config file.
    try
    {
        // libconfig is ANSI/MBCS on Windows - no Unicode support.
        // This translates the path from Unicode to a "generic" path in
        // ANSI/MBCS, which can result in failures.
        configuration.readFile(config_path);
    }
    catch (const libconfig::FileIOException&) {}
    catch (const libconfig::ParseException&) {}
}
Ejemplo n.º 2
0
  void open_config()
  {
    libconfig::Config cfg;
    try  {
      cfg.readFile(TEST_CONF_FILE.c_str());
    }
    catch(const libconfig::FileIOException &fioex)  {
      ASSERT_TRUE(false);
    }
    catch(const libconfig::ParseException &pex)   {
      ASSERT_TRUE(false);
    }

    const libconfig::Setting& config_root = cfg.getRoot();
    test_regex_manager = new RegexManager(TEMP_DIR, config_root, &test_ip_database, &test_swabber_interface);

  }
Ejemplo n.º 3
0
	// Read the config file. If there is an error, report it and exit.
	int ReadConfig(libconfig::Config& cfg, const char* filename)
	{
		try
		{
			cfg.readFile(filename);
		}
		catch (const libconfig::FileIOException&)
		{
			std::cerr << "I/O error while reading config file: " << filename << std::endl;
			return (EXIT_FAILURE);
		}
		catch (const libconfig::ParseException& pex)
		{
			std::cerr	<< "Parse error at " << pex.getFile() << ":" << pex.getLine()
						<< " - " << pex.getError() << std::endl;
			return (EXIT_FAILURE);
		}
		return EXIT_SUCCESS;
	}