예제 #1
0
static void testConfigDiff(void) {
    VBUCKET_CONFIG_HANDLE vb1 = vbucket_config_parse_file(configPath("config-diff1"));
    VBUCKET_CONFIG_HANDLE vb2 = vbucket_config_parse_file(configPath("config-diff2"));
    VBUCKET_CONFIG_DIFF *diff;
    assert(vb2);

    diff = vbucket_compare(vb1, vb2);
    assert(vb1);
    assert(diff);

    assert(diff->sequence_changed);
    assert(diff->n_vb_changes == 1);
    assert(strcmp(diff->servers_added[0], "server4:11211") == 0);
    assert(diff->servers_added[1] == NULL);
    assert(strcmp(diff->servers_removed[0], "server3:11211") == 0);
    assert(diff->servers_removed[1] == NULL);

    vbucket_free_diff(diff);
    vbucket_config_destroy(vb2);

    vb2 = vbucket_config_parse_file(configPath("config-diff3"));
    assert(vb2);

    diff = vbucket_compare(vb1, vb2);
    assert(diff);

    assert(diff->sequence_changed);
    assert(diff->n_vb_changes == -1);
    assert(diff->servers_added[0] == NULL);
    assert(strcmp(diff->servers_removed[0], "server3:11211") == 0);
    assert(diff->servers_removed[1] == NULL);
}
예제 #2
0
bool
XineEngine::init()
{
   DEBUG_BLOCK

   debug() << "'Bringing joy to small mexican gerbils, a few weeks at a time.'\n";

   m_xine = xine_new();

   if( !m_xine ) {
      KMessageBox::error( 0, i18n("Pana could not initialize xine.") );
      return false;
   }

   #ifdef XINE_SAFE_MODE
   xine_engine_set_param( m_xine, XINE_ENGINE_PARAM_VERBOSITY, 99 );
   #endif

   xine_config_load( m_xine, configPath() );
   debug() << "w00t" << configPath() << endl;

   xine_init( m_xine );

   makeNewStream();

   #ifndef XINE_SAFE_MODE
   startTimer( 200 ); //prunes the scope
   #endif

   return true;
}
예제 #3
0
파일: configfile.cpp 프로젝트: msphn/client
QString ConfigFile::excludeFile(Scope scope) const
{
    // prefer sync-exclude.lst, but if it does not exist, check for
    // exclude.lst for compatibility reasons in the user writeable
    // directories.
    QFileInfo fi;

    switch (scope) {
    case UserScope:
        fi.setFile(configPath(), exclFile);

        if (!fi.isReadable()) {
            fi.setFile(configPath(), QLatin1String("exclude.lst"));
        }
        if (!fi.isReadable()) {
            fi.setFile(configPath(), exclFile);
        }
        return fi.absoluteFilePath();
    case SystemScope:
        return ConfigFile::excludeFileFromSystem();
    }

    ASSERT(false);
    return QString();
}
/*
 * Helper function to retrieve just goal instance names
 */
