]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_bus_new.xml
test-execute: Add tests for new PassEnvironment= directive
[thirdparty/systemd.git] / man / sd_bus_new.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 2014 Zbigniew Jędrzejewski-Szmek
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_bus_new">
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>
59 <paramdef>sd_bus **<parameter>bus</parameter></paramdef>
60 </funcprototype>
61
62 <funcprototype>
63 <funcdef>sd_bus *<function>sd_bus_ref</function></funcdef>
64 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
65 </funcprototype>
66
67 <funcprototype>
68 <funcdef>sd_bus *<function>sd_bus_unref</function></funcdef>
69 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
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
78 object. This object is reference-counted, and will be destroyed
79 when all references are gone. Initially, the caller of this
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
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
87 <para>In most cases, it is a better idea to invoke
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>
95
96 <para><function>sd_bus_ref()</function> creates a new reference to
97 <parameter>bus</parameter>.</para>
98
99 <para><function>sd_bus_unref()</function> destroys a reference to
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>
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>
127 <term><constant>-ENOMEM</constant></term>
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
140 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
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>,
150 <citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
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>
154 </para>
155 </refsect1>
156
157 </refentry>