| 1 |
'\" t |
| 2 |
.TH "SD_BUS_ERROR_ADD_MAP" "3" "" "systemd 261~rc3" "sd_bus_error_add_map" |
| 3 |
.\" ----------------------------------------------------------------- |
| 4 |
.\" * Define some portability stuff |
| 5 |
.\" ----------------------------------------------------------------- |
| 6 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 7 |
.\" http://bugs.debian.org/507673 |
| 8 |
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
| 9 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 |
.ie \n(.g .ds Aq \(aq |
| 11 |
.el .ds Aq ' |
| 12 |
.\" ----------------------------------------------------------------- |
| 13 |
.\" * set default formatting |
| 14 |
.\" ----------------------------------------------------------------- |
| 15 |
.\" disable hyphenation |
| 16 |
.nh |
| 17 |
.\" disable justification (adjust text to left margin only) |
| 18 |
.ad l |
| 19 |
.\" ----------------------------------------------------------------- |
| 20 |
.\" * MAIN CONTENT STARTS HERE * |
| 21 |
.\" ----------------------------------------------------------------- |
| 22 |
.SH "NAME" |
| 23 |
sd_bus_error_add_map, sd_bus_error_map, SD_BUS_ERROR_MAP, SD_BUS_ERROR_END \- Additional sd\-dbus error mappings |
| 24 |
.SH "SYNOPSIS" |
| 25 |
.sp |
| 26 |
.ft B |
| 27 |
.nf |
| 28 |
#include <systemd/sd\-bus\&.h> |
| 29 |
.fi |
| 30 |
.ft |
| 31 |
.sp |
| 32 |
.ft B |
| 33 |
.nf |
| 34 |
typedef struct { |
| 35 |
const char *name; |
| 36 |
int code; |
| 37 |
\&... |
| 38 |
} sd_bus_error_map; |
| 39 |
.fi |
| 40 |
.ft |
| 41 |
.sp |
| 42 |
.ft B |
| 43 |
.nf |
| 44 |
\fBSD_BUS_ERROR_MAP(\fR\fB\fIname\fR\fR\fB, \fR\fB\fIcode\fR\fR\fB)\fR |
| 45 |
.fi |
| 46 |
.ft |
| 47 |
.sp |
| 48 |
.ft B |
| 49 |
.nf |
| 50 |
\fBSD_BUS_ERROR_MAP_END\fR |
| 51 |
.fi |
| 52 |
.ft |
| 53 |
.HP \w'int\ sd_bus_error_add_map('u |
| 54 |
.BI "int sd_bus_error_add_map(const\ sd_bus_error_map\ *" "map" ");" |
| 55 |
.SH "DESCRIPTION" |
| 56 |
.PP |
| 57 |
The |
| 58 |
\fBsd_bus_error_add_map()\fR |
| 59 |
call may be used to register additional mappings for converting D\-Bus errors to Linux |
| 60 |
\fIerrno\fR\-style errors\&. The mappings defined with this call are consulted by calls such as |
| 61 |
\fBsd_bus_error_set\fR(3) |
| 62 |
or |
| 63 |
\fBsd_bus_error_get_errno\fR(3)\&. By default, a number of generic, standardized mappings are known, as documented in |
| 64 |
\fBsd-bus-errors\fR(3)\&. Use this call to add further, application\-specific mappings\&. |
| 65 |
.PP |
| 66 |
The function takes a pointer to an array of |
| 67 |
sd_bus_error_map |
| 68 |
structures\&. A reference to the specified array is added to the lookup tables for error mappings\&. Note that the structure is not copied, and that it is hence essential that the array stays available and constant during the entire remaining runtime of the process\&. |
| 69 |
.PP |
| 70 |
The mapping array should be put together with a series of |
| 71 |
\fBSD_BUS_ERROR_MAP()\fR |
| 72 |
macro invocations that take a literal name string and a (positive) |
| 73 |
\fIerrno\fR\-style error number\&. The last entry of the array should be an invocation of the |
| 74 |
\fBSD_BUS_ERROR_MAP_END\fR |
| 75 |
macro\&. The array should not be put together without use of these two macros\&. |
| 76 |
.PP |
| 77 |
Note that the call is idempotent: it is safe to invoke it multiple times with the parameter, which will only add the passed mapping array once\&. |
| 78 |
.PP |
| 79 |
Note that the memory allocated by this call is not intended to be freed during the lifetime of the process\&. It should not be freed explicitly\&. |
| 80 |
.SH "RETURN VALUE" |
| 81 |
.PP |
| 82 |
\fBsd_bus_error_add_map()\fR |
| 83 |
returns a positive value when the new array was added to the lookup tables\&. It returns zero when the same array was already added before\&. On error, a negative |
| 84 |
\fIerrno\fR\-style error code is returned\&. See below for known error codes\&. |
| 85 |
.SS "Errors" |
| 86 |
.PP |
| 87 |
Returned errors may indicate the following problems: |
| 88 |
.PP |
| 89 |
\fB\-EINVAL\fR |
| 90 |
.RS 4 |
| 91 |
The specified mapping array is invalid\&. |
| 92 |
.RE |
| 93 |
.PP |
| 94 |
\fB\-ENOMEM\fR |
| 95 |
.RS 4 |
| 96 |
Memory allocation failed\&. |
| 97 |
.RE |
| 98 |
.SH "NOTES" |
| 99 |
.PP |
| 100 |
Functions described here are available as a shared library, which can be compiled against and linked to with the |
| 101 |
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1) |
| 102 |
file\&. |
| 103 |
.PP |
| 104 |
The code described here uses |
| 105 |
\fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call |
| 106 |
\fBsetenv\fR(3) |
| 107 |
from a parallel thread\&. It is recommended to only do calls to |
| 108 |
\fBsetenv()\fR |
| 109 |
from an early phase of the program when no other threads have been started\&. |
| 110 |
.SH "HISTORY" |
| 111 |
.PP |
| 112 |
\fBsd_bus_error_add_map()\fR |
| 113 |
was added in version 221\&. |
| 114 |
.SH "SEE ALSO" |
| 115 |
.PP |
| 116 |
\fBsystemd\fR(1), \fBsd-bus\fR(3), \fBsd_bus_error\fR(3), \fBsd-bus-errors\fR(3), \fBerrno\fR(3), \fBstrerror_r\fR(3) |