wbem::framework::instance_names_t* wbem::mem_config::MemoryConfigurationFactory::getGoalInstanceNames(
	const bool onlyUnappliedGoals)
		throw (wbem::framework::Exception)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
	framework::instance_names_t *pNames = new framework::instance_names_t();

	try
	{
		std::string hostName = wbem::server::getHostName();

		// get dimm uids
		std::vector<std::string> uids = wbem::physical_asset::NVDIMMFactory::getManageableDeviceUids();

		for (unsigned int i = 0; i < uids.size(); i++)
		{
			framework::attributes_t keys;
			struct config_goal goal;

			NVM_UID uid;
			uid_copy(uids[i].c_str(), uid);
			int rc;
			if ((rc = nvm_get_config_goal(uid, &goal)) == NVM_SUCCESS)
			{
				if (goal.status != CONFIG_GOAL_STATUS_SUCCESS)
				{
					std::string instanceIdStr(uids[i]);
					instanceIdStr += GOAL_CONFIG;
					keys[INSTANCEID_KEY] = framework::Attribute(instanceIdStr, true);

					framework::ObjectPath configPath(hostName, NVM_NAMESPACE,
						MEMORYCONFIGURATION_CREATIONCLASSNAME, keys);
					pNames->push_back(configPath);
				}
				if ((!onlyUnappliedGoals) &&
					(goal.status == CONFIG_GOAL_STATUS_SUCCESS))
				{
					std::string instanceIdStr(uids[i]);
					instanceIdStr += CURRENT_CONFIG;
					keys[INSTANCEID_KEY] = framework::Attribute(instanceIdStr, true);

					framework::ObjectPath configPath(hostName, NVM_NAMESPACE,
						MEMORYCONFIGURATION_CREATIONCLASSNAME, keys);
					pNames->push_back(configPath);
				}
			}
			else if (rc != NVM_ERR_NOTFOUND)
			{
				throw exception::NvmExceptionLibError(rc);
			}
		}
	}
	catch (framework::Exception &) // clean up and re-throw
	{
		delete pNames;
		throw;
	}

	return pNames;
}
예제 #5
0
//--------------------------------------------------------------------------------
// Make sure our data folder exist, if not establish it
SFBool establishFolders(CConfig& config, const SFString& vers)
{
	SFString configFilename = configPath("ethslurp.conf");

	config.setFilename(configFilename);
	if (SFos::folderExists(cachePath()) && SFos::fileExists(configFilename))
	{
		config.loadFile(configFilename);
		return TRUE;
	}

	// create the main folder
	SFos::mkdir(configPath());
	if (!SFos::folderExists(configPath()))
		return FALSE;

	// create the folder for the slurps
	SFos::mkdir(cachePath());
	if (!SFos::folderExists(cachePath()))
		return FALSE;

	config.SetProfileString("SETTINGS",     "cachePath",         cachePath());
	config.SetProfileString("SETTINGS",     "api_key",           EMPTY);

	config.SetProfileString("DISPLAY_STR",  "fmt_fieldList",     EMPTY);

	config.SetProfileString("DISPLAY_STR",  "fmt_txt_file",      "[{HEADER}]\\n[{RECORDS}]");
	config.SetProfileString("DISPLAY_STR",  "fmt_txt_record",    "[{FIELDS}]\\n");
	config.SetProfileString("DISPLAY_STR",  "fmt_txt_field",     "\\t[{FIELD}]");

	config.SetProfileString("DISPLAY_STR",  "fmt_csv_file",      "[{HEADER}]\\n[{RECORDS}]");
	config.SetProfileString("DISPLAY_STR",  "fmt_csv_record",    "[{FIELDS}]\\n");
	config.SetProfileString("DISPLAY_STR",  "fmt_csv_field",     "[\"{FIELD}\"],");

	config.SetProfileString("DISPLAY_STR",  "fmt_html_file",     "<table>\\n[{HEADER}]\\n[{RECORDS}]</table>\\n");
	config.SetProfileString("DISPLAY_STR",  "fmt_html_record",   "\\t<tr>\\n[{FIELDS}]</tr>\\n");
	config.SetProfileString("DISPLAY_STR",  "fmt_html_field",    "\\t\\t<td>[{FIELD}]</td>\\n");

	config.SetProfileString("DISPLAY_STR",  "fmt_json_file",     "[{RECORDS}]\\n");
	config.SetProfileString("DISPLAY_STR",  "fmt_json_record",   "\\n        {\\n[{FIELDS}]        },");
	config.SetProfileString("DISPLAY_STR",  "fmt_json_field",    "\"[{p:FIELD}]\":\"[{FIELD}]\",");

	config.SetProfileString("DISPLAY_STR",  "fmt_custom_file",	 "file:custom_format_file.html");
	config.SetProfileString("DISPLAY_STR",  "fmt_custom_record", "fmt_html_record");
	config.SetProfileString("DISPLAY_STR",  "fmt_custom_field",	 "fmt_html_field");

	config.writeFile(vers);
	return SFos::fileExists(config.getFilename());
}
예제 #6
0
파일: testapp.c 프로젝트: bcui6611/moxi
static void testWrongServer(const char *fname) {
    VBUCKET_CONFIG_HANDLE vb = vbucket_config_parse_file(configPath(fname));
    if (vb == NULL) {
        fprintf(stderr, "vbucket_config_parse_file error: %s\n",
                vbucket_get_error());
        abort();
    }

    /* Starts at 0 */
    assert(vbucket_get_master(vb, 0) == 0);
    /* Does not change when I told it I found the wrong thing */
    assert(vbucket_found_incorrect_master(vb, 0, 1) == 0);
    assert(vbucket_get_master(vb, 0) == 0);
    /* Does change if I tell it I got the right thing and it was wrong. */
    assert(vbucket_found_incorrect_master(vb, 0, 0) == 1);
    assert(vbucket_get_master(vb, 0) == 1);
    /* ...and again */
    assert(vbucket_found_incorrect_master(vb, 0, 1) == 2);
    assert(vbucket_get_master(vb, 0) == 2);
    /* ...and then wraps */
    assert(vbucket_found_incorrect_master(vb, 0, 2) == 0);
    assert(vbucket_get_master(vb, 0) == 0);

    vbucket_config_destroy(vb);
}
예제 #7
0
int main(int argc, char *argv[]) {

	// Start: Setting up memory profiling

	/* Set the GMemVTable to the default table. This needs to be called before
	* any other call to a GLib function. */
	//g_mem_set_vtable (glib_mem_profiler_table);

	/* Call g_mem_profile() when the application exits. */
	//g_atexit (g_mem_profile);

	// END: Setting up memory profiling


	std::string configPath(configBasePath);
	configPath.append("/").append("MainWindow");

	Gtk::Main kit(argc, argv);

	jobManWindow window;

	window.loadServices();

	window.loadPosition(configPath);

	Gtk::Main::run(window);

	window.savePosition(configPath);

	return EXIT_SUCCESS;
}
예제 #8
0
static void testWrongNumVbuckets(const char *fname) {
    VBUCKET_CONFIG_HANDLE vb = vbucket_config_create();
    assert(vb != NULL);
    assert(vbucket_config_parse(vb, LIBVBUCKET_SOURCE_FILE, configPath(fname)) != 0);
    assert(strcmp(vbucket_get_error_message(vb), "Number of vBuckets must be a power of two > 0 and <= 65536") == 0);
    vbucket_config_destroy(vb);
}
예제 #9
0
파일: Config.cpp 프로젝트: Maiven/bwapi
void WriteConfig(const char *pszKey, const char *pszItem, const std::string& value)
{
  // avoid writing unless the value is actually different, because writing causes
  // an annoying popup when having the file open in e.g. notepad++
  if (LoadConfigStringFromFile(pszKey, pszItem, "_NULL") != value)
    WritePrivateProfileStringA(pszKey, pszItem, value.c_str(), configPath().c_str());
}
예제 #10
0
bool Application::InitFileSystem()
{
	///set working directory to where the binary is.
	auto workingDirectory = GetContext().GetFileSystem()->GetWorkingDirectory();
	GetContext().GetFileSystem()->SetWriteDirectory(workingDirectory);

	///create directory for application
	auto applicationDirectory = Path(GetApplicationId());

	if (!GetContext().GetFileSystem()->CreateDirectory(applicationDirectory))
	{
		printf("%s\n", "Failed to create directory for current application.");
		exit(-1);
	}

	Path appendedPath = Path(workingDirectory).append(applicationDirectory.generic_string());
	GetContext().GetFileSystem()->SetWriteDirectory(appendedPath);
	GetContext().GetFileSystem()->AddSearchDirectory(appendedPath);


	auto & fileSystemVars = GetContext().GetApplicationSettingsManager()->GetGroup("filesystem");

	Path logPath(fileSystemVars.GetVar("log_path").ValueS());
	Path configPath(fileSystemVars.GetVar("config_path").ValueS());

	GetContext().GetFileSystem()->CreateDirectory(logPath);
	GetContext().GetFileSystem()->CreateDirectory(configPath);

	return true;
}
예제 #11
0
CuteChessCoreApplication::CuteChessCoreApplication(int& argc, char* argv[])
	: QCoreApplication(argc, argv),
	  m_engineManager(0),
	  m_gameManager(0)
{
	Mersenne::initialize(QTime(0,0,0).secsTo(QTime::currentTime()));

	QCoreApplication::setOrganizationName(QLatin1String("cutechess"));
	QCoreApplication::setOrganizationDomain(QLatin1String("cutechess.org"));
	QCoreApplication::setApplicationName(QLatin1String("cutechess"));

	// Use Ini format on all platforms
	QSettings::setDefaultFormat(QSettings::IniFormat);

	#if QT_VERSION >= 0x050000
	qInstallMessageHandler(CuteChessCoreApplication::messageHandler);
	#else
	qInstallMsgHandler(CuteChessCoreApplication::messageHandler);
	#endif

	// Load the engines
	QString configFile("engines.json");
	if (!QFile::exists(configFile))
		configFile = configPath() + "/" + configFile;
	engineManager()->loadEngines(configFile);
}
예제 #12
0
XineEngine::~XineEngine()
{
    // Wait until the fader thread is done
    if( s_fader ) {
        m_stopFader = true;
        s_fader->resume(); // safety call if the engine is in the pause state
        s_fader->wait();
    }

    delete s_fader;
    delete s_outfader;

    if( PanaConfig::fadeoutOnExit() ) {
        bool terminateFader = false;
        fadeOut( PanaConfig::fadeoutLength(), &terminateFader, true ); // true == exiting
    }

    if( m_xine )       xine_config_save( m_xine, configPath() );

    if( m_stream )     xine_close( m_stream );
    if( m_eventQueue ) xine_event_dispose_queue( m_eventQueue );
    if( m_stream )     xine_dispose( m_stream );
    if( m_audioPort )  xine_close_audio_driver( m_xine, m_audioPort );
    if( m_post )       xine_post_dispose( m_xine, m_post );
    if( m_xine )       xine_exit( m_xine );

    debug() << "xine closed\n";

    debug() << "Scope statistics:\n"
            << "  Average list size: " << Log::bufferCount / Log::scopeCallCount << endl
            << "  Buffer failure:    " << double(Log::noSuitableBuffer*100) / Log::scopeCallCount << "%\n";
}
예제 #13
0
    /**
    *  Config format, (e.g.):
    *
    *       basePath    /data/blt/
    *       metaName    metadb
    *       openMode    rw
    *       pageBits    15
    *       poolSize    4096
    *       segBits     5
    *       hashSize    4096
    */
    Status BLTreeEngine::parseConfig(
        const std::string& path,    // expected to include trailing '/'
        BTLConfig* conf )
    {
        std::string configPath( path+"blt.conf" );
        std::ifstream in( configPath.c_str(), ios::in );
        if (!in.good()) {
            return Status( ErrorCodes::InternalError, "BLTree config file open error" );
        }
        std::string line;
        while (!in.eof()) {
            std::getline( in, line );
            if (0==line.length()) continue;
            if ('#'==line[0]) continue;
            std::size_t n = line.find( '\t' );
            if (std::string::npos == n) continue;

            std::string key = line.substr( 0, n );
            std::string val = line.substr( n+1 );

                 if ("metaName"==key) conf->_metaName = path+val;
            else if ("openMode"==key) conf->_openMode = val;
            else if ("pageBits"==key) conf->_pageBits = strtoul( val.c_str(), NULL, 10 );
            else if ("poolSize"==key) conf->_poolSize = strtoul( val.c_str(), NULL, 10 );
            else if ("segBits" ==key) conf->_segBits  = strtoul( val.c_str(), NULL, 10 );
            else if ("hashSize"==key) conf->_hashSize = strtoul( val.c_str(), NULL, 10 );
        }
    }
예제 #14
0
QString MirallConfigFile::configFile() const
{
    if( qApp->applicationName().isEmpty() ) {
        qApp->setApplicationName( Theme::instance()->appNameGUI() );
    }
    return configPath() + Theme::instance()->configFileName();
}
예제 #15
0
파일: Config.cpp 프로젝트: Maiven/bwapi
int LoadConfigInt(const char *pszKey, const char *pszItem, const int iDefault)
{
  std::string envKey = envKeyName(pszKey, pszItem);
  if (char* v = std::getenv(envKey.c_str()))
    return std::stoi(v);
  else
    return GetPrivateProfileIntA(pszKey, pszItem, iDefault, configPath().c_str());
}
예제 #16
0
static void testConfigDiffKetamaSame(void) {
    VBUCKET_CONFIG_HANDLE vb1 = vbucket_config_parse_file(configPath("ketama-eight-nodes"));
    VBUCKET_CONFIG_HANDLE vb2 = vbucket_config_parse_file(configPath("ketama-ordered-eight-nodes"));
    VBUCKET_CONFIG_DIFF *diff;
    assert(vb1);
    assert(vb2);
    diff = vbucket_compare(vb1, vb2);
    assert(diff);

    assert(diff->sequence_changed == 0);
    assert(diff->n_vb_changes == 0);
    assert(diff->servers_added[0] == NULL);
    assert(diff->servers_removed[0] == NULL);

    vbucket_free_diff(diff);
    vbucket_config_destroy(vb1);
    vbucket_config_destroy(vb2);
}
/*
 * Return the object paths for the MemoryConfiguration Class.
 */
wbem::framework::instance_names_t* wbem::mem_config::MemoryConfigurationFactory::getInstanceNames()
		throw (wbem::framework::Exception)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);

	framework::instance_names_t *pNames = new framework::instance_names_t();
	try
	{
		lib_interface::NvmApi *pApi = lib_interface::NvmApi::getApi();
		std::string hostName = pApi->getHostName();

		std::vector<struct pool> pools;
		pApi->getPools(pools);

		std::vector<std::string> uids = wbem::physical_asset::NVDIMMFactory::getManageableDeviceUids();

		for (unsigned int i = 0; i < uids.size(); i++)
		{
			framework::attributes_t keys;

			NVM_UID uid;
			uid_copy(uids[i].c_str(), uid);

			if (MemoryConfigurationServiceFactory::dimmHasGoal(uid))
			{
				std::string instanceIdStr(uids[i]);
				instanceIdStr += GOAL_CONFIG;
				keys[INSTANCEID_KEY] = framework::Attribute(instanceIdStr, true);

				framework::ObjectPath configPath(hostName, NVM_NAMESPACE,
							MEMORYCONFIGURATION_CREATIONCLASSNAME, keys);
				pNames->push_back(configPath);
			}

			if (dimmIsInAPool(uid, pools))
			{
				std::string instanceIdStr(uids[i]);
				instanceIdStr += CURRENT_CONFIG;
				keys[INSTANCEID_KEY] = framework::Attribute(instanceIdStr, true);

				framework::ObjectPath goalPath(hostName, NVM_NAMESPACE,
						MEMORYCONFIGURATION_CREATIONCLASSNAME, keys);
				pNames->push_back(goalPath);
			}
		}
	}
	catch (framework::Exception &) // clean up and re-throw
	{
		delete pNames;
		throw;
	}

	return pNames;
}
예제 #18
0
FileSystem::FileSystem(const char *rootPath) : ready(false), S(0), N(0), path(rootPath), blocks(0) {
    if(path[path.size()-1] != '/') path.append("/");
    std::string config = configPath(rootPath);
    if(!config.empty()) {
        std::ifstream configFile(config.c_str());
        if(!configFile.is_open()) {
            std::cout << "ERROR: Unable to init filesystem: unable to open config file" << std::endl;
            return;
        }
        configFile >> S >> N;
        configFile.close();
    } else {
예제 #19
0
QString MirallConfigFile::excludeFile(Scope scope) const
{
    // prefer sync-exclude.lst, but if it does not exist, check for
    // exclude.lst for compatibility reasons in the user writeable
    // directories.
    const QString exclFile("sync-exclude.lst");
    QFileInfo fi;

    if (scope != SystemScope) {
        fi.setFile( configPath(), exclFile );

        if( ! fi.isReadable() ) {
            fi.setFile( configPath(), QLatin1String("exclude.lst") );
        }
        if( ! fi.isReadable() ) {
            fi.setFile( configPath(), exclFile );
        }
    }

    if (scope != UserScope) {
        // Check alternative places...
        if( ! fi.isReadable() ) {
#ifdef Q_OS_WIN
            fi.setFile( QCoreApplication::applicationDirPath(), exclFile );
#endif
#ifdef Q_OS_UNIX
            fi.setFile( QString( SYSCONFDIR "/%1").arg(Theme::instance()->appName()), exclFile );
#endif
#ifdef Q_OS_MAC
            // exec path is inside the bundle
            fi.setFile( QCoreApplication::applicationDirPath(),
                        QLatin1String("../Resources/") + exclFile );
#endif
        }
    }
    qDebug() << "  ==> returning exclude file path: " << fi.absoluteFilePath();
    return fi.absoluteFilePath();
    qDebug() << "EMPTY exclude file path!";
    return QString::null;
}
예제 #20
0
QString MirallConfigFile::configFile() const
{
    if( qApp->applicationName().isEmpty() ) {
        qApp->setApplicationName( Theme::instance()->appNameGUI() );
    }
    QString file = configPath() + Theme::instance()->configFileName();
    if( !_customHandle.isEmpty() ) {
        file.append( QLatin1Char('_'));
        file.append( _customHandle );
        qDebug() << __PRETTY_FUNCTION__ << "  OO Custom config file in use: " << file;
    }
    return file;
}
예제 #21
0
CuteChessApplication::CuteChessApplication(int& argc, char* argv[])
	: QApplication(argc, argv),
	  m_engineManager(nullptr),
	  m_gameManager(nullptr),
	  m_gameDatabaseManager(nullptr),
	  m_gameDatabaseDialog(nullptr)
{
	Mersenne::initialize(QTime(0,0,0).msecsTo(QTime::currentTime()));

	// Set the application icon
	QIcon icon;
	icon.addFile(":/icons/cutechess_512x512.png");
	icon.addFile(":/icons/cutechess_256x256.png");
	icon.addFile(":/icons/cutechess_128x128.png");
	icon.addFile(":/icons/cutechess_64x64.png");
	icon.addFile(":/icons/cutechess_32x32.png");
	icon.addFile(":/icons/cutechess_24x24.png");
	icon.addFile(":/icons/cutechess_16x16.png");
	setWindowIcon(icon);

	setQuitOnLastWindowClosed(false);

	QCoreApplication::setOrganizationName("cutechess");
	QCoreApplication::setOrganizationDomain("cutechess.org");
	QCoreApplication::setApplicationName("cutechess");
	QCoreApplication::setApplicationVersion(CUTECHESS_VERSION);

	// Use Ini format on all platforms
	QSettings::setDefaultFormat(QSettings::IniFormat);

	// Load the engines
	engineManager()->loadEngines(configPath() + QLatin1String("/engines.json"));

	// Read the game database state
	gameDatabaseManager()->readState(configPath() + QLatin1String("/gamedb.bin"));

	connect(this, SIGNAL(lastWindowClosed()), this, SLOT(onLastWindowClosed()));
	connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
}
예제 #22
0
QString MirallConfigFile::configFile() const
{
    if( qApp->applicationName().isEmpty() ) {
        qApp->setApplicationName( Theme::instance()->appNameGUI() );
    }
    QString dir = configPath() + Theme::instance()->configFileName();
    if( !_customHandle.isEmpty() ) {
        dir.append( QLatin1Char('_'));
        dir.append( _customHandle );
        qDebug() << "  OO Custom config file in use: " << dir;
    }
    return dir;
}
예제 #23
0
static void testConfigUserPassword(void) {
    VBUCKET_CONFIG_HANDLE vb1;
    VBUCKET_CONFIG_HANDLE vb2;
    VBUCKET_CONFIG_DIFF *diff;

    vb1 = vbucket_config_parse_file(configPath("config-user-password1"));
    assert(vb1);
    assert(strcmp(vbucket_config_get_user(vb1), "theUser") == 0);
    assert(strcmp(vbucket_config_get_password(vb1), "thePassword") == 0);

    vb2 = vbucket_config_parse_file(configPath("config-user-password2"));
    assert(vb2);
    assert(strcmp(vbucket_config_get_user(vb2), "theUserIsDifferent") == 0);
    assert(strcmp(vbucket_config_get_password(vb2), "thePasswordIsDifferent") == 0);

    diff = vbucket_compare(vb1, vb2);
    assert(diff);

    assert(diff->sequence_changed);
    assert(diff->n_vb_changes == 0);
    assert(diff->servers_added[0] == NULL);
    assert(diff->servers_removed[0] == NULL);

    vbucket_free_diff(diff);

    diff = vbucket_compare(vb1, vb1);
    assert(diff);

    assert(diff->sequence_changed == 0);
    assert(diff->n_vb_changes == 0);
    assert(diff->servers_added[0] == NULL);
    assert(diff->servers_removed[0] == NULL);

    vbucket_free_diff(diff);

    vbucket_config_destroy(vb1);
    vbucket_config_destroy(vb2);
}
예제 #24
0
static void testConfigCouchApiBase(void)
{
    VBUCKET_CONFIG_HANDLE vb = vbucket_config_parse_file(configPath("config-couch-api-base"));
    assert(vb);
    assert(strcmp(vbucket_config_get_couch_api_base(vb, 0), "http://192.168.2.123:9500/default") == 0);
    assert(strcmp(vbucket_config_get_couch_api_base(vb, 1), "http://192.168.2.123:9501/default") == 0);
    assert(strcmp(vbucket_config_get_couch_api_base(vb, 2), "http://192.168.2.123:9502/default") == 0);
    assert(strcmp(vbucket_config_get_rest_api_server(vb, 0), "192.168.2.123:9000") == 0);
    assert(strcmp(vbucket_config_get_rest_api_server(vb, 1), "192.168.2.123:9001") == 0);
    assert(strcmp(vbucket_config_get_rest_api_server(vb, 2), "192.168.2.123:9002") == 0);
    assert(strcmp(vbucket_config_get_server(vb, 0), "192.168.2.123:12000") == 0);
    assert(strcmp(vbucket_config_get_server(vb, 1), "192.168.2.123:12002") == 0);
    assert(strcmp(vbucket_config_get_server(vb, 2), "192.168.2.123:12004") == 0);
}
예제 #25
0
bool Application::LoadConfig()
{
	auto & fileSystemVars = GetContext().GetApplicationSettingsManager()->GetGroup("filesystem");

	Path logPath(fileSystemVars.GetVar("log_path").ValueS());
	Path configPath(fileSystemVars.GetVar("config_path").ValueS());

	///REFACTOR: Magic strings
	Path configFilePath = configPath;
	configFilePath.append("config.cfg");
	if (!GetContext().GetApplicationSettingsManager()->LoadSettings(configFilePath))
		GetContext().GetApplicationSettingsManager()->WriteSettings(configFilePath);

	return true;
}
예제 #26
0
파일: testapp.c 프로젝트: bcui6611/moxi
static void testConfig(const char *fname) {
    int whoops = 0;
    const struct key_st *k;
    int i = 0;

    VBUCKET_CONFIG_HANDLE vb = vbucket_config_parse_file(configPath(fname));
    if (vb == NULL) {
        fprintf(stderr, "vbucket_config_parse_file error: %s\n",
                vbucket_get_error());
        abort();
    }

    while ((k = &keys[i++])->key != NULL) {
        int id = vbucket_get_vbucket_by_key(vb, k->key, strlen(k->key));
        if (id != k->vbucket) {
            fprintf(stderr, "Expected vbucket %d for key '%s' but got %d\n",
                    k->vbucket, k->key, id);
            whoops = 1;
        }
    }

    if (whoops) {
        abort();
    }

    assert(vbucket_config_get_num_servers(vb) == 3 || vbucket_config_get_num_servers(vb) == 4);
    assert(vbucket_config_get_num_replicas(vb) == 2);

    for (i = 0; i < 3; ++i) {
        assert(strcmp(vbucket_config_get_server(vb, i), servers[i]) == 0);
    }

    for (i = 0; i < 4; ++i) {
        assert(vbucket_get_master(vb, i) == vbuckets[i].master);
        assert(vbucket_get_replica(vb, i, 0) == vbuckets[i].replicas[0]);
        assert(vbucket_get_replica(vb, i, 1) == vbuckets[i].replicas[1]);
    }

    assert(vbucket_config_get_user(vb) == NULL);
    assert(vbucket_config_get_password(vb) == NULL);

    vbucket_config_destroy(vb);
}
예제 #27
0
XineEngine::~XineEngine()
{
    // Wait until the fader thread is done
    if( s_fader ) {
        m_stopFader = true;
        s_fader->wait();
        delete s_fader;
    }

    // NOTE The fadeout gets stuck when the EQ is active, so we skip it then
    if( !m_equalizerEnabled && m_stream && state() == Engine::Playing )
    {
        const int volume = xine_get_param( m_stream, XINE_PARAM_AUDIO_AMP_LEVEL );
        const double D = 300000 * std::pow( (double)volume, -0.4951 );

        debug() << "Sleeping: " << D << ", " << volume << endl;

        for( int v = volume - 1; v >= 1; v-- ) {
            xine_set_param( m_stream, XINE_PARAM_AUDIO_AMP_LEVEL, v );

            const int sleep = int(D * (-log10( v + 1 ) + 2));

            ::usleep( sleep );
        }
        xine_stop( m_stream );
    }

    if( m_xine )       xine_config_save( m_xine, configPath() );

    if( m_stream )     xine_close( m_stream );
    if( m_eventQueue ) xine_event_dispose_queue( m_eventQueue );
    if( m_stream )     xine_dispose( m_stream );
    if( m_audioPort )  xine_close_audio_driver( m_xine, m_audioPort );
    if( m_post )       xine_post_dispose( m_xine, m_post );
    if( m_xine )       xine_exit( m_xine );

    debug() << "xine closed\n";

    debug() << "Scope statistics:\n"
            << "  Average list size: " << Log::bufferCount / Log::scopeCallCount << endl
            << "  Buffer failure:    " << double(Log::noSuitableBuffer*100) / Log::scopeCallCount << "%\n";
}
예제 #28
0
파일: main.cpp 프로젝트: ze-phyr-us/abacus
int main(int argc, char** argv) {
	if (argc > 2) {
		std::cerr << "Usage: " << argv[0] << " [config file]\n";
		return 1;
	}

	try {
		Vita::string configPath(argc == 2 ? argv[1] : DEFAULT_CONFIG);

		Vita::config config;
		if (!config.loadFile(configPath)) {
			throw Exception(Exception::CONFIG_NOT_FOUND, "Failed to load configuration.");
		}

		if (config.get("daemonize").convert<bool>()) {
			daemonize();
		}

		Listener listener(config.get("device"));
		database = new Db(config.get("database"));
		unsigned int commitPeriod = config.get("commitPeriod").convert<unsigned int>();

		signal(SIGINT, terminate);
		signal(SIGTERM, terminate);

		while (THE_WORLD_IS_NOT_COMING_TO_AN_END) {
			listener.read(config.get("countRepeats").convert<bool>());
			counter++;

			if (commitPeriod > 0 && counter % commitPeriod == 0) {
				database->commit(counter);
				counter = 0;
			}
		}
	}
	catch (Exception e) {
		delete database;
		std::cerr << e.getStrError() << std::endl;
		return e.getCode();
	}
}
예제 #29
0
    void saveSettings()
    {
        QSettings settings(configPath(), QSettings::IniFormat);

        settings.setValue("deviceName", inputDeviceName);
        settings.setValue("outputLocation", outputLocation);
        settings.setValue("operationMode",
                          operationMode == Settings::WhiteList?
                              "whitelist":
                              "blacklist");

        settings.beginGroup("encoder");
            settings.setValue("sampleRate", sampleRate);
            settings.setValue("sampleSize", sampleSize);
            settings.setValue("compression", compression);
        settings.endGroup();

        settings.beginGroup("ui");
            settings.setValue("locale", locale);
        settings.endGroup();
    }
예제 #30
0
static void testWrongServerFFT(const char *fname) {
    VBUCKET_CONFIG_HANDLE vb = vbucket_config_parse_file(configPath(fname));
    int rv = 0;
    int nvb = 0;
    int i = 0;

    if (vb == NULL) {
        fprintf(stderr, "vbucket_config_parse_file error: %s\n", vbucket_get_error());
        abort();
    }

    /* found incorrect master should not be the same as get master now */
    nvb = vbucket_config_get_num_vbuckets(vb);
    for (i = 0; i < nvb; i++) {
        rv = vbucket_get_master(vb, i);
        assert(rv != vbucket_found_incorrect_master(vb, i, rv));
    }
    /* the ideal test case should be that we check that the vbucket */
    /* and the fvbucket map are identical at this point. TODO untill */
    /* we have a vbucketlib function that diffs vbuckets and fvbuckets */
    vbucket_config_destroy(vb);
}