SD_BUS_ME...PEND_BASIC(3)
πΈ NAME πΈ
okay so bestie, welcome to the sd_bus_message_append_basic page (that's SD_BUS_ME...PEND_BASIC(3) in the manual, section 3 β the truncated name is literally how it shows up in the header, iykyk π
). this one does exactly what it says on the tin:
sd_bus_message_append_basic β Attach a single field to a message β¨
π SYNOPSIS π
#include <systemd/sd-bus.h>
int sd_bus_message_append_basic(sd_bus_message *m, char type,
const void *p);
π¦ DESCRIPTION π¦
okay so sd_bus_message_append_basic() appends a single field to the message m. one field. one. don't get greedy π₯
the parameter type is the main character here β it decides how the pointer p gets interpreted π. type has got to be one of the basic types as defined by the Basic Types[1] section of the D-Bus specification, and they're all listed in the very cute table below π.
Table 1. Item type specifiers (the whole squad, no gatekeeping):
"y"β constantSD_BUS_TYPE_BYTEβ unsigned integer β size: 1 byte β expected C type:uint8_t"b"β constantSD_BUS_TYPE_BOOLEANβ boolean β size: 4 bytes β expected C type:int"n"β constantSD_BUS_TYPE_INT16β signed integer β size: 2 bytes β expected C type:int16_t"q"β constantSD_BUS_TYPE_UINT16β unsigned integer β size: 2 bytes β expected C type:uint16_t"i"β constantSD_BUS_TYPE_INT32β signed integer β size: 4 bytes β expected C type:int32_t"u"β constantSD_BUS_TYPE_UINT32β unsigned integer β size: 4 bytes β expected C type:uint32_t"x"β constantSD_BUS_TYPE_INT64β signed integer β size: 8 bytes β expected C type:int64_t"t"β constantSD_BUS_TYPE_UINT64β unsigned integer β size: 8 bytes β expected C type:uint64_t"d"β constantSD_BUS_TYPE_DOUBLEβ floating-point β size: 8 bytes β expected C type:double"s"β constantSD_BUS_TYPE_STRINGβ Unicode string β size: variable β expected C type:char[]"o"β constantSD_BUS_TYPE_OBJECT_PATHβ object path β size: variable β expected C type:char[]"g"β constantSD_BUS_TYPE_SIGNATUREβ signature β size: variable β expected C type:char[]"h"β constantSD_BUS_TYPE_UNIX_FDβ UNIX file descriptor β size: 4 bytes β expected C type:int
so here's the vibe on copying π«Ά: the value of the parameter gets copied into a memory area held by the message object. so the value stays in the possession of the caller β meaning you can freely change it after this call and the bus message you already added it to will not care one bit, no cap β¨. and if type is "h" (UNIX file descriptor), the descriptor is duplicated by this call, and the descriptor you passed stays in possession of the caller. slay, no dangling FDs π
.
for types "s", "o", and "g", the parameter p is interpreted as a pointer to a NUL-terminated character sequence. and as a special case, a NULL pointer is interpreted as an empty string π. the string should be a valid Unicode string encoded as UTF-8. and for the two latter types ("o" and "g"), the additional requirements for a D-Bus object path or type signature should be satisfied too. those requirements should be verified by the recipient of the message β that's their job, not yours, bestie π
β RETURN VALUE β
on success, this call returns 0 or a positive integer π. on failure, it returns a negative errno-style error code π.
π₯ Errors
returned errors may indicate the following problems:
-EINVALβ specified parameter is invalid.-EPERMβ message has been sealed. (no editing, it's locked, periodt π)-ESTALEβ message is in invalid state.-ENXIOβ message cannot be appended to.-ENOMEMβ memory allocation failed.
π§ NOTES π§
the functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file π.
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 β so like, share the objects, don't share the moment π«Ά.
β οΈ okay this part matters so listen up: the code described here usesgetenv(3), which is declared to be not multi-thread-safe. this means the code calling the functions described here must not callsetenv(3)from a parallel thread. it is recommended to only do calls tosetenv()from an early phase of the program when no other threads have been started. highkey do this early, bestie π
π SEE ALSO π
systemd(1), sd-bus(3), sd_bus_message_read_basic(3), sd_bus_message_append(3), The D-Bus specification[2]
π NOTES π
- Basic Types β https://dbus.freedesktop.org/doc/dbus-specification.html#basic-types
- The D-Bus specification β https://dbus.freedesktop.org/doc/dbus-specification.html
and that's the whole page, bestie β brought to you by systemd 261.3 on the SD_BUS_ME...PEND_BASIC(3) manual page, go append something iconic today π
β¨π
π¦ where this page comes from
- ubuntu stonking: libsystemd-dev 261.3-0ubuntu3 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms