LCOV - code coverage report
Current view: top level - build directory/src/plugins/constants - constants.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 236 241 97.9 %
Date: 2019-09-12 12:28:41 Functions: 4 6 66.7 %

          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 <kdbconfig.h>
      11             : #include <kdbmacros.h>
      12             : #include <kdbplugin.h>
      13             : 
      14             : #include <string.h>
      15             : 
      16             : #include <kdberrors.h>
      17             : 
      18             : int elektraConstantsGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UNUSED, Key * parentKey ELEKTRA_UNUSED);
      19             : int elektraConstantsSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UNUSED, Key * parentKey ELEKTRA_UNUSED);
      20             : 
      21          19 : static void elektraAddKeyValue (KeySet * ks, Key * parentKey, const char * key, const char * value)
      22             : {
      23          19 :         Key * k = keyDup (parentKey);
      24          19 :         keyAddName (k, key);
      25          19 :         keySetString (k, value);
      26          19 :         ksAppendKey (ks, k);
      27          19 : }
      28             : 
      29           1 : static void elektraAddConstants (KeySet * ks, Key * parentKey)
      30             : {
      31           1 :         Key * key = keyDup (parentKey);
      32           1 :         ksAppendKey (ks, key);
      33             : 
      34           1 :         key = keyDup (parentKey);
      35           1 :         keyAddName (key, "version");
      36           1 :         keySetString (key, "Duplicate of version info also found below system/elektra/version");
      37           1 :         ksAppendKey (ks, key);
      38             : 
      39             : 
      40           1 :         key = keyDup (key);
      41           1 :         keyAddName (key, "version/KDB_VERSION");
      42           1 :         keySetString (key, "0.9.0");
      43           1 :         ksAppendKey (ks, key);
      44             : 
      45           1 :         key = keyDup (parentKey);
      46           1 :         keyAddName (key, "version/KDB_VERSION_MAJOR");
      47           1 :         keySetString (key, "0");
      48           1 :         ksAppendKey (ks, key);
      49             : 
      50             : 
      51           1 :         key = keyDup (parentKey);
      52           1 :         keyAddName (key, "version/KDB_VERSION_MINOR");
      53           1 :         keySetString (key, "9");
      54           1 :         ksAppendKey (ks, key);
      55             : 
      56             : 
      57           1 :         key = keyDup (parentKey);
      58           1 :         keyAddName (key, "version/KDB_VERSION_MICRO");
      59           1 :         keySetString (key, "0");
      60           1 :         ksAppendKey (ks, key);
      61             : 
      62             : 
      63           1 :         elektraAddKeyValue (ks, parentKey, "version/SO_VERSION", "4");
      64           1 :         elektraAddKeyValue (ks, parentKey, "version/SO_VERSION_TOOLS", "2");
      65           1 :         elektraAddKeyValue (ks, parentKey, "version/SO_VERSION_GETENV", "0");
      66             : 
      67             : 
      68           1 :         key = keyDup (parentKey);
      69           1 :         keyAddName (key, "cmake");
      70           1 :         keySetString (key, "All cmake variables as defined in the file cmake/ElektraCache.cmake");
      71           1 :         ksAppendKey (ks, key);
      72             : 
      73             : 
      74           1 :         key = keyDup (parentKey);
      75           1 :         keyAddName (key, "cmake/PLUGINS");
      76           1 :         keySetString (key, "augeas;base64;blockresolver;c;camel;ccode;conditionals;constants;counter;cpptemplate;crypto_botan;crypto_gcrypt;crypto_openssl;csvstorage;curlget;date;dbus;dbusrecv;desktop;directoryvalue;doc;dpkg;dump;error;fcrypt;file;filecheck;fstab;gitresolver;glob;gopts;gpgme;haskell;hexcode;hexnumber;hidden;hosts;iconv;ini;internalnotification;ipaddr;iterate;jni;journald;keytometa;line;lineendings;list;logchange;lua;macaddr;mathcheck;mini;mmapstorage;mmapstorage_crc;mozprefs;multifile;network;ni;noresolver;null;passwd;path;process;profile;python;python2;quickdump;range;reference;regexdispatcher;rename;resolver_fm_b_b;resolver_fm_hb_b;resolver_fm_hp_b;resolver_fm_hpu_b;resolver_fm_pb_b;resolver_fm_ub_x;resolver_fm_uhb_xb;resolver_fm_xb_x;resolver_fm_xhp_x;resolver_fm_xp_x;rgbcolor;ruby;shell;simpleini;spec;specload;sync;syslog;tcl;template;timeofday;tracer;type;typechecker;uname;unit;validation;wresolver;xerces;xmltool;yajl;yambi;yamlcpp;yamlsmith;yanlr;zeromqrecv;zeromqsend");
      77           1 :         ksAppendKey (ks, key);
      78             : 
      79             : 
      80           1 :         key = keyDup (parentKey);
      81           1 :         keyAddName (key, "cmake/TOOLS");
      82           1 :         keySetString (key, "kdb;pythongen;race;qt-gui");
      83           1 :         ksAppendKey (ks, key);
      84             : 
      85             : 
      86           1 :         key = keyDup (parentKey);
      87           1 :         keyAddName (key, "cmake/KDB_DB_SYSTEM");
      88           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/config/kdb/system");
      89           1 :         ksAppendKey (ks, key);
      90             : 
      91             : 
      92           1 :         key = keyDup (parentKey);
      93           1 :         keyAddName (key, "cmake/KDB_DB_HOME");
      94           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/config/kdb/home");
      95           1 :         ksAppendKey (ks, key);
      96             : 
      97           1 :         elektraAddKeyValue (ks, parentKey, "cmake/KDB_DB_SPEC", "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/config/kdb/spec");
      98           1 :         elektraAddKeyValue (ks, parentKey, "cmake/KDB_DB_DIR", ".dir");
      99           1 :         elektraAddKeyValue (ks, parentKey, "cmake/KDB_DB_FILE", "default.ini");
     100           1 :         elektraAddKeyValue (ks, parentKey, "cmake/KDB_DB_INIT", "elektra.ini");
     101           1 :         elektraAddKeyValue (ks, parentKey, "cmake/KDB_DEFAULT_RESOLVER", "resolver_fm_hpu_b");
     102           1 :         elektraAddKeyValue (ks, parentKey, "cmake/KDB_DEFAULT_STORAGE", "ini");
     103             : 
     104           1 :         key = keyDup (parentKey);
     105           1 :         keyAddName (key, "cmake/KDB_DB_USER");
     106           1 :         keySetString (key, ".config");
     107           1 :         ksAppendKey (ks, key);
     108             : 
     109             : 
     110           1 :         key = keyDup (parentKey);
     111           1 :         keyAddName (key, "cmake/GTEST_ROOT");
     112           1 :         keySetString (key, "/opt/gtest");
     113           1 :         ksAppendKey (ks, key);
     114             : 
     115             : 
     116           1 :         key = keyDup (parentKey);
     117           1 :         keyAddName (key, "cmake/BUILD_SHARED");
     118           1 :         keySetString (key, "ON");
     119           1 :         ksAppendKey (ks, key);
     120             : 
     121             : 
     122           1 :         key = keyDup (parentKey);
     123           1 :         keyAddName (key, "cmake/BUILD_FULL");
     124           1 :         keySetString (key, "OFF");
     125           1 :         ksAppendKey (ks, key);
     126             : 
     127             : 
     128           1 :         key = keyDup (parentKey);
     129           1 :         keyAddName (key, "cmake/BUILD_STATIC");
     130           1 :         keySetString (key, "OFF");
     131           1 :         ksAppendKey (ks, key);
     132             : 
     133             : 
     134           1 :         key = keyDup (parentKey);
     135           1 :         keyAddName (key, "cmake/BINDINGS");
     136           1 :         keySetString (key, "");
     137           1 :         ksAppendKey (ks, key);
     138             : 
     139             : 
     140           1 :         key = keyDup (parentKey);
     141           1 :         keyAddName (key, "cmake/TARGET_INCLUDE_FOLDER");
     142           1 :         keySetString (key, "elektra");
     143           1 :         ksAppendKey (ks, key);
     144             : 
     145             : 
     146           1 :         key = keyDup (parentKey);
     147           1 :         keyAddName (key, "cmake/TARGET_CMAKE_FOLDER");
     148           1 :         keySetString (key, "lib/cmake/Elektra");
     149           1 :         ksAppendKey (ks, key);
     150             : 
     151             : 
     152           1 :         key = keyDup (parentKey);
     153           1 :         keyAddName (key, "cmake/TARGET_PLUGIN_FOLDER");
     154           1 :         keySetString (key, "elektra");
     155           1 :         ksAppendKey (ks, key);
     156             : 
     157           1 :         elektraAddKeyValue (ks, parentKey, "cmake/ENABLE_DEBUG", "ON");
     158           1 :         elektraAddKeyValue (ks, parentKey, "cmake/ENABLE_LOGGER", "OFF");
     159           1 :         elektraAddKeyValue (ks, parentKey, "cmake/ENABLE_ASAN", "OFF");
     160             : 
     161           1 :         elektraAddKeyValue (ks, parentKey, "cmake/BUILTIN_PLUGIN_FOLDER", BUILTIN_PLUGIN_FOLDER);
     162           1 :         elektraAddKeyValue (ks, parentKey, "cmake/BUILTIN_DATA_FOLDER", BUILTIN_DATA_FOLDER);
     163           1 :         elektraAddKeyValue (ks, parentKey, "cmake/BUILTIN_EXEC_FOLDER", BUILTIN_EXEC_FOLDER);
     164             : 
     165           1 :         key = keyDup (parentKey);
     166           1 :         keyAddName (key, "cmake/TARGET_PKGCONFIG_FOLDER");
     167           1 :         keySetString (key, "pkgconfig");
     168           1 :         ksAppendKey (ks, key);
     169             : 
     170           1 :         elektraAddKeyValue (ks, parentKey, "cmake/TARGET_DOCUMENTATION_TEXT_FOLDER", "share/doc/elektra");
     171           1 :         elektraAddKeyValue (ks, parentKey, "cmake/TARGET_DOCUMENTATION_HTML_FOLDER", "share/doc/elektra-api/html");
     172           1 :         elektraAddKeyValue (ks, parentKey, "cmake/TARGET_DOCUMENTATION_MAN_FOLDER", "share/man/man3");
     173           1 :         elektraAddKeyValue (ks, parentKey, "cmake/TARGET_DOCUMENTATION_LATEX_FOLDER", "share/doc/elektra-api/latex");
     174             : 
     175           1 :         key = keyDup (parentKey);
     176           1 :         keyAddName (key, "cmake/TARGET_TOOL_EXEC_FOLDER");
     177           1 :         keySetString (key, "lib/elektra/tool_exec");
     178           1 :         ksAppendKey (ks, key);
     179             : 
     180             : 
     181           1 :         key = keyDup (parentKey);
     182           1 :         keyAddName (key, "cmake/TARGET_TOOL_DATA_FOLDER");
     183           1 :         keySetString (key, "share/elektra/tool_data");
     184           1 :         ksAppendKey (ks, key);
     185             : 
     186             : 
     187           1 :         key = keyDup (parentKey);
     188           1 :         keyAddName (key, "cmake/TARGET_TEST_DATA_FOLDER");
     189           1 :         keySetString (key, "share/elektra/test_data");
     190           1 :         ksAppendKey (ks, key);
     191             : 
     192             : 
     193           1 :         key = keyDup (parentKey);
     194           1 :         keyAddName (key, "cmake/TARGET_TEMPLATE_FOLDER");
     195           1 :         keySetString (key, "share/elektra/templates");
     196           1 :         ksAppendKey (ks, key);
     197             : 
     198           1 :         key = keyDup (parentKey);
     199           1 :         keyAddName (key, "cmake/LIB_SUFFIX");
     200           1 :         keySetString (key, "");
     201           1 :         ksAppendKey (ks, key);
     202             : 
     203             : 
     204           1 :         key = keyDup (parentKey);
     205           1 :         keyAddName (key, "cmake/CMAKE_INSTALL_PREFIX");
     206           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system");
     207           1 :         ksAppendKey (ks, key);
     208             : 
     209             : 
     210           1 :         key = keyDup (parentKey);
     211           1 :         keyAddName (key, "compiler");
     212           1 :         keySetString (key, "Flags defined for compilers as defined in ElektraCompiling.cmake");
     213           1 :         ksAppendKey (ks, key);
     214             : 
     215             : 
     216           1 :         key = keyDup (parentKey);
     217           1 :         keyAddName (key, "compiler/c_flags");
     218           1 :         keySetString (key, " -std=gnu99  -Wno-deprecated-declarations  -Wstrict-prototypes -Werror -Wno-long-long -Wpedantic -Wno-variadic-macros -Wall -Wextra -Wno-overlength-strings -Wsign-compare -Wfloat-equal -Wformat -Wformat-security -Wshadow -Wcomments -Wtrigraphs -Wundef -Wuninitialized -Winit-self -Wmaybe-uninitialized -fprofile-arcs -ftest-coverage -Wsign-compare -Wfloat-equal");
     219           1 :         ksAppendKey (ks, key);
     220             : 
     221             : 
     222           1 :         key = keyDup (parentKey);
     223           1 :         keyAddName (key, "compiler/id");
     224           1 :         keySetString (key, "GNU");
     225           1 :         ksAppendKey (ks, key);
     226             : 
     227             : 
     228           1 :         key = keyDup (parentKey);
     229           1 :         keyAddName (key, "compiler/coverage");
     230           1 :         keySetString (key, "ON");
     231           1 :         ksAppendKey (ks, key);
     232             : 
     233             : 
     234           1 :         key = keyDup (parentKey);
     235           1 :         keyAddName (key, "compiler/cxx_flags");
     236           1 :         keySetString (key, " -std=c++11  -Wno-deprecated-declarations  -Wold-style-cast -Wstrict-null-sentinel -D_GLIBCXX_USE_NANOSLEEP -Wno-missing-field-initializers -Woverloaded-virtual  -Wsign-promo -Werror -Wno-long-long -Wpedantic -Wno-variadic-macros -Wall -Wextra -Wno-overlength-strings -Wsign-compare -Wfloat-equal -Wformat -Wformat-security -Wshadow -Wcomments -Wtrigraphs -Wundef -Wuninitialized -Winit-self -Wmaybe-uninitialized -fprofile-arcs -ftest-coverage");
     237           1 :         ksAppendKey (ks, key);
     238             : 
     239             : 
     240           1 :         key = keyDup (parentKey);
     241           1 :         keyAddName (key, "compiler/pic_flags");
     242           1 :         keySetString (key, "-fPIC");
     243           1 :         ksAppendKey (ks, key);
     244             : 
     245             : 
     246           1 :         key = keyDup (parentKey);
     247           1 :         keyAddName (key, "compiler/static_flags");
     248           1 :         keySetString (key, "");
     249           1 :         ksAppendKey (ks, key);
     250             : 
     251             : 
     252           1 :         key = keyDup (parentKey);
     253           1 :         keyAddName (key, "macros");
     254           1 :         keySetString (key, "Define the macros from kdbos.h and kdbconfig.h");
     255           1 :         ksAppendKey (ks, key);
     256             : 
     257             : 
     258           1 :         key = keyDup (parentKey);
     259           1 :         keyAddName (key, "macros/KDB_MAX_PATH_LENGTH");
     260           1 :         keySetString (key, ELEKTRA_STRINGIFY (KDB_MAX_PATH_LENGTH));
     261           1 :         ksAppendKey (ks, key);
     262             : 
     263             : 
     264           1 :         key = keyDup (parentKey);
     265           1 :         keyAddName (key, "macros/KDB_FILE_MODE");
     266           1 :         keySetString (key, ELEKTRA_STRINGIFY (KDB_FILE_MODE));
     267           1 :         ksAppendKey (ks, key);
     268             : 
     269             : 
     270           1 :         key = keyDup (parentKey);
     271           1 :         keyAddName (key, "macros/KDB_DIR_MODE");
     272           1 :         keySetString (key, ELEKTRA_STRINGIFY (KDB_DIR_MODE));
     273           1 :         ksAppendKey (ks, key);
     274             : 
     275             : 
     276           1 :         key = keyDup (parentKey);
     277           1 :         keyAddName (key, "macros/KDB_PATH_SEPARATOR");
     278           1 :         keySetString (key, ELEKTRA_STRINGIFY (KDB_PATH_SEPARATOR));
     279           1 :         ksAppendKey (ks, key);
     280             : 
     281             : 
     282           1 :         key = keyDup (parentKey);
     283           1 :         keyAddName (key, "macros/KDB_PATH_ESCAPE");
     284           1 :         keySetString (key, ELEKTRA_STRINGIFY (KDB_PATH_ESCAPE));
     285           1 :         ksAppendKey (ks, key);
     286             : 
     287             : 
     288           1 :         key = keyDup (parentKey);
     289           1 :         keyAddName (key, "package");
     290           1 :         keySetString (key, "Infos about the package as it is installed");
     291           1 :         ksAppendKey (ks, key);
     292             : 
     293             : 
     294           1 :         key = keyDup (parentKey);
     295           1 :         keyAddName (key, "package/prefix");
     296           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system");
     297           1 :         ksAppendKey (ks, key);
     298             : 
     299             : 
     300           1 :         key = keyDup (parentKey);
     301           1 :         keyAddName (key, "package/libdir");
     302           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system/lib");
     303           1 :         ksAppendKey (ks, key);
     304             : 
     305             : 
     306           1 :         key = keyDup (parentKey);
     307           1 :         keyAddName (key, "package/includedir");
     308           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system/include/elektra");
     309           1 :         ksAppendKey (ks, key);
     310             : 
     311             : 
     312           1 :         key = keyDup (parentKey);
     313           1 :         keyAddName (key, "package/plugindir");
     314           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system/lib/elektra");
     315           1 :         ksAppendKey (ks, key);
     316             : 
     317             : 
     318           1 :         key = keyDup (parentKey);
     319           1 :         keyAddName (key, "package/tool_execdir");
     320           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system/lib/elektra/tool_exec");
     321           1 :         ksAppendKey (ks, key);
     322             : 
     323             : 
     324           1 :         key = keyDup (parentKey);
     325           1 :         keyAddName (key, "package/templatedir");
     326           1 :         keySetString (key, "/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system/share/elektra/templates");
     327           1 :         ksAppendKey (ks, key);
     328             : 
     329             : 
     330           1 :         key = keyDup (parentKey);
     331           1 :         keyAddName (key, "package/libs");
     332           1 :         keySetString (key, "-L/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system/lib -lelektra");
     333           1 :         ksAppendKey (ks, key);
     334             : 
     335             : 
     336           1 :         key = keyDup (parentKey);
     337           1 :         keyAddName (key, "package/cflags");
     338           1 :         keySetString (key, "-I/home/jenkins/workspace/libelektra_PR-2949-JSVQFJNQUXFDDEIVMWX2NWLWVTIX5MLFKA62ACPFOA3QLNMROQ7Q/system/include/elektra");
     339           1 :         ksAppendKey (ks, key);
     340           1 : }
     341             : 
     342          32 : int elektraConstantsGet (Plugin * handle ELEKTRA_UNUSED, KeySet * ks, Key * parentKey)
     343             : {
     344          32 :         if (!strcmp (keyName (parentKey), "system/elektra/modules/constants"))
     345             :         {
     346          31 :                 ksAppendKey (ks, keyNew ("system/elektra/modules/constants", KEY_VALUE, "constants plugin waits for your orders", KEY_END));
     347          31 :                 ksAppendKey (ks, keyNew ("system/elektra/modules/constants/exports", KEY_END));
     348          31 :                 ksAppendKey (ks, keyNew ("system/elektra/modules/constants/exports/get", KEY_FUNC, elektraConstantsGet, KEY_END));
     349          31 :                 ksAppendKey (ks, keyNew ("system/elektra/modules/constants/exports/set", KEY_FUNC, elektraConstantsSet, KEY_END));
     350          31 :                 KeySet * contract =
     351          31 :                         ksNew (30,
     352             : #include "readme_constants.c"
     353             :                                keyNew ("system/elektra/modules/constants/infos/version", KEY_VALUE, PLUGINVERSION, KEY_END), KS_END);
     354          31 :                 ksAppend (ks, contract);
     355          31 :                 ksDel (contract);
     356          31 :                 return 1;
     357             :         }
     358             : 
     359           1 :         elektraAddConstants (ks, parentKey);
     360             : 
     361           1 :         return 1; /* success */
     362             : }
     363             : 
     364           0 : int elektraConstantsSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * parentKey)
     365             : {
     366           0 :         KeySet * info = ksNew (0, KS_END);
     367           0 :         elektraAddConstants (info, parentKey);
     368           0 :         ELEKTRA_SET_ERROR_READ_ONLY (info, returned, parentKey);
     369           0 :         return 0;
     370             : }
     371             : 
     372          39 : Plugin * ELEKTRA_PLUGIN_EXPORT
     373             : {
     374             :         // clang-format off
     375          39 :         return elektraPluginExport("constants",
     376             :                 ELEKTRA_PLUGIN_GET,     &elektraConstantsGet,
     377             :                 ELEKTRA_PLUGIN_SET,     &elektraConstantsSet,
     378             :                 ELEKTRA_PLUGIN_END);
     379             : }

Generated by: LCOV version 1.13