1SD_BUS_MESSAGE_APPEND_BASICs(d3_)bus_message_append_bSaDs_iBcUS_MESSAGE_APPEND_BASIC(3)
2
3
4
6 sd_bus_message_append_basic - Attach a single field to a message
7
9 #include <systemd/sd-bus.h>
10
11 int sd_bus_message_append_basic(sd_bus_message *m, char type,
12 const void *p);
13
15 sd_bus_message_append_basic() appends a single field to the message m.
16 The parameter type determines how the pointer p is interpreted. type
17 must be one of the basic types as defined by the Basic Types[1] section
18 of the D-Bus specification, and listed in the table below.
19
20 Table 1. Item type specifiers
21 ┌──────────┬─────────────────────────┬────────────────┬──────────┬────────────┐
22 │Specifier │ Constant │ Description │ Size │ Expected C │
23 │ │ │ │ │ Type │
24 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
25 │"y" │ SD_BUS_TYPE_BYTE │ unsigned │ 1 byte │ uint8_t │
26 │ │ │ integer │ │ │
27 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
28 │"b" │ SD_BUS_TYPE_BOOLEAN │ boolean │ 4 bytes │ int │
29 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
30 │"n" │ SD_BUS_TYPE_INT16 │ signed │ 2 bytes │ int16_t │
31 │ │ │ integer │ │ │
32 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
33 │"q" │ SD_BUS_TYPE_UINT16 │ unsigned │ 2 bytes │ uint16_t │
34 │ │ │ integer │ │ │
35 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
36 │"i" │ SD_BUS_TYPE_INT32 │ signed │ 4 bytes │ int32_t │
37 │ │ │ integer │ │ │
38 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
39 │"u" │ SD_BUS_TYPE_UINT32 │ unsigned │ 4 bytes │ uint32_t │
40 │ │ │ integer │ │ │
41 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
42 │"x" │ SD_BUS_TYPE_INT64 │ signed │ 8 bytes │ int64_t │
43 │ │ │ integer │ │ │
44 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
45 │"t" │ SD_BUS_TYPE_UINT64 │ unsigned │ 8 bytes │ uint64_t │
46 │ │ │ integer │ │ │
47 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
48 │"d" │ SD_BUS_TYPE_DOUBLE │ floating-point │ 8 bytes │ double │
49 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
50 │"s" │ SD_BUS_TYPE_STRING │ Unicode string │ variable │ char[] │
51 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
52 │"o" │ SD_BUS_TYPE_OBJECT_PATH │ object path │ variable │ char[] │
53 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
54 │"g" │ SD_BUS_TYPE_SIGNATURE │ signature │ variable │ char[] │
55 ├──────────┼─────────────────────────┼────────────────┼──────────┼────────────┤
56 │"h" │ SD_BUS_TYPE_UNIX_FD │ UNIX file │ 4 bytes │ int │
57 │ │ │ descriptor │ │ │
58 └──────────┴─────────────────────────┴────────────────┴──────────┴────────────┘
59
60 The value of the parameter is copied into a memory area held by the
61 message object, stays in the possession of the caller and may hence be
62 freely changed after this call without affecting the bus message it has
63 been added to. If type is "h" (UNIX file descriptor), the descriptor is
64 duplicated by this call and the passed descriptor stays in possession
65 of the caller.
66
67 For types "s", "o", and "g", the parameter p is interpreted as a
68 pointer to a NUL-terminated character sequence. As a special case, a
69 NULL pointer is interpreted as an empty string. The string should be
70 valid Unicode string encoded as UTF-8. In case of the two latter types,
71 the additional requirements for a D-Bus object path or type signature
72 should be satisfied. Those requirements should be verified by the
73 recipient of the message.
74
76 On success, this call returns 0 or a positive integer. On failure, it
77 returns a negative errno-style error code.
78
79 Errors
80 Returned errors may indicate the following problems:
81
82 -EINVAL
83 Specified parameter is invalid.
84
85 -EPERM
86 Message has been sealed.
87
88 -ESTALE
89 Message is in invalid state.
90
91 -ENXIO
92 Message cannot be appended to.
93
94 -ENOMEM
95 Memory allocation failed.
96
98 These APIs are implemented as a shared library, which can be compiled
99 and linked to with the libsystemd pkg-config(1) file.
100
102 systemd(1), sd-bus(3), sd_bus_message_read_basic(3),
103 sd_bus_message_append(3), The D-Bus specification[2]
104
106 1. Basic Types
107 http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types
108
109 2. The D-Bus specification
110 http://dbus.freedesktop.org/doc/dbus-specification.html
111
112
113
114systemd 250 SD_BUS_MESSAGE_APPEND_BASIC(3)