chiark / gitweb /
Prep v239: sync manager_get_user_by_pid() with upstream updates
[elogind.git] / man / sd_event_source_set_description.xml
1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="sd_event_source_set_description" xmlns:xi="http://www.w3.org/2001/XInclude">
10
11   <refentryinfo>
12     <title>sd_event_source_set_description</title>
13     <productname>elogind</productname>
14   </refentryinfo>
15
16   <refmeta>
17     <refentrytitle>sd_event_source_set_description</refentrytitle>
18     <manvolnum>3</manvolnum>
19   </refmeta>
20
21   <refnamediv>
22     <refname>sd_event_source_set_description</refname>
23     <refname>sd_event_source_get_description</refname>
24
25     <refpurpose>Set or retrieve descriptive names of event sources</refpurpose>
26   </refnamediv>
27
28   <refsynopsisdiv>
29     <funcsynopsis>
30       <funcsynopsisinfo>#include &lt;elogind/sd-event.h&gt;</funcsynopsisinfo>
31
32       <funcprototype>
33         <funcdef>int <function>sd_event_source_set_description</function></funcdef>
34         <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
35         <paramdef>const char *<parameter>description</parameter></paramdef>
36       </funcprototype>
37
38       <funcprototype>
39         <funcdef>int <function>sd_event_source_get_description</function></funcdef>
40         <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
41         <paramdef>const char **<parameter>description</parameter></paramdef>
42       </funcprototype>
43
44     </funcsynopsis>
45   </refsynopsisdiv>
46
47   <refsect1>
48     <title>Description</title>
49
50     <para><function>sd_event_source_set_description()</function> may
51     be used to set an arbitrary descriptive name for the event source
52     object specified as <parameter>source</parameter>. This name will
53     be used in debugging messages generated by
54     <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
55     for this event source, and may be queried using
56     <function>sd_event_source_get_description()</function> for
57     debugging purposes. The <parameter>description</parameter> parameter shall
58     point to a <constant>NUL</constant>-terminated string or be
59     <constant>NULL</constant>. In the latter case, the descriptive
60     name will be unset. The string is copied internally, hence the
61     <parameter>description</parameter> argument is not referenced
62     after the function returns.</para>
63
64     <para><function>sd_event_source_get_description()</function> may
65     be used to query the current descriptive name assigned to the
66     event source object <parameter>source</parameter>. It returns a
67     pointer to the current name in <parameter>description</parameter>,
68     stored in memory internal to the event source. The memory is
69     invalidated when the event source is destroyed or the descriptive
70     name is changed.</para>
71
72     <para>Event source objects generally have no description set when
73     they are created, except for UNIX signal event sources created
74     with
75     <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
76     whose descriptive name is initialized to the signal's C constant
77     name (e.g. <literal>SIGINT</literal> or
78     <literal>SIGTERM</literal>).</para>
79   </refsect1>
80
81   <refsect1>
82     <title>Return Value</title>
83
84     <para>On success, <function>sd_event_source_set_description()</function> and
85     <function>sd_event_source_get_description()</function> return a
86     non-negative integer. On failure, they return a negative
87     errno-style error code.</para>
88   </refsect1>
89
90   <refsect1>
91     <title>Errors</title>
92
93     <para>Returned errors may indicate the following problems:</para>
94
95     <variablelist>
96       <varlistentry>
97         <term><constant>-EINVAL</constant></term>
98
99         <listitem><para><parameter>source</parameter> is not a valid
100         pointer to an <structname>sd_event_source</structname>
101         object or the <parameter>description</parameter> argument for
102         <function>sd_event_source_get_description()</function> is
103         <constant>NULL</constant>.</para></listitem>
104       </varlistentry>
105
106       <varlistentry>
107         <term><constant>-ENOMEM</constant></term>
108
109         <listitem><para>Not enough memory to copy the
110         name.</para></listitem>
111       </varlistentry>
112
113       <varlistentry>
114         <term><constant>-ECHILD</constant></term>
115
116         <listitem><para>The event loop has been created in a different process.</para></listitem>
117
118       </varlistentry>
119
120       <varlistentry>
121         <term><constant>-ENXIO</constant></term>
122
123         <listitem><para>No name was set for the event
124         source.</para></listitem>
125       </varlistentry>
126
127     </variablelist>
128   </refsect1>
129
130   <xi:include href="libelogind-pkgconfig.xml" />
131
132   <refsect1>
133     <title>See Also</title>
134
135     <para>
136       <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
137       <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
138       <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
139       <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
140       <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
141       <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
142       <citerefentry><refentrytitle>sd_event_source_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>
143     </para>
144   </refsect1>
145
146 </refentry>