LCOV - code coverage report
Current view: top level - examples - optsSnippets.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 24 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 <kdbhelper.h>
      10             : #include <kdbopts.h>
      11             : 
      12             : #include <stdio.h>
      13             : #include <stdlib.h>
      14             : 
      15             : extern char ** environ;
      16             : 
      17           0 : static int basicUse (int argc, const char ** argv)
      18             : {
      19           0 :         Key * parentKey = keyNew ("/sw/org/example/#0/current", KEY_END);
      20             :         //! [basic use]
      21           0 :         KDB * kdb = kdbOpen (parentKey);
      22           0 :         KeySet * ks = ksNew (0, KS_END);
      23             : 
      24           0 :         kdbGet (kdb, ks, parentKey);
      25             : 
      26           0 :         int result = elektraGetOpts (ks, argc, argv, (const char **) environ, parentKey);
      27           0 :         if (result == -1)
      28             :         {
      29           0 :                 fprintf (stderr, "ERROR: %s\n", keyString (keyGetMeta (parentKey, "error/reason")));
      30           0 :                 keyDel (parentKey);
      31           0 :                 ksDel (ks);
      32           0 :                 return EXIT_FAILURE;
      33             :         }
      34             : 
      35           0 :         if (result == 1)
      36             :         {
      37           0 :                 char * help = elektraGetOptsHelpMessage (parentKey, NULL, NULL);
      38           0 :                 fprintf (stderr, "%s\n", help);
      39           0 :                 elektraFree (help);
      40           0 :                 keyDel (parentKey);
      41           0 :                 ksDel (ks);
      42           0 :                 return EXIT_SUCCESS;
      43             :         }
      44             : 
      45             :         //! [basic use]
      46           0 :         ksDel (ks);
      47           0 :         kdbClose (kdb, parentKey);
      48           0 :         keyDel (parentKey);
      49           0 :         return EXIT_SUCCESS;
      50             : }
      51             : 
      52           0 : int main (int argc, const char ** argv)
      53             : {
      54           0 :         return basicUse (argc, argv);
      55             : }

Generated by: LCOV version 1.13