1SD_BUS_MESSAGE_READ_BASIC(3)sd_bus_message_read_basiScD_BUS_MESSAGE_READ_BASIC(3)
2
3
4

NAME

6       sd_bus_message_read_basic - Read a basic type from a message
7

SYNOPSIS

9       #include <systemd/sd-bus.h>
10
11       int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p);
12

DESCRIPTION

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       ┌──────────┬─────────────────────────┬─────────────────┬─────────────────┐
31Specifier Constant                Description     Expected C Type 
32       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
33       │"y"       │ SD_BUS_TYPE_BYTE        │ 8bit unsigned   │ uint8_t *       
34       │          │                         │ integer         │                 │
35       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
36       │"b"       │ SD_BUS_TYPE_BOOLEAN     │ boolean         │ int * (NB: not  │
37       │          │                         │                 │ bool *)         │
38       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
39       │"n"       │ SD_BUS_TYPE_INT16       │ 16bit signed    │ int16_t *       
40       │          │                         │ integer         │                 │
41       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
42       │"q"       │ SD_BUS_TYPE_UINT16      │ 16bit unsigned  │ uint16_t *      
43       │          │                         │ integer         │                 │
44       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
45       │"i"       │ SD_BUS_TYPE_INT32       │ 32bit signed    │ int32_t *       
46       │          │                         │ integer         │                 │
47       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
48       │"u"       │ SD_BUS_TYPE_UINT32      │ 32bit unsigned  │ uint32_t *      
49       │          │                         │ integer         │                 │
50       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
51       │"x"       │ SD_BUS_TYPE_INT64       │ 64bit signed    │ int64_t *       
52       │          │                         │ integer         │                 │
53       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
54       │"t"       │ SD_BUS_TYPE_UINT64      │ 64bit unsigned  │ uint64_t *      
55       │          │                         │ integer         │                 │
56       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
57       │"d"       │ SD_BUS_TYPE_DOUBLE      │ IEEE 754 double │ double *        
58       │          │                         │ precision       │                 │
59       │          │                         │ floating-point  │                 │
60       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
61       │"s"       │ SD_BUS_TYPE_STRING      │ UTF-8 string    │ const char **   
62       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
63       │"o"       │ SD_BUS_TYPE_OBJECT_PATH │ D-Bus object    │ const char **   
64       │          │                         │ path string     │                 │
65       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
66       │"g"       │ SD_BUS_TYPE_SIGNATURE   │ D-Bus signature │ const char **   
67       │          │                         │ string          │                 │
68       ├──────────┼─────────────────────────┼─────────────────┼─────────────────┤
69       │"h"       │ SD_BUS_TYPE_UNIX_FD     │ UNIX file       │ int *           
70       │          │                         │ descriptor      │                 │
71       └──────────┴─────────────────────────┴─────────────────┴─────────────────┘
72
73       If there is no object of the specified type at the current position in
74       the message, an error is returned.
75

RETURN VALUE

77       On success, sd_bus_message_read_basic() returns 0 or a positive
78       integer. On failure, it returns a negative errno-style error code.
79
80   Errors
81       Returned errors may indicate the following problems:
82
83       -EINVAL
84           Specified type string is invalid or the message parameter is NULL.
85
86       -ENXIO
87           The message does not contain the specified type at current
88           position.
89
90       -EBADMSG
91           The message cannot be parsed.
92

SEE ALSO

94       systemd(1), sd-bus(3), sd_bus_message_append_basic(3),
95       sd_bus_message_skip(3), sd_bus_message_read(3)
96

NOTES

98        1. D-Bus Specification
99           https://dbus.freedesktop.org/doc/dbus-specification.html
100
101
102
103systemd 245                                       SD_BUS_MESSAGE_READ_BASIC(3)
Impressum