]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
0307f791 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> |
9d3e5d11 | 5 | |
7647c01d LP |
6 | <refentry id="sd_bus_error_add_map" |
7 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
9d3e5d11 LP |
8 | |
9 | <refentryinfo> | |
10 | <title>sd_bus_error_add_map</title> | |
11 | <productname>systemd</productname> | |
9d3e5d11 LP |
12 | </refentryinfo> |
13 | ||
14 | <refmeta> | |
15 | <refentrytitle>sd_bus_error_add_map</refentrytitle> | |
16 | <manvolnum>3</manvolnum> | |
17 | </refmeta> | |
18 | ||
19 | <refnamediv> | |
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> | |
24 | ||
25 | <refpurpose>Additional sd-dbus error mappings</refpurpose> | |
26 | </refnamediv> | |
27 | ||
28 | <refsynopsisdiv> | |
29 | <funcsynopsis> | |
30 | <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> | |
31 | ||
32 | <funcsynopsisinfo>typedef struct { | |
33 | const char *name; | |
34 | int code; | |
1eecafb8 | 35 | … |
9d3e5d11 LP |
36 | } sd_bus_error_map;</funcsynopsisinfo> |
37 | ||
38 | </funcsynopsis> | |
39 | ||
40 | <para> | |
41 | <constant>SD_BUS_ERROR_MAP(<replaceable>name</replaceable>, <replaceable>code</replaceable>)</constant> | |
42 | </para> | |
43 | <para> | |
44 | <constant>SD_BUS_ERROR_MAP_END</constant> | |
45 | </para> | |
46 | ||
47 | <funcprototype> | |
48 | <funcdef>int <function>sd_bus_error_add_map</function></funcdef> | |
49 | <paramdef>const sd_bus_map *<parameter>map</parameter></paramdef> | |
50 | </funcprototype> | |
51 | ||
52 | </refsynopsisdiv> | |
53 | ||
54 | <refsect1> | |
55 | <title>Description</title> | |
56 | ||
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> | |
62 | or | |
63 | <citerefentry><refentrytitle>sd_bus_error_get_errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>. By | |
b938cb90 | 64 | default, a number of generic, standardized mappings are known, as |
9d3e5d11 LP |
65 | documented in |
66 | <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Use | |
67 | this call to add further, application-specific mappings.</para> | |
68 | ||
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 | |
a8eaaee7 | 72 | mappings. Note that the structure is not copied, and that it is hence |
9d3e5d11 LP |
73 | essential that the array stays available and constant during the |
74 | entire remaining runtime of the process.</para> | |
75 | ||
76 | <para>The mapping array should be put together with a series of | |
b938cb90 | 77 | <constant>SD_BUS_ERROR_MAP()</constant> macro invocations that |
9d3e5d11 LP |
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> | |
83 | ||
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> | |
87 | ||
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> | |
91 | </refsect1> | |
92 | ||
93 | <refsect1> | |
94 | <title>Return Value</title> | |
95 | ||
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> | |
101 | </refsect1> | |
102 | ||
103 | <refsect1> | |
104 | <title>Errors</title> | |
105 | ||
106 | <para>Returned errors may indicate the following problems:</para> | |
107 | ||
108 | <variablelist> | |
109 | ||
110 | <varlistentry> | |
111 | <term><constant>-EINVAL</constant></term> | |
112 | ||
113 | <listitem><para>The specified mapping array is invalid.</para></listitem> | |
114 | </varlistentry> | |
115 | ||
116 | <varlistentry> | |
117 | <term><constant>-ENOMEM</constant></term> | |
118 | ||
119 | <listitem><para>Memory allocation failed.</para></listitem> | |
120 | </varlistentry> | |
121 | </variablelist> | |
122 | </refsect1> | |
123 | ||
7647c01d | 124 | <xi:include href="libsystemd-pkgconfig.xml" /> |
9d3e5d11 LP |
125 | |
126 | <refsect1> | |
127 | <title>See Also</title> | |
128 | ||
129 | <para> | |
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> | |
136 | </para> | |
137 | </refsect1> | |
138 | ||
139 | </refentry> |