Home | man(3)
SD_BUS_ME...READ_BASIC(3) sd_bus_message_read_basic SD_BUS_ME...READ_BASIC(3)
NAME
sd_bus_message_read_basic - Read a basic type from a message
SYNOPSIS
#include <systemd/sd-bus.h>
int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p);
DESCRIPTION
sd_bus_message_read_basic() 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 type are described in the D-Bus
Specification[1].
If p is not NULL, it should contain a pointer to an appropriate object.
For example, if type is 'y', the object passed in p should have type
uint8_t *. If type is 's', the object passed in p should have type
const char **. Note that, if the basic type is a pointer (e.g., const
char * 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's lifetime. Similarly, during the lifetime of such a pointer,
the message must not be modified. If type is 'h' (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.
Table 1. Item type specifiers allbox tab(:); lB lB lB lB. T{ Specifier
T}:T{ Constant T}:T{ Description T}:T{ Expected C Type 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{ SD_BUS_TYPE_BYTE T}:T{ 8-bit unsigned
integer T}:T{ uint8_t * T} T{ "b" T}:T{ SD_BUS_TYPE_BOOLEAN T}:T{
boolean T}:T{ int * (NB: not bool *) T} T{ "n" T}:T{ SD_BUS_TYPE_INT16
T}:T{ 16-bit signed integer T}:T{ int16_t * T} T{ "q" T}:T{
SD_BUS_TYPE_UINT16 T}:T{ 16-bit unsigned integer T}:T{ uint16_t * T} T{
"i" T}:T{ SD_BUS_TYPE_INT32 T}:T{ 32-bit signed integer T}:T{ int32_t *
T} T{ "u" T}:T{ SD_BUS_TYPE_UINT32 T}:T{ 32-bit unsigned integer T}:T{
uint32_t * T} T{ "x" T}:T{ SD_BUS_TYPE_INT64 T}:T{ 64-bit signed
integer T}:T{ int64_t * T} T{ "t" T}:T{ SD_BUS_TYPE_UINT64 T}:T{ 64-bit
unsigned integer T}:T{ uint64_t * T} T{ "d" T}:T{ SD_BUS_TYPE_DOUBLE
T}:T{ IEEE 754 double precision floating-point T}:T{ double * T} T{ "s"
T}:T{ SD_BUS_TYPE_STRING T}:T{ UTF-8 string T}:T{ const char ** T} T{
"o" T}:T{ SD_BUS_TYPE_OBJECT_PATH T}:T{ D-Bus object path string T}:T{
const char ** T} T{ "g" T}:T{ SD_BUS_TYPE_SIGNATURE T}:T{ D-Bus
signature string T}:T{ const char ** T} T{ "h" T}:T{
SD_BUS_TYPE_UNIX_FD T}:T{ UNIX file descriptor T}:T{ int * T}
If there is no object of the specified type at the current position in
the message, an error is returned.
RETURN VALUE
On success, sd_bus_message_read_basic() 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.
Errors
Returned errors may indicate the following problems:
-EINVAL
Specified type string is invalid or the message parameter is NULL.
-ENXIO
The message does not contain the specified type at current
position.
-EBADMSG
The message cannot be parsed.
HISTORY
sd_bus_message_read_basic() was added in version 221.
SEE ALSO
systemd(1), sd-bus(3), sd_bus_message_append_basic(3),
sd_bus_message_skip(3), sd_bus_message_read(3)
NOTES
1. D-Bus Specification
https://dbus.freedesktop.org/doc/dbus-specification.html
systemd 257.13 SD_BUS_ME...READ_BASIC(3)