1<?xml version='1.0'?>
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 -->
5
6<refentry id="sd_event_source_set_userdata" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8  <refentryinfo>
9    <title>sd_event_source_set_userdata</title>
10    <productname>systemd</productname>
11  </refentryinfo>
12
13  <refmeta>
14    <refentrytitle>sd_event_source_set_userdata</refentrytitle>
15    <manvolnum>3</manvolnum>
16  </refmeta>
17
18  <refnamediv>
19    <refname>sd_event_source_set_userdata</refname>
20    <refname>sd_event_source_get_userdata</refname>
21
22    <refpurpose>Set or retrieve user data pointer of event sources</refpurpose>
23  </refnamediv>
24
25  <refsynopsisdiv>
26    <funcsynopsis>
27      <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
28
29      <funcprototype>
30        <funcdef>void* <function>sd_event_source_set_userdata</function></funcdef>
31        <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
32        <paramdef>void *<parameter>userdata</parameter></paramdef>
33      </funcprototype>
34
35      <funcprototype>
36        <funcdef>void* <function>sd_event_source_get_userdata</function></funcdef>
37        <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
38      </funcprototype>
39
40    </funcsynopsis>
41  </refsynopsisdiv>
42
43  <refsect1>
44    <title>Description</title>
45
46    <para><function>sd_event_source_set_userdata()</function> may be
47    used to set an arbitrary user data pointer for the event source
48    object specified as <parameter>source</parameter>. The user data
49    pointer is usually specified when creating an event source object
50    with calls such as
51    <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>
52    or
53    <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
54    and may be updated with this call. The user data pointer is also
55    passed to all handler callback functions associated with the event
56    source. The <parameter>userdata</parameter> parameter specifies
57    the new user data pointer to set, the function returns the
58    previous user data pointer. Note that <constant>NULL</constant> is
59    a valid user data pointer.</para>
60
61    <para><function>sd_event_source_get_userdata()</function> may be
62    used to query the current user data pointer assigned to the event
63    source object <parameter>source</parameter>.</para>
64  </refsect1>
65
66  <refsect1>
67    <title>Return Value</title>
68
69    <para>On success,
70    <function>sd_event_source_set_userdata()</function> and
71    <function>sd_event_source_get_userdata()</function> return the
72    previously set user data pointer. On failure, they return
73    <constant>NULL</constant>.</para>
74  </refsect1>
75
76  <xi:include href="libsystemd-pkgconfig.xml" />
77
78  <refsect1>
79    <title>See Also</title>
80
81    <para>
82      <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
83      <citerefentry><refentrytitle>sd_event_add_io</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
84      <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
85      <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
86      <citerefentry><refentrytitle>sd_event_add_child</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
87      <citerefentry><refentrytitle>sd_event_add_inotify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
88      <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
89      <citerefentry><refentrytitle>sd_event_source_set_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>
90    </para>
91  </refsect1>
92
93</refentry>
94