#include <systemd/sd-bus.h>
typedef struct { const char *name; int code; ... } sd_bus_error_map;
SD_BUS_ERROR_MAP(name, code)
SD_BUS_ERROR_MAP_END
The function takes a pointer to an array of sd_bus_error_map structures. A reference to the specified array is added to the lookup tables for error mappings. Note that the structure is not copied, and that it is hence essential that the array stays available and constant during the entire remaining runtime of the process.
The mapping array should be put together with a series of SD_BUS_ERROR_MAP() macro invocations that take a literal name string and a (positive) errno-style error number. The last entry of the array should be an invocation of the SD_BUS_ERROR_MAP_END macro. The array should not be put together without use of these two macros.
Note that the call is idempotent: it is safe to invoke it multiple times with the parameter, which will only add the passed mapping array once.
Note that the memory allocated by this call is not intended to be freed during the lifetime of the process. It should not be freed explicitly.
sd_bus_error_add_map() returns a positive value when the new array was added to the lookup tables. It returns zero when the same array was already added before. On error, a negative errno-style error code is returned. See below for known error codes.
Returned errors may indicate the following problems:
-EINVAL
-ENOMEM
These APIs are implemented as a shared library, which can be compiled and linked to with the libsystemd pkg-config(1) file.
systemd(1), sd-bus(3), sd_bus_error(3), sd-bus-errors(3), errno(3), strerror_r(3)