]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_bus_message_get_cookie.xml
verify: use manager_load_startable_unit_or_warn() to load units for verification
[thirdparty/systemd.git] / man / sd_bus_message_get_cookie.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
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 This file is part of systemd.
9
10 Copyright 2013 Lennart Poettering
11
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 -->
25
26 <refentry id="sd_bus_message_get_cookie">
27
28 <refentryinfo>
29 <title>sd_bus_message_get_cookie</title>
30 <productname>systemd</productname>
31
32 <authorgroup>
33 <author>
34 <contrib>Developer</contrib>
35 <firstname>Lennart</firstname>
36 <surname>Poettering</surname>
37 <email>lennart@poettering.net</email>
38 </author>
39 </authorgroup>
40 </refentryinfo>
41
42 <refmeta>
43 <refentrytitle>sd_bus_message_get_cookie</refentrytitle>
44 <manvolnum>3</manvolnum>
45 </refmeta>
46
47 <refnamediv>
48 <refname>sd_bus_message_get_cookie</refname>
49 <refname>sd_bus_message_get_reply_cookie</refname>
50 <refpurpose>Returns the transaction cookie of a message</refpurpose>
51 </refnamediv>
52
53 <refsynopsisdiv>
54 <funcsynopsis>
55 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
56
57 <funcprototype>
58 <funcdef>int <function>sd_bus_message_get_cookie</function></funcdef>
59 <paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
60 <paramdef>uint64_t *<parameter>cookie</parameter></paramdef>
61 </funcprototype>
62
63 <funcprototype>
64 <funcdef>int <function>sd_bus_message_get_reply_cookie</function></funcdef>
65 <paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
66 <paramdef>uint64_t *<parameter>cookie</parameter></paramdef>
67 </funcprototype>
68 </funcsynopsis>
69 </refsynopsisdiv>
70
71 <refsect1>
72 <title>Description</title>
73
74 <para><function>sd_bus_message_get_cookie()</function> returns the
75 transaction cookie of a message. The cookie uniquely identifies a
76 message within each bus peer, but is not globally unique. It is
77 assigned when a message is sent.</para>
78
79 <para><function>sd_bus_message_get_reply_cookie()</function>
80 returns the transaction cookie of the message the specified
81 message is a response to. When a reply message is generated for a
82 method call message, its cookie is copied over into this field.
83 Note that while every message that is transferred is identified by
84 a cookie, only response messages carry a reply cookie
85 field.</para>
86
87 <para>Both functions take a message object as first parameter and
88 a place to store the 64-bit cookie in.</para>
89 </refsect1>
90
91 <refsect1>
92 <title>Return Value</title>
93
94 <para>On success, these calls return 0 or a positive integer. On
95 failure, these calls return a negative errno-style error
96 code.</para>
97
98 <para>On success, the cookie/reply cookie is returned in the
99 specified 64-bit unsigned integer variable.</para>
100 </refsect1>
101
102 <refsect1>
103 <title>Errors</title>
104
105 <para>Returned errors may indicate the following problems:</para>
106
107 <variablelist>
108 <varlistentry>
109 <term><constant>-EINVAL</constant></term>
110
111 <listitem><para>A specified parameter
112 is invalid.</para></listitem>
113 </varlistentry>
114
115 <varlistentry>
116 <term><constant>-ENODATA</constant></term>
117
118 <listitem><para>No cookie has been assigned to this message.
119 This either indicates that the message has not been sent yet
120 and hence has no cookie assigned, or that the message is not a
121 method response message and hence carries a reply cookie
122 field.</para></listitem>
123 </varlistentry>
124 </variablelist>
125 </refsect1>
126
127 <refsect1>
128 <title>Notes</title>
129
130 <para>The <function>sd_bus_message_get_cookie()</function> and
131 <function>sd_bus_message_get_reply_cookie()</function> interfaces
132 are available as a shared library, which can be compiled and
133 linked to with the
134 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
135 file.</para>
136 </refsect1>
137
138 <refsect1>
139 <title>See Also</title>
140
141 <para>
142 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
143 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
144 <citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
145 </para>
146 </refsect1>
147
148 </refentry>