Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : */
8 :
9 : #include <kdb.h>
10 : #include <stdio.h>
11 :
12 0 : int main (void)
13 : {
14 : // clang-format off
15 : //! [Full Example]
16 : // create a new keyset with 3 keys
17 : // with a hint that about 20 keys will be inside
18 0 : KeySet * myConfig = ksNew (20, keyNew ("user/name1", 0), keyNew ("user/name2", 0), keyNew ("user/name3", 0), KS_END);
19 : // append a key in the keyset
20 0 : ksAppendKey (myConfig, keyNew ("user/name4", 0));
21 :
22 : Key * current;
23 0 : ksRewind (myConfig);
24 0 : while ((current = ksNext (myConfig)) != 0)
25 : {
26 0 : printf ("Key name is %s.\n", keyName (current));
27 : }
28 0 : ksDel (myConfig); // delete keyset and all keys appended
29 : //! [Full Example]
30 : }
|