1SD_BUS_MESSAGE_READ_BASIC(3)sd_bus_message_read_basiScD_BUS_MESSAGE_READ_BASIC(3)
2
3
4
6 sd_bus_message_read_basic - Read a basic type from a message
7
9 #include <systemd/sd-bus.h>
10
11 int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p);
12
14 sd_bus_message_read_basic() reads a basic type from a message and
15 advances the read position in the message. The set of basic types and
16 their ascii codes passed in type are described in the D-Bus
17 Specification[1].
18
19 If p is not NULL, it should contain a pointer to an appropriate object.
20 For example, if type is 'y', the object passed in p should have type
21 uint8_t *. If type is 's', the object passed in p should have type
22 const char **. Note that, if the basic type is a pointer (e.g., const
23 char * in the case of a string), the pointer is only borrowed and the
24 contents must be copied if they are to be used after the end of the
25 messages lifetime. Similarly, during the lifetime of such a pointer,
26 the message must not be modified. See the table below for a complete
27 list of allowed types.
28
29 Table 1. Item type specifiers
30 ┌──────────┬─────────────────────────┬──────────────────┬─────────────────┐
31 │Specifier │ Constant │ Description │ Expected C Type │
32 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
33 │"y" │ SD_BUS_TYPE_BYTE │ unsigned integer │ uint8_t * │
34 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
35 │"b" │ SD_BUS_TYPE_BOOLEAN │ boolean │ int * │
36 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
37 │"n" │ SD_BUS_TYPE_INT16 │ signed integer │ int16_t * │
38 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
39 │"q" │ SD_BUS_TYPE_UINT16 │ unsigned integer │ uint16_t * │
40 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
41 │"i" │ SD_BUS_TYPE_INT32 │ signed integer │ int32_t * │
42 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
43 │"u" │ SD_BUS_TYPE_UINT32 │ unsigned integer │ uint32_t * │
44 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
45 │"x" │ SD_BUS_TYPE_INT64 │ signed integer │ int64_t * │
46 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
47 │"t" │ SD_BUS_TYPE_UINT64 │ unsigned integer │ uint64_t * │
48 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
49 │"d" │ SD_BUS_TYPE_DOUBLE │ floating-point │ double * │
50 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
51 │"s" │ SD_BUS_TYPE_STRING │ Unicode string │ const char ** │
52 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
53 │"o" │ SD_BUS_TYPE_OBJECT_PATH │ object path │ const char ** │
54 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
55 │"g" │ SD_BUS_TYPE_SIGNATURE │ signature │ const char ** │
56 ├──────────┼─────────────────────────┼──────────────────┼─────────────────┤
57 │"h" │ SD_BUS_TYPE_UNIX_FD │ UNIX file │ int * │
58 │ │ │ descriptor │ │
59 └──────────┴─────────────────────────┴──────────────────┴─────────────────┘
60
61 If there is no object of the specified type at the current position in
62 the message, an error is returned.
63
65 On success, sd_bus_message_read_basic() returns 0 or a positive
66 integer. On failure, it returns a negative errno-style error code.
67
69 Returned errors may indicate the following problems:
70
71 -EINVAL
72 Specified type string is invalid or the message parameter is NULL.
73
74 -ENXIO
75 The message does not contain the specified type at current
76 position.
77
78 -EBADMSG
79 The message cannot be parsed.
80
82 systemd(1), sd-bus(3), sd_bus_message_append_basic(3),
83 sd_bus_message_skip(3), sd_bus_message_read(3)
84
86 1. D-Bus Specification
87 https://dbus.freedesktop.org/doc/dbus-specification.html
88
89
90
91systemd 241 SD_BUS_MESSAGE_READ_BASIC(3)