コード例 #1
0
ファイル: dmc.cpp プロジェクト: mixxit/solinia
CDynamicMapClient::CDynamicMapClient(const std::string &/* eid */, NLNET::IModuleSocket * clientGateway, lua_State *luaState)
{

	_ComLua = 0;
		//new CComLuaModule(this, luaState);

	_ActionHistoric.setDMC(this);

	IModuleManager &mm = IModuleManager::getInstance();


	//Edition
	IModule *clientEditionModuleInterface = mm.createModule("ClientEditionModule", "ClientEditionModule", "");

	nlassert(clientEditionModuleInterface != NULL);

	_EditionModule = safe_cast<CClientEditionModule* >(clientEditionModuleInterface);

	_EditionModule->init(clientGateway, this);


	_FrameActionsRecorder = new CFrameActionsRecorder(*this);

	if (!luaState)
	{
		loadFeatures(); // NB nico : when used by the client,  features are loaded externally for now ...
	}

	_InstantFeedBackFlag = false;

}
コード例 #2
0
ファイル: JCHaarFinder.cpp プロジェクト: Daforze/faceRecog
JCHaarFinder::JCHaarFinder()
{
    //ctor
    iImage = new ofImage();

    defaultFeature = "haarcascade_frontalface_default.xml";
    loadFeatures(defaultFeature);
    
}
コード例 #3
0
ファイル: testsvdpp.c プロジェクト: Aakash282/cs156
int main(){
	// Load Movie data
	loadMovieData("../../netflix/um/qual.dta");
	//loadMovieData("../stats/probe.dta");
	printf("test %d\n", movie_data[20]);
	// printf("test %f %f %f %f\n", userOffset[5], userOffset[num_users - 1], movieOffset[5], movieOffset[num_movies - 1]);
	
	// Set up offsets
	userOffset = calloc(num_users, sizeof(float));
	movieOffset = calloc(num_movies, sizeof(float));
	if (userOffset == NULL || movieOffset == NULL) {
		printf("Malloc failed\n");
		return -1;
	}


	// Set up feature arrays for user and movies
	userFeatures = calloc(num_users, sizeof(float *));
	movieFeatures = calloc(num_movies, sizeof(float *));
	implicitFeatures = calloc(num_movies, sizeof(float *));
	userImplicitData = calloc(num_users*2, sizeof(float));
	if (userFeatures == NULL || movieFeatures == NULL || userImplicitData == NULL) {
		printf("Malloc failed\n");
		return -1;
	}


	// Load offsets
	loadData("features/f220_e050/user_offset.dta", userOffset);
	loadData("features/f220_e050/movie_offset.dta", movieOffset);

	
	// Load user implicit data
	loadUserImplicit("../stats/user_implicit_2.dta", userImplicitData);
	// Load 
	initializeImplicitMovies("../../implicit/user_implicit_movies.dta");

	// Load featuress
	loadFeatures("features/f220_e050/user_features.dta", num_users, userFeatures);
	loadFeatures("features/f220_e050/movie_features.dta", num_movies, movieFeatures);
	loadFeatures("features/f220_e050/implicit_features.dta", num_movies, implicitFeatures);
	printf("Test %f %f\n", userFeatures[1][num_features - 1], userFeatures[num_users-1][num_features-1]);

	predictions = calloc(num_lines, sizeof(float));
	if (predictions == NULL) {
		return -1;
	}

	printf("--------------Predicting --------------\n");
	int user, movie, line_number;
	int count = 0;
	float n = userImplicitData[1*2 + 1]; // get n for first user
	float feature_c;
	int temp = 0;
	for (int j = 0; j < num_lines; j++) {
		line_number = j * 2;
		user = movie_data[line_number];
		movie = movie_data[line_number + 1];
		if (temp != user) {
			n = userImplicitData[user*2 + 1];
			getImplicitC(user, n);
			temp = user;
		}
		feature_c = 0;
		for (int i = 0; i < num_features; i++) {
			feature_c += (userFeatures[user][i] + implicitC[i])* movieFeatures[movie][i];
		}
		predictions[count] = clipScore(GLOBAL_AVG + userOffset[user] + movieOffset[movie] + feature_c);
		count++;
	}
	

	printf("-----------Saving results-----------\n");
	saveResults("results/um_test_f220_e050.dta");
	
	free(userOffset);
	free(movieOffset);
	free(movie_data);
	return 0;
}
コード例 #4
0
ファイル: testsvdtime.c プロジェクト: Aakash282/cs156
int main(){
	// Load Movie data
	loadMovieData("../../netflix/um/all_ut.dta");
	//loadMovieData("../stats/probe.dta");
	printf("test %d\n", movie_data[20]);
	// printf("test %f %f %f %f\n", userOffset[5], userOffset[num_users - 1], movieOffset[5], movieOffset[num_movies - 1]);
	
	// Set up offsets
	userOffset = calloc(num_users, sizeof(float));
	movieOffset = calloc(num_movies, sizeof(float));
	
	if (userOffset == NULL || movieOffset == NULL) {
		printf("Malloc failed\n");
		return -1;
	}


	// Set up feature arrays for user and movies
	userFeatures = calloc(num_users, sizeof(float *));
	movieFeatures = calloc(num_movies, sizeof(float *));
	implicitFeatures = calloc(num_movies, sizeof(float *));
	userImplicitData = calloc(num_users*2, sizeof(float));
	itemBinBias = calloc(num_movies, sizeof(float *));
	userAlphas = calloc(num_users, sizeof(float));
	if (userFeatures == NULL || movieFeatures == NULL || userImplicitData == NULL) {
		printf("Malloc failed\n");
		return -1;
	}


	// Load offsets
	loadData("features/f050_e030/user_offset.dta", userOffset);
	loadData("features/f050_e030/movie_offset.dta", movieOffset);
	loadData("features/f050_e030/user_alphas.dta", userAlphas);
	// Load item bin bias
	loadFileAvg("../stats/user_date_avg.dta");
	loadUserDev("../stats/user_date_dev.dta", "features/f050_e030/user_time_bias.dta");
	
	
	// Load user implicit data
	loadUserImplicit("../stats/user_implicit_2.dta", userImplicitData);
	// Load 
	initializeImplicitMovies("../../implicit/user_implicit_movies.dta");

	// Load featuress
	loadFeatures("features/f050_e030/user_features.dta", num_users, num_features, userFeatures);
	loadFeatures("features/f050_e030/movie_features.dta", num_movies, num_features, movieFeatures);
	loadFeatures("features/f050_e030/implicit_features.dta", num_movies, num_features, implicitFeatures);
	loadFeatures("features/f050_e030/item_bin_bias.dta", num_movies, num_time_bins, itemBinBias);
	printf("Test %f %f\n", userFeatures[1][num_features - 1], userFeatures[num_users-1][num_features-1]);

	predictions = calloc(num_lines*3, sizeof(float));
	if (predictions == NULL) {
		return -1;
	}

	printf("--------------Predicting --------------\n");
	int user, movie, line_number, item_bin, date, rating;
	int count = 0;
	int user_date_count = -1;
	float n = userImplicitData[1*2 + 1]; // get n for first user
	float feature_c, alpha, dev, user_time_b;
	int temp = 0;
	int date_temp = 0;
	for (unsigned int j = 0; j < total_size; j++) {
			line_number = j * 4;
			user = movie_data[line_number];
			movie = movie_data[line_number  + 1];
			date = movie_data[line_number   + 2];
			rating = movie_data[line_number + 3];
			if (temp != user) {
				// update implict feature for previous user
				n = userImplicitData[user*2 + 1];
				getImplicitC(user, n);
				temp = user;
				date_temp = 0;
				user_date_count = -1;
			} 
			// Update different date count
			if (date != date_temp) {
				//printf("date %d ", date);
				user_date_count ++;
				date_temp = date;
			}
			// if not in test set continue
			if (rating != 0) {
				continue;
			}

			// Get contribution from each feature
			feature_c = 0;
			for (unsigned int i = 0; i < num_features; i++) {
				feature_c += (userFeatures[user][i] + implicitC[i])* movieFeatures[movie][i];
			}
			//printf("user %d movie %d date %d user_date_count %d rating %d total dates %d\n",
			//	user, movie, date, user_date_count, rating, (int) timeAvg[user]);
			// Get user time bias and alpha
			alpha = userAlphas[user];
			dev = userDev[user][(user_date_count)*2];
			user_time_b = userDev[user][(user_date_count)*2 +1];
			// Get item bin number and bias
			item_bin = (int) floor(date / 75.0);
			predictions[count] = user;
			predictions[count + 1] = movie;
			predictions[count + 2] = (GLOBAL_AVG + userOffset[user] + movieOffset[movie] 
				+ itemBinBias[movie][item_bin] + alpha*dev + user_time_b + feature_c);
			count += 3;
		}
	

	printf("-----------Saving results-----------\n");
	saveResults("results/ut_test_f050_e030.dta");

	free(userOffset);
	free(movieOffset);
	free(movie_data);
	return 0;
}
コード例 #5
0
int ObjectRecognition::find(Mat _image)
{
	//-----------------------------------------------------------
	//  image = imread( "../../../New_modules1/image_014.jpeg");
	//  image = imread( "../../../TestDATA/snap-unknown-20120901-203157-1.jpeg" );
	//  imshow( "mywindow", image );
	//  waitKey(0);


	//      imshow("Capure_Image", image);
	//      waitKey();

	//-----------------Extract the features----------------------------
	//cout<< ss.str() << endl;
	double t = (double)cvGetTickCount(); 
	loadFeatures(_image, keypoints, features, descriptors);

	//-----------------Query the Database----------------------------
	//cout <<endl<<"-----------------Start to QUERY-------------------" <<endl;
	queryDatabase(features, db, ret, ret_num);
	//testAP(ret); 
	//cout << ret <<endl;
	//t = (double)cvGetTickCount()-t;
	//       cout << "voc tree time = " <<  t/((double)cvGetTickFrequency()*1000)<< endl;
	//if (ret[0].Score<0.6 && ret[0].Score>0.24)
	{
		cout << "        Start to Homography   " <<endl;
		initModule_nonfree();
		double HomographyT = (double)cvGetTickCount();
		checkHomography( _image, keypoints, descriptors, ret);
		HomographyT = (double)cvGetTickCount()-HomographyT;
		cout << "Homography time (ms) = " <<  HomographyT/((double)cvGetTickFrequency()*1000)<< endl;
		sort(ret.begin(), ret.end());
		//       if ((ranking/(OBJ_IMG+1))==(ret[0].Id/(OBJ_IMG+1)))
		// 	AP+=1;

		 	//cout<<ret<<endl<<endl;
	}


	int dis_id=0;
	bool ret_correct_flag = false;
	int ret_end = ret.size()-1;
	if (ret[ret_end].Score>ret[0].Score) 
	{
		if(ret[ret_end].Id/10==ret[ret_end-1].Id/10)
		{
			dis_id = ret_end;
			ret_correct_flag = true;
		}
	}
	else 
	{
		if (ret[1].Id/10==ret[0].Id/10)
		{
			dis_id = 0;
			ret_correct_flag = true;
		}
	}


	if ((ret[dis_id].Score>=0.6) && ret_correct_flag)
	{

		cout<< "-----Object "<< ret[dis_id].Id << " is detected!!!---------------"<<endl;
		return ret[dis_id].Id;
		// 	stringstream ss;
		// 	ss<<"../../../New_modules1/image_";
		// 	if(ret[dis_id].Id<10) 			ss<< "00"<<ret[dis_id].Id<< ".jpeg";
		// 	if(ret[dis_id].Id>=10&&ret[dis_id].Id<100) 	ss<< "0"<<ret[dis_id].Id<<".jpeg";
		// 	if(ret[dis_id].Id>=100	)		ss<< ret[dis_id].Id<<".jpeg";
		// 	cout<< ss.str()<< endl;
		// 	Mat r=imread(ss.str());
		// // 	namedWindow(ss.str());
		// // 	imshow(ss.str(), r);
		// // 	moveWindow(ss.str(), 650, 0);
		// 	imshow("result", r);
		//          waitKey(0);
	}
	else
	{
		cout<< "No object!!!!!"<<endl;
		return 255;

	}
	//cout<<"AP is : " << AP <<endl<<endl<<endl;
	//testAP(ret);

	//------------------------------------------------------------------

	//        waitKey(0);
	//       if ( (waitKey(1) & 255) == 27 ) break;

	return 255;
}
コード例 #6
0
ファイル: sp_main_test.cpp プロジェクト: med3590/SPFinal
/****
 * The purpose of the test is to compare the features before and after the saving.
 */
