diff --git a/doc/tutorials/plugins.md b/doc/tutorials/plugins.md index 8990739d4fe..ca6131cb06c 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(RESOURCE_CODE, parentKey, keyString(parentKey)); + ELEKTRA_SET_ERROR(ELEKTRA_ERROR_RESOURCE, 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 (PARSING_CODE, errorKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 79a6409531a..532453039f7 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 (INSTALLATION_CODE, errorKey, "Could not create C++ plugin: %s", msg); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not create C++ plugin: %s", msg); #endif return -1; } diff --git a/src/error/exporterrors.cpp b/src/error/exporterrors.cpp index 267f69c6ab2..53eb15617de 100644 --- a/src/error/exporterrors.cpp +++ b/src/error/exporterrors.cpp @@ -102,7 +102,8 @@ static ostream & printKDBErrors (ostream & os, parse_t & p) continue; } - os << "#define " << p[i]["macro"] << " " << p[i]["number"] << "" << endl; + os << "#define ELEKTRA_WARNING_" << p[i]["macro"] << " " << p[i]["number"] << "" << endl; + os << "#define ELEKTRA_ERROR_" << p[i]["macro"] << " " << p[i]["number"] << "" << endl; } os << endl << endl; diff --git a/src/error/specification b/src/error/specification index ab82e6dca3a..d5aec9f4442 100644 --- a/src/error/specification +++ b/src/error/specification @@ -19,32 +19,32 @@ ignore:true number:01100 description:Resource -macro:RESOURCE_CODE +macro:RESOURCE number:01200 description:Parsing -macro:PARSING_CODE +macro:PARSING number:01300 description:Installation -macro:INSTALLATION_CODE +macro:INSTALLATION number:01400 description:Logical -macro:LOGICAL_CODE +macro:LOGICAL number:02000 description:Conflict -macro:CONFLICT_CODE +macro:CONFLICT number:03000 description:Timeout -macro:TIMEOUT_CODE +macro:TIMEOUT number:04100 description:Validation Syntactic -macro:VALIDATION_SYNTACTIC_CODE +macro:VALIDATION_SYNTACTIC number:04200 description:Validation Semantic -macro:VALIDATION_SEMANTIC_CODE +macro:VALIDATION_SEMANTIC diff --git a/src/include/kdbmacros.h b/src/include/kdbmacros.h index 36ea7740f75..92151739b80 100644 --- a/src/include/kdbmacros.h +++ b/src/include/kdbmacros.h @@ -37,12 +37,12 @@ do \ { \ if (errno == EACCES) \ - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, \ + 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)); \ else \ - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not open configuration file for reading. Reason: %s", \ + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open configuration file for reading. Reason: %s", \ strerror (errno)); \ } while (0) @@ -50,15 +50,15 @@ do \ { \ if (errno == EACCES) \ - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, \ + 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)); \ else \ - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, ":Could not open file for writing %s", strerror (errno)); \ + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, ":Could not open file for writing %s", strerror (errno)); \ } while (0) -#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_ERRORF (RESOURCE_CODE, key, "Unable to allocate %zu bytes.", size); +#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, key, "Unable to allocate %zu bytes.", size); /** * @brief Sets error 84 if info != returned @@ -80,7 +80,7 @@ Key * c = ksNext (info); \ if (!c) \ { \ - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, error, \ + 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)); \ ksDel (info); \ @@ -88,7 +88,7 @@ } \ if (strcmp (keyName (k), keyName (c)) || strcmp (keyString (k), keyString (c))) \ { \ - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, error, \ + 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)); \ @@ -98,7 +98,7 @@ } \ if ((k = ksNext (info)) != 0) \ { \ - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, error, \ + 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)); \ ksDel (info); \ diff --git a/src/libs/elektra/backend.c b/src/libs/elektra/backend.c index ce3cb32815c..ef6aa4b91b2 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 (INSTALLATION_CODE, errorKey, "Could not find mountpoint within root %s", keyName (root)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not find mountpoint within root %s", keyName (root)); return -1; } @@ -91,7 +91,7 @@ int elektraBackendSetMountpoint (Backend * backend, KeySet * elektraConfig, Key if (!backend->mountpoint) { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Could not create mountpoint with name %s and value %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not create mountpoint with name %s and value %s", keyString (foundMountpoint), keyBaseName (root)); return -1; } @@ -202,7 +202,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global errorKey) == -1) { if (!failure) - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "elektraProcessPlugins for error failed"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "elektraProcessPlugins for error failed"); failure = 1; } } @@ -212,7 +212,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global errorKey) == -1) { if (!failure) - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "elektraProcessPlugins for get failed"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "elektraProcessPlugins for get failed"); failure = 1; } } @@ -227,7 +227,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global errorKey) == -1) { if (!failure) - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "elektraProcessPlugins for set failed"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "elektraProcessPlugins for set failed"); failure = 1; } } @@ -235,7 +235,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global { // no one cares about that config if (!failure) - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Unrecognised Config Tree: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Unrecognised Config Tree: %s", keyBaseName (cur)); ksDel (cut); } diff --git a/src/libs/elektra/kdb.c b/src/libs/elektra/kdb.c index 03e6ac72e37..6e602d98e9f 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 (INSTALLATION_CODE, errorKey, "elektraModulesInit returned with -1"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "could not open default backend"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "could not open default backend"); keySetName (errorKey, keyName (initialParent)); keySetString (errorKey, keyString (initialParent)); @@ -295,7 +295,7 @@ KDB * kdbOpen (Key * errorKey) errno = errnosave; return 0; case 0: - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Initial kdbGet() failed, you should either fix " KDB_DB_INIT " or the fallback " KDB_DB_FILE); break; case 2: @@ -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 (INSTALLATION_CODE, errorKey, "Mounting global plugins failed"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Initial loading of trie did not work"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Initial loading of trie did not work"); } keySetString (errorKey, "kdbOpen(): mountDefault"); if (mountDefault (handle, handle->modules, inFallback, errorKey) == -1) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "could not reopen and mount default backend"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (LOGICAL_CODE, errorKey, "Mounting modules did not work"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_LOGICAL, errorKey, "Mounting modules did not work"); } keySetName (errorKey, keyName (initialParent)); @@ -433,7 +433,7 @@ int kdbClose (KDB * handle, Key * errorKey) } else { - ELEKTRA_ADD_WARNING (RESOURCE_CODE, errorKey, "Could not close modules: modules were not open"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, errorKey, "Could not close modules: modules were not open"); } if (handle->global) ksDel (handle->global); @@ -935,13 +935,13 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) { clearError (parentKey); keyDel (oldError); - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "metakey with name \"%s\" passed to kdbGet", keyName (parentKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "metakey with name \"%s\" passed to kdbGet", keyName (parentKey)); return -1; } if (ns == KEY_NS_EMPTY) { - ELEKTRA_ADD_WARNING (VALIDATION_SYNTACTIC_CODE, parentKey, "invalid key name passed to kdbGet"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "invalid key name passed to kdbGet"); } int errnosave = errno; @@ -965,14 +965,14 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) if (!handle || !ks) { clearError (parentKey); - ELEKTRA_SET_ERROR (LOGICAL_CODE, parentKey, "handle or ks null pointer passed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "handle or ks null pointer passed"); goto error; } if (splitBuildup (split, handle, parentKey) == -1) { clearError (parentKey); - ELEKTRA_SET_ERROR (INSTALLATION_CODE, parentKey, "error in splitBuildup"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "error in splitBuildup"); goto error; } @@ -1052,7 +1052,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) if (splitAppoint (split, handle, ks) == -1) { clearError (parentKey); - ELEKTRA_SET_ERROR (INSTALLATION_CODE, parentKey, "error in splitAppoint"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "error in splitAppoint"); goto error; } @@ -1075,7 +1075,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) if (splitGet (split, parentKey, handle) == -1) { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks))); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks))); // continue, because sizes are already updated } ksClear (ks); @@ -1110,7 +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 (INSTALLATION_CODE, parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks))); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks))); // continue, because sizes are already updated } @@ -1302,7 +1302,7 @@ static void elektraSetCommit (Split * split, Key * parentKey) if (ret == -1) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, "Error during commit. This means backend is broken: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, "Error during commit. This means backend is broken: %s", keyName (backend->mountpoint)); } } @@ -1334,7 +1334,7 @@ static void elektraSetRollback (Split * split, Key * parentKey) if (ret == -1) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, "Error during rollback. This means backend is broken: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, "Error during rollback. This means backend is broken: %s", keyName (backend->mountpoint)); } } @@ -1426,7 +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 (INSTALLATION_CODE, parentKey, "metakey with name \"%s\" passed to kdbSet", keyName (parentKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "metakey with name \"%s\" passed to kdbSet", keyName (parentKey)); keyDel (oldError); ELEKTRA_LOG ("ns == KEY_NS_META"); return -1; @@ -1441,7 +1441,7 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) if (!handle || !ks) { clearError (parentKey); // clear previous error to set new one - ELEKTRA_SET_ERROR (LOGICAL_CODE, parentKey, "handle or ks null pointer passed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "handle or ks null pointer passed"); keyDel (oldError); ELEKTRA_LOG ("!handle || !ks"); return -1; @@ -1464,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 (INSTALLATION_CODE, parentKey, "error in splitBuildup"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "error in splitBuildup"); goto error; } ELEKTRA_LOG ("after splitBuildup"); @@ -1474,7 +1474,7 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) if (syncstate == -1) { clearError (parentKey); // clear previous error to set new one - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "No default backend found, but should be. Keyname: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "No default backend found, but should be. Keyname: %s", keyName (ksCurrent (ks))); goto error; } @@ -1492,12 +1492,12 @@ 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 (LOGICAL_CODE, parentKey, "Assert failed: invalid namespace"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "Assert failed: invalid namespace"); ELEKTRA_LOG ("syncstate == -1"); } else if (syncstate < -1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + 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_LOG ("syncstate < -1"); @@ -1573,7 +1573,7 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) Key * found = ksLookup (ks, errorKey, 0); if (!found) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, "Error key %s not found in keyset even though it was found before", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, parentKey, "Error key %s not found in keyset even though it was found before", keyName (errorKey)); } } @@ -1945,7 +1945,7 @@ int kdbEnsure (KDB * handle, KeySet * contract, Key * parentKey) if (elektraStrCmp (pluginName, "list") == 0) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, parentKey, "Cannot specify clauses for the list plugin!!"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "Cannot specify clauses for the list plugin!!"); keyDel (cutpoint); ksDel (pluginsContract); return -1; @@ -1967,7 +1967,7 @@ int kdbEnsure (KDB * handle, KeySet * contract, Key * parentKey) else { ELEKTRA_SET_ERRORF ( - INSTALLATION_CODE, parentKey, + ELEKTRA_ERROR_INSTALLATION, parentKey, "The key '%s' contained the value '%s', but only 'unmounted', 'mounted' or 'remounted' may be used.", keyName (clause), pluginStateString); keyDel (cutpoint); @@ -2000,7 +2000,7 @@ int kdbEnsure (KDB * handle, KeySet * contract, Key * parentKey) { if (pluginState != PLUGIN_STATE_UNMOUNTED) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + 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); diff --git a/src/libs/elektra/mount.c b/src/libs/elektra/mount.c index dd9d98dd0d9..c8e73fe1cea 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 (INSTALLATION_CODE, errorKey, "could not create missing backend"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not create missing backend"); ret = -1; continue; } if (!backend->mountpoint) { - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "backend has no mount point"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "mounting of backend failed"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "could not (re)open default backend"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "could not (re)open init backend"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Could not load plugin %s in process plugin", pluginName); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "no root key found for modules"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "no root key found for modules"); return -1; } diff --git a/src/libs/elektra/plugin.c b/src/libs/elektra/plugin.c index 8ae39304255..52b2e1f5c26 100644 --- a/src/libs/elektra/plugin.c +++ b/src/libs/elektra/plugin.c @@ -57,19 +57,19 @@ int elektraProcessPlugin (Key * cur, int * pluginNumber, char ** pluginName, cha if (fullname[0] != '#') { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Names of Plugins must start with a #. Pluginname: %s", fullname); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Names of Plugins must start with a #. Pluginname: %s", fullname); return -1; } if (fullname[1] < '0' || fullname[1] > '9') { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Tried to set more plugins than defined in NR_OF_PLUGINS Pluginname: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Tried to set more plugins than defined in NR_OF_PLUGINS Pluginname: %s", fullname); return -1; } @@ -188,7 +188,7 @@ int elektraProcessPlugins (Plugin ** plugins, KeySet * modules, KeySet * referen plugins[pluginNumber] = elektraPluginOpen (pluginName, modules, pluginConfig, errorKey); if (!plugins[pluginNumber]) { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Could not load plugin %s in process plugin", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not load plugin %s in process plugin", pluginName); /* Loading plugin did not work */ elektraFree (pluginName); @@ -210,7 +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 (LOGICAL_CODE, errorKey, "Could not reference back to plugin %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_LOGICAL, 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 @@ -228,7 +228,7 @@ int elektraProcessPlugins (Plugin ** plugins, KeySet * modules, KeySet * referen } else { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Unknown additional entries in plugin: %s", keyString (cur)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Unknown additional entries in plugin: %s", keyString (cur)); } } @@ -254,7 +254,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config if (!name || name[0] == '\0') { - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "Not a valid name supplied for a plugin: name is null or empty"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Not a valid name supplied for a plugin: name is null or empty"); goto err_clup; } @@ -269,7 +269,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config if (*n == '\0') { - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "Not a valid name supplied for a plugin: name contained slashes only"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Not a valid name supplied for a plugin: name contained slashes only"); goto err_clup; } @@ -283,7 +283,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config handle = pluginFactory (); if (handle == 0) { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Could not call function exported by ELEKTRA_PLUGIN_EXPORT: %s", name); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not call function exported by ELEKTRA_PLUGIN_EXPORT: %s", name); goto err_clup; } @@ -298,7 +298,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config if ((handle->kdbOpen (handle, errorKey)) == -1) { ELEKTRA_ADD_WARNINGF ( - INSTALLATION_CODE, errorKey, + ELEKTRA_WARNING_INSTALLATION, errorKey, "Open of plugin returned unsuccessfully: %s. Reason contains plugin, see other warnings for details", name); elektraPluginClose (handle, errorKey); goto err_clup; @@ -328,7 +328,7 @@ int elektraPluginClose (Plugin * handle, Key * errorKey) if (handle->kdbClose) { rc = handle->kdbClose (handle, errorKey); - if (rc == -1) ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "kdbClose() failed"); + if (rc == -1) ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "kdbClose() failed"); } ksDel (handle->config); @@ -390,13 +390,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 (INSTALLATION_CODE, error, "Tried to get a key from a missing backend: %s", keyName (error)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, error, "Tried to set a key from a missing backend: %s", keyName (error)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 10fafe65904..be0aae1ee31 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 (INSTALLATION_CODE, warningKey, "Postcondition of backend was violated: %s", warningMsg); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningKey, "Postcondition of backend was violated: %s", warningMsg); elektraFree (warningMsg); cursor_t c = ksGetCursor (ks); keyDel (elektraKsPopAtCursor (ks, c)); diff --git a/src/libs/highlevel/elektra.c b/src/libs/highlevel/elektra.c index cc470519eed..03f193ccd22 100644 --- a/src/libs/highlevel/elektra.c +++ b/src/libs/highlevel/elektra.c @@ -13,6 +13,7 @@ #include "kdbhelper.h" #include "kdblogger.h" #include "kdbprivate.h" +#include "kdberrors.h" #include #ifdef __cplusplus @@ -270,7 +271,7 @@ void elektraSaveKey (Elektra * elektra, Key * key, ElektraError ** error) return; } - if (elektraKDBErrorCode (kdbSetError) != 5) // CONFLICT = 5 + if (elektraKDBErrorCode (kdbSetError) != ELEKTRA_ERROR_CONFLICT) { *error = kdbSetError; return; diff --git a/src/libs/loader/dl.c b/src/libs/loader/dl.c index 24db29185d4..e9c03dc6962 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 (INSTALLATION_CODE, errorKey, "of module: %s, because: %s", moduleName, dlerror ()); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "of module: %s, because: %s", moduleName, dlerror ()); keyDel (moduleKey); elektraFree (moduleName); return 0; @@ -95,7 +95,7 @@ elektraPluginFactory elektraModulesLoad (KeySet * modules, const char * name, Ke module.symbol.v = dlsym (module.handle, "elektraPluginSymbol"); if (module.symbol.v == NULL) { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not get pointer to factory, dlsym failed. Module: %s, because: %s", moduleName, dlerror ()); dlclose (module.handle); keyDel (moduleKey); @@ -119,7 +119,7 @@ int elektraModulesClose (KeySet * modules, Key * errorKey) if (!root) { - ELEKTRA_ADD_WARNING (RESOURCE_CODE, errorKey, "no key system/elektra/modules"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, errorKey, "no key system/elektra/modules"); return -1; } @@ -135,7 +135,7 @@ int elektraModulesClose (KeySet * modules, Key * errorKey) ksAppendKey (newModules, root); } ret = -1; - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, errorKey, "Could not close a module, dlclose failed: %s", dlerror ()); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, 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 fda99f3314f..0f639a65764 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 (INSTALLATION_CODE, error, "Did not find module: %s", name); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, error, "Did not find module: %s", name); keyDel (moduleKey); return 0; } @@ -87,7 +87,7 @@ elektraPluginFactory elektraModulesLoad (KeySet * modules, const char * name, Ke if (module == NULL) { - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, error, + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 fd086e24f1d..a124bc8c12f 100644 --- a/src/libs/opts/opts.c +++ b/src/libs/opts/opts.c @@ -322,7 +322,7 @@ bool processSpec (struct Specification * spec, KeySet * ks, Key * parentKey) { if (elektraStrCmp (keyBaseName (cur), "#") != 0) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "'args=remaining' can only be set on array keys (basename = '#'). Offending key: %s", keyName (cur)); keyDel (specParent); @@ -494,7 +494,7 @@ bool readOptionData (struct OptionData * optionData, Key * key, const char * met } else if (elektraStrCmp (hasArg, "none") != 0 && elektraStrCmp (hasArg, "optional") != 0) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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)); @@ -556,7 +556,7 @@ bool processShortOptSpec (struct Specification * spec, struct OptionData * optio if (shortOpt == '-') { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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)); @@ -565,7 +565,7 @@ bool processShortOptSpec (struct Specification * spec, struct OptionData * optio if (shortOpt == 'h') { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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)); @@ -579,7 +579,7 @@ bool processShortOptSpec (struct Specification * spec, struct OptionData * optio Key * existing = ksLookupByName (spec->options, keyName (shortOptSpec), 0); if (existing != NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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)); keyDel (shortOptSpec); @@ -649,7 +649,7 @@ bool processLongOptSpec (struct Specification * spec, struct OptionData * option if (elektraStrCmp (longOpt, "help") == 0) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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)); @@ -663,7 +663,7 @@ bool processLongOptSpec (struct Specification * spec, struct OptionData * option Key * existing = ksLookupByName (spec->options, keyName (longOptSpec), 0); if (existing != NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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)); keyDel (longOptSpec); @@ -792,7 +792,7 @@ int writeOptionValues (KeySet * ks, Key * keyWithOpt, KeySet * options, Key * er else if (res < 0) { ELEKTRA_SET_ERRORF ( - VALIDATION_SEMANTIC_CODE, errorKey, + ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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,7 +848,7 @@ int writeEnvVarValues (KeySet * ks, Key * keyWithOpt, KeySet * envValues, Key * int res = addProcKey (ks, keyWithOpt, envValueKey); if (res < 0) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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)); @@ -1122,7 +1122,7 @@ bool parseShortOptions (KeySet * optionsSpec, KeySet * options, int argc, const if (optSpec == NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "Unknown short option: -%c", keyBaseName (shortOpt)[0]); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Unknown short option: -%c", keyBaseName (shortOpt)[0]); keyDel (shortOpt); keyDel (optSpec); return false; @@ -1142,7 +1142,7 @@ bool parseShortOptions (KeySet * optionsSpec, KeySet * options, int argc, const } else if (!repeated) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "This option cannot be repeated: -%c", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "This option cannot be repeated: -%c", keyBaseName (shortOpt)[0]); keyDel (shortOpt); keyDel (optSpec); @@ -1157,7 +1157,7 @@ bool parseShortOptions (KeySet * optionsSpec, KeySet * options, int argc, const { if (i >= argc - 1) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "Missing argument for short option: -%c", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Missing argument for short option: -%c", keyBaseName (shortOpt)[0]); keyDel (shortOpt); keyDel (option); @@ -1216,7 +1216,7 @@ bool parseLongOption (KeySet * optionsSpec, KeySet * options, int argc, const ch if (optSpec == NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "Unknown long option: --%s", keyBaseName (longOpt)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Unknown long option: --%s", keyBaseName (longOpt)); keyDel (longOpt); return false; } @@ -1235,7 +1235,7 @@ bool parseLongOption (KeySet * optionsSpec, KeySet * options, int argc, const ch } else if (!repeated) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "This option cannot be repeated: --%s", keyBaseName (longOpt)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "This option cannot be repeated: --%s", keyBaseName (longOpt)); keyDel (longOpt); keyDel (optSpec); return false; @@ -1261,7 +1261,7 @@ bool parseLongOption (KeySet * optionsSpec, KeySet * options, int argc, const ch { if (i >= argc - 1) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "Missing argument for long option: --%s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Missing argument for long option: --%s", keyBaseName (longOpt)); keyDel (longOpt); return false; @@ -1288,7 +1288,7 @@ bool parseLongOption (KeySet * optionsSpec, KeySet * options, int argc, const ch { if (argStart > 0) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "This option cannot have an argument: --%s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 acceaf4da60..b69da2dbec2 100644 --- a/src/libs/pluginprocess/pluginprocess.c +++ b/src/libs/pluginprocess/pluginprocess.c @@ -199,7 +199,7 @@ void elektraPluginProcessStart (Plugin * handle, ElektraPluginProcess * pp) else { ELEKTRA_LOG_DEBUG ("Child: Unrecognized command %s", keyString (commandKey)); - ELEKTRA_SET_ERRORF (LOGICAL_CODE, key, "Received invalid command code or no KeySet: %s", keyString (commandKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, key, "Received invalid command code or no KeySet: %s", keyString (commandKey)); } errno = prevErrno; char * resultStr = longToStr (result); @@ -264,7 +264,7 @@ 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 (VALIDATION_SEMANTIC_CODE, key, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, key, "originalKeySet has to exist when calling GET SET and ERROR via pluginprocess; but it is NULL"); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -329,7 +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 (INSTALLATION_CODE, key, "Received invalid return code or no KeySet: %s", keyString (resultKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, key, "Received invalid return code or no KeySet: %s", keyString (resultKey)); lresult = ELEKTRA_PLUGIN_STATUS_ERROR; } else // Copy everything back into the actual keysets @@ -405,7 +405,7 @@ static int makePipe (ElektraPluginProcess * pp, Key * errorKey, const char * pip if ((ret = pipe (pipeRef))) { cleanupPluginData (pp, errorKey, 1); - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Failed to initialize %s, pipe () returned %d", pipeName, ret); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to initialize %s, pipe () returned %d", pipeName, ret); return 0; } return 1; @@ -476,7 +476,7 @@ ElektraPluginProcess * elektraPluginProcessInit (Key * errorKey) if (!pp->dump) { cleanupPluginData (pp, errorKey, 0); - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Failed to initialize the dump plugin"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to initialize the dump plugin"); return NULL; } @@ -496,7 +496,7 @@ ElektraPluginProcess * elektraPluginProcessInit (Key * errorKey) if (pp->pid < 0) { cleanupPluginData (pp, errorKey, 1); - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Failed to fork the plugin process, fork () returned %d", pp->pid); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 bc7bf7270f2..46980e24fa8 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -30,7 +30,7 @@ #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 (INSTALLATION_CODE, parentKey, getAugeasError (augeasHandle)) +#define ELEKTRA_SET_AUGEAS_ERROR(handle, parrentKey) ELEKTRA_SET_GENERAL_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, getAugeasError (augeasHandle)) struct KeyConversion { @@ -117,7 +117,7 @@ int elektraAugeasGenConf (KeySet * ks, Key * errorKey ELEKTRA_UNUSED) } else { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Could not glob %s", f); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Could not glob %s", f); retval = -1; } return retval; @@ -420,14 +420,14 @@ static int saveTree (augeas * augeasHandle, KeySet * ks, const char * lensPath, if (ret < 0) { /* report the augeas specific error */ - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, getAugeasError (augeasHandle)); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, getAugeasError (augeasHandle)); } return ret; memoryerror: elektraFree (keyArray); - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Unable to allocate memory while saving the augeas tree"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Unable to allocate memory while saving the augeas tree"); return -1; } @@ -444,11 +444,11 @@ int elektraAugeasOpen (Plugin * handle, Key * parentKey) if (ret >= 0) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Unable to allocate memory for a detailed augeas error message"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Unable to allocate memory for a detailed augeas error message"); return -1; } - ELEKTRA_SET_ERROR (INSTALLATION_CODE, parentKey, errormessage); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, errormessage); elektraFree (errormessage); return -1; } @@ -489,7 +489,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 (INSTALLATION_CODE, parentKey, keyName (parentKey)); + if (!lensPath) ELEKTRA_SET_GENERAL_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, keyName (parentKey)); FILE * fh = fopen (keyString (parentKey), "r"); @@ -506,7 +506,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (content == 0) { fclose (fh); - ELEKTRA_SET_ERRNO_ERROR (RESOURCE_CODE, parentKey); + ELEKTRA_SET_ERRNO_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey); } /* convert the string into an augeas tree */ @@ -531,7 +531,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (!conversionData) { fclose (fh); - ELEKTRA_SET_GENERAL_ERROR (INSTALLATION_CODE, parentKey, strerror (errno)); + ELEKTRA_SET_GENERAL_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, strerror (errno)); } conversionData->currentOrder = 0; @@ -566,7 +566,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) if (!lensPath) { - ELEKTRA_SET_GENERAL_ERROR (INSTALLATION_CODE, parentKey, keyName (parentKey)); + ELEKTRA_SET_GENERAL_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, keyName (parentKey)); } FILE * fh = fopen (keyValue (parentKey), "w+"); @@ -588,7 +588,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) if (content == 0) { fclose (fh); - ELEKTRA_SET_ERRNO_ERROR (RESOURCE_CODE, parentKey); + ELEKTRA_SET_ERRNO_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey); } /* convert the string into an augeas tree */ @@ -615,7 +615,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) ret = saveFile (augeasHandle, fh); fclose (fh); - if (ret < 0) ELEKTRA_SET_ERRNO_ERROR (RESOURCE_CODE, parentKey); + if (ret < 0) ELEKTRA_SET_ERRNO_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey); errno = errnosave; return 1; diff --git a/src/plugins/base64/base64.c b/src/plugins/base64/base64.c index e8f0b708887..64a8b542f62 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 (RESOURCE_CODE, parent, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (PARSING_CODE, parent, "Not Base64 encoded: %s", strVal); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parent, "Not Base64 encoded: %s", strVal); } else if (result == -2) { // Memory error - ELEKTRA_SET_ERROR (RESOURCE_CODE, parent, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parent, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parent, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parent, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parent, "Memory allocation failed"); return -1; } diff --git a/src/plugins/blockresolver/blockresolver.c b/src/plugins/blockresolver/blockresolver.c index 7c8b9679664..3e7aef790b4 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 (RESOURCE_CODE, parentKey, "Failed to stat file %s\n", data->realFile); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Couldn't open %s for reading", data->realFile); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (PARSING_CODE, parentKey, "Couldn't find end of block %s", data->identifier); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, parentKey, "Failed to extract block %s\n", data->identifier); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 (RESOURCE_CODE, parentKey, "Couldn't open %s for writing", data->tmpFile); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Failed to stat file %s\n", data->realFile); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to stat file %s\n", data->realFile); return -1; } if (buf.st_mtime > data->mtime) { - ELEKTRA_SET_ERRORF (CONFLICT_CODE, parentKey, "%s has been modified", data->realFile); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, 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 (RESOURCE_CODE, parentKey, "Couldn't open %s for writing", data->realFile); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open %s for writing", data->realFile); goto SET_CLEANUP; } fin = fopen (data->realFile, "r"); if (!fin) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Couldn't open %s for reading", data->realFile); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open %s for reading", data->realFile); goto SET_CLEANUP; } block = (char *) getBlock (fin, 0, data->startPos); if (!block) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "Failed to extract block before %s\n", data->identifier); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, parentKey, "Failed to extract block after %s\n", data->identifier); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 (RESOURCE_CODE, parentKey, "Couldn't open %s for reading", data->tmpFile); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 c8949c85eb9..373546e809d 100644 --- a/src/plugins/boolean/boolean.c +++ b/src/plugins/boolean/boolean.c @@ -135,7 +135,7 @@ static void normalize (Key * key, Key * parentKey, BoolData * data) case TRUE: if (data->invalid & WARNING) { - ELEKTRA_ADD_WARNINGF (VALIDATION_SEMANTIC_CODE, parentKey, + 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); } @@ -145,7 +145,7 @@ static void normalize (Key * key, Key * parentKey, BoolData * data) case FALSE: if (data->invalid & WARNING) { - ELEKTRA_ADD_WARNINGF (VALIDATION_SEMANTIC_CODE, parentKey, + 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); } @@ -343,7 +343,7 @@ int elektraBooleanSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA (keyGetMeta (key, "boolean/invalid"))) { keySetMeta (key, "boolean/invalid", 0); - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s is not a valid boolean value", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s is not a valid boolean value", keyString (originalValue)); retVal = -1; } diff --git a/src/plugins/cachefilter/cachefilter.c b/src/plugins/cachefilter/cachefilter.c index abeea614ac6..3c1a0f0f53c 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 (INSTALLATION_CODE, parentKey, "Cache was not initialized."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 43bd33a4ae2..069a90c7ad3 100644 --- a/src/plugins/camel/camel.c +++ b/src/plugins/camel/camel.c @@ -87,7 +87,7 @@ 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 (PARSING_CODE, data->parentKey, "General parse error: %s:%zu:%zu: " message, keyString (data->parentKey), \ + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, data->parentKey, "General parse error: %s:%zu:%zu: " message, keyString (data->parentKey), \ data->line, data->column, __VA_ARGS__); #define RET_NOK(function) \ diff --git a/src/plugins/conditionals/conditionals.c b/src/plugins/conditionals/conditionals.c index 0e85a4c7aae..bde6b829963 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 (RESOURCE_CODE, parentKey, "Out of memory"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Out of memory"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -244,7 +244,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp { if (!keyGetMeta (parentKey, "error")) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Key %s not found but is required for the evaluation of %s", lookupName, condition); } @@ -253,7 +253,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp } if (elektraRealloc ((void **) &compareTo, keyGetValueSize (key)) < 0) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Out of memory"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Out of memory"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -292,7 +292,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp { if (!keyGetMeta (parentKey, "error")) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Key %s not found but is required for the evaluation of %s", lookupName, condition); } result = FALSE; @@ -500,7 +500,7 @@ static const char * isAssign (Key * key, char * expr, Key * parentKey, KeySet * { if (lastPtr <= firstPtr) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", expr); return NULL; } @@ -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 (VALIDATION_SEMANTIC_CODE, parentKey, "Key %s not found", keyName (lookupKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Key %s not found", keyName (lookupKey)); keyDel (lookupKey); return NULL; } @@ -538,14 +538,14 @@ 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 (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, 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 (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", expr); return NULL; } @@ -564,7 +564,7 @@ static CondResult parseCondition (Key * key, const char * condition, const Key * if ((regcomp (®ex, regexString, REG_EXTENDED | REG_NEWLINE))) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory @@ -619,7 +619,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList CondResult ret; if ((ret = regcomp (®ex1, regexString1, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory @@ -628,7 +628,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if ((ret = regcomp (®ex2, regexString2, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory @@ -638,7 +638,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if ((ret = regcomp (®ex3, regexString3, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory @@ -652,7 +652,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList int nomatch = regexec (®ex1, conditionString, subMatches, m, 0); if (nomatch) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); regfree (®ex2); @@ -662,7 +662,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if (m[1].rm_so == -1) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); regfree (®ex2); @@ -680,7 +680,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList nomatch = regexec (®ex2, conditionString, subMatches, m, 0); if (nomatch) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); regfree (®ex2); @@ -690,7 +690,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if (m[1].rm_so == -1) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); regfree (®ex2); @@ -710,7 +710,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList { if (m[1].rm_so == -1) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", conditionString); regfree (®ex1); @@ -750,12 +750,12 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList ret = parseCondition (key, thenexpr, suffixList, ks, parentKey); if (ret == FALSE) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Validation of Key %s: %s failed. (%s failed)", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Validation of Key %s: %s failed. (%s failed)", keyName (key) + strlen (keyName (parentKey)) + 1, conditionString, thenexpr); } else if (ret == ERROR) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", thenexpr); } @@ -786,14 +786,14 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList if (ret == FALSE) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Validation of Key %s: %s failed. (%s failed)", keyName (key) + strlen (keyName (parentKey)) + 1, conditionString, elseexpr); } else if (ret == ERROR) { ELEKTRA_SET_ERRORF ( - VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", elseexpr); } } @@ -805,7 +805,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } else if (ret == ERROR) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Invalid syntax: \"%s\". Check kdb info conditionals for additional information", condition); } diff --git a/src/plugins/cpptemplate/cpptemplate.cpp b/src/plugins/cpptemplate/cpptemplate.cpp index 1016c518ee9..1ffbcba38b7 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 (INSTALLATION_CODE, key, "Uncaught Exception: %s", error.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, key, "Uncaught Exception: %s", error.what ()); } return status; diff --git a/src/plugins/cpptype/cpptype.cpp b/src/plugins/cpptype/cpptype.cpp index 77f3801b86a..e93ea09ee92 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 (VALIDATION_SEMANTIC_CODE, errorKey, msg.c_str ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, msg.c_str ()); } extern "C" { diff --git a/src/plugins/crypto/botan_operations.cpp b/src/plugins/crypto/botan_operations.cpp index 8ab9d0f68d3..a36fd80560c 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 (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); @@ -89,7 +89,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Failed to create a cryptographic key for encryption because: %s", e.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create a cryptographic key for encryption because: %s", e.what ()); return -1; } } @@ -139,7 +139,7 @@ static int getKeyIvForDecryption (KeySet * config, Key * errorKey, Key * masterK } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Failed to restore the cryptographic key for decryption because: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to restore the cryptographic key for decryption because: %s", e.what ()); return -1; } @@ -153,7 +153,7 @@ int elektraCryptoBotanInit (Key * errorKey) } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Botan initialization failed: %s", e.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Botan initialization failed: %s", e.what ()); return -1; // failure } return 1; // success @@ -237,7 +237,7 @@ int elektraCryptoBotanEncrypt (KeySet * pluginConfig, Key * k, Key * errorKey, K } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Encryption failed because: %s", e.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Encryption failed because: %s", e.what ()); elektraFree (salt); return -1; // failure } @@ -309,7 +309,7 @@ int elektraCryptoBotanDecrypt (KeySet * pluginConfig, Key * k, Key * errorKey, K } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Decryption failed because: %s", e.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Decryption failed because: %s", e.what ()); return -1; // failure } @@ -339,7 +339,7 @@ char * elektraCryptoBotanCreateRandomString (Key * errorKey, const kdb_unsigned_ } catch (std::exception const & e) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Failed to generate random string because: %s", e.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, 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 b2a91a69221..c76c30b4c5b 100644 --- a/src/plugins/crypto/crypto.c +++ b/src/plugins/crypto/crypto.c @@ -79,7 +79,7 @@ static int checkPayloadVersion (Key * k, Key * errorKey) { if (keyGetValueSize (k) < ((ssize_t) ELEKTRA_CRYPTO_MAGIC_NUMBER_LEN)) { - ELEKTRA_SET_ERRORF (PARSING_CODE, errorKey, + 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)); @@ -90,7 +90,7 @@ 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 (PARSING_CODE, errorKey, + 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)); @@ -102,7 +102,7 @@ static int checkPayloadVersion (Key * k, Key * errorKey) if (memcmp (&value[versionOffset], ELEKTRA_CRYPTO_PAYLOAD_VERSION, 2)) { ELEKTRA_SET_ERRORF ( - PARSING_CODE, errorKey, + ELEKTRA_ERROR_PARSING, errorKey, "The version of the cryptographic payload is not compatible with the version of the plugin. Keyname: %s", keyName (k)); return 0; // failure @@ -156,7 +156,7 @@ static kdb_unsigned_short_t elektraCryptoGetRandomPasswordLength (Key * errorKey } else { - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Master password length provided at " ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD_LEN " is invalid. Using default value instead."); } diff --git a/src/plugins/crypto/gcrypt_operations.c b/src/plugins/crypto/gcrypt_operations.c index 65e38ea12c6..de3d343b2bd 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 (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); @@ -71,7 +71,7 @@ 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 (LOGICAL_CODE, errorKey, "Failed to create a cryptographic key for encryption because: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create a cryptographic key for encryption because: %s", gcry_strerror (gcry_err)); return -1; } @@ -114,7 +114,7 @@ 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 (LOGICAL_CODE, errorKey, "Failed to restore the cryptographic key for decryption because: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to restore the cryptographic key for decryption because: %s", gcry_strerror (gcry_err)); return -1; } @@ -148,7 +148,7 @@ int elektraCryptoGcryInit (Key * errorKey) // initialize the rest of the gcrypt library if (!gcry_check_version (GCRYPT_VERSION)) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Libgcrypt version check failed, looking for version: %s", GCRYPT_VERSION); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Libgcrypt version check failed, looking for version: %s", GCRYPT_VERSION); return -1; } gcry_control (GCRYCTL_DISABLE_SECMEM, 0); @@ -205,7 +205,7 @@ int elektraCryptoGcryHandleCreate (elektraCryptoHandle ** handle, KeySet * confi memset (ivBuffer, 0, sizeof (ivBuffer)); keyDel (key); keyDel (iv); - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } @@ -233,7 +233,7 @@ int elektraCryptoGcryHandleCreate (elektraCryptoHandle ** handle, KeySet * confi error: memset (keyBuffer, 0, sizeof (keyBuffer)); memset (ivBuffer, 0, sizeof (ivBuffer)); - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Failed to create handle because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create handle because: %s", gcry_strerror (gcry_err)); gcry_cipher_close (**handle); elektraFree (*handle); (*handle) = NULL; @@ -293,7 +293,7 @@ int elektraCryptoGcryEncrypt (elektraCryptoHandle * handle, Key * k, Key * error kdb_octet_t * output = elektraMalloc (outputLen); if (!output) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); elektraFree (salt); return -1; } @@ -316,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 (INSTALLATION_CODE, errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); memset (output, 0, outputLen); elektraFree (output); elektraFree (salt); @@ -331,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 (INSTALLATION_CODE, errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); memset (output, 0, outputLen); elektraFree (output); elektraFree (salt); @@ -365,7 +365,7 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error // plausibility check if (payloadLen % ELEKTRA_CRYPTO_GCRY_BLOCKSIZE != 0) { - ELEKTRA_SET_ERROR (LOGICAL_CODE, errorKey, "value length is not a multiple of the block size"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "value length is not a multiple of the block size"); return -1; } @@ -373,7 +373,7 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error kdb_octet_t * output = elektraMalloc (payloadLen); if (!output) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } @@ -386,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 (LOGICAL_CODE, errorKey, "Decryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Decryption failed because: %s", gcry_strerror (gcry_err)); memset (output, 0, payloadLen); elektraFree (output); return -1; @@ -403,7 +403,7 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error if (contentLen > dataLen) { ELEKTRA_SET_ERROR ( - PARSING_CODE, errorKey, + ELEKTRA_ERROR_PARSING, errorKey, "restored content length is bigger than the available amount of decrypted data. The header is possibly corrupted."); memset (output, 0, payloadLen); elektraFree (output); @@ -446,7 +446,7 @@ char * elektraCryptoGcryCreateRandomString (Key * errorKey, const kdb_unsigned_s } if (!encoded) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); } return encoded; } diff --git a/src/plugins/crypto/gpg.c b/src/plugins/crypto/gpg.c index 46bcaeba008..b87666231d6 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 (RESOURCE_CODE, errorKey, "gpg binary %s not found", file); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, errorKey, "gpg binary %s has no permission to execute", file); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } return 1; @@ -249,14 +249,14 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgGetBinary) (char ** gpgBin, KeySet * conf, Key * *gpgBin = elektraStrDup (ELEKTRA_CRYPTO_DEFAULT_GPG1_BIN); if (!(*gpgBin)) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } return 1; } // no GPG for us :-( - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "no gpg binary found. Please make sure GnuPG is installed and executable."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "no gpg binary found. Please make sure GnuPG is installed and executable."); return -1; } @@ -447,7 +447,7 @@ static int verifyGpgKeysInConf (Key * root, KeySet * conf, Key * errorKey) { if (isValidGpgKey (conf, rootValue) != 1) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, GPG_ERROR_INVALID_KEY, rootValue); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, GPG_ERROR_INVALID_KEY, rootValue); return -1; // failure } } @@ -462,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 (VALIDATION_SEMANTIC_CODE, errorKey, GPG_ERROR_INVALID_KEY, childValue); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, GPG_ERROR_INVALID_KEY, childValue); return -1; // failure } } @@ -619,14 +619,14 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK // initialize pipes if (pipe (pipe_stdin)) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Pipe initialization failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Pipe initialization failed"); elektraFree (argv[0]); return -1; } if (pipe (pipe_stdout)) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Pipe initialization failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Pipe initialization failed"); closePipe (pipe_stdin); elektraFree (argv[0]); return -1; @@ -634,7 +634,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK if (pipe (pipe_stderr)) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Pipe initialization failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Pipe initialization failed"); closePipe (pipe_stdin); closePipe (pipe_stdout); elektraFree (argv[0]); @@ -645,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 (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); @@ -658,7 +658,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK { case -1: // fork() failed - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "fork failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "fork failed"); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); @@ -718,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 (INSTALLATION_CODE, errorKey, "The communication with the GPG process failed."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "The communication with the GPG process failed."); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); @@ -748,23 +748,23 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK case 1: // bad signature - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "GPG reported a bad signature"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "GPG reported a bad signature"); break; case GPG_CALL_DUP_STDIN: - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "failed to redirect stdin."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "failed to redirect stdin."); break; case GPG_CALL_DUP_STDOUT: - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "failed to redirect stdout."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "failed to redirect stdout."); break; case GPG_CALL_DUP_STDERR: - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "failed to redirect stderr."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "failed to redirect stderr."); break; case GPG_CALL_EXECV: - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "failed to start the gpg binary: %s", argv[0]); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "failed to start the gpg binary: %s", argv[0]); break; default: @@ -774,7 +774,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK { errorBuffer[0] = '\0'; } - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "GPG failed with return value %d. %s", status, errorBuffer); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 02781849ae9..cf093e3c373 100644 --- a/src/plugins/crypto/helper.c +++ b/src/plugins/crypto/helper.c @@ -112,19 +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 (LOGICAL_CODE, errorKey, "missing salt as metakey %s in key %s", ELEKTRA_CRYPTO_META_SALT, keyName (k)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, 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 (LOGICAL_CODE, errorKey, "Salt was not stored Base64 encoded."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "Salt was not stored Base64 encoded."); return -1; } else if (result == -2) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } else if (result < -2) @@ -154,7 +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 (LOGICAL_CODE, errorKey, "payload is too small to contain a salt (payload length is: %zu)", payloadLen); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "payload is too small to contain a salt (payload length is: %zu)", payloadLen); if (salt) *salt = NULL; return -1; } @@ -170,7 +170,7 @@ int ELEKTRA_PLUGIN_FUNCTION (getSaltFromPayload) (Key * errorKey, Key * k, kdb_o // validate restored salt length if (restoredSaltLen < 1 || restoredSaltLen > (payloadLen - headerLen)) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "restored salt has invalid length of %u (payload length is: %zu)", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "restored salt has invalid length of %u (payload length is: %zu)", restoredSaltLen, payloadLen); if (salt) *salt = NULL; return -1; @@ -193,7 +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 (LOGICAL_CODE, errorKey, "missing %s in plugin configuration", ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "missing %s in plugin configuration", ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD); return NULL; } Key * msg = keyDup (master); @@ -223,7 +223,7 @@ kdb_unsigned_long_t ELEKTRA_PLUGIN_FUNCTION (getIterationCount) (Key * errorKey, } else { - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "iteration count provided at " ELEKTRA_CRYPTO_PARAM_ITERATION_COUNT " is invalid. Using default value instead."); } diff --git a/src/plugins/crypto/openssl_operations.c b/src/plugins/crypto/openssl_operations.c index 4ecc4955ec6..1f36b9eaa4c 100644 --- a/src/plugins/crypto/openssl_operations.c +++ b/src/plugins/crypto/openssl_operations.c @@ -60,7 +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 (LOGICAL_CODE, errorKey, "failed to generate random salt with error code %lu", ERR_get_error ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "failed to generate random salt with error code %lu", ERR_get_error ()); pthread_mutex_unlock (&mutex_ssl); return -1; } @@ -73,7 +73,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } if (!saltHexString) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); @@ -87,7 +87,7 @@ 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 (LOGICAL_CODE, errorKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create a cryptographic key for encryption. Libcrypto returned error code: %lu", ERR_get_error ()); pthread_mutex_unlock (&mutex_ssl); @@ -133,7 +133,7 @@ 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 (LOGICAL_CODE, errorKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to restore the cryptographic key for decryption. Libcrypto returned the error code: %lu", ERR_get_error ()); pthread_mutex_unlock (&mutex_ssl); @@ -199,7 +199,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { keyDel (key); keyDel (iv); - ELEKTRA_SET_ERROR (LOGICAL_CODE, errorKey, "Failed to create handle! Invalid key length."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create handle! Invalid key length."); return -1; } @@ -207,7 +207,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { keyDel (key); keyDel (iv); - ELEKTRA_SET_ERROR (LOGICAL_CODE, errorKey, "Failed to create handle! Invalid IV length."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create handle! Invalid IV length."); return -1; } @@ -222,7 +222,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { memset (keyBuffer, 0, sizeof (keyBuffer)); memset (ivBuffer, 0, sizeof (ivBuffer)); - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); return -1; } @@ -239,7 +239,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co if (ERR_peek_error ()) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Failed to create handle! libcrypto error code was: %lu", ERR_get_error ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to create handle! libcrypto error code was: %lu", ERR_get_error ()); elektraFree (*handle); *handle = NULL; pthread_mutex_unlock (&mutex_ssl); @@ -306,7 +306,7 @@ int elektraCryptoOpenSSLEncrypt (elektraCryptoHandle * handle, Key * k, Key * er encrypted = BIO_new (BIO_s_mem ()); if (!encrypted) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); pthread_mutex_unlock (&mutex_ssl); elektraFree (salt); return -1; @@ -387,7 +387,7 @@ int elektraCryptoOpenSSLEncrypt (elektraCryptoHandle * handle, Key * k, Key * er return 1; error: - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Encryption error! libcrypto error code was: %lu", ERR_get_error ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Encryption error! libcrypto error code was: %lu", ERR_get_error ()); BIO_free_all (encrypted); pthread_mutex_unlock (&mutex_ssl); elektraFree (salt); @@ -422,7 +422,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er // plausibility check if (payloadLen % ELEKTRA_CRYPTO_SSL_BLOCKSIZE != 0) { - ELEKTRA_SET_ERROR (PARSING_CODE, errorKey, "value length is not a multiple of the block size"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, "value length is not a multiple of the block size"); return -1; } @@ -432,7 +432,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er BIO * decrypted = BIO_new (BIO_s_mem ()); if (!decrypted) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); pthread_mutex_unlock (&mutex_ssl); return -1; } @@ -466,7 +466,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er plaintextLen = BIO_get_mem_data (decrypted, &plaintext); if (plaintextLen < headerLen) { - ELEKTRA_SET_ERROR (PARSING_CODE, errorKey, "Decryption error! header data is incomplete."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, "Decryption error! header data is incomplete."); goto error; } @@ -479,7 +479,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er // validate restored header if (contentLen > (plaintextLen - headerLen)) { - ELEKTRA_SET_ERROR (PARSING_CODE, errorKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, "Content length is bigger than amount of decrypted data. Data is possibly corrupted."); goto error; } @@ -503,7 +503,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er return 1; error: - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Decryption error! libcrypto error code was: %lu", ERR_get_error ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Decryption error! libcrypto error code was: %lu", ERR_get_error ()); BIO_free_all (decrypted); pthread_mutex_unlock (&mutex_ssl); return -1; @@ -522,7 +522,7 @@ char * elektraCryptoOpenSSLCreateRandomString (Key * errorKey, const kdb_unsigne pthread_mutex_lock (&mutex_ssl); if (!RAND_bytes (buffer, length)) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Failed to generate random string. libcrypto error code was: %lu", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to generate random string. libcrypto error code was: %lu", ERR_get_error ()); pthread_mutex_unlock (&mutex_ssl); return NULL; @@ -535,7 +535,7 @@ char * elektraCryptoOpenSSLCreateRandomString (Key * errorKey, const kdb_unsigne } if (!encoded) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); } return encoded; } diff --git a/src/plugins/csvstorage/csvstorage.c b/src/plugins/csvstorage/csvstorage.c index 83dfcc109e8..72f84d621d8 100644 --- a/src/plugins/csvstorage/csvstorage.c +++ b/src/plugins/csvstorage/csvstorage.c @@ -136,7 +136,7 @@ static char * parseLine (char * origLine, char delim, unsigned long offset, Key isCol = 0; if (!lastLine) { - ELEKTRA_ADD_WARNINGF (PARSING_CODE, parentKey, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, "Unexpected end of line(%lu), all records except the last must and with a newline", lineNr); } @@ -149,7 +149,7 @@ static char * parseLine (char * origLine, char delim, unsigned long offset, Key { line[len - 2] = '\0'; } - ELEKTRA_ADD_WARNINGF (PARSING_CODE, parentKey, "Unexpected end of line(%lu). unbalanced number of double-quotes in (%s)", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, 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 (PARSING_CODE, parentKey, "Unexpected end of line(%lu): (%s)", lineNr, line); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, "Unexpected end of line(%lu): (%s)", lineNr, line); } else { @@ -166,7 +166,7 @@ static char * parseLine (char * origLine, char delim, unsigned long offset, Key } if (hasUnescapedDQuote) { - ELEKTRA_ADD_WARNINGF (PARSING_CODE, parentKey, "Quoted field in line(%lu) has an unescaped double-quote: (%s)", lineNr, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, "Quoted field in line(%lu) has an unescaped double-quote: (%s)", lineNr, line); } @@ -335,7 +335,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP FILE * fp = fopen (fileName, "rb"); if (!fp) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "couldn't open file %s", fileName); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "couldn't open file %s", fileName); return -1; } int lastLine = 0; @@ -352,7 +352,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP { if (columns != fixColumnCount) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "illegal number of columns (%lu - %lu) in Header line: %s", columns, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "illegal number of columns (%lu - %lu) in Header line: %s", columns, fixColumnCount, lineBuffer); elektraFree (lineBuffer); fclose (fp); @@ -480,7 +480,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP { if (fixColumnCount) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "illegal number of columns (%lu - %lu) in line %lu: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "illegal number of columns (%lu - %lu) in line %lu: %s", colCounter, columns, lineCounter, lineBuffer); elektraFree (lineBuffer); fclose (fp); @@ -488,7 +488,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP ksDel (header); return -1; } - ELEKTRA_ADD_WARNINGF (PARSING_CODE, parentKey, "illegal number of columns (%lu - %lu) in line %lu: %s", colCounter, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_PARSING, parentKey, "illegal number of columns (%lu - %lu) in line %lu: %s", colCounter, columns, lineCounter, lineBuffer); } lineCounter += linesRead; @@ -720,7 +720,7 @@ static int csvWrite (KeySet * returned, Key * parentKey, KeySet * exportKS, Key } if (colCounter != columns) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "illegal number of columns (%lu - %lu) in line %lu", colCounter, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 66e6d7478b5..a2d22494481 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 (RESOURCE_CODE, errorKey, "No password specified for SSH password authentication"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Failed to open %s for reading", data->path); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open %s for reading", data->path); return -1; } FILE * fp = fetchFile (data, fd); @@ -632,13 +632,13 @@ int elektraCurlgetGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA fp = fopen (data->path, "rb"); if (fp && data->useLocalCopy) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to fetch configuration from %s, falling back to local copy %s\n", data->getUrl, data->path); } else { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Failed to read configuration\n"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to read configuration\n"); return -1; } } @@ -722,7 +722,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 (CONFLICT_CODE, parentKey, "remote file has changed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, "remote file has changed"); retval = -1; } elektraFree (hash); @@ -733,7 +733,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA else { close (fd); - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to fetch configuration from %s. Aborting because consistency can't be ensured", data->getUrl); if (data->tmpFile) unlink (data->tmpFile); @@ -763,7 +763,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA fp = fopen (tmpFile, "rb"); if (!fp) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Failed to open %s for reading", tmpFile); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open %s for reading", tmpFile); return -1; } fseek (fp, 0L, SEEK_END); @@ -817,7 +817,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "curl upload (HTTP POST) failed: %s\n", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (HTTP POST) failed: %s\n", curl_easy_strerror (res)); retval = -1; } @@ -833,7 +833,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "curl upload (HTTP PUT) failed: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (HTTP PUT) failed: %s", curl_easy_strerror (res)); retval = -1; } @@ -846,7 +846,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "curl upload (HTTP PUT) failed: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (HTTP PUT) failed: %s", curl_easy_strerror (res)); retval = -1; } @@ -883,7 +883,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "curl upload (FTP PUT) failed: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (FTP PUT) failed: %s", curl_easy_strerror (res)); retval = -1; } @@ -909,10 +909,10 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA if (res != CURLE_OK) { if (data->putProto == PROTO_SCP) - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "curl upload (SCP) failed: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (SCP) failed: %s", curl_easy_strerror (res)); else if (data->putProto == PROTO_SFTP) - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "curl upload (SFTP) failed: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "curl upload (SFTP) failed: %s", curl_easy_strerror (res)); retval = -1; } @@ -929,7 +929,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "curl upload (default) failed: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 75d5e9cc34c..1272d83d35f 100644 --- a/src/plugins/date/date.c +++ b/src/plugins/date/date.c @@ -411,7 +411,7 @@ static int validateKey (Key * key, Key * parentKey) rc = formatStringValidation (date, formatString); if (rc == -1) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s doesn't match format string %s", date, formatString); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s doesn't match format string %s", date, formatString); rc = 0; } } @@ -421,15 +421,15 @@ static int validateKey (Key * key, Key * parentKey) if (rc == -1) { if (formatString) - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s doesn't match iso specification %s", date, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s doesn't match iso specification %s", date, formatString); else - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s is not a valid ISO8601 date", date); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s is not a valid ISO8601 date", date); rc = 0; } else if (rc == 0) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "syntax error in ISO8601 format string '%s'", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "syntax error in ISO8601 format string '%s'", formatString); } } @@ -438,7 +438,7 @@ static int validateKey (Key * key, Key * parentKey) rc = rfc2822StringValidation (date); if (rc == -1) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s doesn't match rfc2822 specification", date); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s doesn't match rfc2822 specification", date); rc = 0; } } @@ -447,7 +447,7 @@ static int validateKey (Key * key, Key * parentKey) rc = rfc822StringValidation (date); if (rc == -1) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s doesn't match format string %s", date, formatString); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 c75f9ba82ef..240f92b35cc 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 (INSTALLATION_CODE, *parent, "Unable to insert array value %s", error.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Unable to insert array value %s", error.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, *parent, "Uncaught Exception: %s", error.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *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 (INSTALLATION_CODE, *parent, "Unable to insert array value %s", error.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Unable to insert array value %s", error.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, *parent, "Uncaught exception: %s", error.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught exception: %s", error.what ()); } parent.release (); diff --git a/src/plugins/doc/doc.c b/src/plugins/doc/doc.c index 8b65b5f5703..d73142c16d3 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 (PARSING_CODE, parentKey, "not at the end of file"); +ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "not at the end of file"); //! [plugin errors usage] */ @@ -127,7 +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 (VALIDATION_SYNTACTIC_CODE, parentKey, "Key name %s is not valid, discarding key", key); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "Key name %s is not valid, discarding key", key); keyDel (read); continue; } @@ -139,7 +139,7 @@ int elektraDocGet (Plugin * plugin ELEKTRA_UNUSED, KeySet * returned, Key * pare if (feof (fp) == 0) { fclose (fp); - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, "Invalid line encountered: not at the end of file"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 9bea6b1a908..fd99f293918 100644 --- a/src/plugins/dump/dump.cpp +++ b/src/plugins/dump/dump.cpp @@ -115,7 +115,7 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks) ss >> version; if (version != "1") { - ELEKTRA_SET_ERRORF (PARSING_CODE, errorKey, "Wrong version detected in dumpfile: %s", version.c_str ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey, "Wrong version detected in dumpfile: %s", version.c_str ()); return -1; } } @@ -188,7 +188,7 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks) } else { - ELEKTRA_SET_ERRORF (PARSING_CODE, errorKey, "Wrong version detected in dumpfile: %s", command.c_str ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 61e4a6bb9d8..ca4b0fe0688 100644 --- a/src/plugins/enum/enum.c +++ b/src/plugins/enum/enum.c @@ -215,7 +215,7 @@ static int validateKey (Key * key, Key * parentKey) rc = validateWithArray (key); if (!rc) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Validation of key \"%s\" with string \"%s\" failed.", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 ac84e40a4e1..4111ec66b8b 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 (RESOURCE_CODE, errorKey, "Failed to retrieve the file status of the temporary file."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, errorKey, "Failed to overwrite the temporary file."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Failed to overwrite the temporary file."); return -1; } @@ -226,7 +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 (RESOURCE_CODE, parentKey, "Renaming file %s to %s failed.", tmpFile, keyString (parentKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Renaming file %s to %s failed.", tmpFile, keyString (parentKey)); result = -1; } } @@ -244,7 +244,7 @@ static int fcryptGpgCallAndCleanup (Key * parentKey, KeySet * pluginConfig, char shredTemporaryFile (tmpFileFd, parentKey); if (unlink (tmpFile)) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, + 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)); @@ -253,11 +253,11 @@ static int fcryptGpgCallAndCleanup (Key * parentKey, KeySet * pluginConfig, char if (parentKeyFd >= 0 && close (parentKeyFd)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } if (close (tmpFileFd)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } elektraFree (tmpFile); return result; @@ -279,7 +279,7 @@ static int fcryptEncrypt (KeySet * pluginConfig, Key * parentKey) if (recipientCount == 0 && signatureCount == 0) { ELEKTRA_SET_ERRORF ( - INSTALLATION_CODE, parentKey, + ELEKTRA_ERROR_INSTALLATION, 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; @@ -289,7 +289,7 @@ static int fcryptEncrypt (KeySet * pluginConfig, Key * parentKey) char * tmpFile = getTemporaryFileName (pluginConfig, keyString (parentKey), &tmpFileFd); if (!tmpFile) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Memory allocation failed"); return -1; } @@ -428,7 +428,7 @@ static int fcryptDecrypt (KeySet * pluginConfig, Key * parentKey, fcryptState * char * tmpFile = getTemporaryFileName (pluginConfig, keyString (parentKey), &tmpFileFd); if (!tmpFile) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Memory allocation failed"); return -1; } @@ -482,14 +482,14 @@ static int fcryptDecrypt (KeySet * pluginConfig, Key * parentKey, fcryptState * shredTemporaryFile (tmpFileFd, parentKey); if (unlink (tmpFile)) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, + 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)); } if (close (tmpFileFd)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } elektraFree (tmpFile); } @@ -506,7 +506,7 @@ int ELEKTRA_PLUGIN_FUNCTION (open) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, fcryptState * s = elektraMalloc (sizeof (fcryptState)); if (!s) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Memory allocation failed"); return -1; } @@ -531,7 +531,7 @@ int ELEKTRA_PLUGIN_FUNCTION (close) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED { if (s->tmpFileFd > 0 && close (s->tmpFileFd)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } if (s->tmpFilePath) { @@ -570,7 +570,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, fcryptState * s = (fcryptState *) elektraPluginGetData (handle); if (!s) { - ELEKTRA_SET_ERROR (LOGICAL_CODE, parentKey, "No plugin state is available."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "No plugin state is available."); return -1; } @@ -583,7 +583,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, } else { - ELEKTRA_SET_ERROR (LOGICAL_CODE, parentKey, "The path to the original file is lost."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, parentKey, "The path to the original file is lost."); // clean-up is performed by kdb close return -1; } @@ -593,12 +593,12 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, shredTemporaryFile (s->tmpFileFd, parentKey); if (close (s->tmpFileFd)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } s->tmpFileFd = -1; if (unlink (s->tmpFilePath)) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, + 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)); @@ -632,21 +632,21 @@ int ELEKTRA_PLUGIN_FUNCTION (set) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, int fd = open (configFile, O_RDWR); if (fd == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not open config file %s because %s", configFile, strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open config file %s because %s", configFile, strerror (errno)); return -1; } if (fsync (fd) == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not fsync config file %s because %s", configFile, strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not fsync config file %s because %s", configFile, strerror (errno)); if (close (fd)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } return -1; } if (close (fd)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to close a file descriptor: %s", strerror (errno)); } return 1; } @@ -666,7 +666,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 (INSTALLATION_CODE, errorKey, errorDescription); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, errorDescription); elektraFree (errorDescription); return -1; } diff --git a/src/plugins/file/file.c b/src/plugins/file/file.c index 2d087efe028..1c80dadcce9 100644 --- a/src/plugins/file/file.c +++ b/src/plugins/file/file.c @@ -48,7 +48,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN struct stat sb; if (stat (fileName, &sb) == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "failed to stat file %s, aborting. Reason: %s", fileName, strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "failed to stat file %s, aborting. Reason: %s", fileName, strerror (errno)); return -1; } @@ -62,7 +62,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN if (!buffer) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "failed to allocate buffer of %lld bytes for %s", fileSize, fileName); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "failed to allocate buffer of %lld bytes for %s", fileSize, fileName); return -1; } @@ -70,7 +70,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN fp = fopen (fileName, "rb"); if (!fp) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Failed to open file %s", fileName); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open file %s", fileName); elektraFree (buffer); return -1; } @@ -87,7 +87,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN if (bytesRead < fileSize) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "failed to read %s completely. got %lld of %lld bytes", fileName, bytesRead, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "failed to read %s completely. got %lld of %lld bytes", fileName, bytesRead, fileSize); elektraFree (buffer); fclose (fp); @@ -142,7 +142,7 @@ int elektraFileSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN fp = fopen (fileName, "wb"); if (!fp) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "failed to open %s for writing", fileName); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 2e66b7fe3f4..bea7e57ba12 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 (RESOURCE_CODE, parentKey, "Couldn't open file %s", filename); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Couldn't open file %s", filename); return -1; } iconv_t conv = NULL; @@ -222,7 +222,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che } if (conv == (iconv_t) (-1)) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "Couldn't initialize iconv with encoding %s\n", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Couldn't initialize iconv with encoding %s\n", checkConf->encoding); fclose (fp); return -2; @@ -247,7 +247,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che le_ret = validateLineEnding (line, &(checkConf->validLE), 0); if (le_ret) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "invalid lineending at position %zd", bytesRead + le_ret); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "invalid lineending at position %zd", bytesRead + le_ret); retVal = -1; break; } @@ -257,7 +257,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che null_ret = checkNull (line, bytesRead); if (null_ret) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "found null-byte at position %zd", bytesRead + null_ret); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "found null-byte at position %zd", bytesRead + null_ret); retVal = -1; break; } @@ -267,7 +267,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che iconv_ret = validateEncoding (line, conv, bytesRead); if (iconv_ret) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "invalid encoding at position %zd", bytesRead + iconv_ret); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "invalid encoding at position %zd", bytesRead + iconv_ret); retVal = -1; break; } @@ -277,7 +277,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che bom_ret = checkBom (line); if (bom_ret) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, "found BOM"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "found BOM"); retVal = -1; break; } @@ -288,7 +288,7 @@ static long checkFile (Key * parentKey, const char * filename, checkStruct * che unprintable_ret = checkUnprintable (line); if (unprintable_ret) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "unprintable character at position %zd", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 5671cf5b86e..a1ab18448a7 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 (RESOURCE_CODE, parentKey, "Failed to open Repository %s\n", data->repo); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Failed to get reference %s\n", data->refName); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (CONFLICT_CODE, parentKey, "Fast-forward pull failed, please pull manually\n"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, 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 (RESOURCE_CODE, parentKey, "Failed to get reference %s\n", data->refName); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parentKey, "File %s not found in repository %s\n", data->file, data->repo); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "File %s not found in repository %s\n", data->file, data->repo); git_repository_free (repo); git_libgit2_shutdown (); return 0; @@ -747,7 +747,7 @@ int elektraGitresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE outFile = fopen (keyString (parentKey), "w+"); if (!outFile) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Failed to check out file %s to %s\n", data->file, keyString (parentKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (); @@ -832,14 +832,14 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE git_repository * repo = connectToLocalRepo (data); if (!repo) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Failed to open Repository %s\n", data->repo); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Failed to get reference %s\n", data->refName); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to get reference %s\n", data->refName); git_repository_free (repo); git_libgit2_shutdown (); return -1; @@ -847,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 (RESOURCE_CODE, parentKey, "Failed to get reference %s\n", data->refName); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to get reference %s\n", data->refName); git_reference_free (headRef); git_repository_free (repo); git_libgit2_shutdown (); @@ -860,7 +860,7 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE if (newCommit) { // newer commit in repo - abort - ELEKTRA_SET_ERROR (CONFLICT_CODE, parentKey, "The repository has been updated and is ahead of you"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, "The repository has been updated and is ahead of you"); elektraFree (newCommit); git_reference_free (headRef); git_repository_free (repo); @@ -878,7 +878,7 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE char * newObj = hasNewObjectCommit (data, blob); if (newObj) { - ELEKTRA_SET_ERROR (CONFLICT_CODE, parentKey, "The repository has been updated and is ahead of you"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, 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 f8e1793e5ca..5153240b3dd 100644 --- a/src/plugins/gpgme/gpgme.c +++ b/src/plugins/gpgme/gpgme.c @@ -153,7 +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 (LOGICAL_CODE, errorKey, "Failed to receive the GPG key because: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to receive the GPG key because: %s", gpgme_strerror (err)); elektraGpgmeKeylistFree (&list); return NULL; } @@ -162,7 +162,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er { if (!elektraGpgmeKeylistAdd (&list, key)) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); elektraGpgmeKeylistFree (&list); return NULL; } @@ -182,7 +182,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er err = gpgme_get_key (ctx, keyString (k), &key, 0); if (err) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Failed to receive the GPG key because: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Failed to receive the GPG key because: %s", gpgme_strerror (err)); elektraGpgmeKeylistFree (&list); return NULL; @@ -192,7 +192,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er { if (!elektraGpgmeKeylistAdd (&list, key)) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); elektraGpgmeKeylistFree (&list); return NULL; } @@ -210,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 (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); elektraGpgmeKeylistFree (&list); return NULL; } @@ -249,7 +249,7 @@ static int transferGpgmeDataToElektraKey (gpgme_data_t src, Key * dst, Key * err buffer = (char *) elektraMalloc (ciphertextLen); if (!buffer) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); returnValue = -1; // failure goto cleanup; } @@ -258,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 (LOGICAL_CODE, errorKey, "An error during occurred during the data transfer."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_LOGICAL, errorKey, "An error during occurred during the data transfer."); returnValue = -1; // failure goto cleanup; } @@ -349,7 +349,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Failed to create the gpgme context because: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to create the gpgme context because: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -364,7 +364,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) recipients = extractRecipientFromPluginConfig (pluginConfig, errorKey, ctx); if (!recipients) { - ELEKTRA_SET_ERROR (VALIDATION_SEMANTIC_CODE, errorKey, "No valid recipients were specified."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "No valid recipients were specified."); returnValue = -1; goto cleanup; } @@ -400,7 +400,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) if (err) { returnValue = -1; - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); goto cleanup; } @@ -408,7 +408,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) if (err) { returnValue = -1; - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); gpgme_data_release (input); goto cleanup; } @@ -417,7 +417,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) if (err) { returnValue = -1; - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); gpgme_data_release (ciphertext); gpgme_data_release (input); goto cleanup; @@ -432,12 +432,12 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) generateInvalidKeyErrorMsg (&errorMsg, invalidKey); if (errorMsg) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "Invalid key ID(s): %s", errorMsg); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Invalid key ID(s): %s", errorMsg); elektraFree (errorMsg); } else { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Memory allocation failed"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Memory allocation failed"); } gpgme_data_release (ciphertext); gpgme_data_release (input); @@ -484,7 +484,7 @@ static int gpgDecrypt (ELEKTRA_UNUSED Plugin * handle, KeySet * data, Key * erro err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Failed to the gpgme context because: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to the gpgme context because: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -503,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 (LOGICAL_CODE, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); returnValue = -1; goto cleanup; } @@ -511,7 +511,7 @@ static int gpgDecrypt (ELEKTRA_UNUSED Plugin * handle, KeySet * data, Key * erro err = gpgme_data_new (&plaintext); if (err) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); returnValue = -1; gpgme_data_release (ciphertext); goto cleanup; @@ -520,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 (LOGICAL_CODE, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); returnValue = -1; gpgme_data_release (plaintext); gpgme_data_release (ciphertext); @@ -559,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 (LOGICAL_CODE, errorKey, "Internal error: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, errorKey, "Internal error: %s", gpgme_strerror (err)); return -1; // failure } return 1; // success @@ -600,7 +600,7 @@ int elektraGpgmeCheckconf (Key * errorKey, KeySet * conf) err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Failed to create the gpgme context because: %s", gpgme_strerror (err)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to create the gpgme context because: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -613,7 +613,7 @@ int elektraGpgmeCheckconf (Key * errorKey, KeySet * conf) } else { - ELEKTRA_SET_ERROR (VALIDATION_SEMANTIC_CODE, errorKey, "No valid recipients were specified."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 8615b0888b1..20e34d87be1 100644 --- a/src/plugins/hexnumber/hexnumber.c +++ b/src/plugins/hexnumber/hexnumber.c @@ -68,14 +68,14 @@ static int convertHexToDec (Key * key, Key * parentKey) if (errno == ERANGE && value == ULLONG_MAX) { errno = errnoSaved; - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Hexadecimal number %s out of range 0 to %llu", hexValue, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 (PARSING_CODE, parentKey, "Hexadecimal number '%s' could not be read", hexValue); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Hexadecimal number '%s' could not be read", hexValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } errno = errnoSaved; @@ -84,7 +84,7 @@ static int convertHexToDec (Key * key, Key * parentKey) int result = snprintf (NULL, 0, "%llu", value); if (result < 0) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "Unable to convert '%s' into decimal", hexValue); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to convert '%s' into decimal", hexValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -99,7 +99,7 @@ static int convertHexToDec (Key * key, Key * parentKey) result = snprintf (decValue, length, "%llu", value); if (result < 0) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "Unable to convert '%s' into decimal", hexValue); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to convert '%s' into decimal", hexValue); elektraFree (decValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -138,13 +138,13 @@ static int convertDecToHex (Key * key, Key * parentKey) if (errno == ERANGE && value == ULLONG_MAX) { errno = errnoSaved; - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Decimal number %s out of range 0 to %llu", decValue, ULLONG_MAX); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 (PARSING_CODE, parentKey, "Decimal number '%s' could not be read", decValue); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Decimal number '%s' could not be read", decValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } errno = errnoSaved; @@ -153,7 +153,7 @@ static int convertDecToHex (Key * key, Key * parentKey) const int result = snprintf (NULL, 0, "0x%llx", value); if (result < 0) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "Unable to convert '%s' into hexadecimal", decValue); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to convert '%s' into hexadecimal", decValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -167,7 +167,7 @@ static int convertDecToHex (Key * key, Key * parentKey) if (snprintf (hexValue, length, "0x%llx", value) < 0) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "Unable to convert '%s' into hexadecimal", decValue); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Unable to convert '%s' into hexadecimal", decValue); elektraFree (hexValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -280,7 +280,7 @@ int parseConfig (KeySet * config, HexnumberData * data, Key * errorKey) if (!types) { - ELEKTRA_SET_ERROR (PARSING_CODE, errorKey, "Could not parse config! Types not set correctly."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, errorKey, "Could not parse config! Types not set correctly."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -352,7 +352,7 @@ int elektraHexnumberGet (Plugin * handle, KeySet * returned, Key * parentKey) } else { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, + 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)); status |= ELEKTRA_PLUGIN_STATUS_ERROR; diff --git a/src/plugins/hosts/hosts-get.c b/src/plugins/hosts/hosts-get.c index 94fcbf2c4af..fde1ad3f4c9 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 (PARSING_CODE, parentKey, "general parse error: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 c8b31167035..bf46f73ff33 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 (RESOURCE_CODE, parentKey, strerror (errno)); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, strerror (errno)); fclose (fp); return -1; } diff --git a/src/plugins/iconv/iconv.c b/src/plugins/iconv/iconv.c index e1ed07e5134..02773d78f7b 100644 --- a/src/plugins/iconv/iconv.c +++ b/src/plugins/iconv/iconv.c @@ -178,7 +178,7 @@ int elektraIconvGet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (cur), keyGetValueSize (cur)); if (kdbbUTF8Engine (handle, UTF8_FROM, &convertedData, &convertedDataSize)) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + 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)); elektraFree (convertedData); @@ -197,7 +197,7 @@ int elektraIconvGet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (meta), keyGetValueSize (meta)); if (kdbbUTF8Engine (handle, UTF8_FROM, &convertedData, &convertedDataSize)) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + 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)); elektraFree (convertedData); @@ -230,7 +230,7 @@ int elektraIconvSet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (cur), keyGetValueSize (cur)); if (kdbbUTF8Engine (handle, UTF8_TO, &convertedData, &convertedDataSize)) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + 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)); @@ -250,7 +250,7 @@ int elektraIconvSet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (meta), keyGetValueSize (meta)); if (kdbbUTF8Engine (handle, UTF8_TO, &convertedData, &convertedDataSize)) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + 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)); diff --git a/src/plugins/ini/ini.c b/src/plugins/ini/ini.c index eb65e17a0be..c9eb01293d0 100644 --- a/src/plugins/ini/ini.c +++ b/src/plugins/ini/ini.c @@ -406,7 +406,7 @@ static int iniKeyToElektraKey (void * vhandle, const char * section, const char else if (!lineContinuation) { keyDel (appendKey); - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, handle->parentKey, + 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); return -1; @@ -780,13 +780,13 @@ int elektraIniGet (Plugin * handle, KeySet * returned, Key * parentKey) switch (ret) { case -1: - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Unable to open the ini file"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Unable to open the ini file"); break; case -2: - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Memory allocation error while reading the ini file"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Memory allocation error while reading the ini file"); break; default: - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "Could not parse ini file %s. First error at line %d", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "Could not parse ini file %s. First error at line %d", keyString (parentKey), ret); break; } @@ -1418,7 +1418,7 @@ static int iniWriteKeySet (FILE * fh, Key * parentKey, KeySet * returned, IniPlu else { ELEKTRA_SET_ERROR ( - INSTALLATION_CODE, parentKey, + ELEKTRA_ERROR_INSTALLATION, 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 d961a5869ab..ddf006ec9ac 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 (VALIDATION_SEMANTIC_CODE, parentKey, "Validation of key %s with value %s failed.", keyName (key), + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Validation of key %s with value %s failed.", keyName (key), keyString (key)); } else if (rc == -1) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, "Out of memory"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, "Out of memory"); rc = 0; } diff --git a/src/plugins/jni/jni.c b/src/plugins/jni/jni.c index 15ea1506ecf..e064f7a3493 100644 --- a/src/plugins/jni/jni.c +++ b/src/plugins/jni/jni.c @@ -64,7 +64,7 @@ static void checkException (Data * data, const char * when, Key * warningKey) which = (*data->env)->GetStringUTFChars (data->env, estr, &iseCopy); } - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, warningKey, "During \"%s\", java exception was thrown: %s", when, which); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningKey, "During \"%s\", java exception was thrown: %s", when, which); if (iseCopy == JNI_TRUE) { @@ -80,7 +80,7 @@ static int call1Arg (Data * data, Key * errorKey, const char * method) checkException (data, method, errorKey); if (jerrorKey == 0) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, errorKey, "Cannot create errorKey in %s", method); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Cannot create errorKey in %s", method); return -1; } @@ -88,7 +88,7 @@ static int call1Arg (Data * data, Key * errorKey, const char * method) checkException (data, method, errorKey); if (mid == 0) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, errorKey, "Cannot find org/libelektra/Key in %s", method); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Cannot find org/libelektra/Key in %s", method); return -1; } @@ -96,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 (INSTALLATION_CODE, errorKey, "%s failed with exception", method); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "%s failed with exception", method); result = -1; } checkException (data, method, errorKey); @@ -113,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 (INSTALLATION_CODE, errorKey, "Cannot create ks"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot create ks"); return -1; } @@ -121,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 (INSTALLATION_CODE, errorKey, "Cannot create key"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot create key"); return -1; } @@ -129,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 (RESOURCE_CODE, errorKey, "Cannot find %s", method); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Cannot find %s", method); return -1; } @@ -137,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 (INSTALLATION_CODE, errorKey, "%s failed with exception", method); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "%s failed with exception", method); result = -1; } checkException (data, method, errorKey); @@ -175,7 +175,7 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) k = ksLookupByName (config, "/classpath", 0); if (!k) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Could not find plugin config /classpath"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not find plugin config /classpath"); return -1; } char classpatharg[] = "-Djava.class.path="; @@ -218,14 +218,14 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) elektraFree (classpath); if (res < 0) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Cannot create Java VM"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot create Java VM"); return -1; } k = ksLookupByName (config, "/classname", 0); if (!k) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Could not find plugin config /classname"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Could not find plugin config /classname"); return -1; } @@ -234,56 +234,56 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) data->clsPlugin = (*data->env)->FindClass (data->env, classname); if (data->clsPlugin == 0) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Cannot find class %s", classname); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Cannot find class Key"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find class Key"); return -1; } data->clsKeySet = (*data->env)->FindClass (data->env, "org/libelektra/KeySet"); if (data->clsKeySet == 0) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Cannot find class KeySet"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Cannot find constructor of Key"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Cannot find constructor of KeySet"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Cannot find release of Key"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Cannot find release of KeySet"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find release of KeySet"); return -1; } jmethodID midPluginConstructor = (*data->env)->GetMethodID (data->env, data->clsPlugin, "", "()V"); if (midPluginConstructor == 0) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Cannot find constructor of plugin"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot find constructor of plugin"); return -1; } @@ -291,7 +291,7 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) checkException (data, "creating plugin", errorKey); if (data->plugin == 0) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Cannot create plugin"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Cannot create plugin"); return -1; } diff --git a/src/plugins/keytometa/keytometa.c b/src/plugins/keytometa/keytometa.c index cfdb50b8860..bc8299034f8 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 (RESOURCE_CODE, parentKey, strerror (errno)); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, strerror (errno)); errno = errnosave; return 0; } diff --git a/src/plugins/line/line.c b/src/plugins/line/line.c index 04602b8e9f4..a156e93cc2b 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 (PARSING_CODE, parentKey, "could not increment array from %s", keyName (ksTail (returned))); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "could not increment array from %s", keyName (ksTail (returned))); ret = -1; } else if (feof (fp) == 0) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, "Invalid line encountered: not at the end of file"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 0124ae46d5e..4e610dec305 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 (PARSING_CODE, parentKey, "Invalid line ending at line %lu", line); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, parentKey, "inconsistent line endings at line %lu", line); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 (RESOURCE_CODE, parentKey, "Couldn't open file %s\n", keyString (parentKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 3ce9618be30..e23e0e38162 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 (VALIDATION_SEMANTIC_CODE, errorKey, lua_tostring (L, -1)); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, lua_tostring (L, -1)); else { if (!lua_isnumber (L, -1)) - ELEKTRA_SET_ERROR (VALIDATION_SEMANTIC_CODE, errorKey, "Return value is no integer"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 (INSTALLATION_CODE, errorKey, "No lua script set"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "Unable to create new lua state"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, lua_tostring (data->L, -1)); + if (!lua_isnil (data->L, -1)) ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 8a81f0bbc50..2fdd2ce11bd 100644 --- a/src/plugins/mathcheck/mathcheck.c +++ b/src/plugins/mathcheck/mathcheck.c @@ -290,7 +290,7 @@ static PNElem parsePrefixString (const char * prefixString, Key * curKey, KeySet resultOp = NOT; break; default: - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, "%c isn't a valid operation", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "%c isn't a valid operation", prefixString[start]); regfree (®ex); if (searchKey) @@ -369,7 +369,7 @@ static PNElem parsePrefixString (const char * prefixString, Key * curKey, KeySet } else { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, "Not a valid Polish prefix notation syntax: %s\n", prefixString); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Not a valid Polish prefix notation syntax: %s\n", prefixString); } elektraFree (stack); return result; @@ -398,7 +398,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (fabs (elektraEFtoF (keyString (cur)) - result.value) > EPSILON) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s != %s", val1, val2); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s != %s", val1, val2); return -1; } } @@ -406,7 +406,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (fabs (elektraEFtoF (keyString (cur)) - result.value) < EPSILON) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s == %s but requirement was !=", val1, val2); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s == %s but requirement was !=", val1, val2); return -1; } } @@ -414,7 +414,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) >= result.value) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s not < %s", val1, val2); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s not < %s", val1, val2); return -1; } } @@ -422,7 +422,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) <= result.value) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s not > %s", val1, val2); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s not > %s", val1, val2); return -1; } } @@ -430,7 +430,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) > result.value) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s not <= %s", val1, val2); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s not <= %s", val1, val2); return -1; } } @@ -438,7 +438,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) < result.value) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s not >= %s", val1, val2); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s not >= %s", val1, val2); return -1; } } diff --git a/src/plugins/mini/mini.c b/src/plugins/mini/mini.c index 9ec02495a0f..235fb6644c6 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 (PARSING_CODE, parentKey, "Line %zu: “%s” is not 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); 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 (PARSING_CODE, parentKey, "Unable to read line %zu: %s", lineNumber, strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 a39926dc0c3..1b82b287c3a 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 (RESOURCE_CODE, parentKey, "glob(%s) ran out of memory", pattern); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "glob(%s) ran out of memory", pattern); } else if (ret == GLOB_ABORTED) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "glob(%s) failed with a read error", pattern); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "glob(%s) failed with a read error", pattern); } else if (ret == GLOB_NOMATCH) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, "glob(%s) failed with no matches", pattern); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, 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 20df8f46972..e2484b2cad1 100644 --- a/src/plugins/network/network.c +++ b/src/plugins/network/network.c @@ -63,7 +63,7 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) { if (portNumber < 0 || portNumber > 65535) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Port %ld on key %s was not within 0 - 65535", portNumber, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Port %ld on key %s was not within 0 - 65535", portNumber, keyName (toCheck)); return -1; } @@ -75,7 +75,7 @@ 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 (RESOURCE_CODE, parentKey, "Could not find service with name %s on key %s", keyString (toCheck), + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not find service with name %s on key %s", keyString (toCheck), keyName (toCheck)); return -1; } @@ -93,7 +93,7 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) if (sockfd < 0) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not open a socket: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open a socket: %s", strerror (errno)); } server = gethostbyname (hostname); @@ -101,12 +101,12 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) { if (errno == HOST_NOT_FOUND) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not connect to %s: No such host", hostname); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not connect to %s: No such host", hostname); return -1; } else { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "There was an error trying to connect to host %s: %s", hostname, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "There was an error trying to connect to host %s: %s", hostname, strerror (errno)); return -1; } @@ -124,12 +124,12 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) close (sockfd); if (errno == EADDRINUSE) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Port %s is already in use which was specified on key %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Port %s is already in use which was specified on key %s", keyString (toCheck), keyName (toCheck)); } else { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + 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)); } @@ -180,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 (VALIDATION_SEMANTIC_CODE, parentKey, errmsg); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, errmsg); elektraFree (errmsg); return -1; } diff --git a/src/plugins/passwd/passwd.c b/src/plugins/passwd/passwd.c index dcea71215aa..bb4ac4025d9 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 (RESOURCE_CODE, parentKey, "Failed to open configuration file %s\n", keyString (parentKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Failed to open %s for writing\n", keyString (parentKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Failed to open %s for writing\n", keyString (parentKey)); return -1; } Key * cur; @@ -308,7 +308,7 @@ static int writeKS (KeySet * returned, Key * parentKey, SortBy index) struct passwd * pwd = KStoPasswd (cutKS, index); if (validatepwent (pwd) == -1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "Invalid passwd entry %s:%s:%u:%u:%s:%s:%s\n", pwd->pw_name, + 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); } else diff --git a/src/plugins/path/path.c b/src/plugins/path/path.c index b24d4d6f21e..311ef30f960 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 (VALIDATION_SEMANTIC_CODE, parentKey, "Given path \"%s\" is not absolute", keyString (key)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 (RESOURCE_CODE, parentKey, "Could not stat file, message: %s", errmsg); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, 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 (RESOURCE_CODE, parentKey, "Device not found: %s", keyString (key)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Device not found: %s", keyString (key)); } } else if (!strcmp (keyString (meta), "directory")) { if (!S_ISDIR (buf.st_mode)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Directory not found: %s", keyString (key)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Directory not found: %s", keyString (key)); } } return 1; @@ -129,7 +129,7 @@ static int validatePermission (Key * key, Key * parentKey) // Check if user exists if (p == NULL) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Could not find user \"%s\" for key \"%s\". " "Does the user exist?\"", name, keyName (key)); @@ -157,7 +157,7 @@ static int validatePermission (Key * key, Key * parentKey) name = p->pw_name; if (uid != 0) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, + 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)); @@ -203,7 +203,7 @@ static int validatePermission (Key * key, Key * parentKey) if (euidResult != 0 || egidResult != 0) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, + 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"); return -1; @@ -211,8 +211,8 @@ static int validatePermission (Key * key, Key * parentKey) if (canAccess != 0) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "User %s does not have required permission (%s) on %s", name, modes, - validPath); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "User %s does not have required permission (%s) on %s", name, + modes, validPath); return -1; } @@ -238,12 +238,12 @@ 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 (RESOURCE_CODE, parentKey, + 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"); if (seteuid (currentUID) < 0) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, + 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"); } @@ -265,7 +265,7 @@ 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 (RESOURCE_CODE, parentKey, + 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)); @@ -288,7 +288,7 @@ static int switchUser (Key * key, Key * parentKey, const struct passwd * p) int err = seteuid ((int) p->pw_uid); if (err < 0) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, + 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)); @@ -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 (RESOURCE_CODE, parentKey, "User %s does not have required permission (%s) on %s", p->pw_name, modes, - validPath); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 ef35e3d3a75..c8229ffa34b 100644 --- a/src/plugins/process/process.c +++ b/src/plugins/process/process.c @@ -26,7 +26,7 @@ static int validPluginName (Key * pluginNameKey, Key * errorKey) { if (pluginNameKey == NULL) { - ELEKTRA_ADD_WARNING (VALIDATION_SEMANTIC_CODE, errorKey, + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_VALIDATION_SEMANTIC, 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 (VALIDATION_SEMANTIC_CODE, errorKey, "Plugin configuration parameter plugin has an invalid value: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, errorKey, "Plugin configuration parameter plugin has an invalid value: %s", pluginName); return 0; } else if (elektraStrCmp (pluginName, "process") == 0) { - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "Cannot proxy the process plugin itself"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "Cannot proxy the process plugin itself"); return 0; } return 1; @@ -107,7 +107,7 @@ int elektraProcessOpen (Plugin * handle, Key * errorKey) process->plugin = elektraInvokeOpen (keyString (process->pluginName), process->pluginConfig, errorKey); if (!process->plugin) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Failed to open the proxied plugin %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Failed to open the proxied plugin %s", keyString (process->pluginName)); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -206,7 +206,7 @@ int elektraProcessGet (Plugin * handle, KeySet * returned, Key * parentKey) keyDel (pluginParentKey); if (ksGetSize (pluginContract) == 0) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, parentKey, "Failed to get the contract for %s", keyString (pluginName)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_LOGICAL, 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 a768d2e8c2f..0ecf39dbe2e 100644 --- a/src/plugins/python/python.cpp +++ b/src/plugins/python/python.cpp @@ -101,7 +101,7 @@ static int Python_CallFunction_Int (moduleData * data, PyObject * object, PyObje PyObject * res = Python_CallFunction (object, args); if (!res) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Error while calling python function of script %s%s", + 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"); if (data->printError) PyErr_Print (); } @@ -112,7 +112,7 @@ static int Python_CallFunction_Int (moduleData * data, PyObject * object, PyObje #else if (!PyInt_Check (res)) #endif - ELEKTRA_SET_ERROR (VALIDATION_SEMANTIC_CODE, errorKey, "Return value is no integer"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Return value is no integer"); else ret = PyLong_AsLong (res); } @@ -211,7 +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 (INSTALLATION_CODE, errorKey, "No python script set, please pass a filename via /script"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "No python script set, please pass a filename via /script"); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -247,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 (INSTALLATION_CODE, errorKey, "Unable to create sub interpreter"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to create sub interpreter"); goto error; } PyThreadState_Swap (data->tstate); @@ -255,7 +255,7 @@ 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 (INSTALLATION_CODE, errorKey, "Unable to extend sys.path with built-in path \"%s\"", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to extend sys.path with built-in path \"%s\"", ELEKTRA_PYTHON_SITE_PACKAGES); goto error; } @@ -264,7 +264,7 @@ 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 (INSTALLATION_CODE, errorKey, "Unable to extend sys.path with user-defined /python/path \"%s\"", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to extend sys.path with user-defined /python/path \"%s\"", mname); goto error; } @@ -273,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 (INSTALLATION_CODE, errorKey, "Unable to import kdb module"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to import kdb module"); goto error_print; } Py_XDECREF (kdbModule); @@ -281,7 +281,7 @@ 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 (INSTALLATION_CODE, errorKey, "Unable to extend sys.path with built-in plugin path \"%s\"", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to extend sys.path with built-in plugin path \"%s\"", ELEKTRA_PYTHON_PLUGIN_FOLDER); goto error; } @@ -291,7 +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 (INSTALLATION_CODE, errorKey, "Unable to extend sys.path with script dirname \"%s\"", dname); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to extend sys.path with script dirname \"%s\"", dname); elektraFree (tmpScript); goto error; } @@ -306,7 +306,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) PyObject * pModule = PyImport_ImportModule (bname); if (pModule == nullptr) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "Unable to import python script \"%s\"", keyString (data->script)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "Unable to import python script \"%s\"", keyString (data->script)); elektraFree (tmpScript); goto error_print; } @@ -317,7 +317,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) Py_DECREF (pModule); if (klass == nullptr) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Module doesn't provide a ElektraPlugin class"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "Module doesn't provide a ElektraPlugin class"); goto error_print; } @@ -328,7 +328,7 @@ int PYTHON_PLUGIN_FUNCTION (Open) (ckdb::Plugin * handle, ckdb::Key * errorKey) Py_DECREF (inst_args); if (inst == nullptr) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, "Unable to create instance of ElektraPlugin"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 6eed56b27e5..d021d3279bb 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 (PARSING_CODE, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, errorKey, "Error while reading file"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, errorKey, feof (file) ? "premature end of file" : "unknown error"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, parentKey, "Unknown magic number " ELEKTRA_UNSIGNED_LONG_LONG_F, magic); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 (VALIDATION_SEMANTIC_CODE, parentKey, "missing key type"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 (PARSING_CODE, parentKey, "error while reading file"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (VALIDATION_SEMANTIC_CODE, parentKey, "Unknown key type %c", type); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 (PARSING_CODE, parentKey, "Missing key end"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "Missing key end"); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -386,7 +386,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key const Key * sourceKey = ksLookupByName (returned, nameBuffer.string, 0); if (sourceKey == NULL) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not copy meta data from key '%s': Key not found", nameBuffer.string); keyDel (k); elektraFree (nameBuffer.string); @@ -398,7 +398,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key if (keyCopyMeta (k, sourceKey, metaNameBuffer.string) != 1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not copy meta data from key '%s': Error during copy", &nameBuffer.string[nameBuffer.offset]); keyDel (k); @@ -416,7 +416,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key elektraFree (metaNameBuffer.string); elektraFree (valueBuffer.string); fclose (file); - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "Unknown meta type %c", type); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 0b4903e13d0..0e775f10171 100644 --- a/src/plugins/quickdump/readv1.c +++ b/src/plugins/quickdump/readv1.c @@ -145,7 +145,7 @@ static int readVersion1 (FILE * file, KeySet * returned, Key * parentKey) const Key * sourceKey = ksLookupByName (returned, keyName, 0); if (sourceKey == NULL) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not copy meta data from key '%s': Key not found", keyName); keyDel (k); elektraFree (keyName); @@ -156,7 +156,7 @@ static int readVersion1 (FILE * file, KeySet * returned, Key * parentKey) if (keyCopyMeta (k, sourceKey, metaName) != 1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not copy meta data from key '%s': Error during copy", keyName); keyDel (k); elektraFree (keyName); diff --git a/src/plugins/range/range.c b/src/plugins/range/range.c index ab0c0f61146..bdc8f915738 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 (VALIDATION_SYNTACTIC_CODE, parentKey, "invalid syntax: %s", token); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, 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 (VALIDATION_SYNTACTIC_CODE, parentKey, "invalid syntax: %s", token); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "invalid syntax: %s", token); return -1; } } @@ -439,12 +439,12 @@ static int validateKey (Key * key, Key * parentKey) int rc = validateSingleRange (keyString (key), rangeString, type); if (rc == -1) { - ELEKTRA_SET_ERRORF (VALIDATION_SYNTACTIC_CODE, parentKey, "invalid syntax: %s", keyString (rangeMeta)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "invalid syntax: %s", keyString (rangeMeta)); return -1; } else if (rc == 0) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "value %s not within range %s", keyString (key), + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "value %s not within range %s", keyString (key), rangeString); return 0; } @@ -458,7 +458,7 @@ static int validateKey (Key * key, Key * parentKey) int rc = validateMultipleRanges (keyString (key), rangeString, parentKey, type); if (rc == 0) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "value %s not within range %s", keyString (key), + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 9dd49d26ca5..0396ecb3fe6 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 (RESOURCE_CODE, parentKey, "Reference '%s' uses '/./' or '/../' redundantly.", reference); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Reference '%s' uses '/./' or '/../' redundantly.", reference); } char * fullReference = elektraResolveReference (reference, baseKey, parentKey); @@ -65,7 +65,7 @@ static char * resolveRestriction (const char * restriction, const Key * baseKey, if (elektraIsReferenceRedundant (restriction)) { - ELEKTRA_ADD_WARNINGF (VALIDATION_SEMANTIC_CODE, parentKey, "Restriction '%s' uses '/./' or '/../' redundantly.", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, parentKey, "Restriction '%s' uses '/./' or '/../' redundantly.", restriction); } @@ -136,7 +136,7 @@ static int checkSingleReference (const Key * key, KeySet * allKeys, Key * parent bool error = false; if (refKey == NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Reference '%s', set in key '%s', does not reference an existing key.", ref, elementName); error = true; } @@ -158,7 +158,7 @@ static int checkSingleReference (const Key * key, KeySet * allKeys, Key * parent if (!anyMatch) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Reference '%s', set in key '%s', does not any of the given restrictions.", ref, elementName); error = true; @@ -339,7 +339,7 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * bool error = false; if (refKey == NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Reference '%s', set in key '%s', does not reference an existing key.", ref, elementName); error = true; @@ -365,7 +365,7 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * if (!anyMatch) { ELEKTRA_SET_ERRORF ( - VALIDATION_SEMANTIC_CODE, parentKey, + ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Reference '%s', set in key '%s', does not any of the given restrictions.", ref, elementName); error = true; @@ -408,7 +408,7 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * *strrchr (rootName, '/') = '\0'; if (!checkReferenceGraphAcyclic (referenceGraph, rootName)) { - ELEKTRA_SET_ERROR (VALIDATION_SEMANTIC_CODE, parentKey, "The configuration contains a cyclic reference."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 75784500990..a560f55fb76 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 (VALIDATION_SYNTACTIC_CODE, parentKey, "Regex Group %d for %s not between 0 and 9 read from %s", pos, + 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); return std::string (""); } if (offsets[pos].rm_so == -1) { - ELEKTRA_ADD_WARNINGF (VALIDATION_SYNTACTIC_CODE, parentKey, "Regex Group %d missing for %s", pos, text.c_str ()); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, 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,7 +70,7 @@ 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 (VALIDATION_SYNTACTIC_CODE, parentKey, "String %s of %s did not start with #", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "String %s of %s did not start with #", configString.c_str (), keyName (configKey)); return nullptr; } @@ -81,7 +81,7 @@ Key * elektraRegexstoreProcess (Key * configKey, int * offset, std::string const { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - ELEKTRA_ADD_WARNINGF (VALIDATION_SYNTACTIC_CODE, parentKey, "Could not compile regex %s, because: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "Could not compile regex %s, because: %s", configString.c_str () + 3, buffer); regfree (®ex); return nullptr; @@ -99,7 +99,7 @@ Key * elektraRegexstoreProcess (Key * configKey, int * offset, std::string const { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - ELEKTRA_ADD_WARNINGF (VALIDATION_SYNTACTIC_CODE, parentKey, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, 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 (INSTALLATION_CODE, parentKey, "Key /regexstore not found in configuration"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 0dfef741731..f47a7a47c35 100644 --- a/src/plugins/required/required.c +++ b/src/plugins/required/required.c @@ -51,7 +51,7 @@ int elektraRequiredSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTR { ++c; } - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "key '%s' with %d metadata is not required", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 5993246ceb3..e9b68b40aaa 100644 --- a/src/plugins/resolver/filename.c +++ b/src/plugins/resolver/filename.c @@ -144,7 +144,7 @@ static char * elektraResolvePasswd (Key * warningsKey) elektraFree (buf); if (s != 0) { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, warningsKey, "Could not retrieve from passwd using getpwuid_r: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningsKey, "Could not retrieve from passwd using getpwuid_r: %s", strerror (s)); } return NULL; @@ -186,7 +186,7 @@ static int elektraResolveUserXDGHome (ElektraResolved * handle, Key * warningsKe if (home[0] != '/') { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, warningsKey, + 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", @@ -208,7 +208,7 @@ static int elektraResolveEnvHome (ElektraResolved * handle, Key * warningsKey) if (home[0] != '/') { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, warningsKey, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, warningsKey, "HOME contains a path that is " "not absolute and thus " "it was skipped: %s", @@ -301,14 +301,14 @@ static int elektraResolveMapperUser (ElektraResolved * handle, ElektraResolveTem } if (finished == -1) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, warningsKey, "user resolver failed at step %zu, the configuration is: %s", i, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "user resolver failed at step %zu, the configuration is: %s", i, ELEKTRA_VARIANT_USER); return -1; } if (!(handle->dirname)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, warningsKey, "no resolver set the user dirname, the configuration is: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "no resolver set the user dirname, the configuration is: %s", ELEKTRA_VARIANT_USER); return -1; } @@ -381,7 +381,7 @@ static int elektraResolveSystemXDG (ElektraResolved * handle, ElektraResolveTemp { if (result[0] != '/') { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, warningsKey, + 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", @@ -458,14 +458,14 @@ static int elektraResolveMapperSystem (ElektraResolved * handle, ElektraResolveT } if (finished == -1) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, warningsKey, "no resolver set the user dirname, the configuration is: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "no resolver set the user dirname, the configuration is: %s", ELEKTRA_VARIANT_USER); return -1; } if (!(handle->fullPath)) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, warningsKey, "no resolver set the system dirname, the configuration is: %s", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, 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 (RESOURCE_CODE, warningsKey, "could not alloc for getcwd, defaulting to /"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "could not alloc for getcwd, defaulting to /"); return 0; } @@ -499,7 +499,7 @@ static char * elektraGetCwd (Key * warningsKey) { // give up, we cannot handle the problem elektraFree (cwd); - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, warningsKey, "getcwd failed with errno %d \"%s\", defaulting to /", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "getcwd failed with errno %d \"%s\", defaulting to /", errno, strerror (errno)); return 0; } @@ -509,7 +509,7 @@ static char * elektraGetCwd (Key * warningsKey) elektraRealloc ((void **) &cwd, size); if (cwd == NULL) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, warningsKey, "could not realloc for getcwd size %d, defaulting to /", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "could not realloc for getcwd size %d, defaulting to /", size); return 0; } @@ -648,23 +648,23 @@ ElektraResolved * ELEKTRA_PLUGIN_FUNCTION (filename) (elektraNamespace namespace rc = elektraResolveMapperSystem (handle, tmpDir, warningsKey); break; case KEY_NS_PROC: - ELEKTRA_ADD_WARNING (RESOURCE_CODE, warningsKey, "tried to resolve proc"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve proc"); rc = -1; break; case KEY_NS_EMPTY: - ELEKTRA_ADD_WARNING (RESOURCE_CODE, warningsKey, "tried to resolve empty"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve empty"); rc = -1; break; case KEY_NS_NONE: - ELEKTRA_ADD_WARNING (RESOURCE_CODE, warningsKey, "tried to resolve none"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve none"); rc = -1; break; case KEY_NS_META: - ELEKTRA_ADD_WARNING (RESOURCE_CODE, warningsKey, "tried to resolve meta"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve meta"); rc = -1; break; case KEY_NS_CASCADING: - ELEKTRA_ADD_WARNING (RESOURCE_CODE, warningsKey, "tried to resolve cascading"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, warningsKey, "tried to resolve cascading"); rc = -1; break; } diff --git a/src/plugins/resolver/resolver.c b/src/plugins/resolver/resolver.c index 3f39b89fbe3..5ef1cdb8bf8 100644 --- a/src/plugins/resolver/resolver.c +++ b/src/plugins/resolver/resolver.c @@ -150,12 +150,12 @@ static int elektraLockFile (int fd ELEKTRA_UNUSED, Key * parentKey ELEKTRA_UNUSE { if (errno == EAGAIN || errno == EACCES) { - ELEKTRA_SET_ERROR (CONFLICT_CODE, parentKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, "conflict because other process writes to configuration indicated by file lock"); } else { - ELEKTRA_SET_ERRORF (CONFLICT_CODE, parentKey, "assuming conflict because of failed file lock with message: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, "assuming conflict because of failed file lock with message: %s", strerror (errno)); } return -1; @@ -188,7 +188,7 @@ static int elektraUnlockFile (int fd ELEKTRA_UNUSED, Key * parentKey ELEKTRA_UNU if (ret == -1) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "fcntl SETLK unlocking failed with message: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "fcntl SETLK unlocking failed with message: %s", strerror (errno)); } return ret; @@ -212,12 +212,12 @@ static int elektraLockMutex (Key * parentKey ELEKTRA_UNUSED) if (errno == EBUSY // for trylock || errno == EDEADLK) // for error checking mutex, if enabled { - ELEKTRA_SET_ERROR (CONFLICT_CODE, parentKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, parentKey, "conflict because other thread writes to configuration indicated by mutex lock"); } else { - ELEKTRA_SET_ERRORF (CONFLICT_CODE, parentKey, "assuming conflict because of failed mutex lock with message: %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, "assuming conflict because of failed mutex lock with message: %s", strerror (errno)); } return -1; @@ -240,7 +240,7 @@ static int elektraUnlockMutex (Key * parentKey ELEKTRA_UNUSED) int ret = pthread_mutex_unlock (&elektraResolverMutex); if (ret != 0) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "mutex unlock failed with message: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "mutex unlock failed with message: %s", strerror (errno)); return -1; } return 0; @@ -260,7 +260,7 @@ static void elektraCloseFile (int fd, Key * parentKey) { if (close (fd) == -1) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "close file failed with message: %s", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "close file failed with message: %s", strerror (errno)); } } @@ -323,7 +323,7 @@ static int mapFilesForNamespaces (resolverHandles * p, Key * errorKey) { resolverClose (p); keyDel (testKey); - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Could not resolve spec key"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not resolve spec key"); return -1; } else @@ -345,7 +345,7 @@ static int mapFilesForNamespaces (resolverHandles * p, Key * errorKey) { resolverClose (p); keyDel (testKey); - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Could not resolve dir key"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not resolve dir key"); return -1; } else @@ -366,7 +366,7 @@ static int mapFilesForNamespaces (resolverHandles * p, Key * errorKey) { resolverClose (p); keyDel (testKey); - ELEKTRA_SET_ERRORF (RESOURCE_CODE, errorKey, "Could not resolve user key with conf %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not resolve user key with conf %s", ELEKTRA_VARIANT_USER); return -1; } @@ -388,7 +388,7 @@ static int mapFilesForNamespaces (resolverHandles * p, Key * errorKey) { resolverClose (p); keyDel (testKey); - ELEKTRA_SET_ERRORF (RESOURCE_CODE, errorKey, "Could not resolve system key with conf %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not resolve system key with conf %s", ELEKTRA_VARIANT_SYSTEM); return -1; } @@ -440,7 +440,7 @@ int ELEKTRA_PLUGIN_FUNCTION (open) (Plugin * handle, Key * errorKey) if (!path) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Could not find file configuration"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not find file configuration"); return -1; } @@ -462,21 +462,21 @@ int ELEKTRA_PLUGIN_FUNCTION (open) (Plugin * handle, Key * errorKey) if ((mutexError = pthread_mutexattr_init (&mutexAttr)) != 0) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, errorKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, errorKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 (RESOURCE_CODE, errorKey, "Could not initialize recursive mutex: pthread_mutex_init returned %d", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not initialize recursive mutex: pthread_mutex_init returned %d", mutexError); pthread_mutex_unlock (&elektraResolverInitMutex); return -1; @@ -664,7 +664,7 @@ static int elektraOpenFile (resolverHandle * pk, Key * parentKey) { if (errno == ENOENT) { - ELEKTRA_SET_ERRORF (CONFLICT_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, "The configuration file \"%s\" was there earlier, " "now it is missing", pk->filename); @@ -672,7 +672,7 @@ static int elektraOpenFile (resolverHandle * pk, Key * parentKey) } else if (pk->fd == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not reopen configuration file \"%s\" for writing because \"%s\"", pk->filename, strerror (errno)); return -1; @@ -689,7 +689,7 @@ static int elektraOpenFile (resolverHandle * pk, Key * parentKey) } else if (errno == EEXIST) { - ELEKTRA_SET_ERRORF (CONFLICT_CODE, parentKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_CONFLICT, parentKey, "No configuration file was there earlier, " "now configuration file \"%s\" exists", pk->filename); @@ -720,7 +720,7 @@ static int elektraCreateFile (resolverHandle * pk, Key * parentKey) if (pk->fd == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not create configuration file \"%s\" because %s", pk->filename, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not create configuration file \"%s\" because %s", pk->filename, strerror (errno)); return -1; } @@ -802,7 +802,7 @@ static int elektraMkdirParents (resolverHandle * pk, const char * pathname, Key elektraAddErrnoText (errorText); strcat (errorText, "\" "); elektraAddIdentity (errorText); - ELEKTRA_SET_ERROR (RESOURCE_CODE, parentKey, errorText); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, errorText); elektraFree (errorText); return -1; } @@ -839,16 +839,16 @@ static int elektraCheckConflict (resolverHandle * pk, Key * parentKey) elektraAddErrnoText (errorText); strcat (errorText, "\" "); elektraAddIdentity (errorText); - ELEKTRA_ADD_WARNING (RESOURCE_CODE, parentKey, errorText); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_RESOURCE, parentKey, errorText); elektraFree (errorText); - ELEKTRA_SET_ERROR (CONFLICT_CODE, parentKey, "assuming conflict because of failed stat (warning 29 for details)"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_CONFLICT, 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 (CONFLICT_CODE, parentKey, + 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", @@ -972,7 +972,7 @@ static void elektraUpdateFileTime (resolverHandle * pk, int fd, Key * parentKey) if (futimens (fd, times) == -1) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, "Could not update time stamp of \"%s\", because %s", + 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)); } #elif defined(HAVE_FUTIMES) @@ -981,7 +981,7 @@ static void elektraUpdateFileTime (resolverHandle * pk, int fd, Key * parentKey) if (futimes (fd, times) == -1) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, "Could not update time stamp of \"%s\", because %s", + 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)); } #else @@ -1007,7 +1007,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) int fd = open (pk->tempfile, O_RDWR); if (fd == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not open file again for changing metadata of file \"%s\", because %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open file again for changing metadata of file \"%s\", because %s", pk->tempfile, strerror (errno)); ret = -1; } @@ -1016,7 +1016,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) if (rename (pk->tempfile, pk->filename) == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not rename file: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not rename file: %s", strerror (errno)); ret = -1; } @@ -1025,7 +1025,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) struct stat buf; if (fstat (fd, &buf) == -1) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "Failed to stat file: %s\n", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "Failed to stat file: %s\n", strerror (errno)); } else { @@ -1060,7 +1060,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) // change mode to what it was before if (fchmod (fd, pk->filemode) == -1) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, "Could not fchmod temporary file \"%s\" from %o to %o, because %s", + 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)); } } @@ -1069,7 +1069,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) { if (fchown (fd, pk->uid, pk->gid) == -1) { - ELEKTRA_ADD_WARNINGF (LOGICAL_CODE, parentKey, + 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)); } @@ -1082,7 +1082,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) // checking dirp not needed, fsync will have EBADF if (fsync (dirfd (dirp)) == -1) { - ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, parentKey, "Could not sync directory \"%s\", because %s", pk->dirname, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, parentKey, "Could not sync directory \"%s\", because %s", pk->dirname, strerror (errno)); } closedir (dirp); @@ -1119,7 +1119,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 (RESOURCE_CODE, parentKey, "Could not remove file: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not remove file: %s", strerror (errno)); ret = -1; } @@ -1140,7 +1140,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 (RESOURCE_CODE, parentKey, "Could not remove file: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not remove file: %s", strerror (errno)); ret = -1; } @@ -1175,7 +1175,7 @@ static void elektraUnlinkFile (char * filename, Key * parentKey) int errnoSave = errno; if (unlink (filename) == -1) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "could not unlink the file \"%s\" because of \"%s\"", filename, + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, 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 2a0456e732a..b363951bd7f 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 (INSTALLATION_CODE, warningsKey, StringValueCStr (msg)); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, StringValueCStr (msg)); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, warningsKey, "could not initialize Ruby-VM"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, warningsKey, "could not load Ruby module 'kdb'"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "no 'script' config value specified"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "invalid Ruby plugin. Plugin did not call Kdb::Plugin.define"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, warningsKey, "Error in Ruby-plugin, didn't call Kdb::Plugin.define"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, 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 (INSTALLATION_CODE, parentKey, "plugin does not have a 'get' method"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 d81daa3d2f9..551f9ced282 100644 --- a/src/plugins/shell/shell.c +++ b/src/plugins/shell/shell.c @@ -70,14 +70,14 @@ int elektraShellGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa int retVal = executeCommand (keyString (cmdKey)); if (retVal == -1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "launching childprocess failed with %s\n", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "launching childprocess failed with %s\n", strerror (errno)); return -1; } else if (expectedReturnKey) { if (atoi (keyString (expectedReturnKey)) != retVal) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "return value of %s doesn't match expected exit %s\n", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "return value of %s doesn't match expected exit %s\n", keyString (cmdKey), keyString (expectedReturnKey)); return -1; } @@ -98,14 +98,14 @@ int elektraShellSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_U int retVal = executeCommand (keyString (cmdKey)); if (retVal == -1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "launching childprocess failed with %s\n", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "launching childprocess failed with %s\n", strerror (errno)); return -1; } else if (expectedReturnKey) { if (atoi (keyString (expectedReturnKey)) != retVal) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "return value of %s doesn't match expected exit %s\n", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "return value of %s doesn't match expected exit %s\n", keyString (cmdKey), keyString (expectedReturnKey)); return -1; } @@ -126,14 +126,14 @@ int elektraShellError (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA int retVal = executeCommand (keyString (cmdKey)); if (retVal == -1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "launching childprocess failed with %s\n", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "launching childprocess failed with %s\n", strerror (errno)); return -1; } else if (expectedReturnKey) { if (atoi (keyString (expectedReturnKey)) != retVal) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "return value of %s doesn't match expected exit %s\n", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 e58a77bae3a..626d35d4ee7 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 (PARSING_CODE, parentKey, "invalid 'format' specified"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, "invalid 'format' specified"); return -1; } @@ -280,7 +280,7 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) // discard line if (getline (&key, &size, fp) == -1 && !feof (fp)) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "failed discarding rest of line at position %ld with key %s", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "failed discarding rest of line at position %ld with key %s", ftell (fp), key); elektraFree (key); fclose (fp); @@ -297,7 +297,7 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) if (keyAddName (read, strippedkey) == -1) { - ELEKTRA_ADD_WARNINGF (VALIDATION_SYNTACTIC_CODE, parentKey, "Key name %s is not valid, discarding key", + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SYNTACTIC, parentKey, "Key name %s is not valid, discarding key", strippedkey); keyDel (read); elektraFree (key); @@ -320,7 +320,7 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) if (ksAppendKey (returned, read) != ksize + 1) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "duplicated key %s at position %ld", keyName (read), ftell (fp)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parentKey, "duplicated key %s at position %ld", keyName (read), ftell (fp)); elektraFree (format); fclose (fp); return -1; @@ -330,7 +330,7 @@ int elektraSimpleiniGet (Plugin * handle, KeySet * returned, Key * parentKey) if (feof (fp) == 0) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parentKey, "not at the end of file at position %ld", ftell (fp)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 78b307cbd14..8f0162da2de 100644 --- a/src/plugins/simplespeclang/simplespeclang.cpp +++ b/src/plugins/simplespeclang/simplespeclang.cpp @@ -132,7 +132,7 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks, Plu ss >> read; if (read != getConfigAssign (handle)) { - ELEKTRA_SET_ERRORF (PARSING_CODE, errorKey, "Expected assignment (%s), but got (%s)", + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey, "Expected assignment (%s), but got (%s)", getConfigAssign (handle).c_str (), read.c_str ()); continue; } diff --git a/src/plugins/spec/spec.c b/src/plugins/spec/spec.c index 6313904af8a..9f8a7de86bc 100644 --- a/src/plugins/spec/spec.c +++ b/src/plugins/spec/spec.c @@ -188,10 +188,10 @@ static void handleConflict (Key * parentKey, const char * msg, OnConflict onConf switch (onConflict) { case ERROR: - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "%s", msg); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "%s", msg); break; case WARNING: - ELEKTRA_ADD_WARNINGF (VALIDATION_SEMANTIC_CODE, parentKey, "%s", msg); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, parentKey, "%s", msg); break; case INFO: elektraMetaArrayAdd (parentKey, "logs/spec/info", msg); diff --git a/src/plugins/specload/specload.c b/src/plugins/specload/specload.c index 973c4fec4c9..291c164be67 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 (INSTALLATION_CODE, parentKey, "This plugin can only be used for the spec namespace."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "This plugin can only be used for the spec namespace."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -191,7 +191,7 @@ int elektraSpecloadGet (Plugin * handle, KeySet * returned, Key * parentKey) if (!loadSpec (spec, specload->app, specload->argv, parentKey, specload->quickDump)) { ksDel (spec); - ELEKTRA_SET_ERROR (INSTALLATION_CODE, parentKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, parentKey, "Couldn't load the overlay specification."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, parentKey, "Couldn't create an empty overlay specification."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, parentKey, "This plugin can only be used for the spec namespace."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "This plugin can only be used for the spec namespace."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -237,7 +237,7 @@ int elektraSpecloadSet (Plugin * handle, KeySet * returned, Key * parentKey) if (!loadSpec (spec, specload->app, specload->argv, parentKey, specload->quickDump)) { ksDel (spec); - ELEKTRA_SET_ERROR (INSTALLATION_CODE, parentKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, parentKey, "Couldn't load the overlay specification."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, parentKey, "Couldn't create an empty overlay specification."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, parentKey, "This kind of change is not allowed."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "This kind of change is not allowed."); ksSetCursor (returned, cursor); ksDel (overrides); ksDel (oldData); @@ -341,7 +341,7 @@ int elektraSpecloadCheckConfig (Key * errorKey, KeySet * conf) if (!result) { - ELEKTRA_SET_ERROR (INSTALLATION_CODE, errorKey, + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "You need to set an application using the app config key."); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, errorKey, "You need to set an application using the app config key."); return false; } @@ -363,13 +363,13 @@ bool getAppAndArgs (KeySet * conf, char ** appPtr, char *** argvPtr, Key * error if (app[0] != '/') { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, errorKey, "The value of the app config key ('%s') is not an absolute path.", app); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 (INSTALLATION_CODE, errorKey, "'%s' doesn't exist or is not executable.", app); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, errorKey, "'%s' doesn't exist or is not executable.", app); return false; } @@ -413,7 +413,7 @@ bool loadSpec (KeySet * returned, const char * app, char * argv[], Key * parentK if (pipe (fd) != 0) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "Could not execute app: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not execute app: %s", strerror (errno)); return NULL; } @@ -421,7 +421,7 @@ bool loadSpec (KeySet * returned, const char * app, char * argv[], Key * parentK if (pid == -1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "Could not execute app: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not execute app: %s", strerror (errno)); return NULL; } @@ -448,7 +448,7 @@ bool loadSpec (KeySet * returned, const char * app, char * argv[], Key * parentK if (dup2 (fd[0], STDIN_FILENO) == -1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "Could not execute app: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, parentKey, "Could not execute app: %s", strerror (errno)); return NULL; } @@ -466,7 +466,7 @@ bool loadSpec (KeySet * returned, const char * app, char * argv[], Key * parentK if (dup2 (stdin_copy, STDIN_FILENO) == -1) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, "Could not execute app: %s", strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 9114bada0fc..76da57bc8c4 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 (INSTALLATION_CODE, parentKey, "Could not check the structure of the keyset: %s", msg); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, 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 a04502eed7d..962eb26e04c 100644 --- a/src/plugins/sync/sync.c +++ b/src/plugins/sync/sync.c @@ -52,12 +52,12 @@ int elektraSyncSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN int fd = open (configFile, O_RDWR); if (fd == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not open config file %s because \"%s\"", configFile, strerror (errno)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open config file %s because \"%s\"", configFile, strerror (errno)); return -1; } if (fsync (fd) == -1) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not fsync config file %s because \"%s\"", configFile, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 4464aa34f94..d66f6f2bcd3 100644 --- a/src/plugins/tcl/tcl.cpp +++ b/src/plugins/tcl/tcl.cpp @@ -65,7 +65,7 @@ int elektraTclGet (Plugin *, KeySet * returned, Key * parentKey) } catch (boost::spirit::qi::expectation_failure const & e) { - ELEKTRA_SET_ERROR (PARSING_CODE, *parent, + 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 ()); @@ -74,7 +74,7 @@ int elektraTclGet (Plugin *, KeySet * returned, Key * parentKey) catch (std::exception const & e) { ELEKTRA_SET_ERROR ( - PARSING_CODE, *parent, + ELEKTRA_ERROR_PARSING, *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 4b17648332c..3646cea52fd 100644 --- a/src/plugins/type/type.c +++ b/src/plugins/type/type.c @@ -94,7 +94,7 @@ bool elektraTypeCheckType (const Key * key) static void elektraTypeSetDefaultError (Plugin * handle ELEKTRA_UNUSED, Key * errorKey, const Key * key) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "The type '%s' failed to match for '%s' with string: %s", getTypeName (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)); } @@ -109,13 +109,13 @@ bool elektraTypeValidateKey (Plugin * handle, Key * key, Key * errorKey) const Type * type = findType (typeName); if (type == NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "Unknown type '%s' for key '%s'", typeName, keyName (key)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "Unknown type '%s' for key '%s'", typeName, keyName (key)); return false; } if (type->normalize != NULL && !type->normalize (handle, key)) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, "The value '%s' of key %s could not be normalized (type is '%s')", + 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); return false; } @@ -128,7 +128,7 @@ bool elektraTypeValidateKey (Plugin * handle, Key * key, Key * errorKey) if (type->restore != NULL && !type->restore (handle, key)) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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); return false; @@ -172,7 +172,7 @@ static kdb_long_long_t readBooleans (KeySet * config, struct boolean_pair ** res *subPos = '\0'; if ((trueKey == NULL) != (falseKey == NULL)) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "You must set both true and false for a boolean pair (config key: '%s')", buffer); elektraFree (*result); *result = NULL; @@ -253,7 +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_TYPE, errorKey, "The value of the config key /boolean/restoreas was invalid!"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, "The value of the config key /boolean/restoreas was invalid!"); elektraFree (data); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -300,7 +300,7 @@ int elektraTypeGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par const Type * type = findType (typeName); if (type == NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Unknown type '%s' for key '%s'", typeName, keyName (cur)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Unknown type '%s' for key '%s'", typeName, keyName (cur)); ksSetCursor (returned, cursor); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -310,7 +310,7 @@ int elektraTypeGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par const Key * orig = keyGetMeta (cur, "origvalue"); if (orig != NULL) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, parentKey, + 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)); @@ -320,7 +320,7 @@ int elektraTypeGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par if (!type->normalize (handle, cur)) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + 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); ksSetCursor (returned, cursor); @@ -359,7 +359,7 @@ int elektraTypeSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par const Type * type = findType (typeName); if (type == NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Unknown type '%s' for key '%s'", typeName, keyName (cur)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Unknown type '%s' for key '%s'", typeName, keyName (cur)); ksSetCursor (returned, cursor); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -370,7 +370,7 @@ 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 (VALIDATION_SEMANTIC_CODE, parentKey, + 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); ksSetCursor (returned, cursor); @@ -387,7 +387,7 @@ int elektraTypeSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par if (type->restore != NULL && !type->restore (handle, cur)) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, + 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); ksSetCursor (returned, cursor); diff --git a/src/plugins/type/types.c b/src/plugins/type/types.c index 1156e8e5778..db1ac76ef8e 100644 --- a/src/plugins/type/types.c +++ b/src/plugins/type/types.c @@ -485,7 +485,7 @@ void elektraTypeSetErrorEnum (Plugin * handle ELEKTRA_UNUSED, Key * errorKey, co if (max == NULL) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, errorKey, + 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)); @@ -518,6 +518,6 @@ void elektraTypeSetErrorEnum (Plugin * handle ELEKTRA_UNUSED, Key * errorKey, co elektraWriteArrayNumber (indexStart, index); } - ELEKTRA_SET_ERROR (VALIDATION_SEMANTIC_CODE, errorKey, errorMessage); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_VALIDATION_SEMANTIC, errorKey, errorMessage); elektraFree (errorMessage); } diff --git a/src/plugins/validation/validation.c b/src/plugins/validation/validation.c index 35d4cc8c2a7..04fa420d80b 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 (VALIDATION_SYNTACTIC_CODE, parentKey, "Could not compile regex: %s", buffer); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SYNTACTIC, parentKey, "Could not compile regex: %s", buffer); regfree (®ex); if (freeString) elektraFree (regexString); return 0; @@ -145,7 +145,7 @@ static int validateKey (Key * key, Key * parentKey) const Key * msg = keyGetMeta (key, "check/validation/message"); if (msg) { - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Key value failed to validate: %s", keyString (msg)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, parentKey, "Key value failed to validate: %s", keyString (msg)); regfree (®ex); if (freeString) elektraFree (regexString); return 0; @@ -154,7 +154,7 @@ static int validateKey (Key * key, Key * parentKey) { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - ELEKTRA_SET_ERRORF (VALIDATION_SEMANTIC_CODE, parentKey, "Key value failed to validate: %s", buffer); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_VALIDATION_SEMANTIC, 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 882f14829d8..0d339c8bf63 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 (INSTALLATION_CODE, errorKey, "could not get ALLUSERSPROFILE for spec, using /"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not get ALLUSERSPROFILE for spec, using /"); } else { @@ -163,12 +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 (RESOURCE_CODE, warningsKey, "GetCurrentDirectory failed: %s, defaulting to /", buf); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "GetCurrentDirectory failed: %s, defaulting to /", buf); dir[0] = 0; } else if (dwRet > MAX_PATH) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, warningsKey, "GetCurrentDirectory failed, buffer size too small, needed: %ld", dwRet); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "GetCurrentDirectory failed, buffer size too small, needed: %ld", dwRet); dir[0] = 0; } escapePath (dir); @@ -176,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 (RESOURCE_CODE, warningsKey, "getcwd failed: %s, defaulting to /", strerror (errno)); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, warningsKey, "getcwd failed: %s, defaulting to /", strerror (errno)); dir[0] = 0; } #endif @@ -202,14 +202,14 @@ static void elektraResolveUser (resolverHandle * p, Key * warningsKey) else { strcpy (home, ""); - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, warningsKey, "could not get home (CSIDL_PROFILE), using /"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, warningsKey, "could not get home (CSIDL_PROFILE), using /"); } #else char * home = (char *) getenv ("HOME"); if (!home) { home = ""; - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, warningsKey, "could not get home, using /"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, warningsKey, "could not get home, using /"); } #endif @@ -225,7 +225,7 @@ static void elektraResolveSystem (resolverHandle * p, Key * errorKey) if (!system) { system = ""; - ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "could not get ALLUSERSPROFILE, using /"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "could not get ALLUSERSPROFILE, using /"); } else { @@ -257,7 +257,7 @@ int elektraWresolverOpen (Plugin * handle, Key * errorKey) if (!path) { - ELEKTRA_SET_ERROR (RESOURCE_CODE, errorKey, "Could not find file configuration"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, errorKey, "Could not find file configuration"); return -1; } @@ -385,7 +385,7 @@ int elektraWresolverSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key switch (pk->state) { case 0: - ELEKTRA_SET_ERROR (INSTALLATION_CODE, parentKey, "kdbSet() called before kdbGet()"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_INSTALLATION, parentKey, "kdbSet() called before kdbGet()"); return -1; case 1: ++pk->state; @@ -409,7 +409,7 @@ int elektraWresolverSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key if (stat (pk->filename, &buf) == -1) { - ELEKTRA_ADD_WARNINGF (RESOURCE_CODE, parentKey, "could not stat config file \"%s\", ", pk->filename); + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_RESOURCE, parentKey, "could not stat config file \"%s\", ", pk->filename); // no file found, nothing to do return 0; } @@ -419,7 +419,7 @@ int elektraWresolverSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key { // conflict ELEKTRA_SET_ERRORF ( - CONFLICT_CODE, parentKey, + ELEKTRA_ERROR_CONFLICT, 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 93a79196c83..888daafc030 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 (RESOURCE_CODE, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, asCStr (e.getMessage ())); } catch (const XMLException & e) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, asCStr (e.getMessage ())); } catch (const DOMException & e) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, asCStr (e.getMessage ())); } catch (const XercesPluginException & e) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, e.what ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, e.what ()); } catch (...) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, "Unknown exception occurred while reading xml file"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (RESOURCE_CODE, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_RESOURCE, parentKey, asCStr (e.getMessage ())); } catch (const XMLException & e) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, asCStr (e.getMessage ())); } catch (const DOMException & e) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, asCStr (e.getMessage ())); } catch (const XercesPluginException & e) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, e.what ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parentKey, e.what ()); } catch (...) { - ELEKTRA_SET_ERROR (PARSING_CODE, parentKey, "Unknown exception occurred while writing xml file"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 ded5797cce4..723245812b2 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 (VALIDATION_SEMANTIC_CODE, parentKey, "got boolean which is neither true nor false"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_VALIDATION_SEMANTIC, parentKey, "got boolean which is neither true nor false"); yajl_gen_string (g, (const unsigned char *) keyString (cur), keyGetValueSize (cur) - 1); } } @@ -173,7 +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 (VALIDATION_SEMANTIC_CODE, parentKey, "the key %s has unknown type: %s", keyName (cur), + ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_VALIDATION_SEMANTIC, 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 25041f9c9d4..2bd88ff59a0 100644 --- a/src/plugins/yajl/yajl_parse.c +++ b/src/plugins/yajl/yajl_parse.c @@ -395,7 +395,7 @@ int elektraYajlGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par { if (!feof (fileHandle)) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Error while reading file: %s", keyString (parentKey)); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Error while reading file: %s", keyString (parentKey)); fclose (fileHandle); yajl_free (hand); return -1; @@ -424,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 (PARSING_CODE, parentKey, (char *) str); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 2495d2a162b..aba2e9b9e9a 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 (RESOURCE_CODE, parent.getKey (), "Unable to open file “%s”", filename.c_str ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parent.getKey (), "Unable to open file “%s”", filename.c_str ()); } else if (status == -2) { - ELEKTRA_SET_ERROR (PARSING_CODE, parent.getKey (), "Parsing failed due to memory exhaustion"); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parent.getKey (), "Parsing failed due to memory exhaustion"); } else if (status == -1) { - ELEKTRA_SET_ERROR (PARSING_CODE, parent.getKey (), driver.getErrorMessage ().c_str ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, parent.getKey (), driver.getErrorMessage ().c_str ()); } return status; diff --git a/src/plugins/yambi/yambi.cpp b/src/plugins/yambi/yambi.cpp index 0c13fb51b9e..ad6a4750a73 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 (PARSING_CODE, *parent, runtimeError.what ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, *parent, runtimeError.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, *parent, "Uncaught exception: %s", error.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught exception: %s", error.what ()); } parent.release (); diff --git a/src/plugins/yamlcpp/yamlcpp.cpp b/src/plugins/yamlcpp/yamlcpp.cpp index a4196a06a64..4808c700885 100644 --- a/src/plugins/yamlcpp/yamlcpp.cpp +++ b/src/plugins/yamlcpp/yamlcpp.cpp @@ -75,7 +75,7 @@ int elektraYamlcppGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * } catch (YAML::ParserException const & exception) { - ELEKTRA_SET_ERRORF (PARSING_CODE, parent.getKey (), "Unable to parse file “%s”: %s.", parent.getString ().c_str (), + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, parent.getKey (), "Unable to parse file “%s”: %s.", parent.getString ().c_str (), exception.what ()); } catch (std::overflow_error const & exception) @@ -85,7 +85,7 @@ int elektraYamlcppGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * } catch (YAML::RepresentationException const & exception) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parent.getKey (), "Unable to read data from file “%s”: %s", parent.getString ().c_str (), + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parent.getKey (), "Unable to read data from file “%s”: %s", parent.getString ().c_str (), exception.what ()); } @@ -115,12 +115,12 @@ int elektraYamlcppSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * } catch (YAML::BadFile const & exception) { - ELEKTRA_SET_ERRORF (RESOURCE_CODE, parent.getKey (), "Unable to write to file “%s”: %s.", parent.getString ().c_str (), + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parent.getKey (), "Unable to write to file “%s”: %s.", parent.getString ().c_str (), exception.what ()); } catch (YAML::EmitterException const & exception) { - ELEKTRA_SET_ERRORF (LOGICAL_CODE, parent.getKey (), "Something went wrong while emitting YAML data to file “%s”: %s.", + 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 ()); } diff --git a/src/plugins/yamlsmith/yamlsmith.cpp b/src/plugins/yamlsmith/yamlsmith.cpp index a4b9bc54b8e..0932e94cb16 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 (RESOURCE_CODE, parent.getKey (), "Unable to open file “%s”", parent.getString ().c_str ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 8ff7e7ba6ae..f2b468526be 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 (PARSING_CODE, parent.getKey (), errorListener.message ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 (RESOURCE_CODE, parent.getKey (), "Unable to open file “%s”", parent.getString ().c_str ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, 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 101a10bbc15..71f4543ffee 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 (PARSING_CODE, error.getKey (), "Unable to parse grammar: %s", parser.error_message ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, 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 (RESOURCE_CODE, error.getKey (), "Unable to open file “%s”", filename.c_str ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, error.getKey (), "Unable to open file “%s”", filename.c_str ()); } return input; } @@ -143,7 +143,7 @@ int handleErrors (int const ambiguousOutput, ErrorListener const & errorListener if (ambiguousOutput) { ELEKTRA_SET_ERRORF ( - PARSING_CODE, error.getKey (), + ELEKTRA_ERROR_PARSING, 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 (PARSING_CODE, error.getKey (), errorListener.getErrorMessage ().c_str ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, 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 8d22f769ec5..d5721d337a6 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 (PARSING_CODE, *parent, runtimeError.what ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, *parent, runtimeError.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, *parent, "Uncaught exception: %s", error.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught exception: %s", error.what ()); } parent.release (); diff --git a/src/plugins/yaypeg/yaypeg.cpp b/src/plugins/yaypeg/yaypeg.cpp index f1945cba75a..c8bbd46485f 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 (PARSING_CODE, *parent, runtimeError.what ()); + ELEKTRA_SET_ERROR (ELEKTRA_ERROR_PARSING, *parent, runtimeError.what ()); } catch (exception const & error) { - ELEKTRA_SET_ERRORF (INSTALLATION_CODE, *parent, "Uncaught exception: %s", error.what ()); + ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, *parent, "Uncaught exception: %s", error.what ()); } parent.release (); diff --git a/src/plugins/zeromqsend/zeromqsend.c b/src/plugins/zeromqsend/zeromqsend.c index d3bf932c404..8f1f97188b5 100644 --- a/src/plugins/zeromqsend/zeromqsend.c +++ b/src/plugins/zeromqsend/zeromqsend.c @@ -113,13 +113,13 @@ int elektraZeroMqSendSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key break; case -1: // connection timeout - hub not running - ELEKTRA_ADD_WARNING (TIMEOUT_CODE, parentKey, "could not connect to hub. Please start hub using `kdb run-hub-zeromq`."); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_TIMEOUT, 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 (INSTALLATION_CODE, parentKey, "could not send notifications"); + ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, parentKey, "could not send notifications"); break; }