]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
9d3e5d11 LP |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | ||
5 | <!-- | |
572eb058 | 6 | SPDX-License-Identifier: LGPL-2.1+ |
9d3e5d11 LP |
7 | --> |
8 | ||
7647c01d LP |
9 | <refentry id="sd_bus_error_add_map" |
10 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
9d3e5d11 LP |
11 | |
12 | <refentryinfo> | |
13 | <title>sd_bus_error_add_map</title> | |
14 | <productname>systemd</productname> | |
9d3e5d11 LP |
15 | </refentryinfo> |
16 | ||
17 | <refmeta> | |
18 | <refentrytitle>sd_bus_error_add_map</refentrytitle> | |
19 | <manvolnum>3</manvolnum> | |
20 | </refmeta> | |
21 | ||
22 | <refnamediv> | |
23 | <refname>sd_bus_error_add_map</refname> | |
24 | <refname>sd_bus_error_map</refname> | |
25 | <refname>SD_BUS_ERROR_MAP</refname> | |
26 | <refname>SD_BUS_ERROR_END</refname> | |
27 | ||
28 | <refpurpose>Additional sd-dbus error mappings</refpurpose> | |
29 | </refnamediv> | |
30 | ||
31 | <refsynopsisdiv> | |
32 | <funcsynopsis> | |
33 | <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> | |
34 | ||
35 | <funcsynopsisinfo>typedef struct { | |
36 | const char *name; | |
37 | int code; | |
1eecafb8 | 38 | … |
9d3e5d11 LP |
39 | } sd_bus_error_map;</funcsynopsisinfo> |
40 | ||
41 | </funcsynopsis> | |
42 | ||
43 | <para> | |
44 | <constant>SD_BUS_ERROR_MAP(<replaceable>name</replaceable>, <replaceable>code</replaceable>)</constant> | |
45 | </para> | |
46 | <para> | |
47 | <constant>SD_BUS_ERROR_MAP_END</constant> | |
48 | </para> | |
49 | ||
50 | <funcprototype> | |
51 | <funcdef>int <function>sd_bus_error_add_map</function></funcdef> | |
52 | <paramdef>const sd_bus_map *<parameter>map</parameter></paramdef> | |
53 | </funcprototype> | |
54 | ||
55 | </refsynopsisdiv> | |
56 | ||
57 | <refsect1> | |
58 | <title>Description</title> | |
59 | ||
60 | <para>The <function>sd_bus_error_add_map()</function> call may be | |
61 | used to register additional mappings for converting D-Bus errors | |
62 | to Linux <varname>errno</varname>-style errors. The mappings | |
63 | defined with this call are consulted by calls such as | |
64 | <citerefentry><refentrytitle>sd_bus_error_set</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
65 | or | |
66 | <citerefentry><refentrytitle>sd_bus_error_get_errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>. By | |
b938cb90 | 67 | default, a number of generic, standardized mappings are known, as |
9d3e5d11 LP |
68 | documented in |
69 | <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Use | |
70 | this call to add further, application-specific mappings.</para> | |
71 | ||
72 | <para>The function takes a pointer to an array of | |
73 | <structname>sd_bus_error_map</structname> structures. A reference | |
74 | to the specified array is added to the lookup tables for error | |
a8eaaee7 | 75 | mappings. Note that the structure is not copied, and that it is hence |
9d3e5d11 LP |
76 | essential that the array stays available and constant during the |
77 | entire remaining runtime of the process.</para> | |
78 | ||
79 | <para>The mapping array should be put together with a series of | |
b938cb90 | 80 | <constant>SD_BUS_ERROR_MAP()</constant> macro invocations that |
9d3e5d11 LP |
81 | take a literal name string and a (positive) |
82 | <varname>errno</varname>-style error number. The last entry of the | |
83 | array should be an invocation of the | |
84 | <constant>SD_BUS_ERROR_MAP_END</constant> macro. The array should not be | |
85 | put together without use of these two macros.</para> | |
86 | ||
87 | <para>Note that the call is idempotent: it is safe to invoke it | |
88 | multiple times with the parameter, which will only add the passed | |
89 | mapping array once.</para> | |
90 | ||
91 | <para>Note that the memory allocated by this call is not intended | |
92 | to be freed during the lifetime of the process. It should not be | |
93 | freed explicitly.</para> | |
94 | </refsect1> | |
95 | ||
96 | <refsect1> | |
97 | <title>Return Value</title> | |
98 | ||
99 | <para><function>sd_bus_error_add_map()</function> returns a | |
100 | positive value when the new array was added to the lookup | |
101 | tables. It returns zero when the same array was already added | |
102 | before. On error, a negative <varname>errno</varname>-style error | |
103 | code is returned. See below for known error codes.</para> | |
104 | </refsect1> | |
105 | ||
106 | <refsect1> | |
107 | <title>Errors</title> | |
108 | ||
109 | <para>Returned errors may indicate the following problems:</para> | |
110 | ||
111 | <variablelist> | |
112 | ||
113 | <varlistentry> | |
114 | <term><constant>-EINVAL</constant></term> | |
115 | ||
116 | <listitem><para>The specified mapping array is invalid.</para></listitem> | |
117 | </varlistentry> | |
118 | ||
119 | <varlistentry> | |
120 | <term><constant>-ENOMEM</constant></term> | |
121 | ||
122 | <listitem><para>Memory allocation failed.</para></listitem> | |
123 | </varlistentry> | |
124 | </variablelist> | |
125 | </refsect1> | |
126 | ||
7647c01d | 127 | <xi:include href="libsystemd-pkgconfig.xml" /> |
9d3e5d11 LP |
128 | |
129 | <refsect1> | |
130 | <title>See Also</title> | |
131 | ||
132 | <para> | |
133 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
134 | <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
135 | <citerefentry><refentrytitle>sd_bus_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
136 | <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
137 | <citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
138 | <citerefentry project='die-net'><refentrytitle>strerror_r</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
139 | </para> | |
140 | </refsect1> | |
141 | ||
142 | </refentry> |