Ejemplo n.º 1
0
static void test_us ()
{
	printf ("Test mounting of user and system backends\n");

	KDB * kdb = kdb_new ();
	KeySet * modules = ksNew (0, KS_END);
	elektraModulesInit (modules, 0);
	Key * mp;

	KeySet * config = set_us ();
	ksAppendKey (config, keyNew ("system/elektra/mountpoints", KEY_END));
	succeed_if (mountOpen (kdb, config, modules, 0) == 0, "could not open mount");
	succeed_if (mountDefault (kdb, modules, 1, 0) == 0, "could not mount default backend");

	succeed_if (kdb->split->size == 5, "size of split not correct");
	mp = keyNew ("system", KEY_VALUE, "system", KEY_END);
	compare_key (mp, kdb->split->parents[0]);
	keySetName (mp, "user");
	keySetString (mp, "user");
	compare_key (mp, kdb->split->parents[1]);
	keySetName (mp, "system/elektra");
	keySetString (mp, "default");
	compare_key (mp, kdb->split->parents[4]);
	keyDel (mp);

	Key * key = keyNew ("user/anywhere/backend/simple", KEY_END);
	Backend * backend = trieLookup (kdb->trie, key);

	keyAddBaseName (key, "somewhere");
	keyAddBaseName (key, "deep");
	keyAddBaseName (key, "below");
	Backend * backend2 = trieLookup (kdb->trie, key);
	succeed_if (backend == backend2, "should be same backend");

	succeed_if ((mp = backend->mountpoint) != 0, "no mountpoint found");
	succeed_if_same_string (keyName (mp), "user");
	succeed_if_same_string (keyString (mp), "user");


	keySetName (key, "system/anywhere/tests/backend/two");
	Backend * two = trieLookup (kdb->trie, key);
	succeed_if (two != backend, "should be differnt backend");

	succeed_if ((mp = two->mountpoint) != 0, "no mountpoint found");
	succeed_if_same_string (keyName (mp), "system");
	succeed_if_same_string (keyString (mp), "system");

	keyDel (key);
	kdb_del (kdb);
	elektraModulesClose (modules, 0);
	ksDel (modules);
}
Ejemplo n.º 2
0
char * uni::to_st()
{
  if (this->st_data)
  {
      free(st_data);
      st_data = NULL;
  }
 
  if (us_data == NULL)
  {
      LogError(_T("US_data equaled NULL in uni.cpp, trying to fix."));
      set_us((unsigned short*)L"NULL");
  }

  //make a copy to a string
  UnicodeToAnsi((LPCOLESTR)this->us_data, &st_data);
 
  //return pointer to converted string
  return st_data;
}
Ejemplo n.º 3
0
uni::uni(const unsigned short *us_new)
{
  	init_vars();
	set_us(us_new);

}