LCOV - code coverage report
Current view: top level - examples - kdbget.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 13 0.0 %
Date: 2019-09-12 12:28:41 Functions: 0 1 0.0 %

          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           0 :         KeySet * myConfig = ksNew (0, KS_END);
      15             : 
      16             :         // for error handling see kdbget_error.c
      17             : 
      18             :         // clang-format off
      19             : //! [basic usage]
      20           0 : Key * key = keyNew ("/sw/tests/myapp/#0/current/",  KEY_END);
      21           0 : KDB * handle = kdbOpen (key);
      22           0 : kdbGet (handle, myConfig, key);
      23           0 : Key * result = ksLookupByName (myConfig, "/sw/tests/myapp/#0/current/testkey1", 0);
      24             : //! [basic usage]
      25             :         // clang-format on
      26             : 
      27           0 :         keyDel (key);
      28             : 
      29           0 :         const char * key_name = keyName (result);
      30           0 :         const char * key_value = keyString (result);
      31           0 :         const char * key_comment = keyString (keyGetMeta (result, "comment"));
      32           0 :         printf ("key: %s value: %s comment: %s\n", key_name, key_value, key_comment);
      33             : 
      34           0 :         ksDel (myConfig); // delete the in-memory configuration
      35             : 
      36             : 
      37             :         // maybe you want kdbSet() myConfig here
      38             : 
      39           0 :         kdbClose (handle, 0); // no more affairs with the key database.
      40             : }

Generated by: LCOV version 1.13