1SD_BUS_ERROR_ADD_MAP(3) sd_bus_error_add_map SD_BUS_ERROR_ADD_MAP(3)
2
3
4
6 sd_bus_error_add_map, sd_bus_error_map, SD_BUS_ERROR_MAP,
7 SD_BUS_ERROR_END - Additional sd-dbus error mappings
8
10 #include <systemd/sd-bus.h>
11
12 typedef struct {
13 const char *name;
14 int code;
15 ...
16 } sd_bus_error_map;
17
18 SD_BUS_ERROR_MAP(name, code)
19
20 SD_BUS_ERROR_MAP_END
21
22 int sd_bus_error_add_map(const sd_bus_error_map *map);
23
25 The sd_bus_error_add_map() call may be used to register additional
26 mappings for converting D-Bus errors to Linux errno-style errors. The
27 mappings defined with this call are consulted by calls such as
28 sd_bus_error_set(3) or sd_bus_error_get_errno(3). By default, a number
29 of generic, standardized mappings are known, as documented in sd-bus-
30 errors(3). Use this call to add further, application-specific mappings.
31
32 The function takes a pointer to an array of sd_bus_error_map
33 structures. A reference to the specified array is added to the lookup
34 tables for error mappings. Note that the structure is not copied, and
35 that it is hence essential that the array stays available and constant
36 during the entire remaining runtime of the process.
37
38 The mapping array should be put together with a series of
39 SD_BUS_ERROR_MAP() macro invocations that take a literal name string
40 and a (positive) errno-style error number. The last entry of the array
41 should be an invocation of the SD_BUS_ERROR_MAP_END macro. The array
42 should not be put together without use of these two macros.
43
44 Note that the call is idempotent: it is safe to invoke it multiple
45 times with the parameter, which will only add the passed mapping array
46 once.
47
48 Note that the memory allocated by this call is not intended to be freed
49 during the lifetime of the process. It should not be freed explicitly.
50
52 sd_bus_error_add_map() returns a positive value when the new array was
53 added to the lookup tables. It returns zero when the same array was
54 already added before. On error, a negative errno-style error code is
55 returned. See below for known error codes.
56
57 Errors
58 Returned errors may indicate the following problems:
59
60 -EINVAL
61 The specified mapping array is invalid.
62
63 -ENOMEM
64 Memory allocation failed.
65
67 These APIs are implemented as a shared library, which can be compiled
68 and linked to with the libsystemd pkg-config(1) file.
69
71 systemd(1), sd-bus(3), sd_bus_error(3), sd-bus-errors(3), errno(3),
72 strerror_r(3)
73
74
75
76systemd 251 SD_BUS_ERROR_ADD_MAP(3)