bool main_saveLoad()
{
	LoadedFeatures loadedFeatures = NULL;
	LoadedFeatures features = NULL;

	int numOfImages = 0;
	int numOfFeatures = 0;
	int numOfCoords = 0;

	SPPoint * orgArr = NULL;
	SPPoint pointOrg = NULL;

	SPPoint * loadedArr = NULL;
	SPPoint pointLoad = NULL;

	SP_CONFIG_MSG msg;
	char fileName[30] = "./tests/config/saveLoad.cfg";
	SPConfig conf = spConfigCreate(fileName, &msg);
	ASSERT_TRUE(NULL != conf);

	/****
	 * Allocates, creates(by imageProc) and saves the features
	 ****/
	features = allocateFeaturesList(conf);
	ASSERT_TRUE(NULL != features);
	ASSERT_TRUE(true == debugSaveFeatures(conf, features));

	/****
	 * Load the features from the files
	 *****/
	loadedFeatures = allocateFeaturesList(conf);
	ASSERT_TRUE(NULL != loadedFeatures);
	ASSERT_TRUE(true == loadFeatures(conf, loadedFeatures));


	/****************************************
	 * Compare original and loaded features *
	 ****************************************/
	ASSERT_TRUE(getFeaturesImagesNumber(features) ==
							getFeaturesImagesNumber(loadedFeatures));


	numOfImages = getFeaturesImagesNumber(features);
	for (int index_image=0; index_image<numOfImages ; index_image++)
	{
		numOfFeatures = getFeaturesNumber(features, index_image);
		ASSERT_TRUE(numOfFeatures == getFeaturesNumber(loadedFeatures, index_image));


		for (int index_feature=0; index_feature<numOfFeatures ; index_feature++)
		{
			orgArr = getFeatureArray(features, index_image);
			loadedArr = getFeatureArray(loadedFeatures, index_image);

			pointOrg = orgArr[index_feature];
			pointLoad = loadedArr[index_feature];


			numOfCoords = spPointGetDimension(pointOrg);
			ASSERT_TRUE(numOfCoords == spPointGetDimension(pointLoad));

			ASSERT_TRUE(spPointGetIndex(pointOrg) == spPointGetIndex(pointLoad));


			for (int index_coor=0; index_coor<numOfCoords ; index_coor++)
			{
				ASSERT_TRUE(spPointGetAxisCoor(pointOrg, index_coor) ==
								spPointGetAxisCoor(pointLoad, index_coor));
			}
		}

	}

	loadedFeaturesDestroy(loadedFeatures);
	loadedFeaturesDestroy(features);

	return true;
}
コード例 #7
0
ファイル: StegoFrame.cpp プロジェクト: Andreas-HH/Stegosaurus
StegoFrame::StegoFrame(QWidget* parent) : QMainWindow(parent) {
  QSplitter *central = new QSplitter(Qt::Vertical);
  QScrollArea *hscroll = new QScrollArea();
  QScrollArea *pscroll = new QScrollArea();
  QDomElement stegoDom;
  
  model = new StegoModel();
  model->addView(this);
  
  hw = new HistogramWidget(this, model);
  pw = new PairWidget(this, model);

  fdock = new FeatureDock(this, model);
  cdock = new ConfigDock(hw, pw, this);
//   gdock = new GraphDock(this);
//   tdock = new TableDock(this, model);
  ldial = new LoadDialog(this);
  
  hscroll->setWidgetResizable(1);
  hscroll->setAlignment(Qt::AlignLeft);
//   hscroll->setBackgroundRole(QPalette::Dark);
  hscroll->setWidget(hw);
  pscroll->setWidgetResizable(1);
  pscroll->setAlignment(Qt::AlignLeft);
//   pscroll->setBackgroundRole(QPalette::Dark);
  pscroll->setWidget(pw);
  central->addWidget(hscroll);
  central->addWidget(pscroll);
//   scroll1->setWidget(central);
//   central->show();
  
  setCentralWidget(central);
  addDockWidget(Qt::LeftDockWidgetArea, fdock);
  addDockWidget(Qt::BottomDockWidgetArea, cdock);
//   addDockWidget(Qt::BottomDockWidgetArea, gdock);
//   addDockWidget(Qt::BottomDockWidgetArea, tdock);
  
  openFeaturesAction = new QAction(tr("Open"), this);
  loadFeaturesAction = new QAction(tr("Load"), this);
  openDocAction = new QAction(tr("Open"), this);
  saveDocAction = new QAction(tr("Save"), this);
  mmdAction  = new QAction(tr("MMDs"), this);
  svmAction  = new QAction(tr("SVM classification"), this);
  muAction   = new QAction(tr("Mus"), this);
  
  fdial = new QFileDialog(this);
  fdial->setFileMode(QFileDialog::ExistingFiles);
  fdial->setNameFilter(tr("Features (*.fv)"));
  fdial->setAcceptMode(QFileDialog::AcceptOpen);
  fdial->setDirectory(tr("."));
  
  docMenu = menuBar()->addMenu(tr("Document"));
  fileMenu = menuBar()->addMenu(tr("Features"));
  calcMenu = menuBar()->addMenu(tr("Calculate"));
  fileMenu->addAction(openFeaturesAction);
  fileMenu->addAction(loadFeaturesAction);
  docMenu->addAction(openDocAction);
  docMenu->addAction(saveDocAction);
  calcMenu->addAction(muAction);
  calcMenu->addAction(mmdAction);
  calcMenu->addAction(svmAction);
  
  progress = new QProgressBar(statusBar());
  statusLabel = new QLabel(tr("Ready."));
  statusBar()->addPermanentWidget(statusLabel, 9);
  statusBar()->addPermanentWidget(progress, 1);
  
  connect(openFeaturesAction, SIGNAL(triggered(bool)), this, SLOT(openCollection()));
  connect(loadFeaturesAction, SIGNAL(triggered(bool)), ldial, SLOT(open()));
  connect(saveDocAction, SIGNAL(triggered(bool)), this, SLOT(saveXML()));
  connect(mmdAction, SIGNAL(triggered(bool)), this, SLOT(calcMMDs()));
  connect(svmAction, SIGNAL(triggered(bool)), this, SLOT(classify()));
  connect(muAction, SIGNAL(triggered(bool)), this, SLOT(calcMus()));
  connect(ldial, SIGNAL(accepted()), this, SLOT(loadFeatures()));
  
  document = new QDomDocument();
  xmlFile = new QFile("stegodoc.xml");
  if (xmlFile->exists()) {
    openXML();
//     if (document->firstChildElement().tagName() != QString("stegosaurus"))
//       printf("lol \n");
    sets = document->firstChildElement().firstChildElement(QString("sets"));
    if (sets.isNull()) {
      sets = document->createElement(QString("sets"));
      stegoDom.appendChild(sets);
    }
    mmds = document->firstChildElement().firstChildElement(QString("mmds"));
    if (sets.isNull()) {
      sets = document->createElement(QString("mmds"));
      stegoDom.appendChild(sets);
    }
  } else {
    stegoDom = document->createElement(QString("stegosaurus"));
    sets = document->createElement(QString("sets"));
    stegoDom.appendChild(sets);
    document->appendChild(stegoDom);
  }
  
  setMinimumSize(1280, 720);
  setWindowTitle("Stegosaurus");
}
コード例 #8
0
ファイル: configfile.cpp プロジェクト: bochi/spectrum-gw
Configuration ConfigFile::getConfiguration() {
	Configuration configuration;
	char **bind;
	int i;
	
	if (!m_loaded)
		return DummyConfiguration;

	// Service section
	LOAD_REQUIRED_STRING(configuration.protocol, "service", "protocol");
	std::transform(configuration.protocol.begin(), configuration.protocol.end(), configuration.protocol.begin(), tolower);
	m_protocol = configuration.protocol;

	LOAD_REQUIRED_STRING(configuration.jid, "service", "jid");
	m_jid = configuration.jid;

	LOAD_REQUIRED_STRING(configuration.discoName, "service", "name");
	LOAD_REQUIRED_STRING(configuration.server, "service", "server");
	LOAD_REQUIRED_STRING(configuration.password, "service", "password");
	LOAD_REQUIRED_STRING(configuration.filetransferCache, "service", "filetransfer_cache");
	LOAD_REQUIRED_STRING_DEFAULT(configuration.config_interface, "service", "config_interface", "/var/run/spectrum/" + configuration.jid + ".sock");
	if (!loadInteger(configuration.port, "service", "port")) return DummyConfiguration;
	loadString(configuration.filetransferWeb, "service", "filetransfer_web", "");
	loadString(configuration.pid_f, "service", "pid_file", "/var/run/spectrum/" + configuration.jid);
	loadString(configuration.language, "service", "language", "en");
	loadString(configuration.encoding, "service", "encoding", "");
	loadString(configuration.eventloop, "service", "eventloop", "glib");
	loadBoolean(configuration.jid_escaping, "service", "jid_escaping", true);
	loadBoolean(configuration.onlyForVIP, "service", "only_for_vip", false);
	loadBoolean(configuration.VIPEnabled, "service", "vip_mode", false);
	loadBoolean(configuration.useProxy, "service", "use_proxy", false);
	loadBoolean(configuration.require_tls, "service", "require_tls", true);
	loadStringList(configuration.allowedServers, "service", "allowed_servers");
	loadStringList(configuration.admins, "service", "admins");
	loadHostPort(configuration.filetransfer_proxy_ip, configuration.filetransfer_proxy_port, "service", "filetransfer_bind_address", "", 0);
	loadHostPort(configuration.filetransfer_proxy_streamhost_ip, configuration.filetransfer_proxy_streamhost_port, "service", "filetransfer_public_address", configuration.filetransfer_proxy_ip, configuration.filetransfer_proxy_port);

	if (!loadFeatures(configuration.transportFeatures, "features")) {
		configuration.transportFeatures = TRANSPORT_FEATURE_ALL;
		// TODO: transport_features and vip_features are depracted. remove it for 0.4
		if(g_key_file_has_key(keyfile,"service","transport_features",NULL)) {
			bind = g_key_file_get_string_list (keyfile,"service","transport_features",NULL, NULL);
			configuration.transportFeatures = 0;
			for (i = 0; bind[i]; i++){
				std::string feature(bind[i]);
				if (feature == "avatars")
					configuration.transportFeatures = configuration.transportFeatures | TRANSPORT_FEATURE_AVATARS;
				else if (feature == "chatstate")
					configuration.transportFeatures = configuration.transportFeatures | TRANSPORT_FEATURE_TYPING_NOTIFY;
				else if (feature == "filetransfer")
					configuration.transportFeatures = configuration.transportFeatures | TRANSPORT_FEATURE_FILETRANSFER;
			}
			g_strfreev (bind);
		}
		else configuration.transportFeatures = TRANSPORT_FEATURE_AVATARS | TRANSPORT_FEATURE_FILETRANSFER | TRANSPORT_FEATURE_TYPING_NOTIFY;
	}

	if (!loadFeatures(configuration.VIPFeatures, "vip-features")) {
		configuration.VIPFeatures = TRANSPORT_FEATURE_ALL;
		if(g_key_file_has_key(keyfile,"service","vip_features",NULL)) {
			bind = g_key_file_get_string_list (keyfile,"service","vip_features",NULL, NULL);
			configuration.VIPFeatures = 0;
			for (i = 0; bind[i]; i++){
				std::string feature(bind[i]);
				if (feature == "avatars")
					configuration.VIPFeatures |= TRANSPORT_FEATURE_AVATARS;
				else if (feature == "chatstate")
					configuration.VIPFeatures |= TRANSPORT_FEATURE_TYPING_NOTIFY;
				else if (feature == "filetransfer")
					configuration.VIPFeatures |= TRANSPORT_FEATURE_FILETRANSFER;
			}
			g_strfreev (bind);
		}
		else configuration.VIPFeatures = TRANSPORT_FEATURE_AVATARS | TRANSPORT_FEATURE_FILETRANSFER | TRANSPORT_FEATURE_TYPING_NOTIFY;
	}

	// Database section
	LOAD_REQUIRED_STRING(configuration.sqlType, "database", "type");
	LOAD_REQUIRED_STRING(configuration.sqlDb, "database", "database");
	LOAD_REQUIRED_STRING_DEFAULT(configuration.sqlHost, "database", "host", configuration.sqlType == "sqlite" ? "optional" : "");
	LOAD_REQUIRED_STRING_DEFAULT(configuration.sqlPassword, "database", "password", configuration.sqlType == "sqlite" ? "optional" : "");
	LOAD_REQUIRED_STRING_DEFAULT(configuration.sqlUser, "database", "user", configuration.sqlType == "sqlite" ? "optional" : "");
	LOAD_REQUIRED_STRING_DEFAULT(configuration.sqlPrefix, "database", "prefix", configuration.sqlType == "sqlite" ? "" : "required");
	loadString(configuration.sqlVIP, "database", "vip_statement", "");
	LOAD_REQUIRED_STRING(configuration.userDir, "purple", "userdir");

	// Logging section
	loadString(configuration.logfile, "logging", "log_file", "");
	if (g_key_file_has_key(keyfile, "logging", "log_areas", NULL)) {
		bind = g_key_file_get_string_list(keyfile, "logging", "log_areas", NULL, NULL);
		configuration.logAreas = 0;
		for (i = 0; bind[i]; i++) {
			std::string feature(bind[i]);
			if (feature == "xml") {
				configuration.logAreas = configuration.logAreas | LOG_AREA_XML;
			}
			else if (feature == "purple")
				configuration.logAreas = configuration.logAreas | LOG_AREA_PURPLE;
		}
		g_strfreev (bind);
	}
	else configuration.logAreas = LOG_AREA_XML | LOG_AREA_PURPLE;


	// Registration section
	loadBoolean(configuration.enable_public_registration, "registration", "enable_public_registration", true);
	loadString(configuration.username_mask, "registration", "username_mask", "");
	loadString(configuration.reg_instructions, "registration", "instructions", "");
	loadString(configuration.reg_username_field, "registration", "username_label", "");
	loadString(configuration.reg_allowed_usernames, "registration", "allowed_usernames", "");

	if (configuration.sqlType == "sqlite")
		create_dir(configuration.sqlDb, 0750);
	create_dir(configuration.filetransferCache, 0750);
	create_dir(configuration.config_interface, 0750);
	create_dir(configuration.pid_f, 0750);
	create_dir(configuration.userDir, 0750);
	create_dir(configuration.logfile, 0750);
	return configuration;
}