1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
'\" t
.TH "SD_BUS_MESSAGE_READ_BASIC" "3" "" "systemd 255" "sd_bus_message_read_basic"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
sd_bus_message_read_basic \- Read a basic type from a message
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-bus\&.h>
.fi
.ft
.HP \w'int\ sd_bus_message_read_basic('u
.BI "int sd_bus_message_read_basic(sd_bus_message\ *" "m" ", char\ " "type" ", void\ *" "p" ");"
.SH "DESCRIPTION"
.PP
\fBsd_bus_message_read_basic()\fR
reads a basic type from a message and advances the read position in the message\&. The set of basic types and their ascii codes passed in
\fItype\fR
are described in the
\m[blue]\fBD\-Bus Specification\fR\m[]\&\s-2\u[1]\d\s+2\&.
.PP
If
\fIp\fR
is not
\fBNULL\fR, it should contain a pointer to an appropriate object\&. For example, if
\fItype\fR
is
\fB\*(Aqy\*(Aq\fR, the object passed in
\fIp\fR
should have type
\fBuint8_t *\fR\&. If
\fItype\fR
is
\fB\*(Aqs\*(Aq\fR, the object passed in
\fIp\fR
should have type
\fBconst char **\fR\&. Note that, if the basic type is a pointer (e\&.g\&.,
\fBconst char *\fR
in the case of a string), the pointer is only borrowed and the contents must be copied if they are to be used after the end of the message\*(Aqs lifetime\&. Similarly, during the lifetime of such a pointer, the message must not be modified\&. If
\fItype\fR
is
\fB\*(Aqh\*(Aq\fR
(UNIX file descriptor), the descriptor is not duplicated by this call and the returned descriptor remains in possession of the message object, and needs to be duplicated by the caller in order to keep an open reference to it after the message object is freed (for example by calling
"fcntl(fd, FD_DUPFD_CLOEXEC, 3)")\&. See the table below for a complete list of allowed types\&.
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.B Table\ \&1.\ \&Item type specifiers
.TS
allbox tab(:);
lB lB lB lB.
T{
Specifier
T}:T{
Constant
T}:T{
Description
T}:T{
Expected C Type
T}
.T&
l l l l
l l l l
l l l l
l l l l
l l l l
l l l l
l l l l
l l l l
l l l l
l l l l
l l l l
l l l l
l l l l.
T{
"y"
T}:T{
\fBSD_BUS_TYPE_BYTE\fR
T}:T{
8\-bit unsigned integer
T}:T{
\fBuint8_t *\fR
T}
T{
"b"
T}:T{
\fBSD_BUS_TYPE_BOOLEAN\fR
T}:T{
boolean
T}:T{
\fBint *\fR (NB: not \fBbool *\fR)
T}
T{
"n"
T}:T{
\fBSD_BUS_TYPE_INT16\fR
T}:T{
16\-bit signed integer
T}:T{
\fBint16_t *\fR
T}
T{
"q"
T}:T{
\fBSD_BUS_TYPE_UINT16\fR
T}:T{
16\-bit unsigned integer
T}:T{
\fBuint16_t *\fR
T}
T{
"i"
T}:T{
\fBSD_BUS_TYPE_INT32\fR
T}:T{
32\-bit signed integer
T}:T{
\fBint32_t *\fR
T}
T{
"u"
T}:T{
\fBSD_BUS_TYPE_UINT32\fR
T}:T{
32\-bit unsigned integer
T}:T{
\fBuint32_t *\fR
T}
T{
"x"
T}:T{
\fBSD_BUS_TYPE_INT64\fR
T}:T{
64\-bit signed integer
T}:T{
\fBint64_t *\fR
T}
T{
"t"
T}:T{
\fBSD_BUS_TYPE_UINT64\fR
T}:T{
64\-bit unsigned integer
T}:T{
\fBuint64_t *\fR
T}
T{
"d"
T}:T{
\fBSD_BUS_TYPE_DOUBLE\fR
T}:T{
IEEE 754 double precision floating\-point
T}:T{
\fBdouble *\fR
T}
T{
"s"
T}:T{
\fBSD_BUS_TYPE_STRING\fR
T}:T{
UTF\-8 string
T}:T{
\fBconst char **\fR
T}
T{
"o"
T}:T{
\fBSD_BUS_TYPE_OBJECT_PATH\fR
T}:T{
D\-Bus object path string
T}:T{
\fBconst char **\fR
T}
T{
"g"
T}:T{
\fBSD_BUS_TYPE_SIGNATURE\fR
T}:T{
D\-Bus signature string
T}:T{
\fBconst char **\fR
T}
T{
"h"
T}:T{
\fBSD_BUS_TYPE_UNIX_FD\fR
T}:T{
UNIX file descriptor
T}:T{
\fBint *\fR
T}
.TE
.sp 1
.PP
If there is no object of the specified type at the current position in the message, an error is returned\&.
.SH "RETURN VALUE"
.PP
On success,
\fBsd_bus_message_read_basic()\fR
returns a positive integer\&. If the end of the currently opened array has been reached, it returns 0\&. On failure, it returns a negative errno\-style error code\&.
.SS "Errors"
.PP
Returned errors may indicate the following problems:
.PP
\fB\-EINVAL\fR
.RS 4
Specified type string is invalid or the message parameter is
\fBNULL\fR\&.
.RE
.PP
\fB\-ENXIO\fR
.RS 4
The message does not contain the specified type at current position\&.
.RE
.PP
\fB\-EBADMSG\fR
.RS 4
The message cannot be parsed\&.
.RE
.SH "HISTORY"
.PP
\fBsd_bus_message_read_basic()\fR
was added in version 231\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1),
\fBsd-bus\fR(3),
\fBsd_bus_message_append_basic\fR(3),
\fBsd_bus_message_skip\fR(3),
\fBsd_bus_message_read\fR(3)
.SH "NOTES"
.IP " 1." 4
D-Bus Specification
.RS 4
\%https://dbus.freedesktop.org/doc/dbus-specification.html
.RE
|