2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
6 <refentry id=
"sd_bus_error_add_map"
7 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
10 <title>sd_bus_error_add_map
</title>
11 <productname>systemd
</productname>
15 <refentrytitle>sd_bus_error_add_map
</refentrytitle>
16 <manvolnum>3</manvolnum>
20 <refname>sd_bus_error_add_map
</refname>
21 <refname>sd_bus_error_map
</refname>
22 <refname>SD_BUS_ERROR_MAP
</refname>
23 <refname>SD_BUS_ERROR_END
</refname>
25 <refpurpose>Additional sd-dbus error mappings
</refpurpose>
30 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
32 <funcsynopsisinfo>typedef struct {
36 } sd_bus_error_map;
</funcsynopsisinfo>
41 <constant>SD_BUS_ERROR_MAP(
<replaceable>name
</replaceable>,
<replaceable>code
</replaceable>)
</constant>
44 <constant>SD_BUS_ERROR_MAP_END
</constant>
48 <funcdef>int
<function>sd_bus_error_add_map
</function></funcdef>
49 <paramdef>const sd_bus_map *
<parameter>map
</parameter></paramdef>
55 <title>Description
</title>
57 <para>The
<function>sd_bus_error_add_map()
</function> call may be
58 used to register additional mappings for converting D-Bus errors
59 to Linux
<varname>errno
</varname>-style errors. The mappings
60 defined with this call are consulted by calls such as
61 <citerefentry><refentrytitle>sd_bus_error_set
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
63 <citerefentry><refentrytitle>sd_bus_error_get_errno
</refentrytitle><manvolnum>3</manvolnum></citerefentry>. By
64 default, a number of generic, standardized mappings are known, as
66 <citerefentry><refentrytitle>sd-bus-errors
</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Use
67 this call to add further, application-specific mappings.
</para>
69 <para>The function takes a pointer to an array of
70 <structname>sd_bus_error_map
</structname> structures. A reference
71 to the specified array is added to the lookup tables for error
72 mappings. Note that the structure is not copied, and that it is hence
73 essential that the array stays available and constant during the
74 entire remaining runtime of the process.
</para>
76 <para>The mapping array should be put together with a series of
77 <constant>SD_BUS_ERROR_MAP()
</constant> macro invocations that
78 take a literal name string and a (positive)
79 <varname>errno
</varname>-style error number. The last entry of the
80 array should be an invocation of the
81 <constant>SD_BUS_ERROR_MAP_END
</constant> macro. The array should not be
82 put together without use of these two macros.
</para>
84 <para>Note that the call is idempotent: it is safe to invoke it
85 multiple times with the parameter, which will only add the passed
86 mapping array once.
</para>
88 <para>Note that the memory allocated by this call is not intended
89 to be freed during the lifetime of the process. It should not be
90 freed explicitly.
</para>
94 <title>Return Value
</title>
96 <para><function>sd_bus_error_add_map()
</function> returns a
97 positive value when the new array was added to the lookup
98 tables. It returns zero when the same array was already added
99 before. On error, a negative
<varname>errno
</varname>-style error
100 code is returned. See below for known error codes.
</para>
103 <title>Errors
</title>
105 <para>Returned errors may indicate the following problems:
</para>
110 <term><constant>-EINVAL
</constant></term>
112 <listitem><para>The specified mapping array is invalid.
</para></listitem>
116 <term><constant>-ENOMEM
</constant></term>
118 <listitem><para>Memory allocation failed.
</para></listitem>
124 <xi:include href=
"libsystemd-pkgconfig.xml" />
127 <title>See Also
</title>
130 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
131 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
132 <citerefentry><refentrytitle>sd_bus_error
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
133 <citerefentry><refentrytitle>sd-bus-errors
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
134 <citerefentry project='man-pages'
><refentrytitle>errno
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135 <citerefentry project='die-net'
><refentrytitle>strerror_r
</refentrytitle><manvolnum>3</manvolnum></citerefentry>