From 339d34dfa331926e486340c6343b62266fb28e14 Mon Sep 17 00:00:00 2001 From: Michael Zronek Date: Thu, 11 Apr 2019 22:40:25 +0200 Subject: [PATCH] error: migrated to fixed macro names --- doc/tutorials/plugins.md | 4 +- src/bindings/cpp/include/kdbplugin.hpp | 2 +- src/error/exporterrors.cpp | 40 ++++-- src/include/kdbmacros.h | 47 ++++--- src/libs/elektra/backend.c | 21 +-- src/libs/elektra/kdb.c | 85 ++++++------ src/libs/elektra/mount.c | 14 +- src/libs/elektra/plugin.c | 40 +++--- src/libs/elektra/split.c | 2 +- src/libs/loader/dl.c | 11 +- src/libs/loader/static.c | 6 +- src/libs/opts/opts.c | 87 ++++++------ src/libs/pluginprocess/pluginprocess.c | 17 +-- src/plugins/augeas/augeas.c | 44 +++--- src/plugins/base64/base64.c | 12 +- src/plugins/blockresolver/blockresolver.c | 24 ++-- src/plugins/boolean/boolean.c | 16 +-- src/plugins/cachefilter/cachefilter.c | 2 +- src/plugins/camel/camel.c | 4 +- src/plugins/conditionals/conditionals.c | 98 +++++++------- src/plugins/cpptemplate/cpptemplate.cpp | 2 +- src/plugins/cpptype/cpptype.cpp | 2 +- src/plugins/crypto/botan_operations.cpp | 16 +-- src/plugins/crypto/crypto.c | 29 ++-- src/plugins/crypto/gcrypt_operations.c | 35 +++-- src/plugins/crypto/gpg.c | 45 +++--- src/plugins/crypto/helper.c | 22 ++- src/plugins/crypto/openssl_operations.c | 46 +++---- src/plugins/csvstorage/csvstorage.c | 34 +++-- src/plugins/curlget/curlget.c | 49 ++++--- src/plugins/date/date.c | 17 +-- src/plugins/directoryvalue/directoryvalue.cpp | 8 +- src/plugins/doc/doc.c | 7 +- src/plugins/dump/dump.cpp | 5 +- src/plugins/enum/enum.c | 4 +- src/plugins/fcrypt/fcrypt.c | 74 +++++----- src/plugins/file/file.c | 14 +- src/plugins/filecheck/filecheck.c | 20 ++- src/plugins/gitresolver/gitresolver.c | 24 ++-- src/plugins/gpgme/gpgme.c | 47 +++---- src/plugins/hexnumber/hexnumber.c | 26 ++-- src/plugins/hosts/hosts-get.c | 2 +- src/plugins/hosts/hosts-set.c | 2 +- src/plugins/iconv/iconv.c | 28 ++-- src/plugins/ini/ini.c | 18 +-- src/plugins/ipaddr/ipaddr.c | 6 +- src/plugins/jni/jni.c | 41 +++--- src/plugins/keytometa/keytometa.c | 2 +- src/plugins/line/line.c | 4 +- src/plugins/lineendings/lineendings.c | 6 +- src/plugins/lua/lua.cpp | 10 +- src/plugins/mathcheck/mathcheck.c | 19 ++- src/plugins/mini/mini.c | 4 +- src/plugins/multifile/multifile.c | 6 +- src/plugins/network/network.c | 29 ++-- src/plugins/passwd/passwd.c | 10 +- src/plugins/path/path.c | 66 ++++----- src/plugins/process/process.c | 15 +- src/plugins/python/python.cpp | 35 +++-- src/plugins/quickdump/quickdump.c | 36 ++--- src/plugins/quickdump/readv1.c | 8 +- src/plugins/range/range.c | 12 +- src/plugins/reference/reference.c | 27 ++-- src/plugins/regexstore/regexstore.cpp | 20 +-- src/plugins/required/required.c | 4 +- src/plugins/resolver/filename.c | 69 +++++----- src/plugins/resolver/resolver.c | 128 ++++++++---------- src/plugins/ruby/ruby.cpp | 16 +-- src/plugins/shell/shell.c | 24 ++-- src/plugins/simpleini/simpleini.c | 14 +- src/plugins/simplespeclang/simplespeclang.cpp | 4 +- src/plugins/specload/specload.c | 41 +++--- src/plugins/struct/struct.cpp | 2 +- src/plugins/sync/sync.c | 6 +- src/plugins/tcl/tcl.cpp | 11 +- src/plugins/type/type.c | 57 ++++---- src/plugins/type/types.c | 11 +- src/plugins/validation/validation.c | 7 +- src/plugins/wresolver/wresolver.c | 25 ++-- src/plugins/xerces/xerces.cpp | 20 +-- src/plugins/yajl/yajl_gen.c | 5 +- src/plugins/yajl/yajl_parse.c | 5 +- src/plugins/yambi/convert.cpp | 6 +- src/plugins/yambi/yambi.cpp | 4 +- src/plugins/yamlcpp/yamlcpp.cpp | 17 ++- src/plugins/yamlsmith/yamlsmith.cpp | 2 +- src/plugins/yanlr/yanlr.cpp | 4 +- src/plugins/yawn/convert.cpp | 10 +- src/plugins/yawn/yawn.cpp | 4 +- src/plugins/yaypeg/yaypeg.cpp | 4 +- src/plugins/zeromqsend/zeromqsend.c | 5 +- 91 files changed, 959 insertions(+), 1054 deletions(-) diff --git a/doc/tutorials/plugins.md b/doc/tutorials/plugins.md index ca6131cb06c..77c94bcf43a 100644 --- a/doc/tutorials/plugins.md +++ b/doc/tutorials/plugins.md @@ -340,7 +340,7 @@ Basically the implementation of `elektraLineSet` can be described with the follo // open the file if (error) { - ELEKTRA_SET_ERROR(ELEKTRA_ERROR_RESOURCE, parentKey, keyString(parentKey)); + ELEKTRA_SET_RESOURCE_ERROR( parentKey, keyString(parentKey)); } for (/* each key */) { @@ -404,7 +404,7 @@ int elektraLineCheckConfig (Key * errorKey, KeySet * conf) const char * value = keyString (cur); if (strlen (value) > 3) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey, + ELEKTRA_SET_PARSING_ERRORF ( errorKey, "value %s is more than 3 characters long", value); return -1; // The configuration was not OK and could not be fixed diff --git a/src/bindings/cpp/include/kdbplugin.hpp b/src/bindings/cpp/include/kdbplugin.hpp index 532453039f7..49e0e18db69 100644 --- a/src/bindings/cpp/include/kdbplugin.hpp +++ b/src/bindings/cpp/include/kdbplugin.hpp @@ -76,7 +76,7 @@ class Delegator catch (const char * msg) { #ifdef KDBERRORS_H - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not create C++ plugin: %s", msg); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Could not create C++ plugin: %s", msg); #endif return -1; } diff --git a/src/error/exporterrors.cpp b/src/error/exporterrors.cpp index 53eb15617de..49feea065e0 100644 --- a/src/error/exporterrors.cpp +++ b/src/error/exporterrors.cpp @@ -39,12 +39,26 @@ static ostream & printKDBErrors (ostream & os, parse_t & p) << endl << "#ifdef __cplusplus" << endl << " using namespace ckdb;" << endl - << endl - << "#endif" << endl - << "#define ELEKTRA_SET_ERROR(number, key, text) ELEKTRA_SET_ERROR_HELPER\\" << endl - << " (number, key, text, __FILE__, __LINE__)" << endl - << endl - << "#define ELEKTRA_SET_ERROR_HELPER(number, key, text, file, line) ELEKTRA_SET_ERROR_HELPER_HELPER\\" << endl + << endl; + os << endl << endl; + os << "#endif" << endl; + + for (size_t i = 1; i < p.size (); ++i) + { + os << "#define ELEKTRA_SET_" << p[i]["macro"] << "_ERROR(key, text) ELEKTRA_SET_ERROR_HELPER\\" << endl; + os << " (" << p[i]["number"] << ", key, text, __FILE__, __LINE__)" << endl; + os << "#define ELEKTRA_SET_" << p[i]["macro"] << "_ERRORF(key, text, ...) ELEKTRA_SET_ERRORF_HELPER\\" << endl; + os << " (" << p[i]["number"] << ", key, text, __FILE__, __LINE__, __VA_ARGS__)" << endl << endl; + + os << "#define ELEKTRA_ADD_" << p[i]["macro"] << "_WARNING(key, text) ELEKTRA_ADD_WARNING_HELPER\\" << endl; + os << " (" << p[i]["number"] << ", key, text, __FILE__, __LINE__)" << endl; + os << "#define ELEKTRA_ADD_" << p[i]["macro"] << "_WARNINGF(key, text, ...) ELEKTRA_ADD_WARNINGF_HELPER\\" << endl; + os << " (" << p[i]["number"] << ", key, text, __FILE__, __LINE__, __VA_ARGS__)" << endl << endl; + } + // << "#define ELEKTRA_SET_ERROR(number, key, text) ELEKTRA_SET_ERROR_HELPER\\" << endl + // << " (number, key, text, __FILE__, __LINE__)" << endl + // << endl + os << "#define ELEKTRA_SET_ERROR_HELPER(number, key, text, file, line) ELEKTRA_SET_ERROR_HELPER_HELPER\\" << endl << " (number, key, text, file, line)" << endl << endl << "#define ELEKTRA_SET_ERROR_HELPER_HELPER(number, key, text, file, line) do {ELEKTRA_LOG (\"Add Error %s: %s\", " @@ -53,9 +67,9 @@ static ostream & printKDBErrors (ostream & os, parse_t & p) << " (key, text, file, #line); } while (0)" << endl << endl << endl - << "#define ELEKTRA_ADD_WARNING(number, key, text) ELEKTRA_ADD_WARNING_HELPER\\" << endl - << " (number, key, text, __FILE__, __LINE__)" << endl - << "" << endl + // << "#define ELEKTRA_ADD_WARNING(number, key, text) ELEKTRA_ADD_WARNING_HELPER\\" << endl + // << " (number, key, text, __FILE__, __LINE__)" << endl + // << "" << endl << "#define ELEKTRA_ADD_WARNING_HELPER(number, key, text, file, line) ELEKTRA_ADD_WARNING_HELPER_HELPER\\" << endl << " (number, key, text, file, line)" << endl << "" << endl @@ -303,20 +317,20 @@ static ostream & printKDBErrors (ostream & os, parse_t & p) for (size_t i = 1; i < p.size (); ++i) { os << " if(strcmp(nr, \"" << p[i]["number"] << "\") == 0)" << endl << " {" << endl; - os << " ELEKTRA_ADD_WARNING (" << p[i]["number"] << ", parentKey, message);" << endl + os << " ELEKTRA_ADD_" << p[i]["macro"] << "_WARNING (parentKey, message);" << endl << " return;" << endl << " }" << endl; } - os << " ELEKTRA_ADD_WARNING (01400, parentKey, \"Unkown warning code\");" << endl << "}" << endl << "" << endl; + os << " ELEKTRA_ADD_LOGICAL_WARNING (parentKey, \"Unkown warning code\");" << endl << "}" << endl << "" << endl; os << "static inline void elektraTriggerError (const char *nr, Key *parentKey, const char *message)" << endl << "{" << endl; for (size_t i = 1; i < p.size (); ++i) { os << " if(strcmp(nr, \"" << p[i]["number"] << "\") == 0)" << endl << " {" << endl; - os << " ELEKTRA_SET_ERROR (" << p[i]["number"] << ", parentKey, message);" << endl + os << " ELEKTRA_SET_" << p[i]["macro"] << "_ERROR (parentKey, message);" << endl << " return;" << endl << " }" << endl; } - os << " ELEKTRA_SET_ERROR (01400, parentKey, \"Unkown error code\");" << endl << "}" << endl; + os << " ELEKTRA_SET_LOGICAL_ERROR (parentKey, \"Unkown error code\");" << endl << "}" << endl; os << "#endif" << endl; return os; diff --git a/src/include/kdbmacros.h b/src/include/kdbmacros.h index 02669db20ca..26577497065 100644 --- a/src/include/kdbmacros.h +++ b/src/include/kdbmacros.h @@ -37,28 +37,30 @@ do \ { \ if (errno == EACCES) \ - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, \ - "Insufficient permissions to open configuration file for reading. Reason: %s. You might want " \ - "to retry as root or change access using chmod.", \ - strerror (errno)); \ + ELEKTRA_SET_RESOURCE_ERRORF ( \ + parentKey, \ + "Insufficient permissions to open configuration file for reading. Reason: %s. You might want " \ + "to retry as root or change access using chmod.", \ + strerror (errno)); \ else \ - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, \ - "Could not open configuration file for reading. Reason: %s", strerror (errno)); \ + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open configuration file for reading. Reason: %s", \ + strerror (errno)); \ } while (0) #define ELEKTRA_SET_ERROR_SET(parentKey) \ do \ { \ if (errno == EACCES) \ - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, \ - "Insufficient permissions to open configuration file for writing. You might want to retry as " \ - "root. Errno: %s", \ - strerror (errno)); \ + ELEKTRA_SET_RESOURCE_ERRORF ( \ + parentKey, \ + "Insufficient permissions to open configuration file for writing. You might want to retry as " \ + "root. Errno: %s", \ + strerror (errno)); \ else \ - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, ":Could not open file for writing %s", strerror (errno)); \ + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, ":Could not open file for writing %s", strerror (errno)); \ } while (0) -#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, key, "Unable to allocate %zu bytes.", size); +#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_RESOURCE_ERRORF (key, "Unable to allocate %zu bytes.", size); /** * @brief Sets error 84 if info != returned @@ -80,27 +82,28 @@ Key * c = ksNext (info); \ if (!c) \ { \ - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, error, \ - "Read only plugin, kdbSet not supported but the key %s (value %s) was added", \ - keyName (k), keyString (k)); \ + ELEKTRA_SET_INSTALLATION_ERRORF ( \ + error, "Read only plugin, kdbSet not supported but the key %s (value %s) was added", keyName (k), \ + keyString (k)); \ ksDel (info); \ return -1; \ } \ if (strcmp (keyName (k), keyName (c)) || strcmp (keyString (k), keyString (c))) \ { \ - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, error, \ - "Read only plugin, kdbSet not supported but the key %s (expected %s) was modified to " \ - "%s (expected %s)", \ - keyName (k), keyName (c), keyString (k), keyString (c)); \ + ELEKTRA_SET_INSTALLATION_ERRORF ( \ + error, \ + "Read only plugin, kdbSet not supported but the key %s (expected %s) was modified to " \ + "%s (expected %s)", \ + keyName (k), keyName (c), keyString (k), keyString (c)); \ ksDel (info); \ return -1; \ } \ } \ if ((k = ksNext (info)) != 0) \ { \ - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, error, \ - "Read only plugin, kdbSet not supported but the key %s (value %s) was removed", keyName (k), \ - keyString (k)); \ + ELEKTRA_SET_INSTALLATION_ERRORF (error, \ + "Read only plugin, kdbSet not supported but the key %s (value %s) was removed", \ + keyName (k), keyString (k)); \ ksDel (info); \ return -1; \ } \ diff --git a/src/libs/elektra/backend.c b/src/libs/elektra/backend.c index b8cba64b6fd..b23b85d23b4 100644 --- a/src/libs/elektra/backend.c +++ b/src/libs/elektra/backend.c @@ -80,7 +80,7 @@ int elektraBackendSetMountpoint (Backend * backend, KeySet * elektraConfig, Key if (!foundMountpoint) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not find mountpoint within root %s", keyName (root)); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Could not find mountpoint within root %s", keyName (root)); return -1; } @@ -91,8 +91,8 @@ int elektraBackendSetMountpoint (Backend * backend, KeySet * elektraConfig, Key if (!backend->mountpoint) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not create mountpoint with name %s and value %s", - keyString (foundMountpoint), keyBaseName (root)); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Could not create mountpoint with name %s and value %s", + keyString (foundMountpoint), keyBaseName (root)); return -1; } @@ -201,9 +201,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global if (elektraProcessPlugins (backend->errorplugins, modules, referencePlugins, cut, systemConfig, global, errorKey) == -1) { - if (!failure) - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, - "elektraProcessPlugins for error failed"); + if (!failure) ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "elektraProcessPlugins for error failed"); failure = 1; } } @@ -212,9 +210,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global if (elektraProcessPlugins (backend->getplugins, modules, referencePlugins, cut, systemConfig, global, errorKey) == -1) { - if (!failure) - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, - "elektraProcessPlugins for get failed"); + if (!failure) ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "elektraProcessPlugins for get failed"); failure = 1; } } @@ -228,9 +224,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global if (elektraProcessPlugins (backend->setplugins, modules, referencePlugins, cut, systemConfig, global, errorKey) == -1) { - if (!failure) - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, - "elektraProcessPlugins for set failed"); + if (!failure) ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "elektraProcessPlugins for set failed"); failure = 1; } } @@ -238,8 +232,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global { // no one cares about that config if (!failure) - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Unrecognised Config Tree: %s", - keyBaseName (cur)); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Unrecognised Config Tree: %s", keyBaseName (cur)); ksDel (cut); } } diff --git a/src/libs/elektra/kdb.c b/src/libs/elektra/kdb.c index 341a89a253b..6ecdc783e74 100644 --- a/src/libs/elektra/kdb.c +++ b/src/libs/elektra/kdb.c @@ -270,7 +270,7 @@ KDB * kdbOpen (Key * errorKey) ksDel (handle->global); ksDel (handle->modules); elektraFree (handle); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "elektraModulesInit returned with -1"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "elektraModulesInit returned with -1"); keySetName (errorKey, keyName (initialParent)); keySetString (errorKey, keyString (initialParent)); @@ -287,7 +287,7 @@ KDB * kdbOpen (Key * errorKey) ksDel (handle->global); ksDel (handle->modules); elektraFree (handle); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "could not open default backend"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "could not open default backend"); keySetName (errorKey, keyName (initialParent)); keySetString (errorKey, keyString (initialParent)); @@ -295,8 +295,8 @@ KDB * kdbOpen (Key * errorKey) errno = errnosave; return 0; case 0: - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, - "Initial kdbGet() failed, you should either fix " KDB_DB_INIT " or the fallback " KDB_DB_FILE); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "Initial kdbGet() failed, you should either fix " KDB_DB_INIT + " or the fallback " KDB_DB_FILE); break; case 2: ELEKTRA_LOG ("entered fallback code for bootstrapping"); @@ -309,7 +309,7 @@ KDB * kdbOpen (Key * errorKey) if (mountGlobals (handle, ksDup (keys), handle->modules, errorKey) == -1) { // mountGlobals also sets a warning containing the name of the plugin that failed to load - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Mounting global plugins failed"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "Mounting global plugins failed"); } keySetName (errorKey, keyName (initialParent)); @@ -338,13 +338,13 @@ KDB * kdbOpen (Key * errorKey) // Open the trie, keys will be deleted within mountOpen if (mountOpen (handle, keys, handle->modules, errorKey) == -1) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Initial loading of trie did not work"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "Initial loading of trie did not work"); } keySetString (errorKey, "kdbOpen(): mountDefault"); if (mountDefault (handle, handle->modules, inFallback, errorKey) == -1) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "could not reopen and mount default backend"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "could not reopen and mount default backend"); keySetString (errorKey, "kdbOpen(): close"); kdbClose (handle, errorKey); @@ -361,7 +361,7 @@ KDB * kdbOpen (Key * errorKey) keySetString (errorKey, "kdbOpen(): mountModules"); if (mountModules (handle, handle->modules, errorKey) == -1) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_LOGICAL, errorKey, "Mounting modules did not work"); + ELEKTRA_ADD_LOGICAL_WARNING (errorKey, "Mounting modules did not work"); } keySetName (errorKey, keyName (initialParent)); @@ -433,7 +433,7 @@ int kdbClose (KDB * handle, Key * errorKey) } else { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, errorKey, "Could not close modules: modules were not open"); + ELEKTRA_ADD_RESOURCE_WARNING (errorKey, "Could not close modules: modules were not open"); } if (handle->global) ksDel (handle->global); @@ -935,14 +935,13 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) { clearError (parentKey); keyDel (oldError); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "metakey with name \"%s\" passed to kdbGet", - keyName (parentKey)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "metakey with name \"%s\" passed to kdbGet", keyName (parentKey)); return -1; } if (ns == KEY_NS_EMPTY) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "invalid key name passed to kdbGet"); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNING (parentKey, "invalid key name passed to kdbGet"); } int errnosave = errno; @@ -966,14 +965,14 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) if (!handle || !ks) { clearError (parentKey); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "handle or ks null pointer passed"); + ELEKTRA_SET_LOGICAL_ERROR (parentKey, "handle or ks null pointer passed"); goto error; } if (splitBuildup (split, handle, parentKey) == -1) { clearError (parentKey); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "error in splitBuildup"); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "error in splitBuildup"); goto error; } @@ -1053,7 +1052,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) if (splitAppoint (split, handle, ks) == -1) { clearError (parentKey); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "error in splitAppoint"); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "error in splitAppoint"); goto error; } @@ -1076,8 +1075,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) if (splitGet (split, parentKey, handle) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, parentKey, "Wrong keys in postprocessing: %s", - keyName (ksCurrent (ks))); + ELEKTRA_ADD_INSTALLATION_WARNINGF (parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks))); // continue, because sizes are already updated } ksClear (ks); @@ -1112,8 +1110,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) /* Now post-process the updated keysets */ if (splitGet (split, parentKey, handle) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, parentKey, "Wrong keys in postprocessing: %s", - keyName (ksCurrent (ks))); + ELEKTRA_ADD_INSTALLATION_WARNINGF (parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks))); // continue, because sizes are already updated } @@ -1305,9 +1302,8 @@ static void elektraSetCommit (Split * split, Key * parentKey) if (ret == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, - "Error during commit. This means backend is broken: %s", - keyName (backend->mountpoint)); + ELEKTRA_ADD_LOGICAL_WARNINGF (parentKey, "Error during commit. This means backend is broken: %s", + keyName (backend->mountpoint)); } } } @@ -1338,9 +1334,8 @@ static void elektraSetRollback (Split * split, Key * parentKey) if (ret == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, - "Error during rollback. This means backend is broken: %s", - keyName (backend->mountpoint)); + ELEKTRA_ADD_LOGICAL_WARNINGF (parentKey, "Error during rollback. This means backend is broken: %s", + keyName (backend->mountpoint)); } } } @@ -1431,8 +1426,7 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) if (ns == KEY_NS_META) { clearError (parentKey); // clear previous error to set new one - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "metakey with name \"%s\" passed to kdbSet", - keyName (parentKey)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "metakey with name \"%s\" passed to kdbSet", keyName (parentKey)); keyDel (oldError); ELEKTRA_LOG ("ns == KEY_NS_META"); return -1; @@ -1440,14 +1434,14 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) if (ns == KEY_NS_EMPTY) { - ELEKTRA_ADD_WARNING (VALIDATION_SYNTACTIC_CODE, parentKey, "invalid key name passed to kdbSet"); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNING (parentKey, "invalid key name passed to kdbSet"); ELEKTRA_LOG ("ns == KEY_NS_EMPTY"); } if (!handle || !ks) { clearError (parentKey); // clear previous error to set new one - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "handle or ks null pointer passed"); + ELEKTRA_SET_LOGICAL_ERROR (parentKey, "handle or ks null pointer passed"); keyDel (oldError); ELEKTRA_LOG ("!handle || !ks"); return -1; @@ -1470,7 +1464,7 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) if (splitBuildup (split, handle, parentKey) == -1) { clearError (parentKey); // clear previous error to set new one - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "error in splitBuildup"); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "error in splitBuildup"); goto error; } ELEKTRA_LOG ("after splitBuildup"); @@ -1480,8 +1474,8 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) if (syncstate == -1) { clearError (parentKey); // clear previous error to set new one - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "No default backend found, but should be. Keyname: %s", - keyName (ksCurrent (ks))); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "No default backend found, but should be. Keyname: %s", + keyName (ksCurrent (ks))); goto error; } ELEKTRA_ASSERT (syncstate == 0 || syncstate == 1, "syncstate not 0 or 1, but %d", syncstate); @@ -1498,14 +1492,14 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) if (syncstate < 0) clearError (parentKey); // clear previous error to set new one if (syncstate == -1) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "Assert failed: invalid namespace"); + ELEKTRA_SET_LOGICAL_ERROR (parentKey, "Assert failed: invalid namespace"); ELEKTRA_LOG ("syncstate == -1"); } else if (syncstate < -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Sync state is wrong, maybe kdbSet() is executed without prior kdbGet() on %s", - keyName (split->parents[-syncstate - 2])); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, + "Sync state is wrong, maybe kdbSet() is executed without prior kdbGet() on %s", + keyName (split->parents[-syncstate - 2])); ELEKTRA_LOG ("syncstate < -1"); } keyDel (initialParent); @@ -1579,8 +1573,8 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) Key * found = ksLookup (ks, errorKey, 0); if (!found) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, - "Error key %s not found in keyset even though it was found before", keyName (errorKey)); + ELEKTRA_ADD_LOGICAL_WARNINGF (parentKey, "Error key %s not found in keyset even though it was found before", + keyName (errorKey)); } } @@ -1951,7 +1945,7 @@ int kdbEnsure (KDB * handle, KeySet * contract, Key * parentKey) if (elektraStrCmp (pluginName, "list") == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "Cannot specify clauses for the list plugin!!"); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Cannot specify clauses for the list plugin!!"); keyDel (cutpoint); ksDel (pluginsContract); return -1; @@ -1972,8 +1966,8 @@ int kdbEnsure (KDB * handle, KeySet * contract, Key * parentKey) } else { - ELEKTRA_SET_ERRORF ( - ELEKTRA_ERROR_INSTALLATION, parentKey, + ELEKTRA_SET_INSTALLATION_ERRORF ( + parentKey, "The key '%s' contained the value '%s', but only 'unmounted', 'mounted' or 'remounted' may be used.", keyName (clause), pluginStateString); keyDel (cutpoint); @@ -2006,10 +2000,11 @@ int kdbEnsure (KDB * handle, KeySet * contract, Key * parentKey) { if (pluginState != PLUGIN_STATE_UNMOUNTED) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "The key '%s' contained the value '%s', but only 'unmounted' is supported for " - "non-global clauses at the moment.", - keyName (clause), pluginStateString); + ELEKTRA_SET_INSTALLATION_ERRORF ( + parentKey, + "The key '%s' contained the value '%s', but only 'unmounted' is supported for " + "non-global clauses at the moment.", + keyName (clause), pluginStateString); keyDel (cutpoint); ksDel (pluginConfig); ksDel (pluginsContract); diff --git a/src/libs/elektra/mount.c b/src/libs/elektra/mount.c index c8e73fe1cea..66a88ce1488 100644 --- a/src/libs/elektra/mount.c +++ b/src/libs/elektra/mount.c @@ -68,14 +68,14 @@ int mountOpen (KDB * kdb, KeySet * config, KeySet * modules, Key * errorKey) if (!backend) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not create missing backend"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "could not create missing backend"); ret = -1; continue; } if (!backend->mountpoint) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "backend has no mount point"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "backend has no mount point"); ret = -1; backendClose (backend, errorKey); continue; @@ -83,7 +83,7 @@ int mountOpen (KDB * kdb, KeySet * config, KeySet * modules, Key * errorKey) if (mountBackend (kdb, backend, errorKey) == -1) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "mounting of backend failed"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "mounting of backend failed"); ret = -1; /* mountBackend modified the refcounter. */ backend->refcounter = 1; @@ -117,7 +117,7 @@ int mountDefault (KDB * kdb, KeySet * modules, int inFallback, Key * errorKey) if (!kdb->defaultBackend) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not (re)open default backend"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "could not (re)open default backend"); return -1; } @@ -128,7 +128,7 @@ int mountDefault (KDB * kdb, KeySet * modules, int inFallback, Key * errorKey) if (!kdb->initBackend) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not (re)open init backend"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "could not (re)open init backend"); return -1; } } @@ -311,7 +311,7 @@ int elektraMountGlobalsLoadPlugin (Plugin ** plugin, KeySet * referencePlugins, *plugin = elektraPluginOpen (pluginName, modules, config, errorKey); if (!(*plugin)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not load plugin %s in process plugin", pluginName); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Could not load plugin %s in process plugin", pluginName); return -1; } @@ -474,7 +474,7 @@ int mountModules (KDB * kdb, KeySet * modules, Key * errorKey) if (!root) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "no root key found for modules"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "no root key found for modules"); return -1; } diff --git a/src/libs/elektra/plugin.c b/src/libs/elektra/plugin.c index edd6c75790a..4db93fd9839 100644 --- a/src/libs/elektra/plugin.c +++ b/src/libs/elektra/plugin.c @@ -57,21 +57,20 @@ int elektraProcessPlugin (Key * cur, int * pluginNumber, char ** pluginName, cha if (fullname[0] != '#') { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Names of Plugins must start with a #. Pluginname: %s", - fullname); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Names of Plugins must start with a #. Pluginname: %s", fullname); return -1; } if (fullname[1] < '0' || fullname[1] > '9') { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, - "Names of Plugins must start with the position number as second char. Pluginname: %s", fullname); + ELEKTRA_ADD_INSTALLATION_WARNINGF ( + errorKey, "Names of Plugins must start with the position number as second char. Pluginname: %s", fullname); return -1; } *pluginNumber = fullname[1] - '0'; if (*pluginNumber > NR_OF_PLUGINS) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, - "Tried to set more plugins than defined in NR_OF_PLUGINS Pluginname: %s", fullname); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Tried to set more plugins than defined in NR_OF_PLUGINS Pluginname: %s", + fullname); return -1; } @@ -189,8 +188,8 @@ int elektraProcessPlugins (Plugin ** plugins, KeySet * modules, KeySet * referen plugins[pluginNumber] = elektraPluginOpen (pluginName, modules, pluginConfig, errorKey); if (!plugins[pluginNumber]) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, - "Could not load plugin %s in process plugin", pluginName); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Could not load plugin %s in process plugin", + pluginName); /* Loading plugin did not work */ elektraFree (pluginName); elektraFree (referenceName); @@ -211,8 +210,7 @@ int elektraProcessPlugins (Plugin ** plugins, KeySet * modules, KeySet * referen Key * lookup = ksLookup (referencePlugins, keyNew (referenceName, KEY_END), KDB_O_DEL); if (!lookup) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, errorKey, "Could not reference back to plugin %s", - referenceName); + ELEKTRA_ADD_LOGICAL_WARNINGF (errorKey, "Could not reference back to plugin %s", referenceName); /* Getting a reference plugin at a previous stage did not work. Note that this check is necessary, because loading the plugin could fail for example at errorplugins and at a later point, for example @@ -229,8 +227,7 @@ int elektraProcessPlugins (Plugin ** plugins, KeySet * modules, KeySet * referen } else { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Unknown additional entries in plugin: %s", - keyString (cur)); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Unknown additional entries in plugin: %s", keyString (cur)); } } @@ -256,8 +253,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config if (!name || name[0] == '\0') { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, - "Not a valid name supplied for a plugin: name is null or empty"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "Not a valid name supplied for a plugin: name is null or empty"); goto err_clup; } @@ -272,8 +268,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config if (*n == '\0') { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, - "Not a valid name supplied for a plugin: name contained slashes only"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "Not a valid name supplied for a plugin: name contained slashes only"); goto err_clup; } @@ -287,8 +282,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config handle = pluginFactory (); if (handle == 0) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, - "Could not call function exported by ELEKTRA_PLUGIN_EXPORT: %s", name); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Could not call function exported by ELEKTRA_PLUGIN_EXPORT: %s", name); goto err_clup; } @@ -302,8 +296,8 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config { if ((handle->kdbOpen (handle, errorKey)) == -1) { - ELEKTRA_ADD_WARNINGF ( - ELEKTRA_WARNING_INSTALLATION, errorKey, + ELEKTRA_ADD_INSTALLATION_WARNINGF ( + errorKey, "Open of plugin returned unsuccessfully: %s. Reason contains plugin, see other warnings for details", name); elektraPluginClose (handle, errorKey); goto err_clup; @@ -333,7 +327,7 @@ int elektraPluginClose (Plugin * handle, Key * errorKey) if (handle->kdbClose) { rc = handle->kdbClose (handle, errorKey); - if (rc == -1) ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "kdbClose() failed"); + if (rc == -1) ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "kdbClose() failed"); } ksDel (handle->config); @@ -395,13 +389,13 @@ size_t elektraPluginGetFunction (Plugin * plugin, const char * name) static int elektraMissingGet (Plugin * plugin ELEKTRA_UNUSED, KeySet * ks ELEKTRA_UNUSED, Key * error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, error, "Tried to get a key from a missing backend: %s", keyName (error)); + ELEKTRA_SET_INSTALLATION_ERRORF (error, "Tried to get a key from a missing backend: %s", keyName (error)); return -1; } static int elektraMissingSet (Plugin * plugin ELEKTRA_UNUSED, KeySet * ks ELEKTRA_UNUSED, Key * error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, error, "Tried to set a key from a missing backend: %s", keyName (error)); + ELEKTRA_SET_INSTALLATION_ERRORF (error, "Tried to set a key from a missing backend: %s", keyName (error)); return -1; } diff --git a/src/libs/elektra/split.c b/src/libs/elektra/split.c index be0aae1ee31..ca6f663c93e 100644 --- a/src/libs/elektra/split.c +++ b/src/libs/elektra/split.c @@ -501,7 +501,7 @@ static void elektraDropCurrentKey (KeySet * ks, Key * warningKey, const Backend } strcat (warningMsg, "\" because "); strcat (warningMsg, msg); - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningKey, "Postcondition of backend was violated: %s", warningMsg); + ELEKTRA_ADD_INSTALLATION_WARNINGF (warningKey, "Postcondition of backend was violated: %s", warningMsg); elektraFree (warningMsg); cursor_t c = ksGetCursor (ks); keyDel (elektraKsPopAtCursor (ks, c)); diff --git a/src/libs/loader/dl.c b/src/libs/loader/dl.c index 093190bac13..d0983a1a893 100644 --- a/src/libs/loader/dl.c +++ b/src/libs/loader/dl.c @@ -86,7 +86,7 @@ elektraPluginFactory elektraModulesLoad (KeySet * modules, const char * name, Ke if (module.handle == NULL) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "of module: %s, because: %s", moduleName, dlerror ()); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "of module: %s, because: %s", moduleName, dlerror ()); keyDel (moduleKey); elektraFree (moduleName); return 0; @@ -95,8 +95,8 @@ elektraPluginFactory elektraModulesLoad (KeySet * modules, const char * name, Ke module.symbol.v = dlsym (module.handle, "elektraPluginSymbol"); if (module.symbol.v == NULL) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, - "could not get pointer to factory, dlsym failed. Module: %s, because: %s", moduleName, dlerror ()); + ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "could not get pointer to factory, dlsym failed. Module: %s, because: %s", + moduleName, dlerror ()); dlclose (module.handle); keyDel (moduleKey); elektraFree (moduleName); @@ -119,7 +119,7 @@ int elektraModulesClose (KeySet * modules, Key * errorKey) if (!root) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, errorKey, "no key system/elektra/modules"); + ELEKTRA_ADD_RESOURCE_WARNING (errorKey, "no key system/elektra/modules"); return -1; } @@ -135,8 +135,7 @@ int elektraModulesClose (KeySet * modules, Key * errorKey) ksAppendKey (newModules, root); } ret = -1; - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, errorKey, "Could not close a module, dlclose failed: %s", - dlerror ()); + ELEKTRA_ADD_RESOURCE_WARNINGF (errorKey, "Could not close a module, dlclose failed: %s", dlerror ()); ksAppendKey (newModules, cur); } diff --git a/src/libs/loader/static.c b/src/libs/loader/static.c index 0f639a65764..35730d29967 100644 --- a/src/libs/loader/static.c +++ b/src/libs/loader/static.c @@ -78,7 +78,7 @@ elektraPluginFactory elektraModulesLoad (KeySet * modules, const char * name, Ke if (handle == NULL) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, error, "Did not find module: %s", name); + ELEKTRA_ADD_INSTALLATION_WARNINGF (error, "Did not find module: %s", name); keyDel (moduleKey); return 0; } @@ -87,8 +87,8 @@ elektraPluginFactory elektraModulesLoad (KeySet * modules, const char * name, Ke if (module == NULL) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, error, - "Could not get pointer to factory, static sym failed: no such symbol elektraPluginSymbol"); + ELEKTRA_ADD_INSTALLATION_WARNING ( + error, "Could not get pointer to factory, static sym failed: no such symbol elektraPluginSymbol"); return 0; } diff --git a/src/libs/opts/opts.c b/src/libs/opts/opts.c index 3f8269ffc2b..75536d36f37 100644 --- a/src/libs/opts/opts.c +++ b/src/libs/opts/opts.c @@ -322,9 +322,9 @@ bool processSpec (struct Specification * spec, KeySet * ks, Key * parentKey) { if (elektraStrCmp (keyBaseName (cur), "#") != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "'args=remaining' can only be set on array keys (basename = '#'). Offending key: %s", - keyName (cur)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + parentKey, "'args=remaining' can only be set on array keys (basename = '#'). Offending key: %s", + keyName (cur)); keyDel (specParent); ksDel (spec->options); ksDel (spec->keys); @@ -494,10 +494,11 @@ bool readOptionData (struct OptionData * optionData, Key * key, const char * met } else if (elektraStrCmp (hasArg, "none") != 0 && elektraStrCmp (hasArg, "optional") != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "The flagvalue metadata can only be used, if the opt/arg metadata is set to 'none' or " - "'optional'. (key: %s)", - keyName (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + errorKey, + "The flagvalue metadata can only be used, if the opt/arg metadata is set to 'none' or " + "'optional'. (key: %s)", + keyName (key)); return false; } @@ -556,19 +557,19 @@ bool processShortOptSpec (struct Specification * spec, struct OptionData * optio if (shortOpt == '-') { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "'-' cannot be used as a short option. It would collide with the " - "special string '--'. Offending key: %s", - keyName (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, + "'-' cannot be used as a short option. It would collide with the " + "special string '--'. Offending key: %s", + keyName (key)); return false; } if (shortOpt == 'h') { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "'h' cannot be used as a short option. It would collide with the " - "help option '-h'. Offending key: %s", - keyName (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, + "'h' cannot be used as a short option. It would collide with the " + "help option '-h'. Offending key: %s", + keyName (key)); return false; } @@ -579,9 +580,9 @@ bool processShortOptSpec (struct Specification * spec, struct OptionData * optio Key * existing = ksLookupByName (spec->options, keyName (shortOptSpec), 0); if (existing != NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "The option '-%c' has already been specified for the key '%s'. Additional key: %s", shortOpt, - keyGetMetaString (existing, "key"), keyName (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, + "The option '-%c' has already been specified for the key '%s'. Additional key: %s", + shortOpt, keyGetMetaString (existing, "key"), keyName (key)); keyDel (shortOptSpec); keyDel (existing); return false; @@ -649,10 +650,10 @@ bool processLongOptSpec (struct Specification * spec, struct OptionData * option if (elektraStrCmp (longOpt, "help") == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "'help' cannot be used as a long option. It would collide with the " - "help option '--help'. Offending key: %s", - keyName (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, + "'help' cannot be used as a long option. It would collide with the " + "help option '--help'. Offending key: %s", + keyName (key)); return false; } @@ -663,9 +664,9 @@ bool processLongOptSpec (struct Specification * spec, struct OptionData * option Key * existing = ksLookupByName (spec->options, keyName (longOptSpec), 0); if (existing != NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "The option '--%s' has already been specified for the key '%s'. Additional key: %s", longOpt, - keyGetMetaString (existing, "key"), keyName (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, + "The option '--%s' has already been specified for the key '%s'. Additional key: %s", + longOpt, keyGetMetaString (existing, "key"), keyName (key)); keyDel (longOptSpec); return false; } @@ -791,8 +792,8 @@ int writeOptionValues (KeySet * ks, Key * keyWithOpt, KeySet * options, Key * er } else if (res < 0) { - ELEKTRA_SET_ERRORF ( - ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + errorKey, "The option '%s%s' cannot be used, because another option has already been used for the key '%s'.", isShort ? "-" : "--", isShort ? (const char[]){ keyBaseName (optKey)[0], '\0' } : keyBaseName (optKey), keyName (keyWithOpt)); @@ -848,10 +849,11 @@ int writeEnvVarValues (KeySet * ks, Key * keyWithOpt, KeySet * envValues, Key * int res = addProcKey (ks, keyWithOpt, envValueKey); if (res < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "The environment variable '%s' cannot be used, because another variable has " - "already been used for the key '%s'.", - keyBaseName (envKey), keyName (keyWithOpt)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + errorKey, + "The environment variable '%s' cannot be used, because another variable has " + "already been used for the key '%s'.", + keyBaseName (envKey), keyName (keyWithOpt)); keyDel (envValueKey); ksDel (envMetas); return -1; @@ -1122,8 +1124,7 @@ bool parseShortOptions (KeySet * optionsSpec, KeySet * options, int argc, const if (optSpec == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Unknown short option: -%c", - keyBaseName (shortOpt)[0]); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Unknown short option: -%c", keyBaseName (shortOpt)[0]); keyDel (shortOpt); keyDel (optSpec); return false; @@ -1143,8 +1144,7 @@ bool parseShortOptions (KeySet * optionsSpec, KeySet * options, int argc, const } else if (!repeated) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "This option cannot be repeated: -%c", - keyBaseName (shortOpt)[0]); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "This option cannot be repeated: -%c", keyBaseName (shortOpt)[0]); keyDel (shortOpt); keyDel (optSpec); return false; @@ -1158,8 +1158,8 @@ bool parseShortOptions (KeySet * optionsSpec, KeySet * options, int argc, const { if (i >= argc - 1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "Missing argument for short option: -%c", keyBaseName (shortOpt)[0]); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Missing argument for short option: -%c", + keyBaseName (shortOpt)[0]); keyDel (shortOpt); keyDel (option); return false; @@ -1217,7 +1217,7 @@ bool parseLongOption (KeySet * optionsSpec, KeySet * options, int argc, const ch if (optSpec == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Unknown long option: --%s", keyBaseName (longOpt)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Unknown long option: --%s", keyBaseName (longOpt)); keyDel (longOpt); return false; } @@ -1236,8 +1236,7 @@ bool parseLongOption (KeySet * optionsSpec, KeySet * options, int argc, const ch } else if (!repeated) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "This option cannot be repeated: --%s", - keyBaseName (longOpt)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "This option cannot be repeated: --%s", keyBaseName (longOpt)); keyDel (longOpt); keyDel (optSpec); return false; @@ -1263,8 +1262,8 @@ bool parseLongOption (KeySet * optionsSpec, KeySet * options, int argc, const ch { if (i >= argc - 1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Missing argument for long option: --%s", - keyBaseName (longOpt)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Missing argument for long option: --%s", + keyBaseName (longOpt)); keyDel (longOpt); return false; } @@ -1290,8 +1289,8 @@ bool parseLongOption (KeySet * optionsSpec, KeySet * options, int argc, const ch { if (argStart > 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "This option cannot have an argument: --%s", - keyBaseName (longOpt)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "This option cannot have an argument: --%s", + keyBaseName (longOpt)); keyDel (longOpt); return false; } diff --git a/src/libs/pluginprocess/pluginprocess.c b/src/libs/pluginprocess/pluginprocess.c index 2bccdbade07..e594d82e300 100644 --- a/src/libs/pluginprocess/pluginprocess.c +++ b/src/libs/pluginprocess/pluginprocess.c @@ -199,8 +199,7 @@ void elektraPluginProcessStart (Plugin * handle, ElektraPluginProcess * pp) else { ELEKTRA_LOG_DEBUG ("Child: Unrecognized command %s", keyString (commandKey)); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, key, "Received invalid command code or no KeySet: %s", - keyString (commandKey)); + ELEKTRA_SET_LOGICAL_ERRORF (key, "Received invalid command code or no KeySet: %s", keyString (commandKey)); } errno = prevErrno; char * resultStr = longToStr (result); @@ -265,8 +264,8 @@ int elektraPluginProcessSend (const ElektraPluginProcess * pp, pluginprocess_t c if ((command == ELEKTRA_PLUGINPROCESS_GET || command == ELEKTRA_PLUGINPROCESS_SET || command == ELEKTRA_PLUGINPROCESS_ERROR) && originalKeySet == NULL) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, key, - "originalKeySet has to exist when calling GET SET and ERROR via pluginprocess; but it is NULL"); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR ( + key, "originalKeySet has to exist when calling GET SET and ERROR via pluginprocess; but it is NULL"); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -330,8 +329,7 @@ int elektraPluginProcessSend (const ElektraPluginProcess * pp, pluginprocess_t c long lresult = strtol (keyString (resultKey), &endPtr, 10); if (*endPtr != '\0' || errno == ERANGE || lresult > INT_MAX || lresult < INT_MIN) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, key, "Received invalid return code or no KeySet: %s", - keyString (resultKey)); + ELEKTRA_SET_INSTALLATION_ERRORF (key, "Received invalid return code or no KeySet: %s", keyString (resultKey)); lresult = ELEKTRA_PLUGIN_STATUS_ERROR; } else // Copy everything back into the actual keysets @@ -407,7 +405,7 @@ static int makePipe (ElektraPluginProcess * pp, Key * errorKey, const char * pip if ((ret = pipe (pipeRef))) { cleanupPluginData (pp, errorKey, 1); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to initialize %s, pipe () returned %d", pipeName, ret); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to initialize %s, pipe () returned %d", pipeName, ret); return 0; } return 1; @@ -478,7 +476,7 @@ ElektraPluginProcess * elektraPluginProcessInit (Key * errorKey) if (!pp->dump) { cleanupPluginData (pp, errorKey, 0); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to initialize the dump plugin"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Failed to initialize the dump plugin"); return NULL; } @@ -498,8 +496,7 @@ ElektraPluginProcess * elektraPluginProcessInit (Key * errorKey) if (pp->pid < 0) { cleanupPluginData (pp, errorKey, 1); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to fork the plugin process, fork () returned %d", - pp->pid); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to fork the plugin process, fork () returned %d", pp->pid); return NULL; } diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 49d378d1b97..8dc7c49cfa2 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -20,19 +20,6 @@ #include "aug.h" -#define ELEKTRA_SET_GENERAL_ERROR(id, parentKey, message) \ - do \ - { \ - ELEKTRA_SET_ERROR (id, parentKey, message); \ - errno = errnosave; \ - return -1; \ - } while (0) - -#define ELEKTRA_SET_ERRNO_ERROR(id, parentKey) ELEKTRA_SET_GENERAL_ERROR (id, parentKey, strerror (errno)) - -#define ELEKTRA_SET_AUGEAS_ERROR(handle, parrentKey) \ - ELEKTRA_SET_GENERAL_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, getAugeasError (augeasHandle)) - struct KeyConversion { KeySet * ks; @@ -118,7 +105,7 @@ int elektraAugeasGenConf (KeySet * ks, Key * errorKey ELEKTRA_UNUSED) } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Could not glob %s", f); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Could not glob %s", f); retval = -1; } return retval; @@ -421,14 +408,14 @@ static int saveTree (augeas * augeasHandle, KeySet * ks, const char * lensPath, if (ret < 0) { /* report the augeas specific error */ - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, getAugeasError (augeasHandle)); + ELEKTRA_SET_PARSING_ERROR (parentKey, getAugeasError (augeasHandle)); } return ret; memoryerror: elektraFree (keyArray); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Unable to allocate memory while saving the augeas tree"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Unable to allocate memory while saving the augeas tree"); return -1; } @@ -445,12 +432,11 @@ int elektraAugeasOpen (Plugin * handle, Key * parentKey) if (ret >= 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, - "Unable to allocate memory for a detailed augeas error message"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Unable to allocate memory for a detailed augeas error message"); return -1; } - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, errormessage); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, errormessage); elektraFree (errormessage); return -1; } @@ -491,7 +477,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) /* retrieve the lens to use */ const char * lensPath = getLensPath (handle); - if (!lensPath) ELEKTRA_SET_GENERAL_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, keyName (parentKey)); + if (!lensPath) ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "No Augeas lens was configured: %s", keyName (parentKey)); FILE * fh = fopen (keyString (parentKey), "r"); @@ -508,7 +494,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (content == 0) { fclose (fh); - ELEKTRA_SET_ERRNO_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno)); } /* convert the string into an augeas tree */ @@ -518,7 +504,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (ret < 0) { fclose (fh); - ELEKTRA_SET_AUGEAS_ERROR (augeasHandle, parentKey); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); } /* convert the augeas tree to an Elektra KeySet */ @@ -533,7 +519,9 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (!conversionData) { fclose (fh); - ELEKTRA_SET_GENERAL_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, strerror (errno)); + ELEKTRA_SET_INSTALLATION_ERRORF ( + parentKey, "Unknown or unsupported type found during streaming, assume key as string, type lost. Errno: %s", + strerror (errno)); } conversionData->currentOrder = 0; @@ -548,7 +536,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) { fclose (fh); ksDel (append); - ELEKTRA_SET_AUGEAS_ERROR (augeasHandle, parentKey); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); } fclose (fh); @@ -568,7 +556,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) if (!lensPath) { - ELEKTRA_SET_GENERAL_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, keyName (parentKey)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "No Augeas lens was configured: %s", keyName (parentKey)); } FILE * fh = fopen (keyValue (parentKey), "w+"); @@ -590,7 +578,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) if (content == 0) { fclose (fh); - ELEKTRA_SET_ERRNO_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno)); } /* convert the string into an augeas tree */ @@ -600,7 +588,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) if (ret < 0) { fclose (fh); - ELEKTRA_SET_AUGEAS_ERROR (augeasHandle, parentKey); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); } } @@ -617,7 +605,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) ret = saveFile (augeasHandle, fh); fclose (fh); - if (ret < 0) ELEKTRA_SET_ERRNO_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey); + if (ret < 0) ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open file for writing: %s", strerror (errno)); errno = errnosave; return 1; diff --git a/src/plugins/base64/base64.c b/src/plugins/base64/base64.c index 64a8b542f62..300795cf612 100644 --- a/src/plugins/base64/base64.c +++ b/src/plugins/base64/base64.c @@ -36,7 +36,7 @@ static int unescape (Key * key, Key * parent) char * unescaped = elektraStrDup (&strVal[1]); if (!unescaped) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parent, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (parent, "Memory allocation failed"); return -1; } keySetString (key, unescaped); @@ -107,12 +107,12 @@ static int decode (Key * key, Key * parent, bool metaMode) else if (result == -1) { // Decoding error - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parent, "Not Base64 encoded: %s", strVal); + ELEKTRA_ADD_PARSING_WARNINGF (parent, "Not Base64 encoded: %s", strVal); } else if (result == -2) { // Memory error - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parent, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (parent, "Memory allocation failed"); return -1; } @@ -138,7 +138,7 @@ static int encode (Key * key, Key * parent, bool metaMode) char * base64 = base64Encode (keyValue (key), (size_t) keyGetValueSize (key)); if (!base64) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parent, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (parent, "Memory allocation failed"); return -1; } @@ -152,7 +152,7 @@ static int encode (Key * key, Key * parent, bool metaMode) char * newVal = elektraMalloc (newValLen); if (!newVal) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parent, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (parent, "Memory allocation failed"); elektraFree (base64); return -1; } @@ -192,7 +192,7 @@ static int escape (Key * key, Key * parent) char * escapedVal = elektraMalloc (strValLen + 2); if (!escapedVal) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parent, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (parent, "Memory allocation failed"); return -1; } diff --git a/src/plugins/blockresolver/blockresolver.c b/src/plugins/blockresolver/blockresolver.c index 3e7aef790b4..8445fb81ddf 100644 --- a/src/plugins/blockresolver/blockresolver.c +++ b/src/plugins/blockresolver/blockresolver.c @@ -255,7 +255,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E struct stat buf; if (stat (data->realFile, &buf)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to stat file %s\n", data->realFile); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile); return -1; } if (buf.st_mtime == data->mtime) return 0; @@ -264,7 +264,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E fin = fopen (data->realFile, "r"); if (!fin) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open %s for reading", data->realFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile); goto GET_CLEANUP; } @@ -273,14 +273,14 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E data->endPos = getBlockEnd (fin, data->identifier, data->startPos); if (data->endPos == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Couldn't find end of block %s", data->identifier); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Couldn't find end of block %s", data->identifier); retVal = -1; goto GET_CLEANUP; } block = (char *) getBlock (fin, data->startPos, data->endPos); if (!block) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Failed to extract block %s\n", data->identifier); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Failed to extract block %s\n", data->identifier); retVal = -1; goto GET_CLEANUP; } @@ -289,7 +289,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E fout = fopen (data->tmpFile, "w"); if (!fout) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open %s for writing", data->tmpFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->tmpFile); retVal = -1; goto GET_CLEANUP; } @@ -312,12 +312,12 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E struct stat buf; if (stat (data->realFile, &buf)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to stat file %s\n", data->realFile); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile); return -1; } if (buf.st_mtime > data->mtime) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, "%s has been modified", data->realFile); + ELEKTRA_SET_CONFLICT_ERRORF (parentKey, "%s has been modified", data->realFile); return -1; } FILE * fout = NULL; @@ -337,19 +337,19 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E fout = fopen (mergeFile, "w"); if (!fout) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open %s for writing", data->realFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->realFile); goto SET_CLEANUP; } fin = fopen (data->realFile, "r"); if (!fin) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open %s for reading", data->realFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile); goto SET_CLEANUP; } block = (char *) getBlock (fin, 0, data->startPos); if (!block) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Failed to extract block before %s\n", data->identifier); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Failed to extract block before %s\n", data->identifier); goto SET_CLEANUP; } fwrite (block, 1, data->startPos, fout); @@ -360,14 +360,14 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E block = (char *) getBlock (fin, data->endPos, ftell (fin)); if (!block) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Failed to extract block after %s\n", data->identifier); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Failed to extract block after %s\n", data->identifier); goto SET_CLEANUP; } fclose (fin); fin = fopen (data->tmpFile, "r"); if (!fin) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open %s for reading", data->tmpFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->tmpFile); goto SET_CLEANUP; } char buffer[BUFSIZE_MAX]; diff --git a/src/plugins/boolean/boolean.c b/src/plugins/boolean/boolean.c index 373546e809d..35a3d43a97b 100644 --- a/src/plugins/boolean/boolean.c +++ b/src/plugins/boolean/boolean.c @@ -135,9 +135,9 @@ static void normalize (Key * key, Key * parentKey, BoolData * data) case TRUE: if (data->invalid & WARNING) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, parentKey, - "Key %s with value %s is not a valid boolean. Defaulting to %s.", keyName (key), - origvalue, data->trueValue); + ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNINGF (parentKey, + "Key %s with value %s is not a valid boolean. Defaulting to %s.", + keyName (key), origvalue, data->trueValue); } keySetMeta (key, "origvalue", origvalue); keySetString (key, data->trueValue); @@ -145,9 +145,9 @@ static void normalize (Key * key, Key * parentKey, BoolData * data) case FALSE: if (data->invalid & WARNING) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, parentKey, - "Key %s with value %s is not a valid boolean. Defaulting to %s.", keyName (key), - origvalue, data->falseValue); + ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNINGF (parentKey, + "Key %s with value %s is not a valid boolean. Defaulting to %s.", + keyName (key), origvalue, data->falseValue); } keySetString (key, data->falseValue); keySetMeta (key, "origvalue", origvalue); @@ -343,8 +343,8 @@ int elektraBooleanSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA (keyGetMeta (key, "boolean/invalid"))) { keySetMeta (key, "boolean/invalid", 0); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s is not a valid boolean value", - keyString (originalValue)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s is not a valid boolean value", + keyString (originalValue)); retVal = -1; } if (originalValue) restoreValue (key, keyString (originalValue)); diff --git a/src/plugins/cachefilter/cachefilter.c b/src/plugins/cachefilter/cachefilter.c index 3c1a0f0f53c..c0839c38033 100644 --- a/src/plugins/cachefilter/cachefilter.c +++ b/src/plugins/cachefilter/cachefilter.c @@ -78,7 +78,7 @@ int elektraCachefilterSet (Plugin * handle, KeySet * returned, Key * parentKey) void * cache = elektraPluginGetData (handle); if (cache == NULL) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "Cache was not initialized."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Cache was not initialized."); return -1; // did not call kdbGet() before and therefore // also no elektraCachefilterGet() } diff --git a/src/plugins/camel/camel.c b/src/plugins/camel/camel.c index 1c35ee42ca1..b4ec3b3c8c3 100644 --- a/src/plugins/camel/camel.c +++ b/src/plugins/camel/camel.c @@ -87,8 +87,8 @@ typedef struct ELEKTRA_LOG_DEBUG ("%s:%zu:%zu: " message, strrchr (keyString (data->parentKey), '/') + 1, data->line, data->column, __VA_ARGS__); #define SET_ERROR_PARSE(data, message, ...) \ - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, data->parentKey, "General parse error: %s:%zu:%zu: " message, \ - keyString (data->parentKey), data->line, data->column, __VA_ARGS__); + ELEKTRA_SET_PARSING_ERRORF (data->parentKey, "General parse error: %s:%zu:%zu: " message, keyString (data->parentKey), data->line, \ + data->column, __VA_ARGS__); #define RET_NOK(function) \ if (function->status != OK) \ diff --git a/src/plugins/conditionals/conditionals.c b/src/plugins/conditionals/conditionals.c index 445124db2a5..671d8d4c17f 100644 --- a/src/plugins/conditionals/conditionals.c +++ b/src/plugins/conditionals/conditionals.c @@ -209,7 +209,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp } if (elektraRealloc ((void **) &compareTo, endPos - rightSide) < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Out of memory"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -228,7 +228,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp if (elektraRealloc ((void **) &lookupName, len) < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Out of memory"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -244,16 +244,16 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp { if (!keyGetMeta (parentKey, "error")) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Key %s not found but is required for the evaluation of %s", lookupName, - condition); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, + "Key %s not found but is required for the evaluation of %s", + lookupName, condition); } result = FALSE; goto Cleanup; } if (elektraRealloc ((void **) &compareTo, keyGetValueSize (key)) < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Out of memory"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -269,7 +269,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp if (elektraRealloc ((void **) &lookupName, len) < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Out of memory"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -292,8 +292,8 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp { if (!keyGetMeta (parentKey, "error")) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Key %s not found but is required for the evaluation of %s", lookupName, condition); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Key %s not found but is required for the evaluation of %s", + lookupName, condition); } result = FALSE; goto Cleanup; @@ -500,8 +500,8 @@ static const char * isAssign (Key * key, char * expr, Key * parentKey, KeySet * { if (lastPtr <= firstPtr) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", expr); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", expr); return NULL; } *(lastPtr + 1) = '\0'; @@ -524,7 +524,7 @@ static const char * isAssign (Key * key, char * expr, Key * parentKey, KeySet * Key * assign = ksLookup (ks, lookupKey, KDB_O_NONE); if (!assign) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Key %s not found", keyName (lookupKey)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Key %s not found", keyName (lookupKey)); keyDel (lookupKey); return NULL; } @@ -538,15 +538,15 @@ static const char * isAssign (Key * key, char * expr, Key * parentKey, KeySet * { if (firstPtr == lastPtr) // only one quote in the assign string, invalid syntax { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", expr); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", expr); return NULL; } char * nextMark = strchr (firstPtr + 1, '\''); if (nextMark != lastPtr) // more than two quotes, invalid syntax too { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", expr); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", expr); return NULL; } *lastPtr = '\0'; @@ -564,8 +564,8 @@ static CondResult parseCondition (Key * key, const char * condition, const Key * if ((regcomp (®ex, regexString, REG_EXTENDED | REG_NEWLINE))) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_RESOURCE_ERROR (parentKey, + "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory ksDel (ks); @@ -619,8 +619,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList CondResult ret; if ((ret = regcomp (®ex1, regexString1, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_RESOURCE_ERROR (parentKey, + "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory ksDel (ks); @@ -628,8 +628,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if ((ret = regcomp (®ex2, regexString2, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_RESOURCE_ERROR (parentKey, + "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory regfree (®ex1); @@ -638,8 +638,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if ((ret = regcomp (®ex3, regexString3, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_RESOURCE_ERROR (parentKey, + "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory regfree (®ex1); @@ -652,8 +652,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList int nomatch = regexec (®ex1, conditionString, subMatches, m, 0); if (nomatch) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); regfree (®ex2); regfree (®ex3); @@ -662,8 +662,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if (m[1].rm_so == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); regfree (®ex2); regfree (®ex3); @@ -680,8 +680,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList nomatch = regexec (®ex2, conditionString, subMatches, m, 0); if (nomatch) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); regfree (®ex2); regfree (®ex3); @@ -690,8 +690,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if (m[1].rm_so == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); regfree (®ex2); regfree (®ex3); @@ -710,9 +710,9 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList { if (m[1].rm_so == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", - conditionString); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", + conditionString); regfree (®ex1); regfree (®ex2); regfree (®ex3); @@ -750,15 +750,15 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList ret = parseCondition (key, thenexpr, suffixList, ks, parentKey); if (ret == FALSE) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Validation of Key %s: %s failed. (%s failed)", - keyName (key) + strlen (keyName (parentKey)) + 1, conditionString, thenexpr); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Validation of Key %s: %s failed. (%s failed)", + keyName (key) + strlen (keyName (parentKey)) + 1, conditionString, + thenexpr); } else if (ret == ERROR) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", - thenexpr); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", + thenexpr); } } } @@ -787,15 +787,15 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList if (ret == FALSE) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Validation of Key %s: %s failed. (%s failed)", - keyName (key) + strlen (keyName (parentKey)) + 1, conditionString, elseexpr); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Validation of Key %s: %s failed. (%s failed)", + keyName (key) + strlen (keyName (parentKey)) + 1, + conditionString, elseexpr); } else if (ret == ERROR) { - ELEKTRA_SET_ERRORF ( - ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", elseexpr); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", + elseexpr); } } } @@ -806,8 +806,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } else if (ret == ERROR) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, - "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", condition); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( + parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", condition); } CleanUp: diff --git a/src/plugins/cpptemplate/cpptemplate.cpp b/src/plugins/cpptemplate/cpptemplate.cpp index 1ffbcba38b7..40cfa75520d 100644 --- a/src/plugins/cpptemplate/cpptemplate.cpp +++ b/src/plugins/cpptemplate/cpptemplate.cpp @@ -63,7 +63,7 @@ int elektraCppTemplateOpen (Plugin * handle, Key * key) } catch (exception const & error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, key, "Uncaught Exception: %s", error.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (key, "Uncaught Exception: %s", error.what ()); } return status; diff --git a/src/plugins/cpptype/cpptype.cpp b/src/plugins/cpptype/cpptype.cpp index e93ea09ee92..6a479f7a64b 100644 --- a/src/plugins/cpptype/cpptype.cpp +++ b/src/plugins/cpptype/cpptype.cpp @@ -28,7 +28,7 @@ static void setError (Key * key, Key * errorKey) msg += " with string: "; const char * value = keyString (key); if (value) msg += value; - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, msg.c_str ()); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, msg.c_str ()); } extern "C" { diff --git a/src/plugins/crypto/botan_operations.cpp b/src/plugins/crypto/botan_operations.cpp index eaa31b9e893..e2f4d996a1e 100644 --- a/src/plugins/crypto/botan_operations.cpp +++ b/src/plugins/crypto/botan_operations.cpp @@ -66,7 +66,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } if (!saltHexString) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); @@ -89,8 +89,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create a cryptographic key for encryption because: %s", - e.what ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to create a cryptographic key for encryption because: %s", e.what ()); return -1; } } @@ -140,8 +139,7 @@ static int getKeyIvForDecryption (KeySet * config, Key * errorKey, Key * masterK } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to restore the cryptographic key for decryption because: %s", - e.what ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to restore the cryptographic key for decryption because: %s", e.what ()); return -1; } } @@ -154,7 +152,7 @@ int elektraCryptoBotanInit (Key * errorKey) } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Botan initialization failed: %s", e.what ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Botan initialization failed: %s", e.what ()); return -1; // failure } return 1; // success @@ -238,7 +236,7 @@ int elektraCryptoBotanEncrypt (KeySet * pluginConfig, Key * k, Key * errorKey, K } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Encryption failed because: %s", e.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Encryption failed because: %s", e.what ()); elektraFree (salt); return -1; // failure } @@ -310,7 +308,7 @@ int elektraCryptoBotanDecrypt (KeySet * pluginConfig, Key * k, Key * errorKey, K } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Decryption failed because: %s", e.what ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Decryption failed because: %s", e.what ()); return -1; // failure } @@ -340,7 +338,7 @@ char * elektraCryptoBotanCreateRandomString (Key * errorKey, const kdb_unsigned_ } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to generate random string because: %s", e.what ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to generate random string because: %s", e.what ()); return 0; } } diff --git a/src/plugins/crypto/crypto.c b/src/plugins/crypto/crypto.c index c76c30b4c5b..cb3962eabae 100644 --- a/src/plugins/crypto/crypto.c +++ b/src/plugins/crypto/crypto.c @@ -79,10 +79,11 @@ static int checkPayloadVersion (Key * k, Key * errorKey) { if (keyGetValueSize (k) < ((ssize_t) ELEKTRA_CRYPTO_MAGIC_NUMBER_LEN)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey, - "The provided data could not be recognized as valid cryptographic payload. The data is possibly " - "corrupted. Keyname: %s", - keyName (k)); + ELEKTRA_SET_PARSING_ERRORF ( + errorKey, + "The provided data could not be recognized as valid cryptographic payload. The data is possibly " + "corrupted. Keyname: %s", + keyName (k)); return 0; // failure } @@ -90,10 +91,11 @@ static int checkPayloadVersion (Key * k, Key * errorKey) const kdb_octet_t * value = (kdb_octet_t *) keyValue (k); if (memcmp (value, ELEKTRA_CRYPTO_MAGIC_NUMBER, ELEKTRA_CRYPTO_MAGIC_NUMBER_LEN - 2)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey, - "The provided data could not be recognized as valid cryptographic payload. The data is possibly " - "corrupted. Keyname: %s", - keyName (k)); + ELEKTRA_SET_PARSING_ERRORF ( + errorKey, + "The provided data could not be recognized as valid cryptographic payload. The data is possibly " + "corrupted. Keyname: %s", + keyName (k)); return 0; // failure } @@ -101,9 +103,8 @@ static int checkPayloadVersion (Key * k, Key * errorKey) const size_t versionOffset = ELEKTRA_CRYPTO_MAGIC_NUMBER_LEN - 2; if (memcmp (&value[versionOffset], ELEKTRA_CRYPTO_PAYLOAD_VERSION, 2)) { - ELEKTRA_SET_ERRORF ( - ELEKTRA_ERROR_PARSING, errorKey, - "The version of the cryptographic payload is not compatible with the version of the plugin. Keyname: %s", + ELEKTRA_SET_PARSING_ERRORF ( + errorKey, "The version of the cryptographic payload is not compatible with the version of the plugin. Keyname: %s", keyName (k)); return 0; // failure } @@ -156,9 +157,9 @@ static kdb_unsigned_short_t elektraCryptoGetRandomPasswordLength (Key * errorKey } else { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, - "Master password length provided at " ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD_LEN - " is invalid. Using default value instead."); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, + "Master password length provided at " ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD_LEN + " is invalid. Using default value instead."); } } return ELEKTRA_CRYPTO_DEFAULT_MASTER_PWD_LENGTH; diff --git a/src/plugins/crypto/gcrypt_operations.c b/src/plugins/crypto/gcrypt_operations.c index e54d010a58f..5db22f35b45 100644 --- a/src/plugins/crypto/gcrypt_operations.c +++ b/src/plugins/crypto/gcrypt_operations.c @@ -58,7 +58,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } if (!saltHexString) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); @@ -71,8 +71,8 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK if ((gcry_err = gcry_kdf_derive (keyValue (masterKey), keyGetValueSize (masterKey), GCRY_KDF_PBKDF2, GCRY_MD_SHA512, salt, sizeof (salt), iterations, KEY_BUFFER_SIZE, keyBuffer))) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create a cryptographic key for encryption because: %s", - gcry_strerror (gcry_err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to create a cryptographic key for encryption because: %s", + gcry_strerror (gcry_err)); return -1; } @@ -114,8 +114,8 @@ static int getKeyIvForDecryption (KeySet * config, Key * errorKey, Key * masterK if ((gcry_err = gcry_kdf_derive (keyValue (masterKey), keyGetValueSize (masterKey), GCRY_KDF_PBKDF2, GCRY_MD_SHA512, saltBuffer, saltBufferLen, iterations, KEY_BUFFER_SIZE, keyBuffer))) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to restore the cryptographic key for decryption because: %s", - gcry_strerror (gcry_err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to restore the cryptographic key for decryption because: %s", + gcry_strerror (gcry_err)); return -1; } @@ -148,8 +148,7 @@ int elektraCryptoGcryInit (Key * errorKey) // initialize the rest of the gcrypt library if (!gcry_check_version (GCRYPT_VERSION)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Libgcrypt version check failed, looking for version: %s", - GCRYPT_VERSION); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Libgcrypt version check failed, looking for version: %s", GCRYPT_VERSION); return -1; } gcry_control (GCRYCTL_DISABLE_SECMEM, 0); @@ -206,7 +205,7 @@ int elektraCryptoGcryHandleCreate (elektraCryptoHandle ** handle, KeySet * confi memset (ivBuffer, 0, sizeof (ivBuffer)); keyDel (key); keyDel (iv); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } @@ -234,7 +233,7 @@ int elektraCryptoGcryHandleCreate (elektraCryptoHandle ** handle, KeySet * confi error: memset (keyBuffer, 0, sizeof (keyBuffer)); memset (ivBuffer, 0, sizeof (ivBuffer)); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create handle because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to create handle because: %s", gcry_strerror (gcry_err)); gcry_cipher_close (**handle); elektraFree (*handle); (*handle) = NULL; @@ -294,7 +293,7 @@ int elektraCryptoGcryEncrypt (elektraCryptoHandle * handle, Key * k, Key * error kdb_octet_t * output = elektraMalloc (outputLen); if (!output) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); elektraFree (salt); return -1; } @@ -317,7 +316,7 @@ int elektraCryptoGcryEncrypt (elektraCryptoHandle * handle, Key * k, Key * error gcry_err = gcry_cipher_encrypt (*handle, current, ELEKTRA_CRYPTO_GCRY_BLOCKSIZE, NULL, 0); if (gcry_err != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); memset (output, 0, outputLen); elektraFree (output); elektraFree (salt); @@ -332,7 +331,7 @@ int elektraCryptoGcryEncrypt (elektraCryptoHandle * handle, Key * k, Key * error gcry_err = gcry_cipher_encrypt (*handle, current, dataLen, NULL, 0); if (gcry_err != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); memset (output, 0, outputLen); elektraFree (output); elektraFree (salt); @@ -366,7 +365,7 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error // plausibility check if (payloadLen % ELEKTRA_CRYPTO_GCRY_BLOCKSIZE != 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "value length is not a multiple of the block size"); + ELEKTRA_SET_LOGICAL_ERROR (errorKey, "value length is not a multiple of the block size"); return -1; } @@ -374,7 +373,7 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error kdb_octet_t * output = elektraMalloc (payloadLen); if (!output) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } @@ -387,7 +386,7 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error gcry_err = gcry_cipher_decrypt (*handle, output, payloadLen, NULL, 0); if (gcry_err != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Decryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Decryption failed because: %s", gcry_strerror (gcry_err)); memset (output, 0, payloadLen); elektraFree (output); return -1; @@ -403,8 +402,8 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error // validate restored content length if (contentLen > dataLen) { - ELEKTRA_SET_ERROR ( - ELEKTRA_ERROR_PARSING, errorKey, + ELEKTRA_SET_PARSING_ERROR ( + errorKey, "restored content length is bigger than the available amount of decrypted data. The header is possibly corrupted."); memset (output, 0, payloadLen); elektraFree (output); @@ -447,7 +446,7 @@ char * elektraCryptoGcryCreateRandomString (Key * errorKey, const kdb_unsigned_s } if (!encoded) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); } return encoded; } diff --git a/src/plugins/crypto/gpg.c b/src/plugins/crypto/gpg.c index c9dc3a75dee..f8ce9bc8c1a 100644 --- a/src/plugins/crypto/gpg.c +++ b/src/plugins/crypto/gpg.c @@ -86,7 +86,7 @@ static int isExecutable (const char * file, Key * errorKey) { if (errorKey) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "gpg binary %s not found", file); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "gpg binary %s not found", file); } return -1; } @@ -95,7 +95,7 @@ static int isExecutable (const char * file, Key * errorKey) { if (errorKey) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "gpg binary %s has no permission to execute", file); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "gpg binary %s has no permission to execute", file); } return -2; } @@ -116,7 +116,7 @@ static char * genGpgCandidate (Key * errorKey, char * dir, const char * file) char * result = elektraMalloc (resultLen); if (!result) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return NULL; } snprintf (result, resultLen, "%s/%s", dir, file); @@ -146,7 +146,7 @@ static int searchPathForBin (Key * errorKey, const char * bin, char ** result) char * path = elektraMalloc (envPathLen); if (!path) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } memcpy (path, envPath, envPathLen); @@ -196,7 +196,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgGetBinary) (char ** gpgBin, KeySet * conf, Key * *gpgBin = elektraMalloc (configPathLen + 1); if (!(*gpgBin)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } strncpy (*gpgBin, configPath, configPathLen); @@ -237,7 +237,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgGetBinary) (char ** gpgBin, KeySet * conf, Key * *gpgBin = elektraStrDup (ELEKTRA_CRYPTO_DEFAULT_GPG2_BIN); if (!(*gpgBin)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } return 1; @@ -249,15 +249,14 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgGetBinary) (char ** gpgBin, KeySet * conf, Key * *gpgBin = elektraStrDup (ELEKTRA_CRYPTO_DEFAULT_GPG1_BIN); if (!(*gpgBin)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } return 1; } // no GPG for us :-( - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, - "no gpg binary found. Please make sure GnuPG is installed and executable."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "no gpg binary found. Please make sure GnuPG is installed and executable."); return -1; } @@ -448,7 +447,7 @@ static int verifyGpgKeysInConf (Key * root, KeySet * conf, Key * errorKey) { if (isValidGpgKey (conf, rootValue) != 1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, GPG_ERROR_INVALID_KEY, rootValue); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, GPG_ERROR_INVALID_KEY, rootValue); return -1; // failure } } @@ -463,7 +462,7 @@ static int verifyGpgKeysInConf (Key * root, KeySet * conf, Key * errorKey) const char * childValue = keyString (k); if (isValidGpgKey (conf, childValue) != 1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, GPG_ERROR_INVALID_KEY, childValue); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, GPG_ERROR_INVALID_KEY, childValue); return -1; // failure } } @@ -620,14 +619,14 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK // initialize pipes if (pipe (pipe_stdin)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Pipe initialization failed"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Pipe initialization failed"); elektraFree (argv[0]); return -1; } if (pipe (pipe_stdout)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Pipe initialization failed"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Pipe initialization failed"); closePipe (pipe_stdin); elektraFree (argv[0]); return -1; @@ -635,7 +634,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK if (pipe (pipe_stderr)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Pipe initialization failed"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Pipe initialization failed"); closePipe (pipe_stdin); closePipe (pipe_stdout); elektraFree (argv[0]); @@ -646,7 +645,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK // estimated maximum output size = 2 * input (including headers, etc.) if (msgKey && !(buffer = elektraMalloc (bufferSize))) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); @@ -659,7 +658,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK { case -1: // fork() failed - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "fork failed"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "fork failed"); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); @@ -719,7 +718,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK { if (write (pipe_stdin[1], keyValue (msgKey), sendMessageSize) != sendMessageSize) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "The communication with the GPG process failed."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "The communication with the GPG process failed."); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); @@ -749,23 +748,23 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK case 1: // bad signature - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "GPG reported a bad signature"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "GPG reported a bad signature"); break; case GPG_CALL_DUP_STDIN: - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "failed to redirect stdin."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "failed to redirect stdin."); break; case GPG_CALL_DUP_STDOUT: - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "failed to redirect stdout."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "failed to redirect stdout."); break; case GPG_CALL_DUP_STDERR: - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "failed to redirect stderr."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "failed to redirect stderr."); break; case GPG_CALL_EXECV: - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "failed to start the gpg binary: %s", argv[0]); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "failed to start the gpg binary: %s", argv[0]); break; default: @@ -775,7 +774,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK { errorBuffer[0] = '\0'; } - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "GPG failed with return value %d. %s", status, errorBuffer); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "GPG failed with return value %d. %s", status, errorBuffer); break; } diff --git a/src/plugins/crypto/helper.c b/src/plugins/crypto/helper.c index 89f38c46a42..a428fa24dc1 100644 --- a/src/plugins/crypto/helper.c +++ b/src/plugins/crypto/helper.c @@ -112,20 +112,19 @@ int ELEKTRA_PLUGIN_FUNCTION (getSaltFromMetakey) (Key * errorKey, Key * k, kdb_o const Key * meta = keyGetMeta (k, ELEKTRA_CRYPTO_META_SALT); if (!meta) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "missing salt as metakey %s in key %s", ELEKTRA_CRYPTO_META_SALT, - keyName (k)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "missing salt as metakey %s in key %s", ELEKTRA_CRYPTO_META_SALT, keyName (k)); return -1; } int result = ELEKTRA_PLUGIN_FUNCTION (base64Decode) (errorKey, keyString (meta), salt, &saltLenInternal); if (result == -1) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "Salt was not stored Base64 encoded."); + ELEKTRA_SET_LOGICAL_ERROR (errorKey, "Salt was not stored Base64 encoded."); return -1; } else if (result == -2) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } else if (result < -2) @@ -155,8 +154,7 @@ int ELEKTRA_PLUGIN_FUNCTION (getSaltFromPayload) (Key * errorKey, Key * k, kdb_o // validate payload length if ((size_t) payloadLen < sizeof (size_t) || payloadLen < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "payload is too small to contain a salt (payload length is: %zu)", - payloadLen); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "payload is too small to contain a salt (payload length is: %zu)", payloadLen); if (salt) *salt = NULL; return -1; } @@ -172,8 +170,8 @@ int ELEKTRA_PLUGIN_FUNCTION (getSaltFromPayload) (Key * errorKey, Key * k, kdb_o // validate restored salt length if (restoredSaltLen < 1 || restoredSaltLen > (payloadLen - headerLen)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "restored salt has invalid length of %u (payload length is: %zu)", - restoredSaltLen, payloadLen); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "restored salt has invalid length of %u (payload length is: %zu)", restoredSaltLen, + payloadLen); if (salt) *salt = NULL; return -1; } @@ -195,8 +193,7 @@ Key * ELEKTRA_PLUGIN_FUNCTION (getMasterPassword) (Key * errorKey, KeySet * conf Key * master = ksLookupByName (config, ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD, 0); if (!master) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "missing %s in plugin configuration", - ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "missing %s in plugin configuration", ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD); return NULL; } Key * msg = keyDup (master); @@ -226,9 +223,8 @@ kdb_unsigned_long_t ELEKTRA_PLUGIN_FUNCTION (getIterationCount) (Key * errorKey, } else { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, - "iteration count provided at " ELEKTRA_CRYPTO_PARAM_ITERATION_COUNT - " is invalid. Using default value instead."); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "iteration count provided at " ELEKTRA_CRYPTO_PARAM_ITERATION_COUNT + " is invalid. Using default value instead."); } } return ELEKTRA_CRYPTO_DEFAULT_ITERATION_COUNT; diff --git a/src/plugins/crypto/openssl_operations.c b/src/plugins/crypto/openssl_operations.c index 0844c398661..d367f5a7606 100644 --- a/src/plugins/crypto/openssl_operations.c +++ b/src/plugins/crypto/openssl_operations.c @@ -60,8 +60,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK pthread_mutex_lock (&mutex_ssl); if (!RAND_bytes (salt, ELEKTRA_CRYPTO_DEFAULT_SALT_LEN - 1)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "failed to generate random salt with error code %lu", - ERR_get_error ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "failed to generate random salt with error code %lu", ERR_get_error ()); pthread_mutex_unlock (&mutex_ssl); return -1; } @@ -74,7 +73,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } if (!saltHexString) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); @@ -88,9 +87,9 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK if (!PKCS5_PBKDF2_HMAC_SHA1 (keyValue (masterKey), keyGetValueSize (masterKey), salt, sizeof (salt), iterations, KEY_BUFFER_SIZE, keyBuffer)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, - "Failed to create a cryptographic key for encryption. Libcrypto returned error code: %lu", - ERR_get_error ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, + "Failed to create a cryptographic key for encryption. Libcrypto returned error code: %lu", + ERR_get_error ()); pthread_mutex_unlock (&mutex_ssl); return -1; } @@ -134,9 +133,9 @@ static int getKeyIvForDecryption (KeySet * config, Key * errorKey, Key * masterK if (!PKCS5_PBKDF2_HMAC_SHA1 (keyValue (masterKey), keyGetValueSize (masterKey), saltBuffer, saltBufferLen, iterations, KEY_BUFFER_SIZE, keyBuffer)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, - "Failed to restore the cryptographic key for decryption. Libcrypto returned the error code: %lu", - ERR_get_error ()); + ELEKTRA_SET_LOGICAL_ERRORF ( + errorKey, "Failed to restore the cryptographic key for decryption. Libcrypto returned the error code: %lu", + ERR_get_error ()); pthread_mutex_unlock (&mutex_ssl); return -1; } @@ -200,7 +199,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { keyDel (key); keyDel (iv); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create handle! Invalid key length."); + ELEKTRA_SET_LOGICAL_ERROR (errorKey, "Failed to create handle! Invalid key length."); return -1; } @@ -208,7 +207,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { keyDel (key); keyDel (iv); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create handle! Invalid IV length."); + ELEKTRA_SET_LOGICAL_ERROR (errorKey, "Failed to create handle! Invalid IV length."); return -1; } @@ -223,7 +222,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { memset (keyBuffer, 0, sizeof (keyBuffer)); memset (ivBuffer, 0, sizeof (ivBuffer)); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); return -1; } @@ -240,8 +239,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co if (ERR_peek_error ()) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create handle! libcrypto error code was: %lu", - ERR_get_error ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to create handle! libcrypto error code was: %lu", ERR_get_error ()); elektraFree (*handle); *handle = NULL; pthread_mutex_unlock (&mutex_ssl); @@ -308,7 +306,7 @@ int elektraCryptoOpenSSLEncrypt (elektraCryptoHandle * handle, Key * k, Key * er encrypted = BIO_new (BIO_s_mem ()); if (!encrypted) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); pthread_mutex_unlock (&mutex_ssl); elektraFree (salt); return -1; @@ -389,7 +387,7 @@ int elektraCryptoOpenSSLEncrypt (elektraCryptoHandle * handle, Key * k, Key * er return 1; error: - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Encryption error! libcrypto error code was: %lu", ERR_get_error ()); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Encryption error! libcrypto error code was: %lu", ERR_get_error ()); BIO_free_all (encrypted); pthread_mutex_unlock (&mutex_ssl); elektraFree (salt); @@ -424,7 +422,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er // plausibility check if (payloadLen % ELEKTRA_CRYPTO_SSL_BLOCKSIZE != 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, "value length is not a multiple of the block size"); + ELEKTRA_SET_PARSING_ERROR (errorKey, "value length is not a multiple of the block size"); return -1; } @@ -434,7 +432,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er BIO * decrypted = BIO_new (BIO_s_mem ()); if (!decrypted) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); pthread_mutex_unlock (&mutex_ssl); return -1; } @@ -468,7 +466,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er plaintextLen = BIO_get_mem_data (decrypted, &plaintext); if (plaintextLen < headerLen) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, "Decryption error! header data is incomplete."); + ELEKTRA_SET_PARSING_ERROR (errorKey, "Decryption error! header data is incomplete."); goto error; } @@ -481,8 +479,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er // validate restored header if (contentLen > (plaintextLen - headerLen)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, - "Content length is bigger than amount of decrypted data. Data is possibly corrupted."); + ELEKTRA_SET_PARSING_ERROR (errorKey, "Content length is bigger than amount of decrypted data. Data is possibly corrupted."); goto error; } @@ -505,7 +502,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er return 1; error: - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Decryption error! libcrypto error code was: %lu", ERR_get_error ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Decryption error! libcrypto error code was: %lu", ERR_get_error ()); BIO_free_all (decrypted); pthread_mutex_unlock (&mutex_ssl); return -1; @@ -524,8 +521,7 @@ char * elektraCryptoOpenSSLCreateRandomString (Key * errorKey, const kdb_unsigne pthread_mutex_lock (&mutex_ssl); if (!RAND_bytes (buffer, length)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to generate random string. libcrypto error code was: %lu", - ERR_get_error ()); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to generate random string. libcrypto error code was: %lu", ERR_get_error ()); pthread_mutex_unlock (&mutex_ssl); return NULL; } @@ -537,7 +533,7 @@ char * elektraCryptoOpenSSLCreateRandomString (Key * errorKey, const kdb_unsigne } if (!encoded) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); } return encoded; } diff --git a/src/plugins/csvstorage/csvstorage.c b/src/plugins/csvstorage/csvstorage.c index c2c0a2dea43..f9706f33b47 100644 --- a/src/plugins/csvstorage/csvstorage.c +++ b/src/plugins/csvstorage/csvstorage.c @@ -136,9 +136,9 @@ static char * parseLine (char * origLine, char delim, unsigned long offset, Key isCol = 0; if (!lastLine) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, - "Unexpected end of line(%lu), all records except the last must and with a newline", - lineNr); + ELEKTRA_ADD_PARSING_WARNINGF ( + parentKey, "Unexpected end of line(%lu), all records except the last must and with a newline", + lineNr); } } } @@ -149,8 +149,8 @@ static char * parseLine (char * origLine, char delim, unsigned long offset, Key { line[len - 2] = '\0'; } - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, - "Unexpected end of line(%lu). unbalanced number of double-quotes in (%s)", lineNr, line); + ELEKTRA_ADD_PARSING_WARNINGF (parentKey, "Unexpected end of line(%lu). unbalanced number of double-quotes in (%s)", lineNr, + line); } else if (isCol) { @@ -158,7 +158,7 @@ static char * parseLine (char * origLine, char delim, unsigned long offset, Key { line[len - 2] = '\0'; } - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, "Unexpected end of line(%lu): (%s)", lineNr, line); + ELEKTRA_ADD_PARSING_WARNINGF (parentKey, "Unexpected end of line(%lu): (%s)", lineNr, line); } else { @@ -166,8 +166,7 @@ static char * parseLine (char * origLine, char delim, unsigned long offset, Key } if (hasUnescapedDQuote) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, "Quoted field in line(%lu) has an unescaped double-quote: (%s)", - lineNr, line); + ELEKTRA_ADD_PARSING_WARNINGF (parentKey, "Quoted field in line(%lu) has an unescaped double-quote: (%s)", lineNr, line); } return line; @@ -335,7 +334,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP FILE * fp = fopen (fileName, "rb"); if (!fp) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "couldn't open file %s", fileName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "couldn't open file %s", fileName); return -1; } int lastLine = 0; @@ -352,8 +351,8 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP { if (columns != fixColumnCount) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "illegal number of columns (%lu - %lu) in Header line: %s", - columns, fixColumnCount, lineBuffer); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "illegal number of columns (%lu - %lu) in Header line: %s", columns, + fixColumnCount, lineBuffer); elektraFree (lineBuffer); fclose (fp); return -1; @@ -480,17 +479,16 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP { if (fixColumnCount) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, - "illegal number of columns (%lu - %lu) in line %lu: %s", colCounter, columns, - lineCounter, lineBuffer); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "illegal number of columns (%lu - %lu) in line %lu: %s", colCounter, + columns, lineCounter, lineBuffer); elektraFree (lineBuffer); fclose (fp); keyDel (dirKey); ksDel (header); return -1; } - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, "illegal number of columns (%lu - %lu) in line %lu: %s", - colCounter, columns, lineCounter, lineBuffer); + ELEKTRA_ADD_PARSING_WARNINGF (parentKey, "illegal number of columns (%lu - %lu) in line %lu: %s", colCounter, + columns, lineCounter, lineBuffer); } lineCounter += linesRead; elektraFree (lineBuffer); @@ -721,8 +719,8 @@ static int csvWrite (KeySet * returned, Key * parentKey, KeySet * exportKS, Key } if (colCounter != columns) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "illegal number of columns (%lu - %lu) in line %lu", - colCounter, columns, lineCounter); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "illegal number of columns (%lu - %lu) in line %lu", colCounter, columns, + lineCounter); fclose (fp); return -1; } diff --git a/src/plugins/curlget/curlget.c b/src/plugins/curlget/curlget.c index 6aebef69550..3699a165a64 100644 --- a/src/plugins/curlget/curlget.c +++ b/src/plugins/curlget/curlget.c @@ -427,7 +427,7 @@ int elektraCurlgetOpen (Plugin * handle, Key * errorKey ELEKTRA_UNUSED) { if (!data->password) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "No password specified for SSH password authentication"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "No password specified for SSH password authentication"); if (data->uploadFileName) elektraFree (data->__uploadFileName); elektraFree (data); data = NULL; @@ -620,7 +620,7 @@ int elektraCurlgetGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA if (fd == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open %s for reading", data->path); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading", data->path); return -1; } FILE * fp = fetchFile (data, fd); @@ -632,13 +632,12 @@ int elektraCurlgetGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA fp = fopen (data->path, "rb"); if (fp && data->useLocalCopy) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, - "Failed to fetch configuration from %s, falling back to local copy %s\n", data->getUrl, - data->path); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to fetch configuration from %s, falling back to local copy %s\n", + data->getUrl, data->path); } else { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to read configuration\n"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Failed to read configuration\n"); return -1; } } @@ -722,7 +721,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA ++(data->setPhase); if (strncmp ((char *) data->lastHash, (char *) hash, MD5_DIGEST_LENGTH)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, "remote file has changed"); + ELEKTRA_SET_CONFLICT_ERROR (parentKey, "remote file has changed"); retval = -1; } elektraFree (hash); @@ -733,9 +732,9 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA else { close (fd); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, - "Failed to fetch configuration from %s. Aborting because consistency can't be ensured", - data->getUrl); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, + "Failed to fetch configuration from %s. Aborting because consistency can't be ensured", + data->getUrl); if (data->tmpFile) unlink (data->tmpFile); data->tmpFile = NULL; if (data->useLocalCopy) keySetString (parentKey, data->path); @@ -763,7 +762,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA fp = fopen (tmpFile, "rb"); if (!fp) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open %s for reading", tmpFile); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading", tmpFile); return -1; } fseek (fp, 0L, SEEK_END); @@ -817,8 +816,8 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, - "curl upload (HTTP POST) failed: %s\n", curl_easy_strerror (res)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (HTTP POST) failed: %s\n", + curl_easy_strerror (res)); retval = -1; } curl_formfree (formpost); @@ -833,8 +832,8 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (HTTP PUT) failed: %s", - curl_easy_strerror (res)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (HTTP PUT) failed: %s", + curl_easy_strerror (res)); retval = -1; } } @@ -846,8 +845,8 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (HTTP PUT) failed: %s", - curl_easy_strerror (res)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (HTTP PUT) failed: %s", + curl_easy_strerror (res)); retval = -1; } } @@ -883,8 +882,8 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (FTP PUT) failed: %s", - curl_easy_strerror (res)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (FTP PUT) failed: %s", + curl_easy_strerror (res)); retval = -1; } } @@ -909,11 +908,11 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA if (res != CURLE_OK) { if (data->putProto == PROTO_SCP) - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (SCP) failed: %s", - curl_easy_strerror (res)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (SCP) failed: %s", + curl_easy_strerror (res)); else if (data->putProto == PROTO_SFTP) - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (SFTP) failed: %s", - curl_easy_strerror (res)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (SFTP) failed: %s", + curl_easy_strerror (res)); retval = -1; } } @@ -929,8 +928,8 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (default) failed: %s", - curl_easy_strerror (res)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (default) failed: %s", + curl_easy_strerror (res)); retval = -1; } } diff --git a/src/plugins/date/date.c b/src/plugins/date/date.c index 67e309e96bc..9024968ba10 100644 --- a/src/plugins/date/date.c +++ b/src/plugins/date/date.c @@ -411,8 +411,7 @@ static int validateKey (Key * key, Key * parentKey) rc = formatStringValidation (date, formatString); if (rc == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s doesn't match format string %s", date, - formatString); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s doesn't match format string %s", date, formatString); rc = 0; } } @@ -422,16 +421,15 @@ static int validateKey (Key * key, Key * parentKey) if (rc == -1) { if (formatString) - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s doesn't match iso specification %s", - date, formatString); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s doesn't match iso specification %s", date, + formatString); else - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s is not a valid ISO8601 date", date); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s is not a valid ISO8601 date", date); rc = 0; } else if (rc == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "syntax error in ISO8601 format string '%s'", - formatString); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "syntax error in ISO8601 format string '%s'", formatString); } } else if (!strcasecmp (stdString, "RFC2822")) @@ -439,7 +437,7 @@ static int validateKey (Key * key, Key * parentKey) rc = rfc2822StringValidation (date); if (rc == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s doesn't match rfc2822 specification", date); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s doesn't match rfc2822 specification", date); rc = 0; } } @@ -448,8 +446,7 @@ static int validateKey (Key * key, Key * parentKey) rc = rfc822StringValidation (date); if (rc == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s doesn't match format string %s", date, - formatString); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s doesn't match format string %s", date, formatString); rc = 0; } } diff --git a/src/plugins/directoryvalue/directoryvalue.cpp b/src/plugins/directoryvalue/directoryvalue.cpp index 240f92b35cc..50f12702369 100644 --- a/src/plugins/directoryvalue/directoryvalue.cpp +++ b/src/plugins/directoryvalue/directoryvalue.cpp @@ -81,11 +81,11 @@ int elektraDirectoryValueGet (Plugin * handle, KeySet * returned, Key * parentKe } catch (range_error const & error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Unable to insert array value %s", error.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (*parent, "Unable to insert array value %s", error.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught Exception: %s", error.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (*parent, "Uncaught Exception: %s", error.what ()); } #ifdef HAVE_LOGGER @@ -114,11 +114,11 @@ int elektraDirectoryValueSet (Plugin * handle, KeySet * returned, Key * parentKe } catch (range_error const & error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Unable to insert array value %s", error.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (*parent, "Unable to insert array value %s", error.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught exception: %s", error.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (*parent, "Uncaught exception: %s", error.what ()); } parent.release (); diff --git a/src/plugins/doc/doc.c b/src/plugins/doc/doc.c index e2cc54a83a7..3f6d6da5b3b 100644 --- a/src/plugins/doc/doc.c +++ b/src/plugins/doc/doc.c @@ -90,7 +90,7 @@ module:simpleini //! [plugin errors spec] //! [plugin errors usage] -ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "not at the end of file"); +ELEKTRA_SET_PARSING_ERROR ( parentKey, "not at the end of file"); //! [plugin errors usage] */ @@ -127,8 +127,7 @@ int elektraDocGet (Plugin * plugin ELEKTRA_UNUSED, KeySet * returned, Key * pare Key * read = keyNew (keyName (parentKey), KEY_END); if (keyAddName (read, key) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "Key name %s is not valid, discarding key", - key); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parentKey, "Key name %s is not valid, discarding key", key); keyDel (read); continue; } @@ -140,7 +139,7 @@ int elektraDocGet (Plugin * plugin ELEKTRA_UNUSED, KeySet * returned, Key * pare if (feof (fp) == 0) { fclose (fp); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "Invalid line encountered: not at the end of file"); + ELEKTRA_SET_PARSING_ERROR (parentKey, "Invalid line encountered: not at the end of file"); return -1; } diff --git a/src/plugins/dump/dump.cpp b/src/plugins/dump/dump.cpp index f627934f988..6cfea5440b5 100644 --- a/src/plugins/dump/dump.cpp +++ b/src/plugins/dump/dump.cpp @@ -115,8 +115,7 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks) ss >> version; if (version != "1") { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey, "Wrong version detected in dumpfile: %s", - version.c_str ()); + ELEKTRA_SET_PARSING_ERRORF (errorKey, "Wrong version detected in dumpfile: %s", version.c_str ()); return -1; } } @@ -189,7 +188,7 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks) } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey, "Wrong version detected in dumpfile: %s", command.c_str ()); + ELEKTRA_SET_PARSING_ERRORF (errorKey, "Wrong version detected in dumpfile: %s", command.c_str ()); return -1; } } diff --git a/src/plugins/enum/enum.c b/src/plugins/enum/enum.c index ca4b0fe0688..ff6175daf95 100644 --- a/src/plugins/enum/enum.c +++ b/src/plugins/enum/enum.c @@ -215,8 +215,8 @@ static int validateKey (Key * key, Key * parentKey) rc = validateWithArray (key); if (!rc) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Validation of key \"%s\" with string \"%s\" failed.", - keyName (key), keyString (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Validation of key \"%s\" with string \"%s\" failed.", keyName (key), + keyString (key)); } return rc; } diff --git a/src/plugins/fcrypt/fcrypt.c b/src/plugins/fcrypt/fcrypt.c index 5ef8f7fc673..a4e1db41fe3 100644 --- a/src/plugins/fcrypt/fcrypt.c +++ b/src/plugins/fcrypt/fcrypt.c @@ -127,7 +127,7 @@ static int shredTemporaryFile (int fd, Key * errorKey) if (fstat (fd, &tmpStat)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Failed to retrieve the file status of the temporary file."); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Failed to retrieve the file status of the temporary file."); return -1; } @@ -146,7 +146,7 @@ static int shredTemporaryFile (int fd, Key * errorKey) return 1; error: - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Failed to overwrite the temporary file."); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Failed to overwrite the temporary file."); return -1; } @@ -226,8 +226,7 @@ static int fcryptGpgCallAndCleanup (Key * parentKey, KeySet * pluginConfig, char // gpg call returned success, overwrite the original file with the gpg payload data if (rename (tmpFile, keyString (parentKey)) != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Renaming file %s to %s failed.", tmpFile, - keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Renaming file %s to %s failed.", tmpFile, keyString (parentKey)); result = -1; } } @@ -245,20 +244,21 @@ static int fcryptGpgCallAndCleanup (Key * parentKey, KeySet * pluginConfig, char shredTemporaryFile (tmpFileFd, parentKey); if (unlink (tmpFile)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, - "Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try to delete " - "the file manually. Affected file: %s, error description: %s", - tmpFile, strerror (errno)); + ELEKTRA_ADD_LOGICAL_WARNINGF ( + parentKey, + "Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try to delete " + "the file manually. Affected file: %s, error description: %s", + tmpFile, strerror (errno)); } } if (parentKeyFd >= 0 && close (parentKeyFd)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } if (close (tmpFileFd)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } elektraFree (tmpFile); return result; @@ -279,8 +279,8 @@ static int fcryptEncrypt (KeySet * pluginConfig, Key * parentKey) if (recipientCount == 0 && signatureCount == 0) { - ELEKTRA_SET_ERRORF ( - ELEKTRA_ERROR_INSTALLATION, parentKey, + ELEKTRA_SET_INSTALLATION_ERRORF ( + parentKey, "Missing GPG recipient key (specified as %s) or GPG signature key (specified as %s) in plugin configuration.", ELEKTRA_RECIPIENT_KEY, ELEKTRA_SIGNATURE_KEY); return -1; @@ -290,7 +290,7 @@ static int fcryptEncrypt (KeySet * pluginConfig, Key * parentKey) char * tmpFile = getTemporaryFileName (pluginConfig, keyString (parentKey), &tmpFileFd); if (!tmpFile) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Memory allocation failed"); return -1; } @@ -429,7 +429,7 @@ static int fcryptDecrypt (KeySet * pluginConfig, Key * parentKey, fcryptState * char * tmpFile = getTemporaryFileName (pluginConfig, keyString (parentKey), &tmpFileFd); if (!tmpFile) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Memory allocation failed"); return -1; } @@ -483,15 +483,15 @@ static int fcryptDecrypt (KeySet * pluginConfig, Key * parentKey, fcryptState * shredTemporaryFile (tmpFileFd, parentKey); if (unlink (tmpFile)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, - "Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try to delete " - "the file manually. Affected file: %s, error description: %s", - tmpFile, strerror (errno)); + ELEKTRA_ADD_LOGICAL_WARNINGF ( + parentKey, + "Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try to delete " + "the file manually. Affected file: %s, error description: %s", + tmpFile, strerror (errno)); } if (close (tmpFileFd)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", - strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } elektraFree (tmpFile); } @@ -508,7 +508,7 @@ int ELEKTRA_PLUGIN_FUNCTION (open) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, fcryptState * s = elektraMalloc (sizeof (fcryptState)); if (!s) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Memory allocation failed"); return -1; } @@ -533,8 +533,7 @@ int ELEKTRA_PLUGIN_FUNCTION (close) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED { if (s->tmpFileFd > 0 && close (s->tmpFileFd)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", - strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } if (s->tmpFilePath) { @@ -573,7 +572,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, fcryptState * s = (fcryptState *) elektraPluginGetData (handle); if (!s) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "No plugin state is available."); + ELEKTRA_SET_LOGICAL_ERROR (parentKey, "No plugin state is available."); return -1; } @@ -586,7 +585,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, } else { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "The path to the original file is lost."); + ELEKTRA_SET_LOGICAL_ERROR (parentKey, "The path to the original file is lost."); // clean-up is performed by kdb close return -1; } @@ -596,16 +595,16 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, shredTemporaryFile (s->tmpFileFd, parentKey); if (close (s->tmpFileFd)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", - strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } s->tmpFileFd = -1; if (unlink (s->tmpFilePath)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, - "Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try " - "to delete the file manually. Affected file: %s, error description: %s", - s->tmpFilePath, strerror (errno)); + ELEKTRA_ADD_LOGICAL_WARNINGF ( + parentKey, + "Failed to unlink a temporary file. WARNING: unencrypted data may leak! Please try " + "to delete the file manually. Affected file: %s, error description: %s", + s->tmpFilePath, strerror (errno)); } elektraFree (s->tmpFilePath); s->tmpFilePath = NULL; @@ -636,24 +635,21 @@ int ELEKTRA_PLUGIN_FUNCTION (set) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, int fd = open (configFile, O_RDWR); if (fd == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open config file %s because %s", configFile, - strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open config file %s because %s", configFile, strerror (errno)); return -1; } if (fsync (fd) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not fsync config file %s because %s", configFile, - strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not fsync config file %s because %s", configFile, strerror (errno)); if (close (fd)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", - strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } return -1; } if (close (fd)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } return 1; } @@ -673,7 +669,7 @@ int ELEKTRA_PLUGIN_FUNCTION (checkconf) (Key * errorKey, KeySet * conf) if (recipientCount == 0 && signatureCount == 0) { char * errorDescription = ELEKTRA_PLUGIN_FUNCTION (getMissingGpgKeyErrorText) (conf); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, errorDescription); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, errorDescription); elektraFree (errorDescription); return -1; } diff --git a/src/plugins/file/file.c b/src/plugins/file/file.c index 7236b29d6cc..624d2578276 100644 --- a/src/plugins/file/file.c +++ b/src/plugins/file/file.c @@ -48,8 +48,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN struct stat sb; if (stat (fileName, &sb) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "failed to stat file %s, aborting. Reason: %s", fileName, - strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "failed to stat file %s, aborting. Reason: %s", fileName, strerror (errno)); return -1; } @@ -63,8 +62,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN if (!buffer) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "failed to allocate buffer of %lld bytes for %s", fileSize, - fileName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "failed to allocate buffer of %lld bytes for %s", fileSize, fileName); return -1; } @@ -72,7 +70,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN fp = fopen (fileName, "rb"); if (!fp) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open file %s", fileName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open file %s", fileName); elektraFree (buffer); return -1; } @@ -89,8 +87,8 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN if (bytesRead < fileSize) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "failed to read %s completely. got %lld of %lld bytes", fileName, - bytesRead, fileSize); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "failed to read %s completely. got %lld of %lld bytes", fileName, bytesRead, + fileSize); elektraFree (buffer); fclose (fp); return -1; @@ -144,7 +142,7 @@ int elektraFileSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN fp = fopen (fileName, "wb"); if (!fp) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "failed to open %s for writing", fileName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "failed to open %s for writing", fileName); return -1; } ssize_t svalueSize = keyGetValueSize (key); diff --git a/src/plugins/filecheck/filecheck.c b/src/plugins/filecheck/filecheck.c index fdf88317b47..cc592065818 100644 --- a/src/plugins/filecheck/filecheck.c +++ b/src/plugins/filecheck/filecheck.c @@ -206,7 +206,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che FILE * fp = fopen (filename, "rb"); if (fp == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open file %s", filename); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open file %s", filename); return -1; } iconv_t conv = NULL; @@ -222,8 +222,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che } if (conv == (iconv_t) (-1)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Couldn't initialize iconv with encoding %s\n", - checkConf->encoding); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Couldn't initialize iconv with encoding %s\n", checkConf->encoding); fclose (fp); return -2; } @@ -247,8 +246,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che le_ret = validateLineEnding (line, &(checkConf->validLE), 0); if (le_ret) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "invalid lineending at position %zd", - bytesRead + le_ret); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "invalid lineending at position %zd", bytesRead + le_ret); retVal = -1; break; } @@ -258,8 +256,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che null_ret = checkNull (line, bytesRead); if (null_ret) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "found null-byte at position %zd", - bytesRead + null_ret); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "found null-byte at position %zd", bytesRead + null_ret); retVal = -1; break; } @@ -269,8 +266,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che iconv_ret = validateEncoding (line, conv, bytesRead); if (iconv_ret) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "invalid encoding at position %zd", - bytesRead + iconv_ret); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "invalid encoding at position %zd", bytesRead + iconv_ret); retVal = -1; break; } @@ -280,7 +276,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che bom_ret = checkBom (line); if (bom_ret) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "found BOM"); + ELEKTRA_SET_PARSING_ERROR (parentKey, "found BOM"); retVal = -1; break; } @@ -291,8 +287,8 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che unprintable_ret = checkUnprintable (line); if (unprintable_ret) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "unprintable character at position %zd", - bytesRead + unprintable_ret); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "unprintable character at position %zd", + bytesRead + unprintable_ret); retVal = -1; break; } diff --git a/src/plugins/gitresolver/gitresolver.c b/src/plugins/gitresolver/gitresolver.c index 5f9cdb1afb7..18084de91de 100644 --- a/src/plugins/gitresolver/gitresolver.c +++ b/src/plugins/gitresolver/gitresolver.c @@ -641,7 +641,7 @@ int elektraGitresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE git_repository * repo = connectToLocalRepo (data); if (!repo) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open Repository %s\n", data->repo); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open Repository %s\n", data->repo); git_libgit2_shutdown (); return -1; } @@ -652,7 +652,7 @@ int elektraGitresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE git_reference * headRef = getHeadRef (data, repo); if (!headRef) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to get reference %s\n", data->refName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to get reference %s\n", data->refName); git_repository_free (repo); git_libgit2_shutdown (); return -1; @@ -662,7 +662,7 @@ int elektraGitresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE int rc = pullFromRemote (data, repo); if (rc) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, "Fast-forward pull failed, please pull manually\n"); + ELEKTRA_SET_CONFLICT_ERROR (parentKey, "Fast-forward pull failed, please pull manually\n"); git_repository_free (repo); git_libgit2_shutdown (); return -1; @@ -671,7 +671,7 @@ int elektraGitresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE const git_oid * headObj = git_reference_target (headRef); if (!headObj) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to get reference %s\n", data->refName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to get reference %s\n", data->refName); git_reference_free (headRef); git_repository_free (repo); git_libgit2_shutdown (); @@ -704,7 +704,7 @@ int elektraGitresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE git_object * blob = getBlob (data, repo); if (!blob) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "File %s not found in repository %s\n", data->file, data->repo); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "File %s not found in repository %s\n", data->file, data->repo); git_repository_free (repo); git_libgit2_shutdown (); return 0; @@ -747,8 +747,7 @@ int elektraGitresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE outFile = fopen (keyString (parentKey), "w+"); if (!outFile) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to check out file %s to %s\n", data->file, - keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to check out file %s to %s\n", data->file, keyString (parentKey)); git_object_free (blob); git_repository_free (repo); git_libgit2_shutdown (); @@ -833,14 +832,14 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE git_repository * repo = connectToLocalRepo (data); if (!repo) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open Repository %s\n", data->repo); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open Repository %s\n", data->repo); git_libgit2_shutdown (); return -1; } git_reference * headRef = getHeadRef (data, repo); if (!headRef) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to get reference %s\n", data->refName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to get reference %s\n", data->refName); git_repository_free (repo); git_libgit2_shutdown (); return -1; @@ -848,7 +847,7 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE const git_oid * headObj = git_reference_target (headRef); if (!headObj) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to get reference %s\n", data->refName); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to get reference %s\n", data->refName); git_reference_free (headRef); git_repository_free (repo); git_libgit2_shutdown (); @@ -861,7 +860,7 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE if (newCommit) { // newer commit in repo - abort - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, "The repository has been updated and is ahead of you"); + ELEKTRA_SET_CONFLICT_ERROR (parentKey, "The repository has been updated and is ahead of you"); elektraFree (newCommit); git_reference_free (headRef); git_repository_free (repo); @@ -879,8 +878,7 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE char * newObj = hasNewObjectCommit (data, blob); if (newObj) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, - "The repository has been updated and is ahead of you"); + ELEKTRA_SET_CONFLICT_ERROR (parentKey, "The repository has been updated and is ahead of you"); elektraFree (newObj); git_object_free (blob); git_repository_free (repo); diff --git a/src/plugins/gpgme/gpgme.c b/src/plugins/gpgme/gpgme.c index b906868afdc..466df2033e9 100644 --- a/src/plugins/gpgme/gpgme.c +++ b/src/plugins/gpgme/gpgme.c @@ -153,8 +153,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er err = gpgme_get_key (ctx, keyString (gpgRecipientRoot), &key, 0); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to receive the GPG key because: %s", - gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to receive the GPG key because: %s", gpgme_strerror (err)); elektraGpgmeKeylistFree (&list); return NULL; } @@ -163,7 +162,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er { if (!elektraGpgmeKeylistAdd (&list, key)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); elektraGpgmeKeylistFree (&list); return NULL; } @@ -183,8 +182,8 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er err = gpgme_get_key (ctx, keyString (k), &key, 0); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to receive the GPG key because: %s", - gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Failed to receive the GPG key because: %s", + gpgme_strerror (err)); elektraGpgmeKeylistFree (&list); return NULL; } @@ -193,7 +192,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er { if (!elektraGpgmeKeylistAdd (&list, key)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); elektraGpgmeKeylistFree (&list); return NULL; } @@ -211,7 +210,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er gpgme_key_t * keyArray = elektraMalloc ((list.size + 1) * sizeof (gpgme_key_t)); if (!keyArray) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); elektraGpgmeKeylistFree (&list); return NULL; } @@ -250,7 +249,7 @@ static int transferGpgmeDataToElektraKey (gpgme_data_t src, Key * dst, Key * err buffer = (char *) elektraMalloc (ciphertextLen); if (!buffer) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); returnValue = -1; // failure goto cleanup; } @@ -259,7 +258,7 @@ static int transferGpgmeDataToElektraKey (gpgme_data_t src, Key * dst, Key * err readCount = gpgme_data_read (src, buffer, ciphertextLen); if (readCount != ciphertextLen) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "An error during occurred during the data transfer."); + ELEKTRA_SET_LOGICAL_ERROR (errorKey, "An error during occurred during the data transfer."); returnValue = -1; // failure goto cleanup; } @@ -350,8 +349,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to create the gpgme context because: %s", - gpgme_strerror (err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to create the gpgme context because: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -366,7 +364,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) recipients = extractRecipientFromPluginConfig (pluginConfig, errorKey, ctx); if (!recipients) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "No valid recipients were specified."); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "No valid recipients were specified."); returnValue = -1; goto cleanup; } @@ -402,7 +400,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) if (err) { returnValue = -1; - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Internal error: %s", gpgme_strerror (err)); goto cleanup; } @@ -410,7 +408,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) if (err) { returnValue = -1; - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Internal error: %s", gpgme_strerror (err)); gpgme_data_release (input); goto cleanup; } @@ -419,7 +417,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) if (err) { returnValue = -1; - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Internal error: %s", gpgme_strerror (err)); gpgme_data_release (ciphertext); gpgme_data_release (input); goto cleanup; @@ -434,12 +432,12 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) generateInvalidKeyErrorMsg (&errorMsg, invalidKey); if (errorMsg) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Invalid key ID(s): %s", errorMsg); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Invalid key ID(s): %s", errorMsg); elektraFree (errorMsg); } else { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Memory allocation failed"); } gpgme_data_release (ciphertext); gpgme_data_release (input); @@ -486,7 +484,7 @@ static int gpgDecrypt (ELEKTRA_UNUSED Plugin * handle, KeySet * data, Key * erro err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to the gpgme context because: %s", gpgme_strerror (err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to the gpgme context because: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -505,7 +503,7 @@ static int gpgDecrypt (ELEKTRA_UNUSED Plugin * handle, KeySet * data, Key * erro err = gpgme_data_new_from_mem (&ciphertext, keyValue (k), keyGetValueSize (k), 0); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Internal error: %s", gpgme_strerror (err)); returnValue = -1; goto cleanup; } @@ -513,7 +511,7 @@ static int gpgDecrypt (ELEKTRA_UNUSED Plugin * handle, KeySet * data, Key * erro err = gpgme_data_new (&plaintext); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Internal error: %s", gpgme_strerror (err)); returnValue = -1; gpgme_data_release (ciphertext); goto cleanup; @@ -522,7 +520,7 @@ static int gpgDecrypt (ELEKTRA_UNUSED Plugin * handle, KeySet * data, Key * erro err = gpgme_op_decrypt (ctx, ciphertext, plaintext); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Internal error: %s", gpgme_strerror (err)); returnValue = -1; gpgme_data_release (plaintext); gpgme_data_release (ciphertext); @@ -561,7 +559,7 @@ int elektraGpgmeOpen (ELEKTRA_UNUSED Plugin * handle, ELEKTRA_UNUSED Key * error err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_LOGICAL_ERRORF (errorKey, "Internal error: %s", gpgme_strerror (err)); return -1; // failure } return 1; // success @@ -602,8 +600,7 @@ int elektraGpgmeCheckconf (Key * errorKey, KeySet * conf) err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to create the gpgme context because: %s", - gpgme_strerror (err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to create the gpgme context because: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -616,7 +613,7 @@ int elektraGpgmeCheckconf (Key * errorKey, KeySet * conf) } else { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "No valid recipients were specified."); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "No valid recipients were specified."); return -1; // failure } return 1; // success diff --git a/src/plugins/hexnumber/hexnumber.c b/src/plugins/hexnumber/hexnumber.c index 8e93849aa90..1b7aa810575 100644 --- a/src/plugins/hexnumber/hexnumber.c +++ b/src/plugins/hexnumber/hexnumber.c @@ -68,14 +68,13 @@ static int convertHexToDec (Key * key, Key * parentKey) if (errno == ERANGE && value == ULLONG_MAX) { errno = errnoSaved; - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Hexadecimal number %s out of range 0 to %llu", hexValue, - ULLONG_MAX); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Hexadecimal number %s out of range 0 to %llu", hexValue, ULLONG_MAX); return ELEKTRA_PLUGIN_STATUS_ERROR; } else if ((errno != 0 && value == 0) || endPtr == hexValue || *endPtr != '\0') { errno = errnoSaved; - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Hexadecimal number '%s' could not be read", hexValue); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Hexadecimal number '%s' could not be read", hexValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } errno = errnoSaved; @@ -84,7 +83,7 @@ static int convertHexToDec (Key * key, Key * parentKey) int result = snprintf (NULL, 0, "%llu", value); if (result < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to convert '%s' into decimal", hexValue); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Unable to convert '%s' into decimal", hexValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -99,7 +98,7 @@ static int convertHexToDec (Key * key, Key * parentKey) result = snprintf (decValue, length, "%llu", value); if (result < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to convert '%s' into decimal", hexValue); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Unable to convert '%s' into decimal", hexValue); elektraFree (decValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -138,14 +137,13 @@ static int convertDecToHex (Key * key, Key * parentKey) if (errno == ERANGE && value == ULLONG_MAX) { errno = errnoSaved; - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Decimal number %s out of range 0 to %llu", decValue, - ULLONG_MAX); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Decimal number %s out of range 0 to %llu", decValue, ULLONG_MAX); return ELEKTRA_PLUGIN_STATUS_ERROR; } else if ((errno != 0 && value == 0) || endPtr == decValue) { errno = errnoSaved; - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Decimal number '%s' could not be read", decValue); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Decimal number '%s' could not be read", decValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } errno = errnoSaved; @@ -154,7 +152,7 @@ static int convertDecToHex (Key * key, Key * parentKey) const int result = snprintf (NULL, 0, "0x%llx", value); if (result < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to convert '%s' into hexadecimal", decValue); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Unable to convert '%s' into hexadecimal", decValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -168,7 +166,7 @@ static int convertDecToHex (Key * key, Key * parentKey) if (snprintf (hexValue, length, "0x%llx", value) < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to convert '%s' into hexadecimal", decValue); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Unable to convert '%s' into hexadecimal", decValue); elektraFree (hexValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -281,7 +279,7 @@ int parseConfig (KeySet * config, HexnumberData * data, Key * errorKey) if (!types) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, "Could not parse config! Types not set correctly."); + ELEKTRA_SET_PARSING_ERROR (errorKey, "Could not parse config! Types not set correctly."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -353,9 +351,9 @@ int elektraHexnumberGet (Plugin * handle, KeySet * returned, Key * parentKey) } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, - "Key '%s' has unit/base metadata set as hex but value '%s' does not start with 0x", - keyName (cur), keyString (cur)); + ELEKTRA_SET_PARSING_ERRORF ( + parentKey, "Key '%s' has unit/base metadata set as hex but value '%s' does not start with 0x", + keyName (cur), keyString (cur)); status |= ELEKTRA_PLUGIN_STATUS_ERROR; } } diff --git a/src/plugins/hosts/hosts-get.c b/src/plugins/hosts/hosts-get.c index fde1ad3f4c9..083226832d4 100644 --- a/src/plugins/hosts/hosts-get.c +++ b/src/plugins/hosts/hosts-get.c @@ -307,7 +307,7 @@ int elektraHostsGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "general parse error: %s", strerror (errno)); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "general parse error: %s", strerror (errno)); ksDel (append); ret = -1; } diff --git a/src/plugins/hosts/hosts-set.c b/src/plugins/hosts/hosts-set.c index bf46f73ff33..f4669f1720e 100644 --- a/src/plugins/hosts/hosts-set.c +++ b/src/plugins/hosts/hosts-set.c @@ -139,7 +139,7 @@ int elektraHostsSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa if (ret < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, strerror (errno)); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, strerror (errno)); fclose (fp); return -1; } diff --git a/src/plugins/iconv/iconv.c b/src/plugins/iconv/iconv.c index 02773d78f7b..1f930c61a36 100644 --- a/src/plugins/iconv/iconv.c +++ b/src/plugins/iconv/iconv.c @@ -178,9 +178,9 @@ int elektraIconvGet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (cur), keyGetValueSize (cur)); if (kdbbUTF8Engine (handle, UTF8_FROM, &convertedData, &convertedDataSize)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Could not convert string %s, got result %s, encoding settings are from %s to %s", - keyString (cur), convertedData, getFrom (handle), getTo (handle)); + ELEKTRA_SET_INSTALLATION_ERRORF ( + parentKey, "Could not convert string %s, got result %s, encoding settings are from %s to %s", + keyString (cur), convertedData, getFrom (handle), getTo (handle)); elektraFree (convertedData); return -1; } @@ -197,9 +197,9 @@ int elektraIconvGet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (meta), keyGetValueSize (meta)); if (kdbbUTF8Engine (handle, UTF8_FROM, &convertedData, &convertedDataSize)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Could not convert string %s, got result %s, encoding settings are from %s to %s", - keyString (meta), convertedData, getFrom (handle), getTo (handle)); + ELEKTRA_SET_INSTALLATION_ERRORF ( + parentKey, "Could not convert string %s, got result %s, encoding settings are from %s to %s", + keyString (meta), convertedData, getFrom (handle), getTo (handle)); elektraFree (convertedData); return -1; } @@ -230,10 +230,10 @@ int elektraIconvSet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (cur), keyGetValueSize (cur)); if (kdbbUTF8Engine (handle, UTF8_TO, &convertedData, &convertedDataSize)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Could not convert string %s, got result %s," - " encoding settings are from %s to %s (but swapped for write)", - keyString (cur), convertedData, getFrom (handle), getTo (handle)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, + "Could not convert string %s, got result %s," + " encoding settings are from %s to %s (but swapped for write)", + keyString (cur), convertedData, getFrom (handle), getTo (handle)); elektraFree (convertedData); return -1; } @@ -250,10 +250,10 @@ int elektraIconvSet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (meta), keyGetValueSize (meta)); if (kdbbUTF8Engine (handle, UTF8_TO, &convertedData, &convertedDataSize)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Could not convert string %s, got result %s," - " encodings settings are from %s to %s (but swapped for write)", - keyString (meta), convertedData, getFrom (handle), getTo (handle)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, + "Could not convert string %s, got result %s," + " encodings settings are from %s to %s (but swapped for write)", + keyString (meta), convertedData, getFrom (handle), getTo (handle)); elektraFree (convertedData); return -1; } diff --git a/src/plugins/ini/ini.c b/src/plugins/ini/ini.c index c9eb01293d0..127d6c36c8c 100644 --- a/src/plugins/ini/ini.c +++ b/src/plugins/ini/ini.c @@ -406,9 +406,9 @@ static int iniKeyToElektraKey (void * vhandle, const char * section, const char else if (!lineContinuation) { keyDel (appendKey); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, handle->parentKey, - "We found the key %s a second time in the INI file in section %s\n", keyName (existingKey), - section); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (handle->parentKey, + "We found the key %s a second time in the INI file in section %s\n", + keyName (existingKey), section); return -1; } } @@ -780,14 +780,14 @@ int elektraIniGet (Plugin * handle, KeySet * returned, Key * parentKey) switch (ret) { case -1: - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Unable to open the ini file"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Unable to open the ini file"); break; case -2: - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Memory allocation error while reading the ini file"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Memory allocation error while reading the ini file"); break; default: - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Could not parse ini file %s. First error at line %d", - keyString (parentKey), ret); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Could not parse ini file %s. First error at line %d", keyString (parentKey), + ret); break; } ret = -1; @@ -1417,8 +1417,8 @@ static int iniWriteKeySet (FILE * fh, Key * parentKey, KeySet * returned, IniPlu } else { - ELEKTRA_SET_ERROR ( - ELEKTRA_ERROR_INSTALLATION, parentKey, + ELEKTRA_SET_INSTALLATION_ERROR ( + parentKey, "Encountered a multiline value but multiline support is not enabled. " "Have a look at kdb info ini for more details"); ret = -1; diff --git a/src/plugins/ipaddr/ipaddr.c b/src/plugins/ipaddr/ipaddr.c index 02ba69faca2..08d7aec36a3 100644 --- a/src/plugins/ipaddr/ipaddr.c +++ b/src/plugins/ipaddr/ipaddr.c @@ -102,12 +102,12 @@ static int validateKey (Key * key, Key * parentKey) if (!rc) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Validation of key %s with value %s failed.", - keyName (key), keyString (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Validation of key %s with value %s failed.", keyName (key), + keyString (key)); } else if (rc == -1) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Out of memory"); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory"); rc = 0; } diff --git a/src/plugins/jni/jni.c b/src/plugins/jni/jni.c index 355fe1f7130..a96c0a2b5c4 100644 --- a/src/plugins/jni/jni.c +++ b/src/plugins/jni/jni.c @@ -64,8 +64,7 @@ static void checkException (Data * data, const char * when, Key * warningKey) which = (*data->env)->GetStringUTFChars (data->env, estr, &iseCopy); } - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningKey, "During \"%s\", java exception was thrown: %s", when, - which); + ELEKTRA_ADD_INSTALLATION_WARNINGF (warningKey, "During \"%s\", java exception was thrown: %s", when, which); if (iseCopy == JNI_TRUE) { @@ -81,7 +80,7 @@ static int call1Arg (Data * data, Key * errorKey, const char * method) checkException (data, method, errorKey); if (jerrorKey == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Cannot create errorKey in %s", method); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Cannot create errorKey in %s", method); return -1; } @@ -89,7 +88,7 @@ static int call1Arg (Data * data, Key * errorKey, const char * method) checkException (data, method, errorKey); if (mid == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Cannot find org/libelektra/Key in %s", method); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Cannot find org/libelektra/Key in %s", method); return -1; } @@ -97,7 +96,7 @@ static int call1Arg (Data * data, Key * errorKey, const char * method) result = (*data->env)->CallIntMethod (data->env, data->plugin, mid, jerrorKey); if ((*data->env)->ExceptionCheck (data->env)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "%s failed with exception", method); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "%s failed with exception", method); result = -1; } checkException (data, method, errorKey); @@ -114,7 +113,7 @@ static int call2Arg (Data * data, KeySet * ks, Key * errorKey, const char * meth checkException (data, method, errorKey); if (jks == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot create ks"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot create ks"); return -1; } @@ -122,7 +121,7 @@ static int call2Arg (Data * data, KeySet * ks, Key * errorKey, const char * meth checkException (data, method, errorKey); if (jkey == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot create key"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot create key"); return -1; } @@ -130,7 +129,7 @@ static int call2Arg (Data * data, KeySet * ks, Key * errorKey, const char * meth checkException (data, method, errorKey); if (mid == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Cannot find %s", method); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Cannot find %s", method); return -1; } @@ -138,7 +137,7 @@ static int call2Arg (Data * data, KeySet * ks, Key * errorKey, const char * meth result = (*data->env)->CallIntMethod (data->env, data->plugin, mid, jks, jkey); if ((*data->env)->ExceptionCheck (data->env)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "%s failed with exception", method); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "%s failed with exception", method); result = -1; } checkException (data, method, errorKey); @@ -176,7 +175,7 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) k = ksLookupByName (config, "/classpath", 0); if (!k) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not find plugin config /classpath"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Could not find plugin config /classpath"); return -1; } char classpatharg[] = "-Djava.class.path="; @@ -219,14 +218,14 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) elektraFree (classpath); if (res < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot create Java VM"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot create Java VM"); return -1; } k = ksLookupByName (config, "/classname", 0); if (!k) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Could not find plugin config /classname"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Could not find plugin config /classname"); return -1; } @@ -235,56 +234,56 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) data->clsPlugin = (*data->env)->FindClass (data->env, classname); if (data->clsPlugin == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find class %s", classname); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Cannot find class %s", classname); return -1; } data->clsKey = (*data->env)->FindClass (data->env, "org/libelektra/Key"); if (data->clsKey == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find class Key"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot find class Key"); return -1; } data->clsKeySet = (*data->env)->FindClass (data->env, "org/libelektra/KeySet"); if (data->clsKeySet == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find class KeySet"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot find class KeySet"); return -1; } data->midKeyConstr = (*data->env)->GetMethodID (data->env, data->clsKey, "", "(J)V"); if (data->midKeyConstr == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find constructor of Key"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot find constructor of Key"); return -1; } data->midKeySetConstr = (*data->env)->GetMethodID (data->env, data->clsKeySet, "", "(J)V"); if (data->midKeySetConstr == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find constructor of KeySet"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot find constructor of KeySet"); return -1; } data->midKeyRelease = (*data->env)->GetMethodID (data->env, data->clsKey, "release", "()V"); if (data->midKeyRelease == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find release of Key"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot find release of Key"); return -1; } data->midKeySetRelease = (*data->env)->GetMethodID (data->env, data->clsKeySet, "release", "()V"); if (data->midKeySetRelease == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find release of KeySet"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot find release of KeySet"); return -1; } jmethodID midPluginConstructor = (*data->env)->GetMethodID (data->env, data->clsPlugin, "", "()V"); if (midPluginConstructor == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find constructor of plugin"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot find constructor of plugin"); return -1; } @@ -292,7 +291,7 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) checkException (data, "creating plugin", errorKey); if (data->plugin == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot create plugin"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot create plugin"); return -1; } diff --git a/src/plugins/keytometa/keytometa.c b/src/plugins/keytometa/keytometa.c index bc8299034f8..c21258c66f2 100644 --- a/src/plugins/keytometa/keytometa.c +++ b/src/plugins/keytometa/keytometa.c @@ -253,7 +253,7 @@ int elektraKeyToMetaGet (Plugin * handle, KeySet * returned, Key * parentKey ELE if (ret < 0) { elektraFree (keyArray); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, strerror (errno)); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, strerror (errno)); errno = errnosave; return 0; } diff --git a/src/plugins/line/line.c b/src/plugins/line/line.c index a156e93cc2b..53962b82602 100644 --- a/src/plugins/line/line.c +++ b/src/plugins/line/line.c @@ -100,12 +100,12 @@ int elektraLineGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par if (ret == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "could not increment array from %s", keyName (ksTail (returned))); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "could not increment array from %s", keyName (ksTail (returned))); ret = -1; } else if (feof (fp) == 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "Invalid line encountered: not at the end of file"); + ELEKTRA_SET_PARSING_ERROR (parentKey, "Invalid line encountered: not at the end of file"); ret = -1; } diff --git a/src/plugins/lineendings/lineendings.c b/src/plugins/lineendings/lineendings.c index 4e610dec305..1f08baac8e9 100644 --- a/src/plugins/lineendings/lineendings.c +++ b/src/plugins/lineendings/lineendings.c @@ -93,7 +93,7 @@ static int checkLineEndings (const char * fileName, Lineending validLineEnding, if (validLineEnding != NA && lineEnding != validLineEnding) { fclose (fp); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Invalid line ending at line %lu", line); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Invalid line ending at line %lu", line); return -2; } ++line; @@ -101,7 +101,7 @@ static int checkLineEndings (const char * fileName, Lineending validLineEnding, else if (lineEnding != found && found != NA) { fclose (fp); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "inconsistent line endings at line %lu", line); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "inconsistent line endings at line %lu", line); return -3; } fc = sc; @@ -151,7 +151,7 @@ int elektraLineendingsSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Ke switch (ret) { case (-1): - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open file %s\n", keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open file %s\n", keyString (parentKey)); return 1; break; case (-2): diff --git a/src/plugins/lua/lua.cpp b/src/plugins/lua/lua.cpp index e23e0e38162..75321992c7c 100644 --- a/src/plugins/lua/lua.cpp +++ b/src/plugins/lua/lua.cpp @@ -77,11 +77,11 @@ static int Lua_CallFunction_Int (lua_State * L, int nargs, ckdb::Key * errorKey) { int ret = -1; if (lua_pcall (L, nargs, 1, 0) != LUA_OK) - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, lua_tostring (L, -1)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, lua_tostring (L, -1)); else { if (!lua_isnumber (L, -1)) - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Return value is no integer"); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "Return value is no integer"); else ret = lua_tonumber (L, -1); } @@ -139,7 +139,7 @@ int elektraLuaOpen (ckdb::Plugin * handle, ckdb::Key * errorKey) { return 0; // by convention: success if /module exists } - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "No lua script set"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "No lua script set"); return -1; } @@ -149,7 +149,7 @@ int elektraLuaOpen (ckdb::Plugin * handle, ckdb::Key * errorKey) /* init new lua state */ if ((data->L = lua_newstate (Lua_alloc, NULL)) == NULL) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to create new lua state"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Unable to create new lua state"); goto error; } @@ -169,7 +169,7 @@ int elektraLuaOpen (ckdb::Plugin * handle, ckdb::Key * errorKey) return Lua_CallFunction_Helper2 (data->L, "elektraOpen", config, errorKey); error_print: - if (!lua_isnil (data->L, -1)) ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, lua_tostring (data->L, -1)); + if (!lua_isnil (data->L, -1)) ELEKTRA_SET_INSTALLATION_ERROR (errorKey, lua_tostring (data->L, -1)); error: /* destroy lua */ Lua_Shutdown (data->L); diff --git a/src/plugins/mathcheck/mathcheck.c b/src/plugins/mathcheck/mathcheck.c index 2736303c4e8..cc78132ad66 100644 --- a/src/plugins/mathcheck/mathcheck.c +++ b/src/plugins/mathcheck/mathcheck.c @@ -290,8 +290,7 @@ static PNElem parsePrefixString (const char * prefixString, Key * curKey, KeySet resultOp = NOT; break; default: - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "%c isn't a valid operation", - prefixString[start]); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "%c isn't a valid operation", prefixString[start]); regfree (®ex); if (searchKey) { @@ -369,8 +368,7 @@ static PNElem parsePrefixString (const char * prefixString, Key * curKey, KeySet } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Not a valid Polish prefix notation syntax: %s\n", - prefixString); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Not a valid Polish prefix notation syntax: %s\n", prefixString); } elektraFree (stack); return result; @@ -399,7 +397,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (fabs (elektraEFtoF (keyString (cur)) - result.value) > EPSILON) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s != %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s != %s", val1, val2); return -1; } } @@ -407,8 +405,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (fabs (elektraEFtoF (keyString (cur)) - result.value) < EPSILON) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s == %s but requirement was !=", val1, - val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s == %s but requirement was !=", val1, val2); return -1; } } @@ -416,7 +413,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) >= result.value) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s not < %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s not < %s", val1, val2); return -1; } } @@ -424,7 +421,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) <= result.value) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s not > %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s not > %s", val1, val2); return -1; } } @@ -432,7 +429,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) > result.value) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s not <= %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s not <= %s", val1, val2); return -1; } } @@ -440,7 +437,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) < result.value) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s not >= %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s not >= %s", val1, val2); return -1; } } diff --git a/src/plugins/mini/mini.c b/src/plugins/mini/mini.c index 235fb6644c6..689d56917ba 100644 --- a/src/plugins/mini/mini.c +++ b/src/plugins/mini/mini.c @@ -138,7 +138,7 @@ static inline void parseLine (char * line, size_t lineNumber, KeySet * keySet, K if (*equals == '\0' || equals == pair) { ELEKTRA_LOG_WARNING ("Ignored line %zu since “%s” does not contain a valid key value pair", lineNumber, pair); - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, "Line %zu: “%s” is not a valid key value pair", lineNumber, pair); + ELEKTRA_ADD_PARSING_WARNINGF (parentKey, "Line %zu: “%s” is not a valid key value pair", lineNumber, pair); return; } @@ -192,7 +192,7 @@ static int parseINI (FILE * file, KeySet * keySet, Key * parentKey) if (!feof (file)) { ELEKTRA_LOG_WARNING ("%s:%zu: Unable to read line", keyString (parentKey), lineNumber); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to read line %zu: %s", lineNumber, strerror (errno)); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Unable to read line %zu: %s", lineNumber, strerror (errno)); errno = errorNumber; return ELEKTRA_PLUGIN_STATUS_ERROR; } diff --git a/src/plugins/multifile/multifile.c b/src/plugins/multifile/multifile.c index 1b82b287c3a..0934413032e 100644 --- a/src/plugins/multifile/multifile.c +++ b/src/plugins/multifile/multifile.c @@ -407,15 +407,15 @@ static Codes updateFilesGlob (Plugin * handle, MultiConfig * mc, KeySet * found, { if (ret == GLOB_NOSPACE) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "glob(%s) ran out of memory", pattern); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "glob(%s) ran out of memory", pattern); } else if (ret == GLOB_ABORTED) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "glob(%s) failed with a read error", pattern); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "glob(%s) failed with a read error", pattern); } else if (ret == GLOB_NOMATCH) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "glob(%s) failed with no matches", pattern); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "glob(%s) failed with no matches", pattern); } return ERROR; } diff --git a/src/plugins/network/network.c b/src/plugins/network/network.c index e5addbcdde1..764347a8a80 100644 --- a/src/plugins/network/network.c +++ b/src/plugins/network/network.c @@ -63,8 +63,8 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) { if (portNumber < 0 || portNumber > 65535) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Port %ld on key %s was not within 0 - 65535", - portNumber, keyName (toCheck)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Port %ld on key %s was not within 0 - 65535", portNumber, + keyName (toCheck)); return -1; } portNumberNetworkByteOrder = htons (portNumber); @@ -75,8 +75,8 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) service = getservbyname (keyString (toCheck), NULL); // NULL means we accept both tcp and udp if (service == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not find service with name %s on key %s", - keyString (toCheck), keyName (toCheck)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not find service with name %s on key %s", keyString (toCheck), + keyName (toCheck)); return -1; } portNumberNetworkByteOrder = service->s_port; @@ -93,7 +93,7 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) if (sockfd < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open a socket: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open a socket: %s", strerror (errno)); } server = gethostbyname (hostname); @@ -101,13 +101,13 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) { if (errno == HOST_NOT_FOUND) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not connect to %s: No such host", hostname); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not connect to %s: No such host", hostname); return -1; } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "There was an error trying to connect to host %s: %s", - hostname, strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "There was an error trying to connect to host %s: %s", hostname, + strerror (errno)); return -1; } // TODO: Maybe consider errno == TRY_AGAIN separately and try to reconnect @@ -124,15 +124,14 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) close (sockfd); if (errno == EADDRINUSE) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Port %s is already in use which was specified on key %s", keyString (toCheck), - keyName (toCheck)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Port %s is already in use which was specified on key %s", + keyString (toCheck), keyName (toCheck)); } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Could not bind to port %s which was specified on key %s. Reason: %s", keyString (toCheck), - keyName (toCheck), strerror (errno)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, + "Could not bind to port %s which was specified on key %s. Reason: %s", + keyString (toCheck), keyName (toCheck), strerror (errno)); } return -1; } @@ -181,7 +180,7 @@ int elektraNetworkSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * strcat (errmsg, keyValue (cur)); strcat (errmsg, " message: "); strcat (errmsg, gaimsg); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, errmsg); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (parentKey, errmsg); elektraFree (errmsg); return -1; } diff --git a/src/plugins/passwd/passwd.c b/src/plugins/passwd/passwd.c index 1e2bfe4901e..48e899695f5 100644 --- a/src/plugins/passwd/passwd.c +++ b/src/plugins/passwd/passwd.c @@ -202,7 +202,7 @@ int elektraPasswdGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_ FILE * pwfile = fopen (keyString (parentKey), "r"); if (!pwfile) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open configuration file %s\n", keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open configuration file %s\n", keyString (parentKey)); return -1; } #if defined(USE_FGETPWENT) @@ -296,7 +296,7 @@ static int writeKS (KeySet * returned, Key * parentKey, SortBy index) FILE * pwfile = fopen (keyString (parentKey), "w"); if (!pwfile) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open %s for writing\n", keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for writing\n", keyString (parentKey)); return -1; } Key * cur; @@ -308,9 +308,9 @@ static int writeKS (KeySet * returned, Key * parentKey, SortBy index) struct passwd * pwd = KStoPasswd (cutKS, index); if (validatepwent (pwd) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Invalid passwd entry %s:%s:%u:%u:%s:%s:%s\n", - pwd->pw_name, pwd->pw_passwd, pwd->pw_uid, pwd->pw_gid, pwd->pw_gecos, pwd->pw_dir, - pwd->pw_shell); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Invalid passwd entry %s:%s:%u:%u:%s:%s:%s\n", pwd->pw_name, + pwd->pw_passwd, pwd->pw_uid, pwd->pw_gid, pwd->pw_gecos, pwd->pw_dir, + pwd->pw_shell); } else { diff --git a/src/plugins/path/path.c b/src/plugins/path/path.c index c48b81d7641..15fb802ae77 100644 --- a/src/plugins/path/path.c +++ b/src/plugins/path/path.c @@ -59,7 +59,7 @@ static int validateKey (Key * key, Key * parentKey) } else if (keyString (key)[0] != '/') { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Given path \"%s\" is not absolute", keyString (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Given path \"%s\" is not absolute", keyString (key)); return 0; } int errnosave = errno; @@ -76,7 +76,7 @@ static int validateKey (Key * key, Key * parentKey) strcat (errmsg, keyName (key)); strcat (errmsg, " with path: "); strcat (errmsg, keyValue (key)); - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Could not stat file, message: %s", errmsg); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Could not stat file, message: %s", errmsg); elektraFree (errmsg); errno = errnosave; return -1; @@ -85,14 +85,14 @@ static int validateKey (Key * key, Key * parentKey) { if (!S_ISBLK (buf.st_mode)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Device not found: %s", keyString (key)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Device not found: %s", keyString (key)); } } else if (!strcmp (keyString (meta), "directory")) { if (!S_ISDIR (buf.st_mode)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Directory not found: %s", keyString (key)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Directory not found: %s", keyString (key)); } } return 1; @@ -129,10 +129,10 @@ static int validatePermission (Key * key, Key * parentKey) // Check if user exists if (p == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Could not find user \"%s\" for key \"%s\". " - "Does the user exist?\"", - name, keyName (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, + "Could not find user \"%s\" for key \"%s\". " + "Does the user exist?\"", + name, keyName (key)); return -1; } name = p->pw_name; @@ -157,10 +157,10 @@ static int validatePermission (Key * key, Key * parentKey) name = p->pw_name; if (uid != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, - "To check permissions for %s I need to be the root user." - " Are you running kdb as root?\"", - keyName (key)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, + "To check permissions for %s I need to be the root user." + " Are you running kdb as root?\"", + keyName (key)); return -1; } } @@ -203,16 +203,16 @@ static int validatePermission (Key * key, Key * parentKey) if (euidResult != 0 || egidResult != 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, - "There was a problem in the user switching process." - "Please report the issue at https://issues.libelektra.org"); + ELEKTRA_SET_LOGICAL_ERROR (parentKey, + "There was a problem in the user switching process." + "Please report the issue at https://issues.libelektra.org"); return -1; } if (canAccess != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "User %s does not have required permission (%s) on %s", - name, modes, validPath); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "User %s does not have required permission (%s) on %s", name, modes, + validPath); return -1; } @@ -238,14 +238,14 @@ static int getAllGroups (Key * parentKey, uid_t currentUID, const struct passwd // therefore ngroups now contains the actual number of groups for the user if (getgrouplist (p->pw_name, (int) p->pw_gid, (*groups), &ngroups) < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, - "There was a problem in the getting all groups for the user." - "Please report the issue at https://issues.libelektra.org"); + ELEKTRA_SET_LOGICAL_ERROR (parentKey, + "There was a problem in the getting all groups for the user." + "Please report the issue at https://issues.libelektra.org"); if (seteuid (currentUID) < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, - "There was a problem in the user switching process." - "Please report the issue at https://issues.libelektra.org"); + ELEKTRA_SET_LOGICAL_ERROR (parentKey, + "There was a problem in the user switching process." + "Please report the issue at https://issues.libelektra.org"); } return -1; } @@ -265,10 +265,10 @@ static int switchGroup (Key * key, Key * parentKey, const char * name, const str int gidErr = setegid ((int) gr->gr_gid); if (gidErr < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, - "Could not set egid of user \"%s\" for key \"%s\"." - " Are you running kdb as root?\"", - name, keyName (key)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, + "Could not set egid of user \"%s\" for key \"%s\"." + " Are you running kdb as root?\"", + name, keyName (key)); return -1; } return 0; @@ -288,10 +288,10 @@ static int switchUser (Key * key, Key * parentKey, const struct passwd * p) int err = seteuid ((int) p->pw_uid); if (err < 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, - "Could not set euid of user \"%s\" for key \"%s\"." - " Are you running kdb as root?\"", - p->pw_name, keyName (key)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, + "Could not set euid of user \"%s\" for key \"%s\"." + " Are you running kdb as root?\"", + p->pw_name, keyName (key)); return -1; } return 0; @@ -312,8 +312,8 @@ static int handleNoUserCase (Key * parentKey, const char * validPath, const char int result = access (validPath, modeMask); if (result != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "User %s does not have required permission (%s) on %s", - p->pw_name, modes, validPath); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "User %s does not have required permission (%s) on %s", p->pw_name, + modes, validPath); return -1; } return 1; diff --git a/src/plugins/process/process.c b/src/plugins/process/process.c index ebeb3825c09..227dd7adfce 100644 --- a/src/plugins/process/process.c +++ b/src/plugins/process/process.c @@ -26,8 +26,8 @@ static int validPluginName (Key * pluginNameKey, Key * errorKey) { if (pluginNameKey == NULL) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_VALIDATION_SEMANTIC, errorKey, - "Missing plugin configuration parameter plugin="); + ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNING (errorKey, + "Missing plugin configuration parameter plugin="); return 0; } @@ -36,13 +36,13 @@ static int validPluginName (Key * pluginNameKey, Key * errorKey) const char * pluginName = keyString (pluginNameKey); if (elektraStrCmp (pluginName, "(null)") == 0 || keyIsBinary (pluginNameKey)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, errorKey, - "Plugin configuration parameter plugin has an invalid value: %s", pluginName); + ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNINGF (errorKey, "Plugin configuration parameter plugin has an invalid value: %s", + pluginName); return 0; } else if (elektraStrCmp (pluginName, "process") == 0) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Cannot proxy the process plugin itself"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "Cannot proxy the process plugin itself"); return 0; } return 1; @@ -107,8 +107,7 @@ int elektraProcessOpen (Plugin * handle, Key * errorKey) process->plugin = elektraInvokeOpen (keyString (process->pluginName), process->pluginConfig, errorKey); if (!process->plugin) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to open the proxied plugin %s", - keyString (process->pluginName)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to open the proxied plugin %s", keyString (process->pluginName)); return ELEKTRA_PLUGIN_STATUS_ERROR; } return ELEKTRA_PLUGIN_STATUS_SUCCESS; @@ -206,7 +205,7 @@ int elektraProcessGet (Plugin * handle, KeySet * returned, Key * parentKey) keyDel (pluginParentKey); if (ksGetSize (pluginContract) == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, parentKey, "Failed to get the contract for %s", keyString (pluginName)); + ELEKTRA_SET_LOGICAL_ERRORF (parentKey, "Failed to get the contract for %s", keyString (pluginName)); ksDel (pluginContract); return ELEKTRA_PLUGIN_STATUS_ERROR; } diff --git a/src/plugins/python/python.cpp b/src/plugins/python/python.cpp index 03f7c12164c..efdf1442f23 100644 --- a/src/plugins/python/python.cpp +++ b/src/plugins/python/python.cpp @@ -101,8 +101,8 @@ static int Python_CallFunction_Int (moduleData * data, PyObject * object, PyObje PyObject * res = Python_CallFunction (object, args); if (!res) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Error while calling python function of script %s%s", - keyString (data->script), data->printError ? "" : ", use /print to print error messages"); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Error while calling python function of script %s%s", keyString (data->script), + data->printError ? "" : ", use /print to print error messages"); if (data->printError) PyErr_Print (); } else @@ -112,7 +112,7 @@ static int Python_CallFunction_Int (moduleData * data, PyObject * object, PyObje #else if (!PyInt_Check (res)) #endif - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Return value is no integer"); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "Return value is no integer"); else ret = PyLong_AsLong (res); } @@ -211,8 +211,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) return ELEKTRA_PLUGIN_STATUS_SUCCESS; // by convention: success if /module exists } - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, - "No python script set, please pass a filename via /script"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "No python script set, please pass a filename via /script"); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -248,7 +247,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) data->tstate = Py_NewInterpreter (); if (data->tstate == nullptr) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to create sub interpreter"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Unable to create sub interpreter"); goto error; } PyThreadState_Swap (data->tstate); @@ -256,8 +255,8 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) /* extend sys path for kdb module */ if (!Python_AppendToSysPath (ELEKTRA_PYTHON_SITE_PACKAGES)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to extend sys.path with built-in path \"%s\"", - ELEKTRA_PYTHON_SITE_PACKAGES); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Unable to extend sys.path with built-in path \"%s\"", + ELEKTRA_PYTHON_SITE_PACKAGES); goto error; } @@ -265,8 +264,8 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) const char * mname = keyString (ksLookupByName (elektraPluginGetConfig (handle), "/python/path", 0)); if (!Python_AppendToSysPath (mname)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, - "Unable to extend sys.path with user-defined /python/path \"%s\"", mname); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Unable to extend sys.path with user-defined /python/path \"%s\"", + mname); goto error; } @@ -274,7 +273,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) PyObject * kdbModule = PyImport_ImportModule ("kdb"); if (kdbModule == nullptr) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to import kdb module"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Unable to import kdb module"); goto error_print; } Py_XDECREF (kdbModule); @@ -282,8 +281,8 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) /* extend sys path for standard plugins */ if (!Python_AppendToSysPath (ELEKTRA_PYTHON_PLUGIN_FOLDER)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, - "Unable to extend sys.path with built-in plugin path \"%s\"", ELEKTRA_PYTHON_PLUGIN_FOLDER); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Unable to extend sys.path with built-in plugin path \"%s\"", + ELEKTRA_PYTHON_PLUGIN_FOLDER); goto error; } @@ -292,8 +291,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) const char * dname = dirname (tmpScript); if (!Python_AppendToSysPath (dname)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to extend sys.path with script dirname \"%s\"", - dname); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Unable to extend sys.path with script dirname \"%s\"", dname); elektraFree (tmpScript); goto error; } @@ -308,8 +306,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) PyObject * pModule = PyImport_ImportModule (bname); if (pModule == nullptr) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to import python script \"%s\"", - keyString (data->script)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Unable to import python script \"%s\"", keyString (data->script)); elektraFree (tmpScript); goto error_print; } @@ -320,7 +317,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) Py_DECREF (pModule); if (klass == nullptr) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Module doesn't provide a ElektraPlugin class"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Module doesn't provide a ElektraPlugin class"); goto error_print; } @@ -331,7 +328,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) Py_DECREF (inst_args); if (inst == nullptr) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to create instance of ElektraPlugin"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Unable to create instance of ElektraPlugin"); goto error_print; } data->instance = inst; diff --git a/src/plugins/quickdump/quickdump.c b/src/plugins/quickdump/quickdump.c index d021d3279bb..8764d0dac02 100644 --- a/src/plugins/quickdump/quickdump.c +++ b/src/plugins/quickdump/quickdump.c @@ -61,7 +61,7 @@ static inline bool writeData (FILE * file, const char * data, kdb_unsigned_long_ { if (!varintWrite (file, size)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_PARSING_ERROR (errorKey, feof (file) ? "premature end of file" : "unknown error"); return false; } @@ -69,7 +69,7 @@ static inline bool writeData (FILE * file, const char * data, kdb_unsigned_long_ { if (fwrite (data, sizeof (char), size, file) < size) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_PARSING_ERROR (errorKey, feof (file) ? "premature end of file" : "unknown error"); return false; } } @@ -81,7 +81,7 @@ static inline bool readUInt64 (FILE * file, kdb_unsigned_long_long_t * valuePtr, { if (fread (valuePtr, sizeof (kdb_unsigned_long_long_t), 1, file) < 1) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, "Error while reading file"); + ELEKTRA_SET_PARSING_ERROR (errorKey, "Error while reading file"); return false; } *valuePtr = le64toh (*valuePtr); @@ -94,14 +94,14 @@ static inline char * readString (FILE * file, Key * errorKey) kdb_unsigned_long_long_t size; if (!readUInt64 (file, &size, errorKey)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_PARSING_ERROR (errorKey, feof (file) ? "premature end of file" : "unknown error"); return NULL; } char * string = elektraMalloc (size + 1); if (fread (string, sizeof (char), size, file) < size) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_PARSING_ERROR (errorKey, feof (file) ? "premature end of file" : "unknown error"); elektraFree (string); return NULL; } @@ -115,7 +115,7 @@ static inline bool readStringIntoBufferV2 (FILE * file, struct stringbuffer * bu kdb_unsigned_long_long_t size; if (!readUInt64 (file, &size, errorKey)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_PARSING_ERROR (errorKey, feof (file) ? "premature end of file" : "unknown error"); return false; } @@ -146,7 +146,7 @@ static inline bool readStringIntoBuffer (FILE * file, struct stringbuffer * buff if (fread (&buffer->string[buffer->offset], sizeof (char), size, file) < size) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_PARSING_ERROR (errorKey, feof (file) ? "premature end of file" : "unknown error"); return false; } buffer->string[newSize - 1] = '\0'; @@ -212,7 +212,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key break; default: fclose (file); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unknown magic number " ELEKTRA_UNSIGNED_LONG_LONG_F, magic); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "Unknown magic number " ELEKTRA_UNSIGNED_LONG_LONG_F, magic); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -255,7 +255,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key elektraFree (metaNameBuffer.string); elektraFree (valueBuffer.string); fclose (file); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "missing key type"); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (parentKey, "missing key type"); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -290,7 +290,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key elektraFree (nameBuffer.string); elektraFree (metaNameBuffer.string); fclose (file); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "error while reading file"); + ELEKTRA_SET_PARSING_ERROR (parentKey, "error while reading file"); return ELEKTRA_PLUGIN_STATUS_ERROR; } k = keyNew (nameBuffer.string, KEY_BINARY, KEY_SIZE, (size_t) valueSize, KEY_VALUE, value, KEY_END); @@ -317,7 +317,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key elektraFree (metaNameBuffer.string); elektraFree (valueBuffer.string); fclose (file); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Unknown key type %c", type); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Unknown key type %c", type); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -327,7 +327,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { keyDel (k); fclose (file); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "Missing key end"); + ELEKTRA_SET_PARSING_ERROR (parentKey, "Missing key end"); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -386,8 +386,8 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key const Key * sourceKey = ksLookupByName (returned, nameBuffer.string, 0); if (sourceKey == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Could not copy meta data from key '%s': Key not found", nameBuffer.string); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Could not copy meta data from key '%s': Key not found", + nameBuffer.string); keyDel (k); elektraFree (nameBuffer.string); elektraFree (metaNameBuffer.string); @@ -398,9 +398,9 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key if (keyCopyMeta (k, sourceKey, metaNameBuffer.string) != 1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Could not copy meta data from key '%s': Error during copy", - &nameBuffer.string[nameBuffer.offset]); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, + "Could not copy meta data from key '%s': Error during copy", + &nameBuffer.string[nameBuffer.offset]); keyDel (k); elektraFree (nameBuffer.string); elektraFree (metaNameBuffer.string); @@ -416,7 +416,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key elektraFree (metaNameBuffer.string); elektraFree (valueBuffer.string); fclose (file); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Unknown meta type %c", type); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Unknown meta type %c", type); return ELEKTRA_PLUGIN_STATUS_ERROR; } } diff --git a/src/plugins/quickdump/readv1.c b/src/plugins/quickdump/readv1.c index 0e775f10171..d0aadbc5c0d 100644 --- a/src/plugins/quickdump/readv1.c +++ b/src/plugins/quickdump/readv1.c @@ -145,8 +145,8 @@ static int readVersion1 (FILE * file, KeySet * returned, Key * parentKey) const Key * sourceKey = ksLookupByName (returned, keyName, 0); if (sourceKey == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Could not copy meta data from key '%s': Key not found", keyName); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Could not copy meta data from key '%s': Key not found", + keyName); keyDel (k); elektraFree (keyName); elektraFree (metaName); @@ -156,8 +156,8 @@ static int readVersion1 (FILE * file, KeySet * returned, Key * parentKey) if (keyCopyMeta (k, sourceKey, metaName) != 1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Could not copy meta data from key '%s': Error during copy", keyName); + ELEKTRA_SET_INSTALLATION_ERRORF ( + parentKey, "Could not copy meta data from key '%s': Error during copy", keyName); keyDel (k); elektraFree (keyName); elektraFree (metaName); diff --git a/src/plugins/range/range.c b/src/plugins/range/range.c index bdc8f915738..895e44c37b7 100644 --- a/src/plugins/range/range.c +++ b/src/plugins/range/range.c @@ -336,7 +336,7 @@ static int validateMultipleRanges (const char * valueStr, const char * rangeStri else if (rc == -1) { elektraFree (localCopy); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "invalid syntax: %s", token); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "invalid syntax: %s", token); return -1; } while ((token = strtok_r (NULL, ",", &savePtr)) != NULL) @@ -350,7 +350,7 @@ static int validateMultipleRanges (const char * valueStr, const char * rangeStri else if (rc == -1) { elektraFree (localCopy); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "invalid syntax: %s", token); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "invalid syntax: %s", token); return -1; } } @@ -439,13 +439,12 @@ static int validateKey (Key * key, Key * parentKey) int rc = validateSingleRange (keyString (key), rangeString, type); if (rc == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "invalid syntax: %s", keyString (rangeMeta)); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "invalid syntax: %s", keyString (rangeMeta)); return -1; } else if (rc == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "value %s not within range %s", keyString (key), - rangeString); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "value %s not within range %s", keyString (key), rangeString); return 0; } else @@ -458,8 +457,7 @@ static int validateKey (Key * key, Key * parentKey) int rc = validateMultipleRanges (keyString (key), rangeString, parentKey, type); if (rc == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "value %s not within range %s", keyString (key), - rangeString); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "value %s not within range %s", keyString (key), rangeString); } return rc; } diff --git a/src/plugins/reference/reference.c b/src/plugins/reference/reference.c index 0396ecb3fe6..cb34fa8209f 100644 --- a/src/plugins/reference/reference.c +++ b/src/plugins/reference/reference.c @@ -46,7 +46,7 @@ static Key * resolveReference (KeySet * allKeys, const char * reference, const K if (elektraIsReferenceRedundant (reference)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Reference '%s' uses '/./' or '/../' redundantly.", reference); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Reference '%s' uses '/./' or '/../' redundantly.", reference); } char * fullReference = elektraResolveReference (reference, baseKey, parentKey); @@ -65,8 +65,7 @@ static char * resolveRestriction (const char * restriction, const Key * baseKey, if (elektraIsReferenceRedundant (restriction)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, parentKey, "Restriction '%s' uses '/./' or '/../' redundantly.", - restriction); + ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNINGF (parentKey, "Restriction '%s' uses '/./' or '/../' redundantly.", restriction); } return elektraResolveReference (restriction, baseKey, parentKey); @@ -136,8 +135,8 @@ static int checkSingleReference (const Key * key, KeySet * allKeys, Key * parent bool error = false; if (refKey == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Reference '%s', set in key '%s', does not reference an existing key.", ref, elementName); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + parentKey, "Reference '%s', set in key '%s', does not reference an existing key.", ref, elementName); error = true; } @@ -158,9 +157,9 @@ static int checkSingleReference (const Key * key, KeySet * allKeys, Key * parent if (!anyMatch) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Reference '%s', set in key '%s', does not any of the given restrictions.", ref, - elementName); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + parentKey, "Reference '%s', set in key '%s', does not any of the given restrictions.", ref, + elementName); error = true; } } @@ -339,9 +338,9 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * bool error = false; if (refKey == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "Reference '%s', set in key '%s', does not reference an existing key.", ref, - elementName); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + parentKey, "Reference '%s', set in key '%s', does not reference an existing key.", ref, + elementName); error = true; } @@ -364,8 +363,8 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * if (!anyMatch) { - ELEKTRA_SET_ERRORF ( - ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + parentKey, "Reference '%s', set in key '%s', does not any of the given restrictions.", ref, elementName); error = true; @@ -408,7 +407,7 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * *strrchr (rootName, '/') = '\0'; if (!checkReferenceGraphAcyclic (referenceGraph, rootName)) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "The configuration contains a cyclic reference."); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (parentKey, "The configuration contains a cyclic reference."); elektraFree (rootName); rgDel (referenceGraph); diff --git a/src/plugins/regexstore/regexstore.cpp b/src/plugins/regexstore/regexstore.cpp index 714776107e5..4c7d110955a 100644 --- a/src/plugins/regexstore/regexstore.cpp +++ b/src/plugins/regexstore/regexstore.cpp @@ -43,13 +43,13 @@ std::string elektraRegexstorePos (std::string const & str, int offset, std::stri int pos = index - '0'; if (pos < 0 || pos > 9) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, - "Regex Group %d for %s not between 0 and 9 read from %s", pos, text.c_str (), &index); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parentKey, "Regex Group %d for %s not between 0 and 9 read from %s", pos, + text.c_str (), &index); return std::string (""); } if (offsets[pos].rm_so == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "Regex Group %d missing for %s", pos, text.c_str ()); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parentKey, "Regex Group %d missing for %s", pos, text.c_str ()); return std::string (""); } return str.substr (offset + offsets[pos].rm_so, offsets[pos].rm_eo - offsets[pos].rm_so); @@ -70,8 +70,8 @@ Key * elektraRegexstoreProcess (Key * configKey, int * offset, std::string const if (configString.length () < 3 && configString[0] != '#' && (configString[1] < '0' || configString[1] > '9') && configString[2] != ' ') { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, - "String %s of %s did not start with #", configString.c_str (), keyName (configKey)); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parentKey, "String %s of %s did not start with #", + configString.c_str (), keyName (configKey)); return nullptr; } @@ -81,8 +81,8 @@ Key * elektraRegexstoreProcess (Key * configKey, int * offset, std::string const { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "Could not compile regex %s, because: %s", - configString.c_str () + 3, buffer); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parentKey, "Could not compile regex %s, because: %s", configString.c_str () + 3, + buffer); regfree (®ex); return nullptr; } @@ -99,8 +99,8 @@ Key * elektraRegexstoreProcess (Key * configKey, int * offset, std::string const { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, - "Regex exec returned error (not in manual for linux), because: %s", buffer); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parentKey, "Regex exec returned error (not in manual for linux), because: %s", + buffer); regfree (®ex); return nullptr; } @@ -191,7 +191,7 @@ int elektraRegexstoreGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key Key * confParent = ksLookupByName (conf, "/regexstore", 0); if (!confParent) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "Key /regexstore not found in configuration"); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Key /regexstore not found in configuration"); return -1; } ksNext (conf); // skip root diff --git a/src/plugins/required/required.c b/src/plugins/required/required.c index 6e20076f6a9..0572082cb05 100644 --- a/src/plugins/required/required.c +++ b/src/plugins/required/required.c @@ -51,8 +51,8 @@ int elektraRequiredSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTR { ++c; } - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "key '%s' with %d metadata is not required", keyName (cur), c); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "key '%s' with %d metadata is not required", + keyName (cur), c); return -1; // error } } diff --git a/src/plugins/resolver/filename.c b/src/plugins/resolver/filename.c index b83bab34a32..6948ce8f2a1 100644 --- a/src/plugins/resolver/filename.c +++ b/src/plugins/resolver/filename.c @@ -144,8 +144,8 @@ static char * elektraResolvePasswd (Key * warningsKey) elektraFree (buf); if (s != 0) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningsKey, - "Could not retrieve from passwd using getpwuid_r: %s", strerror (s)); + ELEKTRA_ADD_INSTALLATION_WARNINGF (warningsKey, "Could not retrieve from passwd using getpwuid_r: %s", + strerror (s)); } return NULL; } @@ -186,11 +186,11 @@ static int elektraResolveUserXDGHome (ElektraResolved * handle, Key * warningsKe if (home[0] != '/') { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningsKey, - "XDG_CONFIG_HOME contains a path that is " - "not absolute (violates XDG specification) and thus " - "it was skipped: %s", - home); + ELEKTRA_ADD_INSTALLATION_WARNINGF (warningsKey, + "XDG_CONFIG_HOME contains a path that is " + "not absolute (violates XDG specification) and thus " + "it was skipped: %s", + home); return 0; } elektraResolveUsingHome (handle, home, 0); @@ -208,11 +208,11 @@ static int elektraResolveEnvHome (ElektraResolved * handle, Key * warningsKey) if (home[0] != '/') { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningsKey, - "HOME contains a path that is " - "not absolute and thus " - "it was skipped: %s", - home); + ELEKTRA_ADD_INSTALLATION_WARNINGF (warningsKey, + "HOME contains a path that is " + "not absolute and thus " + "it was skipped: %s", + home); return 0; } elektraResolveUsingHome (handle, home, 1); @@ -301,15 +301,15 @@ static int elektraResolveMapperUser (ElektraResolved * handle, ElektraResolveTem } if (finished == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "user resolver failed at step %zu, the configuration is: %s", - i, ELEKTRA_VARIANT_USER); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "user resolver failed at step %zu, the configuration is: %s", i, + ELEKTRA_VARIANT_USER); return -1; } if (!(handle->dirname)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "no resolver set the user dirname, the configuration is: %s", - ELEKTRA_VARIANT_USER); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "no resolver set the user dirname, the configuration is: %s", + ELEKTRA_VARIANT_USER); return -1; } @@ -381,11 +381,11 @@ static int elektraResolveSystemXDG (ElektraResolved * handle, ElektraResolveTemp { if (result[0] != '/') { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningsKey, - "XDG_CONFIG_DIRS contains a path that is " - "not absolute (violates XDG specification) and thus " - "it was skipped: %s", - result); + ELEKTRA_ADD_INSTALLATION_WARNINGF (warningsKey, + "XDG_CONFIG_DIRS contains a path that is " + "not absolute (violates XDG specification) and thus " + "it was skipped: %s", + result); result = strtok_r (0, ":", &saveptr); continue; @@ -458,15 +458,15 @@ static int elektraResolveMapperSystem (ElektraResolved * handle, ElektraResolveT } if (finished == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "no resolver set the user dirname, the configuration is: %s", - ELEKTRA_VARIANT_USER); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "no resolver set the user dirname, the configuration is: %s", + ELEKTRA_VARIANT_USER); return -1; } if (!(handle->fullPath)) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "no resolver set the system dirname, the configuration is: %s", - ELEKTRA_VARIANT_SYSTEM); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "no resolver set the system dirname, the configuration is: %s", + ELEKTRA_VARIANT_SYSTEM); return -1; } @@ -484,7 +484,7 @@ static char * elektraGetCwd (Key * warningsKey) char * cwd = elektraMalloc (size); if (cwd == NULL) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "could not alloc for getcwd, defaulting to /"); + ELEKTRA_ADD_RESOURCE_WARNING (warningsKey, "could not alloc for getcwd, defaulting to /"); return 0; } @@ -499,8 +499,8 @@ static char * elektraGetCwd (Key * warningsKey) { // give up, we cannot handle the problem elektraFree (cwd); - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, - "getcwd failed with errno %d \"%s\", defaulting to /", errno, strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "getcwd failed with errno %d \"%s\", defaulting to /", errno, + strerror (errno)); return 0; } @@ -509,8 +509,7 @@ static char * elektraGetCwd (Key * warningsKey) elektraRealloc ((void **) &cwd, size); if (cwd == NULL) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, - "could not realloc for getcwd size %d, defaulting to /", size); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "could not realloc for getcwd size %d, defaulting to /", size); return 0; } } @@ -648,23 +647,23 @@ ElektraResolved * ELEKTRA_PLUGIN_FUNCTION (filename) (elektraNamespace namespace rc = elektraResolveMapperSystem (handle, tmpDir, warningsKey); break; case KEY_NS_PROC: - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve proc"); + ELEKTRA_ADD_RESOURCE_WARNING (warningsKey, "tried to resolve proc"); rc = -1; break; case KEY_NS_EMPTY: - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve empty"); + ELEKTRA_ADD_RESOURCE_WARNING (warningsKey, "tried to resolve empty"); rc = -1; break; case KEY_NS_NONE: - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve none"); + ELEKTRA_ADD_RESOURCE_WARNING (warningsKey, "tried to resolve none"); rc = -1; break; case KEY_NS_META: - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve meta"); + ELEKTRA_ADD_RESOURCE_WARNING (warningsKey, "tried to resolve meta"); rc = -1; break; case KEY_NS_CASCADING: - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve cascading"); + ELEKTRA_ADD_RESOURCE_WARNING (warningsKey, "tried to resolve cascading"); rc = -1; break; } diff --git a/src/plugins/resolver/resolver.c b/src/plugins/resolver/resolver.c index 796a7616540..d7364b54ad4 100644 --- a/src/plugins/resolver/resolver.c +++ b/src/plugins/resolver/resolver.c @@ -150,13 +150,13 @@ static int elektraLockFile (int fd ELEKTRA_UNUSED, Key * parentKey ELEKTRA_UNUSE { if (errno == EAGAIN || errno == EACCES) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, - "conflict because other process writes to configuration indicated by file lock"); + ELEKTRA_SET_CONFLICT_ERROR (parentKey, + "conflict because other process writes to configuration indicated by file lock"); } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, - "assuming conflict because of failed file lock with message: %s", strerror (errno)); + ELEKTRA_SET_CONFLICT_ERRORF (parentKey, "assuming conflict because of failed file lock with message: %s", + strerror (errno)); } return -1; } @@ -188,8 +188,7 @@ static int elektraUnlockFile (int fd ELEKTRA_UNUSED, Key * parentKey ELEKTRA_UNU if (ret == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "fcntl SETLK unlocking failed with message: %s", - strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "fcntl SETLK unlocking failed with message: %s", strerror (errno)); } return ret; @@ -213,13 +212,13 @@ static int elektraLockMutex (Key * parentKey ELEKTRA_UNUSED) if (errno == EBUSY // for trylock || errno == EDEADLK) // for error checking mutex, if enabled { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, - "conflict because other thread writes to configuration indicated by mutex lock"); + ELEKTRA_SET_CONFLICT_ERROR (parentKey, + "conflict because other thread writes to configuration indicated by mutex lock"); } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, - "assuming conflict because of failed mutex lock with message: %s", strerror (errno)); + ELEKTRA_SET_CONFLICT_ERRORF (parentKey, "assuming conflict because of failed mutex lock with message: %s", + strerror (errno)); } return -1; } @@ -241,7 +240,7 @@ static int elektraUnlockMutex (Key * parentKey ELEKTRA_UNUSED) int ret = pthread_mutex_unlock (&elektraResolverMutex); if (ret != 0) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "mutex unlock failed with message: %s", strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "mutex unlock failed with message: %s", strerror (errno)); return -1; } return 0; @@ -261,7 +260,7 @@ static void elektraCloseFile (int fd, Key * parentKey) { if (close (fd) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "close file failed with message: %s", strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "close file failed with message: %s", strerror (errno)); } } @@ -324,7 +323,7 @@ static int mapFilesForNamespaces (resolverHandles * p, Key * errorKey) { resolverClose (p); keyDel (testKey); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not resolve spec key"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Could not resolve spec key"); return -1; } else @@ -346,7 +345,7 @@ static int mapFilesForNamespaces (resolverHandles * p, Key * errorKey) { resolverClose (p); keyDel (testKey); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not resolve dir key"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Could not resolve dir key"); return -1; } else @@ -367,8 +366,7 @@ static int mapFilesForNamespaces (resolverHandles * p, Key * errorKey) { resolverClose (p); keyDel (testKey); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not resolve user key with conf %s", - ELEKTRA_VARIANT_USER); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Could not resolve user key with conf %s", ELEKTRA_VARIANT_USER); return -1; } else @@ -389,8 +387,7 @@ static int mapFilesForNamespaces (resolverHandles * p, Key * errorKey) { resolverClose (p); keyDel (testKey); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not resolve system key with conf %s", - ELEKTRA_VARIANT_SYSTEM); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Could not resolve system key with conf %s", ELEKTRA_VARIANT_SYSTEM); return -1; } else @@ -441,7 +438,7 @@ int ELEKTRA_PLUGIN_FUNCTION (open) (Plugin * handle, Key * errorKey) if (!path) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not find file configuration"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Could not find file configuration"); return -1; } @@ -463,22 +460,22 @@ int ELEKTRA_PLUGIN_FUNCTION (open) (Plugin * handle, Key * errorKey) if ((mutexError = pthread_mutexattr_init (&mutexAttr)) != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, - "Could not initialize recursive mutex: pthread_mutexattr_init returned %d", mutexError); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Could not initialize recursive mutex: pthread_mutexattr_init returned %d", + mutexError); pthread_mutex_unlock (&elektraResolverInitMutex); return -1; } if ((mutexError = pthread_mutexattr_settype (&mutexAttr, PTHREAD_MUTEX_RECURSIVE)) != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, - "Could not initialize recursive mutex: pthread_mutexattr_settype returned %d", mutexError); + ELEKTRA_SET_RESOURCE_ERRORF ( + errorKey, "Could not initialize recursive mutex: pthread_mutexattr_settype returned %d", mutexError); pthread_mutex_unlock (&elektraResolverInitMutex); return -1; } if ((mutexError = pthread_mutex_init (&elektraResolverMutex, &mutexAttr)) != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, - "Could not initialize recursive mutex: pthread_mutex_init returned %d", mutexError); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Could not initialize recursive mutex: pthread_mutex_init returned %d", + mutexError); pthread_mutex_unlock (&elektraResolverInitMutex); return -1; } @@ -665,17 +662,16 @@ static int elektraOpenFile (resolverHandle * pk, Key * parentKey) { if (errno == ENOENT) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, - "The configuration file \"%s\" was there earlier, " - "now it is missing", - pk->filename); + ELEKTRA_SET_CONFLICT_ERRORF (parentKey, + "The configuration file \"%s\" was there earlier, " + "now it is missing", + pk->filename); return -1; } else if (pk->fd == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, - "Could not reopen configuration file \"%s\" for writing because \"%s\"", pk->filename, - strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not reopen configuration file \"%s\" for writing because \"%s\"", + pk->filename, strerror (errno)); return -1; } // successfully reopened @@ -690,10 +686,10 @@ static int elektraOpenFile (resolverHandle * pk, Key * parentKey) } else if (errno == EEXIST) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, - "No configuration file was there earlier, " - "now configuration file \"%s\" exists", - pk->filename); + ELEKTRA_SET_CONFLICT_ERRORF (parentKey, + "No configuration file was there earlier, " + "now configuration file \"%s\" exists", + pk->filename); return -1; } @@ -721,8 +717,8 @@ static int elektraCreateFile (resolverHandle * pk, Key * parentKey) if (pk->fd == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not create configuration file \"%s\" because %s", - pk->filename, strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not create configuration file \"%s\" because %s", pk->filename, + strerror (errno)); return -1; } return 0; @@ -803,7 +799,7 @@ static int elektraMkdirParents (resolverHandle * pk, const char * pathname, Key elektraAddErrnoText (errorText); strcat (errorText, "\" "); elektraAddIdentity (errorText); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, errorText); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, errorText); elektraFree (errorText); return -1; } @@ -840,21 +836,22 @@ static int elektraCheckConflict (resolverHandle * pk, Key * parentKey) elektraAddErrnoText (errorText); strcat (errorText, "\" "); elektraAddIdentity (errorText); - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, parentKey, errorText); + ELEKTRA_ADD_RESOURCE_WARNING (parentKey, errorText); elektraFree (errorText); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, "assuming conflict because of failed stat (warning 29 for details)"); + ELEKTRA_SET_CONFLICT_ERROR (parentKey, "assuming conflict because of failed stat (warning 29 for details)"); return -1; } if (ELEKTRA_STAT_SECONDS (buf) != pk->mtime.tv_sec || ELEKTRA_STAT_NANO_SECONDS (buf) != pk->mtime.tv_nsec) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, - "conflict, file modification time stamp %ld.%ld is different than our time stamp %ld.%ld, config file " - "name is \"%s\", " - "our identity is uid: %u, euid: %u, gid: %u, egid: %u", - ELEKTRA_STAT_SECONDS (buf), ELEKTRA_STAT_NANO_SECONDS (buf), pk->mtime.tv_sec, pk->mtime.tv_nsec, - pk->filename, getuid (), geteuid (), getgid (), getegid ()); + ELEKTRA_SET_CONFLICT_ERRORF ( + parentKey, + "conflict, file modification time stamp %ld.%ld is different than our time stamp %ld.%ld, config file " + "name is \"%s\", " + "our identity is uid: %u, euid: %u, gid: %u, egid: %u", + ELEKTRA_STAT_SECONDS (buf), ELEKTRA_STAT_NANO_SECONDS (buf), pk->mtime.tv_sec, pk->mtime.tv_nsec, pk->filename, + getuid (), geteuid (), getgid (), getegid ()); return -1; } @@ -973,8 +970,8 @@ static void elektraUpdateFileTime (resolverHandle * pk, int fd, Key * parentKey) if (futimens (fd, times) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, "Could not update time stamp of \"%s\", because %s", - fd == pk->fd ? pk->filename : pk->tempfile, strerror (errno)); + ELEKTRA_ADD_LOGICAL_WARNINGF (parentKey, "Could not update time stamp of \"%s\", because %s", + fd == pk->fd ? pk->filename : pk->tempfile, strerror (errno)); } #elif defined(HAVE_FUTIMES) const struct timeval times[2] = { { pk->mtime.tv_sec, pk->mtime.tv_nsec / 1000 }, // atime @@ -982,8 +979,8 @@ static void elektraUpdateFileTime (resolverHandle * pk, int fd, Key * parentKey) if (futimes (fd, times) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, "Could not update time stamp of \"%s\", because %s", - fd == pk->fd ? pk->filename : pk->tempfile, strerror (errno)); + ELEKTRA_ADD_LOGICAL_WARNINGF (parentKey, "Could not update time stamp of \"%s\", because %s", + fd == pk->fd ? pk->filename : pk->tempfile, strerror (errno)); } #else #warning futimens/futimes not defined @@ -1008,9 +1005,8 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) int fd = open (pk->tempfile, O_RDWR); if (fd == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, - "Could not open file again for changing metadata of file \"%s\", because %s", pk->tempfile, - strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open file again for changing metadata of file \"%s\", because %s", + pk->tempfile, strerror (errno)); ret = -1; } @@ -1018,7 +1014,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) if (rename (pk->tempfile, pk->filename) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not rename file: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not rename file: %s", strerror (errno)); ret = -1; } @@ -1027,7 +1023,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) struct stat buf; if (fstat (fd, &buf) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to stat file: %s\n", strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file: %s\n", strerror (errno)); } else { @@ -1062,9 +1058,8 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) // change mode to what it was before if (fchmod (fd, pk->filemode) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, - "Could not fchmod temporary file \"%s\" from %o to %o, because %s", pk->tempfile, buf.st_mode, - pk->filemode, strerror (errno)); + ELEKTRA_ADD_LOGICAL_WARNINGF (parentKey, "Could not fchmod temporary file \"%s\" from %o to %o, because %s", + pk->tempfile, buf.st_mode, pk->filemode, strerror (errno)); } } @@ -1072,9 +1067,8 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) { if (fchown (fd, pk->uid, pk->gid) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, - "Could not fchown temporary file \"%s\" from %d.%d to %d.%d, because %s", pk->tempfile, - buf.st_uid, buf.st_gid, pk->uid, pk->gid, strerror (errno)); + ELEKTRA_ADD_LOGICAL_WARNINGF (parentKey, "Could not fchown temporary file \"%s\" from %d.%d to %d.%d, because %s", + pk->tempfile, buf.st_uid, buf.st_gid, pk->uid, pk->gid, strerror (errno)); } } @@ -1085,8 +1079,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) // checking dirp not needed, fsync will have EBADF if (fsync (dirfd (dirp)) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, parentKey, "Could not sync directory \"%s\", because %s", pk->dirname, - strerror (errno)); + ELEKTRA_ADD_INSTALLATION_WARNINGF (parentKey, "Could not sync directory \"%s\", because %s", pk->dirname, strerror (errno)); } closedir (dirp); @@ -1122,7 +1115,7 @@ int ELEKTRA_PLUGIN_FUNCTION (set) (Plugin * handle, KeySet * ks, Key * parentKey ELEKTRA_LOG ("check if removal of the configuration file \"%s\" would work later", pk->filename); if (access (pk->dirname, W_OK | X_OK) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not remove file: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not remove file: %s", strerror (errno)); ret = -1; } @@ -1143,7 +1136,7 @@ int ELEKTRA_PLUGIN_FUNCTION (set) (Plugin * handle, KeySet * ks, Key * parentKey ELEKTRA_LOG ("unlink configuration file \"%s\"", pk->filename); if (unlink (pk->filename) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not remove file: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not remove file: %s", strerror (errno)); ret = -1; } @@ -1178,8 +1171,7 @@ static void elektraUnlinkFile (char * filename, Key * parentKey) int errnoSave = errno; if (unlink (filename) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "could not unlink the file \"%s\" because of \"%s\"", filename, - strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "could not unlink the file \"%s\" because of \"%s\"", filename, strerror (errno)); errno = errnoSave; } } diff --git a/src/plugins/ruby/ruby.cpp b/src/plugins/ruby/ruby.cpp index b363951bd7f..07e7cf9208b 100644 --- a/src/plugins/ruby/ruby.cpp +++ b/src/plugins/ruby/ruby.cpp @@ -133,7 +133,7 @@ static VALUE clear_ruby_exception_add_warning (ckdb::Key * warningsKey) VALUE exception = clear_ruby_exception (); VALUE msg = get_exception_string (exception); - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, warningsKey, StringValueCStr (msg)); + ELEKTRA_ADD_INSTALLATION_WARNING (warningsKey, StringValueCStr (msg)); return exception; } @@ -143,7 +143,7 @@ static VALUE clear_ruby_exception_set_error (ckdb::Key * errorKey) VALUE exception = clear_ruby_exception (); VALUE msg = get_exception_string (exception); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, StringValueCStr (msg)); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, StringValueCStr (msg)); return exception; } @@ -311,7 +311,7 @@ static int init_ruby_environment (ckdb::Key * warningsKey) ELEKTRA_LOG ("init and start Ruby-VM"); if (ruby_setup ()) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, warningsKey, "could not initialize Ruby-VM"); + ELEKTRA_ADD_INSTALLATION_WARNING (warningsKey, "could not initialize Ruby-VM"); return -1; } @@ -338,7 +338,7 @@ static int init_ruby_environment (ckdb::Key * warningsKey) rb_protect (require_kdb, Qnil, &state); if (state) { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, warningsKey, "could not load Ruby module 'kdb'"); + ELEKTRA_ADD_INSTALLATION_WARNING (warningsKey, "could not load Ruby module 'kdb'"); return -1; } @@ -404,7 +404,7 @@ int RUBY_PLUGIN_FUNCTION (CheckConf) (ckdb::Key * errorKey, ckdb::KeySet * conf) { /* no script specified * do not issue an error or 'kdb info ruby' causes problems */ - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "no 'script' config value specified"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "no 'script' config value specified"); return -1; } @@ -430,7 +430,7 @@ int RUBY_PLUGIN_FUNCTION (CheckConf) (ckdb::Key * errorKey, ckdb::KeySet * conf) if (global_plugin_instance == Qnil) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "invalid Ruby plugin. Plugin did not call Kdb::Plugin.define"); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "invalid Ruby plugin. Plugin did not call Kdb::Plugin.define"); global_context_mutex.unlock (); return -1; @@ -511,7 +511,7 @@ int RUBY_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * warningsKey) /* error, the Ruby-plugin did not call Kdb::Plugin.define * so we do not have a Plugin instance */ - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, warningsKey, "Error in Ruby-plugin, didn't call Kdb::Plugin.define"); + ELEKTRA_ADD_INSTALLATION_WARNING (warningsKey, "Error in Ruby-plugin, didn't call Kdb::Plugin.define"); return 0; } @@ -651,7 +651,7 @@ int RUBY_PLUGIN_FUNCTION (Get) (ckdb::Plugin * handle, ckdb::KeySet * returned, else { /* if not 'get' method is available, this plugin is useless, therefore set and error */ - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "plugin does not have a 'get' method"); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "plugin does not have a 'get' method"); return -1; } return -1; diff --git a/src/plugins/shell/shell.c b/src/plugins/shell/shell.c index 1adaf473247..69ebc4e3309 100644 --- a/src/plugins/shell/shell.c +++ b/src/plugins/shell/shell.c @@ -70,17 +70,15 @@ int elektraShellGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa int retVal = executeCommand (keyString (cmdKey)); if (retVal == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "launching childprocess failed with %s\n", - strerror (errno)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "launching childprocess failed with %s\n", strerror (errno)); return -1; } else if (expectedReturnKey) { if (atoi (keyString (expectedReturnKey)) != retVal) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "return value of %s doesn't match expected exit %s\n", keyString (cmdKey), - keyString (expectedReturnKey)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "return value of %s doesn't match expected exit %s\n", + keyString (cmdKey), keyString (expectedReturnKey)); return -1; } } @@ -100,17 +98,15 @@ int elektraShellSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_U int retVal = executeCommand (keyString (cmdKey)); if (retVal == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "launching childprocess failed with %s\n", - strerror (errno)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "launching childprocess failed with %s\n", strerror (errno)); return -1; } else if (expectedReturnKey) { if (atoi (keyString (expectedReturnKey)) != retVal) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "return value of %s doesn't match expected exit %s\n", keyString (cmdKey), - keyString (expectedReturnKey)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "return value of %s doesn't match expected exit %s\n", + keyString (cmdKey), keyString (expectedReturnKey)); return -1; } } @@ -130,17 +126,15 @@ int elektraShellError (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA int retVal = executeCommand (keyString (cmdKey)); if (retVal == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "launching childprocess failed with %s\n", - strerror (errno)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "launching childprocess failed with %s\n", strerror (errno)); return -1; } else if (expectedReturnKey) { if (atoi (keyString (expectedReturnKey)) != retVal) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "return value of %s doesn't match expected exit %s\n", keyString (cmdKey), - keyString (expectedReturnKey)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "return value of %s doesn't match expected exit %s\n", + keyString (cmdKey), keyString (expectedReturnKey)); return -1; } } diff --git a/src/plugins/simpleini/simpleini.c b/src/plugins/simpleini/simpleini.c index a6d2b7c13b5..a8f1fbf9bf3 100644 --- a/src/plugins/simpleini/simpleini.c +++ b/src/plugins/simpleini/simpleini.c @@ -251,7 +251,7 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) char * format = getReadFormat (handle); if (!format) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "invalid 'format' specified"); + ELEKTRA_SET_PARSING_ERROR (parentKey, "invalid 'format' specified"); return -1; } @@ -280,8 +280,8 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) // discard line if (getline (&key, &size, fp) == -1 && !feof (fp)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, - "failed discarding rest of line at position %ld with key %s", ftell (fp), key); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "failed discarding rest of line at position %ld with key %s", + ftell (fp), key); elektraFree (key); fclose (fp); return -1; @@ -297,8 +297,7 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) if (keyAddName (read, strippedkey) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "Key name %s is not valid, discarding key", - strippedkey); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (parentKey, "Key name %s is not valid, discarding key", strippedkey); keyDel (read); elektraFree (key); if (n == 2) @@ -320,8 +319,7 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) if (ksAppendKey (returned, read) != ksize + 1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "duplicated key %s at position %ld", keyName (read), - ftell (fp)); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "duplicated key %s at position %ld", keyName (read), ftell (fp)); elektraFree (format); fclose (fp); return -1; @@ -331,7 +329,7 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) if (feof (fp) == 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "not at the end of file at position %ld", ftell (fp)); + ELEKTRA_SET_PARSING_ERRORF (parentKey, "not at the end of file at position %ld", ftell (fp)); elektraFree (format); fclose (fp); return -1; diff --git a/src/plugins/simplespeclang/simplespeclang.cpp b/src/plugins/simplespeclang/simplespeclang.cpp index 8f0162da2de..26ed074b544 100644 --- a/src/plugins/simplespeclang/simplespeclang.cpp +++ b/src/plugins/simplespeclang/simplespeclang.cpp @@ -132,8 +132,8 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks, Plu ss >> read; if (read != getConfigAssign (handle)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey, "Expected assignment (%s), but got (%s)", - getConfigAssign (handle).c_str (), read.c_str ()); + ELEKTRA_SET_PARSING_ERRORF (errorKey, "Expected assignment (%s), but got (%s)", getConfigAssign (handle).c_str (), + read.c_str ()); continue; } diff --git a/src/plugins/specload/specload.c b/src/plugins/specload/specload.c index bcaed163173..f598db2f169 100644 --- a/src/plugins/specload/specload.c +++ b/src/plugins/specload/specload.c @@ -180,7 +180,7 @@ int elektraSpecloadGet (Plugin * handle, KeySet * returned, Key * parentKey) if (keyGetNamespace (parentKey) != KEY_NS_SPEC) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "This plugin can only be used for the spec namespace."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "This plugin can only be used for the spec namespace."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -191,8 +191,8 @@ int elektraSpecloadGet (Plugin * handle, KeySet * returned, Key * parentKey) if (!loadSpec (spec, specload->app, specload->argv, parentKey, specload->quickDump)) { ksDel (spec); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Couldn't load the base specification. Make sure the app is available and the arguments are correct."); + ELEKTRA_SET_INSTALLATION_ERROR ( + parentKey, "Couldn't load the base specification. Make sure the app is available and the arguments are correct."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -201,7 +201,7 @@ int elektraSpecloadGet (Plugin * handle, KeySet * returned, Key * parentKey) if (elektraInvoke2Args (specload->quickDump, "get", spec, parentKey) == ELEKTRA_PLUGIN_STATUS_ERROR) { ksDel (spec); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "Couldn't load the overlay specification."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Couldn't load the overlay specification."); return ELEKTRA_PLUGIN_STATUS_ERROR; } } @@ -211,7 +211,7 @@ int elektraSpecloadGet (Plugin * handle, KeySet * returned, Key * parentKey) if (elektraInvoke2Args (specload->quickDump, "set", ks, parentKey) == ELEKTRA_PLUGIN_STATUS_ERROR) { ksDel (ks); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "Couldn't create an empty overlay specification."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Couldn't create an empty overlay specification."); return ELEKTRA_PLUGIN_STATUS_ERROR; } ksDel (ks); @@ -227,7 +227,7 @@ int elektraSpecloadSet (Plugin * handle, KeySet * returned, Key * parentKey) { if (keyGetNamespace (parentKey) != KEY_NS_SPEC) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "This plugin can only be used for the spec namespace."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "This plugin can only be used for the spec namespace."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -237,8 +237,8 @@ int elektraSpecloadSet (Plugin * handle, KeySet * returned, Key * parentKey) if (!loadSpec (spec, specload->app, specload->argv, parentKey, specload->quickDump)) { ksDel (spec); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, - "Couldn't load the base specification. Make sure the app is available and the arguments are correct."); + ELEKTRA_SET_INSTALLATION_ERROR ( + parentKey, "Couldn't load the base specification. Make sure the app is available and the arguments are correct."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -248,7 +248,7 @@ int elektraSpecloadSet (Plugin * handle, KeySet * returned, Key * parentKey) if (elektraInvoke2Args (specload->quickDump, "get", oldData, parentKey) == ELEKTRA_PLUGIN_STATUS_ERROR) { ksDel (oldData); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "Couldn't load the overlay specification."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Couldn't load the overlay specification."); return ELEKTRA_PLUGIN_STATUS_ERROR; } } @@ -257,7 +257,7 @@ int elektraSpecloadSet (Plugin * handle, KeySet * returned, Key * parentKey) if (elektraInvoke2Args (specload->quickDump, "set", oldData, parentKey) == ELEKTRA_PLUGIN_STATUS_ERROR) { ksDel (oldData); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "Couldn't create an empty overlay specification."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Couldn't create an empty overlay specification."); return ELEKTRA_PLUGIN_STATUS_ERROR; } } @@ -281,7 +281,7 @@ int elektraSpecloadSet (Plugin * handle, KeySet * returned, Key * parentKey) if (changeAllowed < 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "This kind of change is not allowed."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "This kind of change is not allowed."); ksSetCursor (returned, cursor); ksDel (overrides); ksDel (oldData); @@ -341,8 +341,8 @@ int elektraSpecloadCheckConfig (Key * errorKey, KeySet * conf) if (!result) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, - "Couldn't load the specification. Make sure the app is available and the arguments are correct."); + ELEKTRA_SET_INSTALLATION_ERROR ( + errorKey, "Couldn't load the specification. Make sure the app is available and the arguments are correct."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -355,7 +355,7 @@ bool getAppAndArgs (KeySet * conf, char ** appPtr, char *** argvPtr, Key * error if (appKey == NULL) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "You need to set an application using the app config key."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "You need to set an application using the app config key."); return false; } @@ -363,14 +363,13 @@ bool getAppAndArgs (KeySet * conf, char ** appPtr, char *** argvPtr, Key * error if (app[0] != '/') { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "The value of the app config key ('%s') is not an absolute path.", - app); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "The value of the app config key ('%s') is not an absolute path.", app); return false; } if (access (app, X_OK) != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "'%s' doesn't exist or is not executable.", app); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "'%s' doesn't exist or is not executable.", app); return false; } @@ -414,7 +413,7 @@ bool loadSpec (KeySet * returned, const char * app, char * argv[], Key * parentK if (pipe (fd) != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not execute app: %s", strerror (errno)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Could not execute app: %s", strerror (errno)); return NULL; } @@ -422,7 +421,7 @@ bool loadSpec (KeySet * returned, const char * app, char * argv[], Key * parentK if (pid == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not execute app: %s", strerror (errno)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Could not execute app: %s", strerror (errno)); return NULL; } @@ -449,7 +448,7 @@ bool loadSpec (KeySet * returned, const char * app, char * argv[], Key * parentK if (dup2 (fd[0], STDIN_FILENO) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not execute app: %s", strerror (errno)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Could not execute app: %s", strerror (errno)); return NULL; } @@ -467,7 +466,7 @@ bool loadSpec (KeySet * returned, const char * app, char * argv[], Key * parentK if (dup2 (stdin_copy, STDIN_FILENO) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not execute app: %s", strerror (errno)); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Could not execute app: %s", strerror (errno)); return NULL; } close (stdin_copy); diff --git a/src/plugins/struct/struct.cpp b/src/plugins/struct/struct.cpp index 76da57bc8c4..66607b578d3 100644 --- a/src/plugins/struct/struct.cpp +++ b/src/plugins/struct/struct.cpp @@ -68,7 +68,7 @@ int elektraStructSet (ckdb::Plugin * handle, ckdb::KeySet * returned, ckdb::Key } catch (const char * msg) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not check the structure of the keyset: %s", msg); + ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, "Could not check the structure of the keyset: %s", msg); return -1; } diff --git a/src/plugins/sync/sync.c b/src/plugins/sync/sync.c index 0630774a185..41ef67b0abb 100644 --- a/src/plugins/sync/sync.c +++ b/src/plugins/sync/sync.c @@ -52,14 +52,12 @@ int elektraSyncSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN int fd = open (configFile, O_RDWR); if (fd == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open config file %s because \"%s\"", configFile, - strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open config file %s because \"%s\"", configFile, strerror (errno)); return -1; } if (fsync (fd) == -1) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not fsync config file %s because \"%s\"", configFile, - strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not fsync config file %s because \"%s\"", configFile, strerror (errno)); close (fd); return -1; } diff --git a/src/plugins/tcl/tcl.cpp b/src/plugins/tcl/tcl.cpp index d66f6f2bcd3..c79825eaf9b 100644 --- a/src/plugins/tcl/tcl.cpp +++ b/src/plugins/tcl/tcl.cpp @@ -65,16 +65,15 @@ int elektraTclGet (Plugin *, KeySet * returned, Key * parentKey) } catch (boost::spirit::qi::expectation_failure const & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, *parent, - std::string (std::string ("file: ") + parent.getString () + - " could not be parsed because: " + std::string (e.first, e.last)) - .c_str ()); + ELEKTRA_SET_PARSING_ERROR (*parent, std::string (std::string ("file: ") + parent.getString () + + " could not be parsed because: " + std::string (e.first, e.last)) + .c_str ()); ret = -1; } catch (std::exception const & e) { - ELEKTRA_SET_ERROR ( - ELEKTRA_ERROR_PARSING, *parent, + ELEKTRA_SET_PARSING_ERROR ( + *parent, std::string (std::string ("file: ") + parent.getString () + " could not be parsed because: " + e.what ()).c_str ()); ret = -1; } diff --git a/src/plugins/type/type.c b/src/plugins/type/type.c index 5c2ba00a63a..9ba98b964cb 100644 --- a/src/plugins/type/type.c +++ b/src/plugins/type/type.c @@ -94,8 +94,8 @@ bool elektraTypeCheckType (const Key * key) static void elektraTypeSetDefaultError (Plugin * handle ELEKTRA_UNUSED, Key * errorKey, const Key * key) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "The type '%s' failed to match for '%s' with string: %s", - getTypeName (key), keyName (key), keyString (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "The type '%s' failed to match for '%s' with string: %s", getTypeName (key), + keyName (key), keyString (key)); } bool elektraTypeValidateKey (Plugin * handle, Key * key, Key * errorKey) @@ -109,15 +109,14 @@ bool elektraTypeValidateKey (Plugin * handle, Key * key, Key * errorKey) const Type * type = findType (typeName); if (type == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Unknown type '%s' for key '%s'", typeName, keyName (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Unknown type '%s' for key '%s'", typeName, keyName (key)); return false; } if (type->normalize != NULL && !type->normalize (handle, key)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "The value '%s' of key %s could not be normalized (type is '%s')", keyString (key), keyName (key), - typeName); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "The value '%s' of key %s could not be normalized (type is '%s')", + keyString (key), keyName (key), typeName); return false; } @@ -129,9 +128,9 @@ bool elektraTypeValidateKey (Plugin * handle, Key * key, Key * errorKey) if (type->restore != NULL && !type->restore (handle, key)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "The normalized value '%s' of key %s could not be restored (type is '%s')", keyString (key), - keyName (key), typeName); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, + "The normalized value '%s' of key %s could not be restored (type is '%s')", + keyString (key), keyName (key), typeName); return false; } @@ -173,8 +172,8 @@ static kdb_long_long_t readBooleans (KeySet * config, struct boolean_pair ** res *subPos = '\0'; if ((trueKey == NULL) != (falseKey == NULL)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "You must set both true and false for a boolean pair (config key: '%s')", buffer); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + errorKey, "You must set both true and false for a boolean pair (config key: '%s')", buffer); elektraFree (*result); *result = NULL; return -2; @@ -254,8 +253,7 @@ int elektraTypeOpen (Plugin * handle, Key * errorKey) data->booleanRestore = readBooleanRestore (conf); if (data->booleanRestore < -1 || data->booleanRestore >= data->booleanCount) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "The value of the config key /boolean/restoreas was invalid!"); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "The value of the config key /boolean/restoreas was invalid!"); elektraFree (data); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -302,8 +300,7 @@ int elektraTypeGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par const Type * type = findType (typeName); if (type == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Unknown type '%s' for key '%s'", typeName, - keyName (cur)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Unknown type '%s' for key '%s'", typeName, keyName (cur)); ksSetCursor (returned, cursor); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -313,19 +310,20 @@ int elektraTypeGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par const Key * orig = keyGetMeta (cur, "origvalue"); if (orig != NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, - "The key %s was already normalized by a different plugin! Please ensure that there is " - "only one plugin active that will normalize this key.", - keyName (cur)); + ELEKTRA_SET_INSTALLATION_ERRORF ( + parentKey, + "The key %s was already normalized by a different plugin! Please ensure that there is " + "only one plugin active that will normalize this key.", + keyName (cur)); ksSetCursor (returned, cursor); return ELEKTRA_PLUGIN_STATUS_ERROR; } if (!type->normalize (handle, cur)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "The value '%s' of key %s could not be normalized (type is '%s')", keyString (cur), - keyName (cur), typeName); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, + "The value '%s' of key %s could not be normalized (type is '%s')", + keyString (cur), keyName (cur), typeName); ksSetCursor (returned, cursor); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -362,8 +360,7 @@ int elektraTypeSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par const Type * type = findType (typeName); if (type == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Unknown type '%s' for key '%s'", typeName, - keyName (cur)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Unknown type '%s' for key '%s'", typeName, keyName (cur)); ksSetCursor (returned, cursor); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -374,9 +371,9 @@ int elektraTypeSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par // skip normalization origvalue already set if (orig == NULL && !type->normalize (handle, cur)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "The value '%s' of key %s could not be normalized (type is '%s')", keyString (cur), - keyName (cur), typeName); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, + "The value '%s' of key %s could not be normalized (type is '%s')", + keyString (cur), keyName (cur), typeName); ksSetCursor (returned, cursor); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -391,9 +388,9 @@ int elektraTypeSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par if (type->restore != NULL && !type->restore (handle, cur)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, - "The normalized value '%s' of key %s could not be restored (type is '%s')", keyString (cur), - keyName (cur), typeName); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, + "The normalized value '%s' of key %s could not be restored (type is '%s')", + keyString (cur), keyName (cur), typeName); ksSetCursor (returned, cursor); return ELEKTRA_PLUGIN_STATUS_ERROR; } diff --git a/src/plugins/type/types.c b/src/plugins/type/types.c index db1ac76ef8e..c11a0967e64 100644 --- a/src/plugins/type/types.c +++ b/src/plugins/type/types.c @@ -485,10 +485,11 @@ void elektraTypeSetErrorEnum (Plugin * handle ELEKTRA_UNUSED, Key * errorKey, co if (max == NULL) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, - "The type 'enum' failed to match for '%s' with string: %s\n" - "No values allowed! (check/enum is an empty array, or parent isn't set to last element)", - keyName (key), keyString (key)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF ( + errorKey, + "The type 'enum' failed to match for '%s' with string: %s\n" + "No values allowed! (check/enum is an empty array, or parent isn't set to last element)", + keyName (key), keyString (key)); return; } @@ -518,6 +519,6 @@ void elektraTypeSetErrorEnum (Plugin * handle ELEKTRA_UNUSED, Key * errorKey, co elektraWriteArrayNumber (indexStart, index); } - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, errorMessage); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, errorMessage); elektraFree (errorMessage); } diff --git a/src/plugins/validation/validation.c b/src/plugins/validation/validation.c index ecd71556ad2..ca25796d2a1 100644 --- a/src/plugins/validation/validation.c +++ b/src/plugins/validation/validation.c @@ -111,7 +111,7 @@ static int validateKey (Key * key, Key * parentKey) { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Could not compile regex: %s", buffer); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Could not compile regex: %s", buffer); regfree (®ex); if (freeString) elektraFree (regexString); return 0; @@ -145,8 +145,7 @@ static int validateKey (Key * key, Key * parentKey) const Key * msg = keyGetMeta (key, "check/validation/message"); if (msg) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Key value failed to validate: %s", - keyString (msg)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Key value failed to validate: %s", keyString (msg)); regfree (®ex); if (freeString) elektraFree (regexString); return 0; @@ -155,7 +154,7 @@ static int validateKey (Key * key, Key * parentKey) { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Key value failed to validate: %s", buffer); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Key value failed to validate: %s", buffer); regfree (®ex); if (freeString) elektraFree (regexString); return 0; diff --git a/src/plugins/wresolver/wresolver.c b/src/plugins/wresolver/wresolver.c index 8244338ddbc..b6ceaf72220 100644 --- a/src/plugins/wresolver/wresolver.c +++ b/src/plugins/wresolver/wresolver.c @@ -125,7 +125,7 @@ static void elektraResolveSpec (resolverHandle * p, Key * errorKey) if (!system) { system = ""; - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not get ALLUSERSPROFILE for spec, using /"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "could not get ALLUSERSPROFILE for spec, using /"); } else { @@ -163,13 +163,12 @@ static void elektraResolveDir (resolverHandle * p, Key * warningsKey) char buf[256]; FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 256, NULL); - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "GetCurrentDirectory failed: %s, defaulting to /", buf); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "GetCurrentDirectory failed: %s, defaulting to /", buf); dir[0] = 0; } else if (dwRet > MAX_PATH) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, - "GetCurrentDirectory failed, buffer size too small, needed: %ld", dwRet); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "GetCurrentDirectory failed, buffer size too small, needed: %ld", dwRet); dir[0] = 0; } escapePath (dir); @@ -177,7 +176,7 @@ static void elektraResolveDir (resolverHandle * p, Key * warningsKey) char dir[KDB_MAX_PATH_LENGTH]; if (getcwd (dir, KDB_MAX_PATH_LENGTH) == 0) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "getcwd failed: %s, defaulting to /", strerror (errno)); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "getcwd failed: %s, defaulting to /", strerror (errno)); dir[0] = 0; } #endif @@ -203,14 +202,14 @@ static void elektraResolveUser (resolverHandle * p, Key * warningsKey) else { strcpy (home, ""); - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, warningsKey, "could not get home (CSIDL_PROFILE), using /"); + ELEKTRA_ADD_INSTALLATION_WARNING (warningsKey, "could not get home (CSIDL_PROFILE), using /"); } #else char * home = (char *) getenv ("HOME"); if (!home) { home = ""; - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, warningsKey, "could not get home, using /"); + ELEKTRA_ADD_INSTALLATION_WARNING (warningsKey, "could not get home, using /"); } #endif @@ -226,7 +225,7 @@ static void elektraResolveSystem (resolverHandle * p, Key * errorKey) if (!system) { system = ""; - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not get ALLUSERSPROFILE, using /"); + ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "could not get ALLUSERSPROFILE, using /"); } else { @@ -258,7 +257,7 @@ int elektraWresolverOpen (Plugin * handle, Key * errorKey) if (!path) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not find file configuration"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Could not find file configuration"); return -1; } @@ -386,7 +385,7 @@ int elektraWresolverSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key switch (pk->state) { case 0: - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "kdbSet() called before kdbGet()"); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "kdbSet() called before kdbGet()"); return -1; case 1: ++pk->state; @@ -410,7 +409,7 @@ int elektraWresolverSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key if (stat (pk->filename, &buf) == -1) { - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "could not stat config file \"%s\", ", pk->filename); + ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "could not stat config file \"%s\", ", pk->filename); // no file found, nothing to do return 0; } @@ -419,8 +418,8 @@ int elektraWresolverSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key if (pk->mtime != buf.st_mtime) { // conflict - ELEKTRA_SET_ERRORF ( - ELEKTRA_ERROR_CONFLICT, parentKey, + ELEKTRA_SET_CONFLICT_ERRORF ( + parentKey, "conflict, file modification time stamp %ld is different than our time stamp %ld config file name is \"%s\", ", (long) buf.st_mtime, (long) pk->mtime, pk->filename); pk->state = 0; // invalid state, need to kdbGet again diff --git a/src/plugins/xerces/xerces.cpp b/src/plugins/xerces/xerces.cpp index 888daafc030..50eaa61af08 100644 --- a/src/plugins/xerces/xerces.cpp +++ b/src/plugins/xerces/xerces.cpp @@ -65,23 +65,23 @@ int elektraXercesGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (const OutOfMemoryException & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, asCStr (e.getMessage ())); } catch (const XMLException & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_PARSING_ERROR (parentKey, asCStr (e.getMessage ())); } catch (const DOMException & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_PARSING_ERROR (parentKey, asCStr (e.getMessage ())); } catch (const XercesPluginException & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, e.what ()); + ELEKTRA_SET_PARSING_ERROR (parentKey, e.what ()); } catch (...) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "Unknown exception occurred while reading xml file"); + ELEKTRA_SET_PARSING_ERROR (parentKey, "Unknown exception occurred while reading xml file"); } // Avoid destruction of the pointers at the end @@ -103,23 +103,23 @@ int elektraXercesSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (const OutOfMemoryException & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_RESOURCE_ERROR (parentKey, asCStr (e.getMessage ())); } catch (const XMLException & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_PARSING_ERROR (parentKey, asCStr (e.getMessage ())); } catch (const DOMException & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_PARSING_ERROR (parentKey, asCStr (e.getMessage ())); } catch (const XercesPluginException & e) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, e.what ()); + ELEKTRA_SET_PARSING_ERROR (parentKey, e.what ()); } catch (...) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "Unknown exception occurred while writing xml file"); + ELEKTRA_SET_PARSING_ERROR (parentKey, "Unknown exception occurred while writing xml file"); } // Avoid destruction of the pointers at the end diff --git a/src/plugins/yajl/yajl_gen.c b/src/plugins/yajl/yajl_gen.c index 723245812b2..2696da0ab71 100644 --- a/src/plugins/yajl/yajl_gen.c +++ b/src/plugins/yajl/yajl_gen.c @@ -163,7 +163,7 @@ static void elektraGenValue (yajl_gen g, Key * parentKey, const Key * cur) } else { - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_VALIDATION_SEMANTIC, parentKey, "got boolean which is neither true nor false"); + ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNING (parentKey, "got boolean which is neither true nor false"); yajl_gen_string (g, (const unsigned char *) keyString (cur), keyGetValueSize (cur) - 1); } } @@ -173,8 +173,7 @@ static void elektraGenValue (yajl_gen g, Key * parentKey, const Key * cur) } else { // unknown or unsupported type, render it as string but add warning - ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, parentKey, "the key %s has unknown type: %s", keyName (cur), - keyString (type)); + ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNINGF (parentKey, "the key %s has unknown type: %s", keyName (cur), keyString (type)); yajl_gen_string (g, (const unsigned char *) keyString (cur), keyGetValueSize (cur) - 1); } } diff --git a/src/plugins/yajl/yajl_parse.c b/src/plugins/yajl/yajl_parse.c index 452564c42c5..6adc1be78aa 100644 --- a/src/plugins/yajl/yajl_parse.c +++ b/src/plugins/yajl/yajl_parse.c @@ -395,8 +395,7 @@ int elektraYajlGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par { if (!feof (fileHandle)) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Error while reading file: %s", - keyString (parentKey)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", keyString (parentKey)); fclose (fileHandle); yajl_free (hand); return -1; @@ -425,7 +424,7 @@ int elektraYajlGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par if (test_status) { unsigned char * str = yajl_get_error (hand, 1, fileData, rd); - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, (char *) str); + ELEKTRA_SET_PARSING_ERROR (parentKey, (char *) str); yajl_free_error (hand, str); yajl_free (hand); fclose (fileHandle); diff --git a/src/plugins/yambi/convert.cpp b/src/plugins/yambi/convert.cpp index aba2e9b9e9a..853a8383aff 100644 --- a/src/plugins/yambi/convert.cpp +++ b/src/plugins/yambi/convert.cpp @@ -46,15 +46,15 @@ int addToKeySet (CppKeySet & keySet, CppKey & parent, string const & filename) { if (status == -3) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parent.getKey (), "Unable to open file “%s”", filename.c_str ()); + ELEKTRA_SET_RESOURCE_ERRORF (parent.getKey (), "Unable to open file “%s”", filename.c_str ()); } else if (status == -2) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parent.getKey (), "Parsing failed due to memory exhaustion"); + ELEKTRA_SET_PARSING_ERROR (parent.getKey (), "Parsing failed due to memory exhaustion"); } else if (status == -1) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parent.getKey (), driver.getErrorMessage ().c_str ()); + ELEKTRA_SET_PARSING_ERROR (parent.getKey (), driver.getErrorMessage ().c_str ()); } return status; diff --git a/src/plugins/yambi/yambi.cpp b/src/plugins/yambi/yambi.cpp index ad6a4750a73..606f1de8f5e 100644 --- a/src/plugins/yambi/yambi.cpp +++ b/src/plugins/yambi/yambi.cpp @@ -70,11 +70,11 @@ int elektraYambiGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa } catch (runtime_error const & runtimeError) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, *parent, runtimeError.what ()); + ELEKTRA_SET_PARSING_ERROR (*parent, runtimeError.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught exception: %s", error.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (*parent, "Uncaught exception: %s", error.what ()); } parent.release (); diff --git a/src/plugins/yamlcpp/yamlcpp.cpp b/src/plugins/yamlcpp/yamlcpp.cpp index 9bbd6576847..e7781dfee7f 100644 --- a/src/plugins/yamlcpp/yamlcpp.cpp +++ b/src/plugins/yamlcpp/yamlcpp.cpp @@ -75,8 +75,8 @@ int elektraYamlcppGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * } catch (YAML::ParserException const & exception) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parent.getKey (), "Unable to parse file “%s”: %s.", parent.getString ().c_str (), - exception.what ()); + ELEKTRA_SET_PARSING_ERRORF (parent.getKey (), "Unable to parse file “%s”: %s.", parent.getString ().c_str (), + exception.what ()); } catch (std::overflow_error const & exception) { @@ -85,8 +85,8 @@ int elektraYamlcppGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * } catch (YAML::RepresentationException const & exception) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parent.getKey (), "Unable to read data from file “%s”: %s", - parent.getString ().c_str (), exception.what ()); + ELEKTRA_SET_RESOURCE_ERRORF (parent.getKey (), "Unable to read data from file “%s”: %s", parent.getString ().c_str (), + exception.what ()); } parent.release (); @@ -115,14 +115,13 @@ int elektraYamlcppSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * } catch (YAML::BadFile const & exception) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parent.getKey (), "Unable to write to file “%s”: %s.", - parent.getString ().c_str (), exception.what ()); + ELEKTRA_SET_RESOURCE_ERRORF (parent.getKey (), "Unable to write to file “%s”: %s.", parent.getString ().c_str (), + exception.what ()); } catch (YAML::EmitterException const & exception) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, parent.getKey (), - "Something went wrong while emitting YAML data to file “%s”: %s.", parent.getString ().c_str (), - exception.what ()); + ELEKTRA_SET_LOGICAL_ERRORF (parent.getKey (), "Something went wrong while emitting YAML data to file “%s”: %s.", + parent.getString ().c_str (), exception.what ()); } parent.release (); diff --git a/src/plugins/yamlsmith/yamlsmith.cpp b/src/plugins/yamlsmith/yamlsmith.cpp index 0932e94cb16..fad37330064 100644 --- a/src/plugins/yamlsmith/yamlsmith.cpp +++ b/src/plugins/yamlsmith/yamlsmith.cpp @@ -264,7 +264,7 @@ int elektraYamlsmithSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key } else { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parent.getKey (), "Unable to open file “%s”", parent.getString ().c_str ()); + ELEKTRA_SET_RESOURCE_ERRORF (parent.getKey (), "Unable to open file “%s”", parent.getString ().c_str ()); } parent.release (); diff --git a/src/plugins/yanlr/yanlr.cpp b/src/plugins/yanlr/yanlr.cpp index f2b468526be..ec24395aae1 100644 --- a/src/plugins/yanlr/yanlr.cpp +++ b/src/plugins/yanlr/yanlr.cpp @@ -92,7 +92,7 @@ int parseYAML (ifstream & file, CppKeySet & keys, CppKey & parent) ParseTree * tree = parser.yaml (); if (parser.getNumberOfSyntaxErrors () > 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parent.getKey (), errorListener.message ()); + ELEKTRA_SET_PARSING_ERROR (parent.getKey (), errorListener.message ()); return ELEKTRA_PLUGIN_STATUS_ERROR; } walker.walk (&listener, tree); @@ -127,7 +127,7 @@ int elektraYanlrGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa ifstream file (parent.getString ()); if (!file.is_open ()) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parent.getKey (), "Unable to open file “%s”", parent.getString ().c_str ()); + ELEKTRA_SET_RESOURCE_ERRORF (parent.getKey (), "Unable to open file “%s”", parent.getString ().c_str ()); return ELEKTRA_PLUGIN_STATUS_ERROR; } diff --git a/src/plugins/yawn/convert.cpp b/src/plugins/yawn/convert.cpp index 71f4543ffee..83b2603c6bc 100644 --- a/src/plugins/yawn/convert.cpp +++ b/src/plugins/yawn/convert.cpp @@ -101,7 +101,7 @@ string parseGrammar (yaep & parser, CppKey & error) if (parser.parse_grammar (1, grammar.c_str ()) != 0) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, error.getKey (), "Unable to parse grammar: %s", parser.error_message ()); + ELEKTRA_SET_PARSING_ERRORF (error.getKey (), "Unable to parse grammar: %s", parser.error_message ()); return ""; } return grammar; @@ -120,7 +120,7 @@ ifstream openFile (string const & filename, CppKey & error) ifstream input{ filename }; if (!input.good ()) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, error.getKey (), "Unable to open file “%s”", filename.c_str ()); + ELEKTRA_SET_RESOURCE_ERRORF (error.getKey (), "Unable to open file “%s”", filename.c_str ()); } return input; } @@ -142,8 +142,8 @@ int handleErrors (int const ambiguousOutput, ErrorListener const & errorListener { if (ambiguousOutput) { - ELEKTRA_SET_ERRORF ( - ELEKTRA_ERROR_PARSING, error.getKey (), + ELEKTRA_SET_PARSING_ERRORF ( + error.getKey (), "The content of file “%s” showed that the grammar:\n%s\nproduces ambiguous output!\n" "Please fix the grammar, to make sure it produces only one unique syntax tree for every kind of YAML input.", filename.c_str (), grammar.c_str ()); @@ -152,7 +152,7 @@ int handleErrors (int const ambiguousOutput, ErrorListener const & errorListener if (errorListener.getNumberOfErrors () > 0) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, error.getKey (), errorListener.getErrorMessage ().c_str ()); + ELEKTRA_SET_PARSING_ERROR (error.getKey (), errorListener.getErrorMessage ().c_str ()); return -1; } return 0; diff --git a/src/plugins/yawn/yawn.cpp b/src/plugins/yawn/yawn.cpp index d5721d337a6..4a4c92a1755 100644 --- a/src/plugins/yawn/yawn.cpp +++ b/src/plugins/yawn/yawn.cpp @@ -76,11 +76,11 @@ int elektraYawnGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par } catch (runtime_error const & runtimeError) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, *parent, runtimeError.what ()); + ELEKTRA_SET_PARSING_ERROR (*parent, runtimeError.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught exception: %s", error.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (*parent, "Uncaught exception: %s", error.what ()); } parent.release (); diff --git a/src/plugins/yaypeg/yaypeg.cpp b/src/plugins/yaypeg/yaypeg.cpp index c8bbd46485f..35d106d6c90 100644 --- a/src/plugins/yaypeg/yaypeg.cpp +++ b/src/plugins/yaypeg/yaypeg.cpp @@ -69,11 +69,11 @@ int elektraYaypegGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (runtime_error const & runtimeError) { - ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, *parent, runtimeError.what ()); + ELEKTRA_SET_PARSING_ERROR (*parent, runtimeError.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught exception: %s", error.what ()); + ELEKTRA_SET_INSTALLATION_ERRORF (*parent, "Uncaught exception: %s", error.what ()); } parent.release (); diff --git a/src/plugins/zeromqsend/zeromqsend.c b/src/plugins/zeromqsend/zeromqsend.c index 014661d06fc..fae2f2a6924 100644 --- a/src/plugins/zeromqsend/zeromqsend.c +++ b/src/plugins/zeromqsend/zeromqsend.c @@ -113,14 +113,13 @@ int elektraZeroMqSendSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key break; case -1: // connection timeout - hub not running - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_TIMEOUT, parentKey, - "could not connect to hub. Please start hub using `kdb run-hub-zeromq`."); + ELEKTRA_ADD_TIMEOUT_WARNING (parentKey, "could not connect to hub. Please start hub using `kdb run-hub-zeromq`."); break; case -2: // subscription timeout - no applications are listening for notifications, can be ignored break; default: - ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, parentKey, "could not send notifications"); + ELEKTRA_ADD_INSTALLATION_WARNING (parentKey, "could not send notifications"); break; }