]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_event_source_set_prepare.xml
tree-wide: use mdash instead of a two minuses
[thirdparty/systemd.git] / man / sd_event_source_set_prepare.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 This file is part of systemd.
7
8 Copyright 2015 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd_event_source_set_prepare" xmlns:xi="http://www.w3.org/2001/XInclude">
25
26 <refentryinfo>
27 <title>sd_event_source_set_prepare</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>sd_event_source_set_prepare</refentrytitle>
42 <manvolnum>3</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd_event_source_set_prepare</refname>
47
48 <refpurpose>Set a preparation callback for event sources</refpurpose>
49 </refnamediv>
50
51 <refsynopsisdiv>
52 <funcsynopsis>
53 <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
54
55 <funcprototype>
56 <funcdef>int <function>sd_event_source_set_prepare</function></funcdef>
57 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
58 <paramdef>sd_event_handler_t <parameter>callback</parameter></paramdef>
59 </funcprototype>
60
61 <funcprototype>
62 <funcdef>typedef int (*<function>sd_event_handler_t</function>)</funcdef>
63 <paramdef>sd_event_source *<parameter>s</parameter></paramdef>
64 <paramdef>void *<parameter>userdata</parameter></paramdef>
65 </funcprototype>
66
67 </funcsynopsis>
68 </refsynopsisdiv>
69
70 <refsect1>
71 <title>Description</title>
72
73 <para><function>sd_event_source_set_prepare()</function> may be
74 used to set a preparation callback for the event source object
75 specified as <parameter>source</parameter>. The callback function
76 specified as <parameter>callback</parameter> will be invoked
77 immediately before the event loop goes to sleep to wait for
78 incoming events. It is invoked with the user data pointer passed
79 when the event source was created. The callback function may be
80 used to reconfigure the precise events to wait for. If the
81 <parameter>callback</parameter> parameter is passed as NULL the
82 callback function is reset. </para>
83
84 <para>Event source objects have no preparation callback associated
85 when they are first created with calls such as
86 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
87 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Preparation
88 callback functions are supported for all event source types with
89 the exception of those created with
90 <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Preparation
91 callback functions are dispatched in the order indicated by the
92 event source's priority field, as set with
93 <citerefentry><refentrytitle>sd_event_source_set_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Preparation
94 callbacks of disabled event sources (see
95 <citerefentry><refentrytitle>sd_event_source_set_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
96 are not invoked.</para>
97 </refsect1>
98
99 <refsect1>
100 <title>Return Value</title>
101
102 <para>On success,
103 <function>sd_event_source_set_prepare()</function> returns a
104 non-negative integer. On failure, it returns a negative
105 errno-style error code.</para>
106 </refsect1>
107
108 <refsect1>
109 <title>Errors</title>
110
111 <para>Returned errors may indicate the following problems:</para>
112
113 <variablelist>
114 <varlistentry>
115 <term><constant>-EINVAL</constant></term>
116
117 <listitem><para><parameter>source</parameter> is not a valid
118 pointer to an <structname>sd_event_source</structname>
119 object.</para></listitem>
120 </varlistentry>
121
122 <varlistentry>
123 <term><constant>-ESTALE</constant></term>
124
125 <listitem><para>The event loop is already terminated.</para></listitem>
126
127 </varlistentry>
128 <varlistentry>
129 <term><constant>-ENOMEM</constant></term>
130
131 <listitem><para>Not enough memory.</para></listitem>
132 </varlistentry>
133
134 <varlistentry>
135 <term><constant>-ECHILD</constant></term>
136
137 <listitem><para>The event loop has been created in a different process.</para></listitem>
138
139 </varlistentry>
140
141 <varlistentry>
142 <term><constant>-EDOM</constant></term>
143
144 <listitem><para>The specified event source has been created
145 with
146 <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
147
148 </varlistentry>
149
150 </variablelist>
151 </refsect1>
152
153 <xi:include href="libsystemd-pkgconfig.xml" />
154
155 <refsect1>
156 <title>See Also</title>
157
158 <para>
159 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
160 <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
161 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
162 <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
163 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
164 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
165 <citerefentry><refentrytitle>sd_event_source_set_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
166 <citerefentry><refentrytitle>sd_event_source_set_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
167 <citerefentry><refentrytitle>sd_event_source_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>
168 </para>
169 </refsect1>
170
171 </refentry>