2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id=
"sd_event_source_set_description" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
9 <title>sd_event_source_set_description
</title>
10 <productname>systemd
</productname>
14 <refentrytitle>sd_event_source_set_description
</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_event_source_set_description
</refname>
20 <refname>sd_event_source_get_description
</refname>
22 <refpurpose>Set or retrieve descriptive names of event sources
</refpurpose>
27 <funcsynopsisinfo>#include
<systemd/sd-event.h
></funcsynopsisinfo>
30 <funcdef>int
<function>sd_event_source_set_description
</function></funcdef>
31 <paramdef>sd_event_source *
<parameter>source
</parameter></paramdef>
32 <paramdef>const char *
<parameter>description
</parameter></paramdef>
36 <funcdef>int
<function>sd_event_source_get_description
</function></funcdef>
37 <paramdef>sd_event_source *
<parameter>source
</parameter></paramdef>
38 <paramdef>const char **
<parameter>description
</parameter></paramdef>
45 <title>Description
</title>
47 <para><function>sd_event_source_set_description()
</function> may
48 be used to set an arbitrary descriptive name for the event source
49 object specified as
<parameter>source
</parameter>. This name will
50 be used in debugging messages generated by
51 <citerefentry><refentrytitle>sd-event
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
52 for this event source, and may be queried using
53 <function>sd_event_source_get_description()
</function> for
54 debugging purposes. The
<parameter>description
</parameter> parameter shall
55 point to a
<constant>NUL
</constant>-terminated string or be
56 <constant>NULL
</constant>. In the latter case, the descriptive
57 name will be unset. The string is copied internally, hence the
58 <parameter>description
</parameter> argument is not referenced
59 after the function returns.
</para>
61 <para><function>sd_event_source_get_description()
</function> may
62 be used to query the current descriptive name assigned to the
63 event source object
<parameter>source
</parameter>. It returns a
64 pointer to the current name in
<parameter>description
</parameter>,
65 stored in memory internal to the event source. The memory is
66 invalidated when the event source is destroyed or the descriptive
67 name is changed.
</para>
69 <para>Event source objects generally have no description set when
70 they are created, except for UNIX signal event sources created
72 <citerefentry><refentrytitle>sd_event_add_signal
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
73 whose descriptive name is initialized to the signal's C constant
74 name (e.g.
<literal>SIGINT
</literal> or
75 <literal>SIGTERM
</literal>).
</para>
79 <title>Return Value
</title>
81 <para>On success,
<function>sd_event_source_set_description()
</function> and
82 <function>sd_event_source_get_description()
</function> return a non-negative integer. On failure, they
83 return a negative errno-style error code.
</para>
88 <para>Returned errors may indicate the following problems:
</para>
92 <term><constant>-EINVAL
</constant></term>
94 <listitem><para><parameter>source
</parameter> is not a valid pointer to an
95 <structname>sd_event_source
</structname> object or the
<parameter>description
</parameter> argument
96 for
<function>sd_event_source_get_description()
</function> is
<constant>NULL
</constant>.
101 <term><constant>-ENOMEM
</constant></term>
103 <listitem><para>Not enough memory to copy the name.
</para></listitem>
107 <term><constant>-ECHILD
</constant></term>
109 <listitem><para>The event loop has been created in a different process.
</para></listitem>
114 <term><constant>-ENXIO
</constant></term>
116 <listitem><para>No name was set for the event source.
</para></listitem>
123 <xi:include href=
"libsystemd-pkgconfig.xml" />
126 <title>See Also
</title>
129 <citerefentry><refentrytitle>sd-event
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
130 <citerefentry><refentrytitle>sd_event_add_io
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
131 <citerefentry><refentrytitle>sd_event_add_time
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
132 <citerefentry><refentrytitle>sd_event_add_signal
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
133 <citerefentry><refentrytitle>sd_event_add_child
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
134 <citerefentry><refentrytitle>sd_event_add_inotify
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135 <citerefentry><refentrytitle>sd_event_add_defer
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
136 <citerefentry><refentrytitle>sd_event_source_set_userdata
</refentrytitle><manvolnum>3</manvolnum></citerefentry>