SD_VARLINK_SET_DESCRIPTION(3)

πŸ’… NAME

okay so bestie, welcome to the group chat for sd_varlink_set_description and sd_varlink_get_description β€” the two functions that let you set or query the description of a Varlink connection object. that's it, that's the whole vibe ✨


πŸŽ€ SYNOPSIS

#include <systemd/sd-varlink.h>

int sd_varlink_set_description(sd_varlink *link,
                               const char *description);

const char* sd_varlink_get_description(sd_varlink *link);

like, look at them. immaculate. no notes. 🫢


🌸 DESCRIPTION

so sd_varlink_set_description() sets the description string β€” the one that gets used in logging β€” to whatever string you pass in. it's giving "name tag for your connection." 🏷️ the string is copied internally and freed when the Varlink connection object is deallocated, so you don't have to babysit it, she's independent now πŸ’…

the description argument may be NULL, and in that case the description is unset. poof. gone. πŸ™ˆ

then there's sd_varlink_get_description() β€” she returns a description string for the specified Varlink connection. this string may have been previously set with sd_varlink_set_description(). but if it wasn't set that way, a default string or NULL may be returned β€” it lowkey depends on how the connection was allocated and set up. so like, don't assume, okay? 😭


⭐ RETURN VALUE

  • On success, sd_varlink_set_description() returns a non-negative integer. slay. πŸŽ‰
  • On failure, it returns a negative errno-style error code. not slay. πŸ’€
  • sd_varlink_get_description() returns either NULL or a pointer to the description string.

πŸ¦‹ Errors

the errors it might throw at you are these, and they're literally:

  • -EINVAL β€” an argument is invalid. bestie something you passed in is not it πŸ™ˆ
  • -ENOMEM β€” memory allocation failed. the malloc said no 🫠

πŸ”₯ 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. standard systemd girlie behavior, you know the drill ✨

⚠️ okay important thing: the code described here uses 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) 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. like, do it before the party starts, not mid-party. periodt. πŸŽ€

🌈 HISTORY

  • sd_varlink_set_description() was added in version 257.
  • sd_varlink_get_description() was added in version 258.

generational glow-up honestly πŸ‘‘


πŸ’œ SEE ALSO

go read those, iykyk πŸ“š


anyway bestie that's the whole page β€” brought to you by systemd 259.10, the version that made this all possible πŸ’– mwah, go forth and describe your varlinks responsibly βœ¨πŸ¦‹

πŸ“¦ where this page comes from