sd_bus_message_append.3 7.17 KB
Newer Older
1
'\" t
2
.TH "SD_BUS_MESSAGE_APPEND" "3" "" "systemd 215" "sd_bus_message_append"
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 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
.\" -----------------------------------------------------------------
.\" * 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_append \- Attach parts of message based on a format string
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-bus\&.h>
.fi
.ft
.HP \w'int\ sd_bus_message_append('u
.BI "int sd_bus_message_append(sd_bus_message\ *" "m" ", const\ char\ *" "types" ", \&.\&.\&.);"
.SH "DESCRIPTION"
.PP
The
\fBsd_bus_message_append\fR
function appends a sequence of items to message
\fIm\fR\&. The format string
\fItypes\fR
describes the types of arguments that follow\&.
.PP
The format string is composed of the elements shown in the table below\&. It contains zero or more single "complete types"\&. Each complete type may be one of the basic types or a fully described container type\&. A container type may be a structure, a variant type code, an array with its element type, or a dictionary with its entry type\&. The format string is
\fBNUL\fR\-terminated\&.
.PP
In case of a basic type, one argument of the corresponding type is expected\&.
.PP
A structure is denoted by a sequence of complete types between
"("
and
")"\&. This sequence cannot be empty \(em it must contain at least one type\&. Arguments corresponding to this nested sequence follow the same rules as if they were not nested\&.
.PP
A variant is denoted by
"v"\&. Correspoding arguments must include a format string denoting a complete type, and following that, arguments corresponding to the specified type\&.
.PP
An array is denoted by
"a"
followed by a complete type\&. Corresponding arguments must include the size of the array, and then repeated this number of times, arguments corresponding to the nested type\&.
.PP
A dictionary is an array of dictionary entries, denoted by
"a"
followed by a pair of complete types between
"{"
and
"}"\&. The first of those types must be a basic type\&. Corresponding arguments must include the size of the dictionary, and then repeated this number of times, arguments corresponding to each of the two nested types\&.
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.B Table\ \&1.\ \&Item format specifiers
.TS
allbox tab(:);
lB lB lB lB.
T{
Specifier
T}:T{
Constant
T}:T{
Description
T}:T{
Size
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
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{
unsigned interger
T}:T{
1 byte
T}
T{
"b"
T}:T{
\fBSD_BUS_TYPE_BOOLEAN\fR
T}:T{
boolean
T}:T{
4 bytes
T}
T{
"n"
T}:T{
\fBSD_BUS_TYPE_INT16\fR
T}:T{
signed integer
T}:T{
2 bytes
T}
T{
"q"
T}:T{
\fBSD_BUS_TYPE_UINT16\fR
T}:T{
unsigned integer
T}:T{
2 bytes
T}
T{
"i"
T}:T{
\fBSD_BUS_TYPE_INT32\fR
T}:T{
signed integer
T}:T{
4 bytes
T}
T{
"u"
T}:T{
\fBSD_BUS_TYPE_UINT32\fR
T}:T{
unsigned integer
T}:T{
4 bytes
T}
T{
"x"
T}:T{
\fBSD_BUS_TYPE_INT64\fR
T}:T{
signed integer
T}:T{
8 bytes
T}
T{
"t"
T}:T{
\fBSD_BUS_TYPE_UINT64\fR
T}:T{
unsigned integer
T}:T{
8 bytes
T}
T{
"d"
T}:T{
\fBSD_BUS_TYPE_DOUBLE\fR
T}:T{
floating\-point
T}:T{
8 bytes
T}
T{
"s"
T}:T{
\fBSD_BUS_TYPE_STRING\fR
T}:T{
Unicode string
T}:T{
variable
T}
T{
"o"
T}:T{
\fBSD_BUS_TYPE_OBJECT_PATH\fR
T}:T{
object path
T}:T{
variable
T}
T{
"g"
T}:T{
\fBSD_BUS_TYPE_SIGNATURE\fR
T}:T{
signature
T}:T{
variable
T}
T{
"h"
T}:T{
\fBSD_BUS_TYPE_UNIX_FD\fR
T}:T{
UNIX file descriptor
T}:T{
4 bytes
T}
T{
"a"
T}:T{
\fBSD_BUS_TYPE_ARRAY\fR
T}:T{
array
T}:T{
determined by array type and size
T}
T{
"v"
T}:T{
\fBSD_BUS_TYPE_VARIANT\fR
T}:T{
variant
T}:T{
determined by the type argument
T}
T{
"("
T}:T{
\fBSD_BUS_TYPE_STRUCT_BEGIN\fR
T}:T{
array start
T}:T{
determined by the nested types
T}
T{
")"
T}:T{
\fBSD_BUS_TYPE_STRUCT_END\fR
T}:T{
array end
T}:
T{
"{"
T}:T{
\fBSD_BUS_TYPE_DICT_ENTRY_BEGIN\fR
T}:T{
dictionary entry start
T}:T{
determined by the nested types
T}
T{
"}"
T}:T{
\fBSD_BUS_TYPE_DICT_ENTRY_END\fR
T}:T{
dictionary entry end
T}:
.TE
.sp 1
.SH "TYPES STRING GRAMMAR"
.sp
.if n \{\
.RS 4
.\}
.nf
types ::= complete_type*
complete_type ::= basic_type | variant | structure | array | dictionary
basic_type ::= "y" | "n" | "q" | "u" | "i" | "x" | "t" | "d" |
               "b" | "h" |
               "s" | "o" | "g"
variant ::= "v"
structure ::= "(" complete_type+ ")"
array ::= "a" complete_type
dictionary ::= "a" "{" basic_type complete_type "}"
.fi
.if n \{\
.RE
.\}
.SH "EXAMPLES"
.PP
Append a single basic type (the string
"a string"):
.sp
.if n \{\
.RS 4
.\}
.nf
sd_bus_message *m;
\&.\&.\&.
sd_bus_message_append(m, "s", "a string");
.fi
.if n \{\
.RE
.\}
.PP
Append all types of integers:
.sp
.if n \{\
.RS 4
.\}
.nf
uint8_t y = 1;
int16_t n = 2;
uint16_t q = 3;
int32_t i = 4;
uint32_t u = 5;
int32_t x = 6;
uint32_t t = 7;
double d = 8\&.0;
sd_bus_message_append(m, "ynqiuxtd", y, n, q, i, u, x, t, d);
.fi
.if n \{\
.RE
.\}
.PP
Append a structure composed of string and a D\-Bus path:
.sp
.if n \{\
.RS 4
.\}
.nf
sd_bus_message_append(m, "(so)", "a string", "/a/path");
.fi
.if n \{\
.RE
.\}
.PP
Append an array of UNIX file descriptors:
.sp
.if n \{\
.RS 4
.\}
.nf
sd_bus_message_append(m, "ah", 3, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO);
.fi
.if n \{\
.RE
.\}
.PP
Append a variant, with the real type "g" (signature), and value "sdbusisgood":
.sp
.if n \{\
.RS 4
.\}
.nf
sd_bus_message_append(m, "v", "g", "sdbusisgood");
.fi
.if n \{\
.RE
.\}
.PP
Append a dictionary containing the mapping {1=>"a", 2=>"b", 3=>""}:
.sp
.if n \{\
.RS 4
.\}
.nf
sd_bus_message_append(m, "a{is}", 3, 1, "a", 2, "b", 3, NULL);
     
.fi
.if n \{\
.RE
.\}
.SH "RETURN VALUE"
.PP
On success, this call returns 0 or a positive integer\&. On failure, this call returns a negative errno\-style error code\&.
.SH "ERRORS"
.PP
Returned errors may indicate the following problems:
.PP
\fI\-EINVAL\fR
.RS 4
Specified parameter is invalid\&.
.RE
.PP
\fI\-EPERM\fR
.RS 4
Message has been sealed\&.
.RE
.PP
\fI\-ESTALE\fR
.RS 4
Message is in invalid state\&.
.RE
.PP
\fI\-ENXIO\fR
.RS 4
Message cannot be appended to\&.
.RE
.PP
\fI\-ENOMEM\fR
.RS 4
Memory allocation failed\&.
.RE
.SH "NOTES"
.PP
\fBsd_bus_open_user()\fR
and other functions described here are available as a shared library, which can be compiled and linked to with the
\fBlibsystemd\-bus\fR\ \&\fBpkg-config\fR(1)
file\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1),
\fBsd-bus\fR(3),
\fBsd_bus_new\fR(3),
\fBsd_bus_ref\fR(3),
\fBsd_bus_unref\fR(3),
\fBssh\fR(1),
\fBsystemd-machined.service\fR(8),
\fBmachinectl\fR(1)