SD\_BUS\_MESSAGE\_APPEND\_BASIC(3) sd\_bus\_message\_append\_basic SD\_BUS\_MESSAGE\_APPEND\_BASIC(3)

.SH "NAME" sd\_bus\_message\_append\_basic - Attach a single field to a message

.SH "SYNOPSIS"

```
#include <systemd/sd-bus.h>
```

.HP 768u **int sd\_bus\_message\_append\_basic(sd\_bus\_message \*m, char type, const void \*p);**

.SH "DESCRIPTION"

.PP **sd\_bus\_message\_append\_basic()** appends a single field to the message *m*. The parameter *type* determines how the pointer *p* is interpreted. *type* must be one of the basic types as defined by the **Basic Types**\[1] section of the D-Bus specification, and listed in the table below.

.sp  
**Table 1. Item type specifiers**

**Specifier** **Constant** **Description** **Size** **Expected C Type** y **SD\_BUS\_TYPE\_BYTE** unsigned integer 1 byte uint8\_t b **SD\_BUS\_TYPE\_BOOLEAN** boolean 4 bytes int n **SD\_BUS\_TYPE\_INT16** signed integer 2 bytes int16\_t q **SD\_BUS\_TYPE\_UINT16** unsigned integer 2 bytes uint16\_t i **SD\_BUS\_TYPE\_INT32** signed integer 4 bytes int32\_t u **SD\_BUS\_TYPE\_UINT32** unsigned integer 4 bytes uint32\_t x **SD\_BUS\_TYPE\_INT64** signed integer 8 bytes int64\_t t **SD\_BUS\_TYPE\_UINT64** unsigned integer 8 bytes uint64\_t d **SD\_BUS\_TYPE\_DOUBLE** floating-point 8 bytes double s **SD\_BUS\_TYPE\_STRING** Unicode string variable char\[] o **SD\_BUS\_TYPE\_OBJECT\_PATH** object path variable char\[] g **SD\_BUS\_TYPE\_SIGNATURE** signature variable char\[] h **SD\_BUS\_TYPE\_UNIX\_FD** UNIX file descriptor 4 bytes int

.PP The value of the parameter is copied into a memory area held by the message object, stays in the possession of the caller and may hence be freely changed after this call without affecting the bus message it has been added to. If *type* is h (UNIX file descriptor), the descriptor is duplicated by this call and the passed descriptor stays in possession of the caller.

.PP For types s, o, and g, the parameter *p* is interpreted as a pointer to a **NUL**-terminated character sequence. As a special case, a **NULL** pointer is interpreted as an empty string. The string should be valid Unicode string encoded as UTF-8. In case of the two latter types, the additional requirements for a D-Bus object path or type signature should be satisfied. Those requirements should be verified by the recipient of the message.

.SH "RETURN VALUE"

.PP On success, this call returns 0 or a positive integer. On failure, it returns a negative errno-style error code.

.SS "Errors"

.PP Returned errors may indicate the following problems:

.PP **-EINVAL**

Specified parameter is invalid.

.RE

.PP **-EPERM**

Message has been sealed.

.RE

.PP **-ESTALE**

Message is in invalid state.

.RE

.PP **-ENXIO**

Message cannot be appended to.

.RE

.PP **-ENOMEM**

Memory allocation failed.

.RE

.SH "NOTES"

.PP Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/man/os/systemd/pkg-config.1) file.

.PP All functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. Different threads may access the same object at different times. Multiple independent objects may be used from different threads in parallel.

.PP The code described here uses [**getenv**(3)](/man/os/systemd/getenv.3), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call [**setenv**(3)](/man/os/systemd/setenv.3) from a parallel thread. It is recommended to only do calls to **setenv()** from an early phase of the program when no other threads have been started.

.SH "SEE ALSO"

.PP [**systemd**(1)](/man/os/systemd/systemd.1), [**sd-bus**(3)](/man/os/systemd/sd-bus.3), [**sd\_bus\_message\_read\_basic**(3)](/man/os/systemd/sd_bus_message_read_basic.3), [**sd\_bus\_message\_append**(3)](/man/os/systemd/sd_bus_message_append.3), **The D-Bus specification**\[2]

# [NOTES](#NOTES)

1\.

Basic Types

https://dbus.freedesktop.org/doc/dbus-specification.html#basic-types

2\.

The D-Bus specification

https://dbus.freedesktop.org/doc/dbus-specification.html

systemd 262.2

---

Document: sd_bus_message_append_basic(3) from systemd 262.2-r1 (Chainguard OS)
Source: https://github.com/systemd/systemd
