]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_new.xml
sd-event: define a new PREPARING state
[thirdparty/systemd.git] / man / sd_bus_new.xml
CommitLineData
3802a3d3 1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
cd6d5e1c 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
cd6d5e1c
ZJS
4
5<!--
b975b0d5 6 This file is part of systemd.
cd6d5e1c 7
b975b0d5 8 Copyright 2014 Zbigniew Jędrzejewski-Szmek
cd6d5e1c 9
b975b0d5
ZJS
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.
cd6d5e1c 14
b975b0d5
ZJS
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.
cd6d5e1c 19
b975b0d5
ZJS
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/>.
cd6d5e1c
ZJS
22-->
23
48f69d8f 24<refentry id="sd_bus_new">
cd6d5e1c
ZJS
25
26 <refentryinfo>
27 <title>sd_bus_new</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>A monkey with a typewriter</contrib>
33 <firstname>Zbigniew</firstname>
34 <surname>Jędrzejewski-Szmek</surname>
35 <email>zbyszek@in.waw.pl</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>sd_bus_new</refentrytitle>
42 <manvolnum>3</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd_bus_new</refname>
47 <refname>sd_bus_ref</refname>
48 <refname>sd_bus_unref</refname>
49
50 <refpurpose>Create a new bus object and create or destroy references to it</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_new</function></funcdef>
8dc385e7 59 <paramdef>sd_bus **<parameter>bus</parameter></paramdef>
cd6d5e1c
ZJS
60 </funcprototype>
61
62 <funcprototype>
8dc385e7
JE
63 <funcdef>sd_bus *<function>sd_bus_ref</function></funcdef>
64 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
cd6d5e1c
ZJS
65 </funcprototype>
66
67 <funcprototype>
8dc385e7
JE
68 <funcdef>sd_bus *<function>sd_bus_unref</function></funcdef>
69 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
cd6d5e1c
ZJS
70 </funcprototype>
71 </funcsynopsis>
72 </refsynopsisdiv>
73
74 <refsect1>
75 <title>Description</title>
76
77 <para><function>sd_bus_new()</function> creates a new bus
73e231ab 78 object. This object is reference-counted, and will be destroyed
cd6d5e1c 79 when all references are gone. Initially, the caller of this
db03761e
UTL
80 function owns the sole reference and the bus object will not be
81 connected to any bus. To connect it to a bus, make sure
850df10a
LP
82 to set an address with
83 <citerefentry><refentrytitle>sd_bus_set_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>
84 or a related call, and then start the connection with
85 <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
86
7ca41557 87 <para>In most cases, it is a better idea to invoke
850df10a
LP
88 <citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
89 <citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>
90 or related calls instead of the more low-level
91 <function>sd_bus_new()</function> and
92 <function>sd_bus_start()</function>. The higher-level calls not
93 only allocate a bus object but also start the connection to a
94 well-known bus in a single function invocation.</para>
cd6d5e1c
ZJS
95
96 <para><function>sd_bus_ref()</function> creates a new reference to
db03761e 97 <parameter>bus</parameter>.</para>
cd6d5e1c 98
4cf8496d 99 <para><function>sd_bus_unref()</function> destroys a reference to
db03761e
UTL
100 <parameter>bus</parameter>. Once the reference count has dropped
101 to zero, <parameter>bus</parameter> cannot be used anymore, so
102 further calls to <function>sd_bus_ref()</function> or
103 <function>sd_bus_unref()</function> are illegal.</para>
cd6d5e1c
ZJS
104 </refsect1>
105
106 <refsect1>
107 <title>Return Value</title>
108
109 <para>On success, <function>sd_bus_new()</function> returns 0 or a
110 positive integer. On failure, it returns a negative errno-style
111 error code.</para>
112
113 <para><function>sd_bus_ref</function> always returns the argument.
114 </para>
115
116 <para><function>sd_bus_unref</function> always returns
117 <constant>NULL</constant>.</para>
118 </refsect1>
119
120 <refsect1>
121 <title>Errors</title>
122
123 <para>Returned errors may indicate the following problems:</para>
124
125 <variablelist>
126 <varlistentry>
8474b70c 127 <term><constant>-ENOMEM</constant></term>
cd6d5e1c
ZJS
128
129 <listitem><para>Memory allocation failed.</para></listitem>
130 </varlistentry>
131 </variablelist>
132 </refsect1>
133
134 <refsect1>
135 <title>Notes</title>
136
137 <para><function>sd_bus_new()</function> and other functions
138 described here are available as a shared library, which can be
139 compiled and linked to with the
5aded369 140 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
cd6d5e1c
ZJS
141 file.</para>
142 </refsect1>
143
144 <refsect1>
145 <title>See Also</title>
146
147 <para>
148 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
149 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
cd6d5e1c 150 <citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
850df10a
LP
151 <citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
152 <citerefentry><refentrytitle>sd_bus_open_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
153 <citerefentry><refentrytitle>sd_bus_open_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>
cd6d5e1c
ZJS
154 </para>
155 </refsect1>
156
157</refentry>