本文整理汇总了C++中PLUGIN_OPEN函数的典型用法代码示例。如果您正苦于以下问题:C++ PLUGIN_OPEN函数的具体用法?C++ PLUGIN_OPEN怎么用?C++ PLUGIN_OPEN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PLUGIN_OPEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_setDirectionMatch
void test_setDirectionMatch()
{
Key *parentKey = keyNew ("user/tests/glob", KEY_END);
KeySet *conf = ksNew (20,
keyNew ("user/glob/set/#1", KEY_VALUE, "/*",
KEY_META, "testmetakey1", "testvalue1",
KEY_META, "testmetakey2", "testvalue2",
KEY_END),
keyNew ("user/glob/get/#1", KEY_VALUE, "/*/*",
KEY_META, "testmetakey1", "testvalue1",
KEY_META, "testmetakey2", "testvalue2",
KEY_END),
KS_END);
PLUGIN_OPEN("glob");
KeySet* ks = createKeys ();
succeed_if(plugin->kdbSet (plugin, ks, parentKey) >= 1,
"call to kdbSet was not successful");
succeed_if(output_error (parentKey), "error in kdbSet");
succeed_if(output_warnings (parentKey), "warnings in kdbSet");
testKeys (ks);
ksDel(ks);
keyDel(parentKey);
PLUGIN_CLOSE();
}
示例2: test_intNoUpdateWithValueExceedingIntMin
static void test_intNoUpdateWithValueExceedingIntMin (void)
{
printf ("test no update with value that exceeds INT_MIN\n");
KeySet * conf = ksNew (0, KS_END);
PLUGIN_OPEN ("internalnotification");
Key * valueKey = keyNew ("user/test/internalnotification/value", KEY_END);
KeySet * ks = ksNew (1, valueKey, KS_END);
int value = 123;
succeed_if (internalnotificationRegisterInt (plugin, valueKey, &value) == 1,
"call to elektraInternalnotificationRegisterInt was not successful");
long long exceedsInt = (long long) INT_MIN - 1;
char * stringValue = convertLongLongToString (exceedsInt);
keySetString (valueKey, stringValue);
elektraInternalnotificationUpdateRegisteredKeys (plugin, ks);
succeed_if (value == 123, "registered value was updated");
elektraFree (stringValue);
ksDel (ks);
PLUGIN_CLOSE ();
}
示例3: test_mmap_ksCopy
static void test_mmap_ksCopy (const char * tmpFile)
{
Key * parentKey = keyNew (TEST_ROOT_KEY, KEY_VALUE, tmpFile, KEY_END);
KeySet * conf = ksNew (0, KS_END);
PLUGIN_OPEN ("mmapstorage");
KeySet * ks = simpleTestKeySet ();
succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful");
succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 1, "kdbGet was not successful");
succeed_if ((ks->flags & KS_FLAG_MMAP_ARRAY) == KS_FLAG_MMAP_ARRAY, "KeySet array not in mmap");
KeySet * copyKs = ksNew (0, KS_END);
if (ksCopy (copyKs, ks) == 1)
{
compare_keyset (copyKs, ks);
compare_keyset (ks, copyKs);
}
else
{
yield_error ("ksCopy failed");
}
ksDel (copyKs);
keyDel (parentKey);
ksDel (ks);
PLUGIN_CLOSE ();
}
示例4: test_mmap_opmphm
static void test_mmap_opmphm (const char * tmpFile)
{
Key * parentKey = keyNew (TEST_ROOT_KEY, KEY_VALUE, tmpFile, KEY_END);
KeySet * conf = ksNew (0, KS_END);
PLUGIN_OPEN ("mmapstorage");
KeySet * ks = largeTestKeySet ();
succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful");
ksDel (ks);
ks = ksNew (0, KS_END);
succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 1, "kdbGet was not successful");
const char * name = "user/tests/mmapstorage/dir7/key3";
Key * found = ksLookupByName (ks, name, KDB_O_OPMPHM);
if (!found)
{
yield_error ("Key not found.")
}
// write keyset with OPMPHM structures
succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful");
ksDel (ks);
keyDel (parentKey);
PLUGIN_CLOSE ();
}
示例5: test_readfstab
void test_readfstab (const char * file)
{
Key * parentKey = keyNew ("user/tests/fstab", KEY_VALUE, srcdir_file (file), KEY_END);
KeySet * conf = 0;
PLUGIN_OPEN ("fstab");
KeySet * ks = ksNew (0, KS_END);
printf ("Reading fstab using file: %s\n", file);
succeed_if (plugin->kdbGet (plugin, ks, parentKey) >= 1, "call to kdbGet was not successful");
// output_keyset(ks);
Key * key = ksLookupByName (ks, "user/tests/fstab/\\//device", 0);
exit_if_fail (key, "rootfs device not found");
succeed_if (strcmp ("/dev/sda1", keyValue (key)) == 0, "device not correct");
key = ksLookupByName (ks, "user/tests/fstab/\\/media\\/ext4/device", 0);
exit_if_fail (key, "media device not found");
succeed_if (strcmp ("/dev/sdg1", keyValue (key)) == 0, "device not correct");
exit_if_fail (key = ksLookupByName (ks, "user/tests/fstab/\\/media\\/ext4/dumpfreq", 0), "rootfs device not found");
succeed_if (strcmp ("0", keyValue (key)) == 0, "dumpfreq not correct");
ksDel (ks);
keyDel (parentKey);
PLUGIN_CLOSE ();
}
示例6: test_differentMetaNames
void test_differentMetaNames () {
Key *parentKey = keyNew ("user/tests/keytometa", KEY_END);
KeySet *conf = ksNew(0, KS_END);
PLUGIN_OPEN("keytometa");
KeySet *ks = createDifferentMetaNameTestKeys();
succeed_if(plugin->kdbGet (plugin, ks, parentKey) >= 1,
"call to kdbGet was not successful");
succeed_if(output_error (parentKey), "error in kdbGet");
succeed_if(output_warnings (parentKey), "warnings in kdbGet");
Key *key = ksLookupByName(ks, "user/normalkey1", 0);
succeed_if (key, "normalkey1 was removed");
const Key *metaKey1 = keyGetMeta(key, "testmeta1");
succeed_if (metaKey1, "normalkey1 contained no meta testmeta1");
const char *expected1 = "meta line1";
succeed_if (!strcmp (keyString(metaKey1), expected1), "metakey testmeta1 of normalkey1 contained incorrect data");
const Key *metaKey2= keyGetMeta(key, "testmeta2");
succeed_if (metaKey2, "normalkey1 contained no meta testmeta1");
const char *expected2 = "meta line2";
succeed_if (!strcmp (keyString(metaKey2), expected2), "metakey testmeta1 of normalkey1 contained incorrect data");
keyDel (parentKey);
ksDel(ks);
PLUGIN_CLOSE ();
}
示例7: test_addNewBaseToParentKey
static void test_addNewBaseToParentKey()
{
Key *parentKey = keyNew ("user/tests/rename", KEY_END);
KeySet *conf = ksNew (20,
keyNew ("system/cut", KEY_VALUE, "new/base", KEY_END), KS_END);
PLUGIN_OPEN("rename");
KeySet *ks = ksNew(0, KS_END);
keyIncRef(parentKey);
ksAppendKey (ks, parentKey);
succeed_if(plugin->kdbSet (plugin, ks, parentKey) >= 1,
"call to kdbSet was not successful");
succeed_if(output_error (parentKey), "error in kdbSet");
succeed_if(output_warnings (parentKey), "warnings in kdbSet");
Key *key = ksLookupByName (ks, "user/tests/rename/new/base", 0);
succeed_if (key, "new base was not correctly appended to parent key");
ksDel(ks);
keyDecRef(parentKey);
keyDel(parentKey);
PLUGIN_CLOSE ();
}
示例8: test_mmap_metacopy
static void test_mmap_metacopy (const char * tmpFile)
{
Key * parentKey = keyNew (TEST_ROOT_KEY, KEY_VALUE, tmpFile, KEY_END);
KeySet * conf = ksNew (0, KS_END);
PLUGIN_OPEN ("mmapstorage");
KeySet * ks = metaTestKeySet ();
Key * shareMeta = keyNew (0);
keySetMeta (shareMeta, "sharedmeta", "shared meta key test");
Key * current;
ksRewind (ks);
while ((current = ksNext (ks)) != 0)
{
keyCopyMeta (current, shareMeta, "sharedmeta");
}
KeySet * expected = ksDeepDup (ks);
succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful");
KeySet * returned = ksNew (0, KS_END);
succeed_if (plugin->kdbGet (plugin, returned, parentKey) == 1, "kdbGet was not successful");
compare_keyset (expected, returned);
ksDel (expected);
ksDel (returned);
keyDel (parentKey);
keyDel (shareMeta);
ksDel (ks);
PLUGIN_CLOSE ();
}
示例9: test_metaConfigTakesPrecedence
static void test_metaConfigTakesPrecedence()
{
Key *parentKey = keyNew ("user/tests/rename", KEY_END);
KeySet *conf = ksNew (20,
keyNew ("system/cut", KEY_VALUE, "will/be", KEY_END), KS_END);
PLUGIN_OPEN("rename");
KeySet *ks = createSimpleMetaTestKeys();
ksAppendKey(ks, parentKey);
succeed_if(plugin->kdbGet (plugin, ks, parentKey) >= 1,
"call to kdbGet was not successful");
succeed_if(output_error (parentKey), "error in kdbGet");
succeed_if(output_warnings (parentKey), "warnings in kdbGet");
/* the first two keys should have been renamed by their metadata */
Key* key = ksLookupByName (ks, "user/tests/rename/key1", KDB_O_NONE);
succeed_if(key, "key1 was not correctly renamed");
key = ksLookupByName (ks, "user/tests/rename/key2", KDB_O_NONE);
succeed_if(key, "key2 was not correctly renamed");
/* the third key should have been renamed by the global config */
key = ksLookupByName (ks, "user/tests/rename/stripped", KDB_O_NONE);
succeed_if(key, "key3 was renamed but would replace the parent key");
/* the fourth key was not renamed because the prefix did not match */
key = ksLookupByName (ks, "user/tests/rename/will/not/be/stripped/key4", KDB_O_NONE);
succeed_if(key, "key4 was renamed although its prefix did not match");
keyDel (parentKey);
ksDel(ks);
PLUGIN_CLOSE ();
}
示例10: test_rebaseOfNewKeys
static void test_rebaseOfNewKeys()
{
Key *parentKey = keyNew ("user/tests/rename", KEY_END);
KeySet *conf = ksNew (20,
keyNew ("system/cut", KEY_VALUE, "new/base", KEY_END), KS_END);
PLUGIN_OPEN("rename");
KeySet *ks = ksNew(20,
/* this key was seen by rename before and wont be changed */
keyNew("user/tests/rename/key1",
KEY_VALUE, "value1",
KEY_META, ELEKTRA_ORIGINAL_NAME_META, "user/tests/rename/key1",
KEY_END),
/* this key was not seen by rename before and will be renamed */
keyNew("user/tests/rename/key2",
KEY_VALUE, "value2",
KEY_END),
KS_END);
succeed_if(plugin->kdbSet (plugin, ks, parentKey) >= 1,
"call to kdbSet was not successful");
succeed_if(output_error (parentKey), "error in kdbSet");
succeed_if(output_warnings (parentKey), "warnings in kdbSet");
Key* key = ksLookupByName (ks, "user/tests/rename/key1", KDB_O_NONE);
succeed_if(key, "key1 was not found anymore, but it should not have been renamed");
key = ksLookupByName (ks, "user/tests/rename/new/base/key2", KDB_O_NONE);
succeed_if(key, "key2 was not correctly renamed");
keyDel (parentKey);
ksDel(ks);
PLUGIN_CLOSE ();
}
示例11: test_readPref
static void test_readPref (char * fileName)
{
Key * parentKey = keyNew ("user/tests/pref-read", KEY_VALUE, srcdir_file (fileName), KEY_END);
KeySet * conf = ksNew (0, KS_END);
PLUGIN_OPEN ("mozprefs");
KeySet * ks = ksNew (0, KS_END);
succeed_if (plugin->kdbGet (plugin, ks, parentKey) >= 1, "call to kdbGet was not successful");
Key * key = ksLookupByName (ks, "user/tests/pref-read/user/a/user/key", KDB_O_NONE);
exit_if_fail (key, "Key a.user.key not found");
succeed_if (!strcmp (keyString (key), "usertest"), "Key a.user.key contains invalid data");
key = ksLookupByName (ks, "user/tests/pref-read/lock/a/lock/key", KDB_O_NONE);
exit_if_fail (key, "Key a.lock.key not found");
succeed_if (!strcmp (keyString (key), "true"), "Key a.lock.key contains invalid data");
key = ksLookupByName (ks, "user/tests/pref-read/pref/a/default/key", KDB_O_NONE);
exit_if_fail (key, "Key a.default.key not found");
succeed_if (!strcmp (keyString (key), "1"), "Key a.default.key contains invalid data");
key = ksLookupByName (ks, "user/tests/pref-read/sticky/a/sticky/key", KDB_O_NONE);
exit_if_fail (key, "Key a.sticky.key not found");
succeed_if (!strcmp (keyString (key), "false"), "Key a.sticky.key contains invalid data");
ksDel (ks);
keyDel (parentKey);
PLUGIN_CLOSE ();
}
示例12: test_withoutConfig
static void test_withoutConfig()
{
Key *parentKey = keyNew ("user/tests/rename", KEY_END);
Key *parentKeyCopy = keyDup(parentKey);
KeySet *conf = ksNew (0, KS_END);
PLUGIN_OPEN("rename");
KeySet *ks = createSimpleTestKeys();
ksAppendKey(ks, parentKey);
succeed_if(plugin->kdbGet (plugin, ks, parentKey) >= 1,
"call to kdbGet was not successful");
succeed_if(output_error (parentKey), "error in kdbGet");
succeed_if(output_warnings (parentKey), "warnings in kdbGet");
KeySet *expected = createSimpleTestKeys();
ksAppendKey(expected, parentKeyCopy);
compareKeySets(ks, expected);
keyDel (parentKey);
keyDel (parentKeyCopy);
ksDel(expected);
ksDel(ks);
PLUGIN_CLOSE ();
}
示例13: testreadwritecomplicated
static void testreadwritecomplicated (const char * file)
{
Key * parentKey = keyNew ("user/tests/csvstorage", KEY_VALUE, srcdir_file (file), KEY_END);
KeySet * conf = ksNew (10, keyNew ("system/delimiter", KEY_VALUE, ";", KEY_END),
keyNew ("system/header", KEY_VALUE, "colname", KEY_END), KS_END);
KeySet * ks = ksNew (0, KS_END);
PLUGIN_OPEN ("csvstorage");
succeed_if (plugin->kdbGet (plugin, ks, parentKey) > 0, "call to kdbGet was not successful");
succeed_if (!strcmp (keyString (ksLookupByName (ks, "user/tests/csvstorage/#1/col3", KDB_O_NONE)), "l1;c3"),
"key value doesn't match expected value");
succeed_if (!strcmp (keyString (ksLookupByName (ks, "user/tests/csvstorage/#1/col4", KDB_O_NONE)), "l1\"\"c4"),
"key value doesn't match expected value");
succeed_if (!strcmp (keyString (ksLookupByName (ks, "user/tests/csvstorage/#2/col3", KDB_O_NONE)), "l2\nc3"),
"key value doesn't match expected value");
succeed_if (!strcmp (keyString (ksLookupByName (ks, "user/tests/csvstorage/#4/col4", KDB_O_NONE)), "l4\"\"c4"),
"key value doesn't match expected value");
succeed_if (!strcmp (keyString (ksLookupByName (ks, "user/tests/csvstorage/#5/col3", KDB_O_NONE)), "l5\"\"\nc3"),
"key value doesn't match expected value");
keySetString (parentKey, elektraFilename ());
succeed_if (plugin->kdbSet (plugin, ks, parentKey) >= 0, "error: wrote invalid data");
succeed_if (compare_line_files (srcdir_file (file), keyString (parentKey)), "files do not match as expected");
ksDel (ks);
keyDel (parentKey);
PLUGIN_CLOSE ();
}
示例14: test_mmap_ks_copy_with_meta
static void test_mmap_ks_copy_with_meta (const char * tmpFile)
{
Key * parentKey = keyNew (TEST_ROOT_KEY, KEY_VALUE, tmpFile, KEY_END);
KeySet * conf = ksNew (0, KS_END);
PLUGIN_OPEN ("mmapstorage");
KeySet * ks = metaTestKeySet ();
succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful");
ksDel (ks);
KeySet * returned = ksNew (0, KS_END);
succeed_if (plugin->kdbGet (plugin, returned, parentKey) == 1, "kdbGet was not successful");
KeySet * expected = metaTestKeySet ();
compare_keyset (expected, returned);
KeySet * copiedKs = ksNew (0, KS_END);
ksCopy (copiedKs, returned);
compare_keyset (expected, copiedKs);
ksDel (copiedKs);
ksDel (expected);
ksDel (returned);
keyDel (parentKey);
PLUGIN_CLOSE ();
}
示例15: test_readline
void test_readline(){
char * filename = srcdir_file("line/linetest");
Key * parentKey = keyNew ("user/tests/line", KEY_VALUE, filename, KEY_END);
KeySet *conf = 0;
PLUGIN_OPEN("line");
printf("%s\n", filename);
KeySet *ks=ksNew(0, KS_END);
succeed_if (plugin->kdbGet(plugin, ks, parentKey) >= 1, "call to kdbGet was not successful");
Key *key = ksLookupByName(ks, "user/tests/line/#0", 0);
exit_if_fail (key, "line1 key not found");
succeed_if (strcmp("test1", keyValue(key)) == 0, "line ´ does not match");
key = ksLookupByName(ks, "user/tests/line/#_10", 0);
exit_if_fail (key, "line11 key not found");
succeed_if (strcmp("", keyValue(key)) == 0, "line 10 should be blank");
key = ksLookupByName(ks, "user/tests/line/#_13", 0);
exit_if_fail (key, "line14 key not found");
succeed_if (strcmp("printf(\"hello world\\n\");", keyValue(key)) == 0, "line 13 not correct");
ksDel (ks);
keyDel(parentKey);
PLUGIN_CLOSE();
}