LCOV - code coverage report
Current view: top level - examples - ksCut.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 15 0.0 %
Date: 2019-09-12 12:28:41 Functions: 0 2 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             : 
      11             : #include <stdio.h>
      12             : 
      13           0 : void outputKeySet (KeySet * returned)
      14             : {
      15           0 :         ksRewind (returned);
      16           0 :         while (ksNext (returned))
      17             :         {
      18           0 :                 printf ("%s\n", keyName (ksCurrent (returned)));
      19             :         }
      20           0 : }
      21             : 
      22           0 : int main (void)
      23             : {
      24             :         // clang-format off
      25             :         //! [cut]
      26           0 :         Key * parentKey = keyNew ("system/mountpoint/interest", KEY_END);
      27           0 :         KDB * kdb = kdbOpen (parentKey);
      28           0 :         KeySet * ks = ksNew (0, KS_END);
      29           0 :         kdbGet (kdb, ks, parentKey);
      30           0 :         KeySet * returned = ksCut (ks, parentKey);
      31           0 :         kdbSet (kdb, ks, parentKey); // all keys below cutpoint are now removed
      32           0 :         kdbClose (kdb, parentKey);
      33             :         //! [cut]
      34           0 :         outputKeySet (returned);
      35           0 :         outputKeySet (ks);
      36             : }

Generated by: LCOV version 1.13