1 <?xml version='
1.0'
?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
8 This file is part of systemd.
10 Copyright 2015 Lennart Poettering
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 <refentry id=
"sd_bus_error_add_map">
29 <title>sd_bus_error_add_map
</title>
30 <productname>systemd
</productname>
34 <contrib>Developer
</contrib>
35 <firstname>Lennart
</firstname>
36 <surname>Poettering
</surname>
37 <email>lennart@poettering.net
</email>
43 <refentrytitle>sd_bus_error_add_map
</refentrytitle>
44 <manvolnum>3</manvolnum>
48 <refname>sd_bus_error_add_map
</refname>
49 <refname>sd_bus_error_map
</refname>
50 <refname>SD_BUS_ERROR_MAP
</refname>
51 <refname>SD_BUS_ERROR_END
</refname>
53 <refpurpose>Additional sd-dbus error mappings
</refpurpose>
58 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
60 <funcsynopsisinfo>typedef struct {
64 } sd_bus_error_map;
</funcsynopsisinfo>
69 <constant>SD_BUS_ERROR_MAP(
<replaceable>name
</replaceable>,
<replaceable>code
</replaceable>)
</constant>
72 <constant>SD_BUS_ERROR_MAP_END
</constant>
76 <funcdef>int
<function>sd_bus_error_add_map
</function></funcdef>
77 <paramdef>const sd_bus_map *
<parameter>map
</parameter></paramdef>
83 <title>Description
</title>
85 <para>The
<function>sd_bus_error_add_map()
</function> call may be
86 used to register additional mappings for converting D-Bus errors
87 to Linux
<varname>errno
</varname>-style errors. The mappings
88 defined with this call are consulted by calls such as
89 <citerefentry><refentrytitle>sd_bus_error_set
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
91 <citerefentry><refentrytitle>sd_bus_error_get_errno
</refentrytitle><manvolnum>3</manvolnum></citerefentry>. By
92 default, a number of generic, standardized mappings are known, as
94 <citerefentry><refentrytitle>sd-bus-errors
</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Use
95 this call to add further, application-specific mappings.
</para>
97 <para>The function takes a pointer to an array of
98 <structname>sd_bus_error_map
</structname> structures. A reference
99 to the specified array is added to the lookup tables for error
100 mappings. Note that the structure is not copied, and that it is hence
101 essential that the array stays available and constant during the
102 entire remaining runtime of the process.
</para>
104 <para>The mapping array should be put together with a series of
105 <constant>SD_BUS_ERROR_MAP()
</constant> macro invocations that
106 take a literal name string and a (positive)
107 <varname>errno
</varname>-style error number. The last entry of the
108 array should be an invocation of the
109 <constant>SD_BUS_ERROR_MAP_END
</constant> macro. The array should not be
110 put together without use of these two macros.
</para>
112 <para>Note that the call is idempotent: it is safe to invoke it
113 multiple times with the parameter, which will only add the passed
114 mapping array once.
</para>
116 <para>Note that the memory allocated by this call is not intended
117 to be freed during the lifetime of the process. It should not be
118 freed explicitly.
</para>
122 <title>Return Value
</title>
124 <para><function>sd_bus_error_add_map()
</function> returns a
125 positive value when the new array was added to the lookup
126 tables. It returns zero when the same array was already added
127 before. On error, a negative
<varname>errno
</varname>-style error
128 code is returned. See below for known error codes.
</para>
132 <title>Errors
</title>
134 <para>Returned errors may indicate the following problems:
</para>
139 <term><constant>-EINVAL
</constant></term>
141 <listitem><para>The specified mapping array is invalid.
</para></listitem>
145 <term><constant>-ENOMEM
</constant></term>
147 <listitem><para>Memory allocation failed.
</para></listitem>
155 <para>The various error definitions described here are available
156 as a shared library, which can be compiled and linked to with the
157 <constant>libsystemd
</constant> <citerefentry
158 project='die-net'
><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
163 <title>See Also
</title>
166 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
167 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
168 <citerefentry><refentrytitle>sd_bus_error
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
169 <citerefentry><refentrytitle>sd-bus-errors
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
170 <citerefentry project='man-pages'
><refentrytitle>errno
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
171 <citerefentry project='die-net'
><refentrytitle>strerror_r
</refentrytitle><manvolnum>3</manvolnum></citerefentry>