1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_bus_path_encode</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
visibility: hidden;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
visibility: visible;
}
</style><a href="index.html">Index </a>·
<a href="systemd.directives.html">Directives </a>·
<a href="../python-systemd/index.html">Python </a>·
<span style="float:right">systemd 221</span><hr><div class="refentry"><a name="sd_bus_path_encode"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_bus_path_encode, sd_bus_path_decode — Convert an external identifier into an object path and back</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <systemd/sd-bus.h></pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_path_encode</b>(</code></td><td>const char *<var class="pdparam">prefix</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">external_id</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">ret_path</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_path_decode</b>(</code></td><td>const char *<var class="pdparam">path</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">prefix</var>, </td></tr><tr><td> </td><td>char **<var class="pdparam">ret_external_id</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm47623234167024"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><code class="function">sd_bus_path_encode()</code> and
<code class="function">sd_bus_path_decode()</code> convert external
identifier strings into object paths and back. These functions are
useful to map application-specific string identifiers of any kind
into bus object paths in a simple, reversible and safe way.</p><p><code class="function">sd_bus_path_encode()</code> takes a bus path
prefix and an external identifier string as arguments, plus a
place to store the returned bus path string. The bus path prefix
must be a valid bus path, starting with a slash
"<code class="literal">/</code>", and not ending in one. The external
identifier string may be in any format, may be the empty string,
and has no restrictions on the charset — however, it must
always be <code class="constant">NUL</code>-terminated. The returned string
will be the concatenation of the bus path prefix plus an escaped
version of the external identifier string. This operation may be
reversed with <code class="function">sd_bus_decode()</code>. It is
recommended to only use external identifiers that generally
require little escaping to be turned into valid bus path
identifiers (for example, by sticking to a 7-bit ASCII character
set), in order to ensure the resulting bus path is still short and
easily processed.</p><p><code class="function">sd_bus_path_decode()</code> reverses the
operation of <code class="function">sd_bus_path_encode()</code> and thus
regenerates an external identifier string from a bus path. It
takes a bus path and a prefix string, plus a place to store the
returned external identifier string. If the bus path does not
start with the specified prefix, 0 is returned and the returned
string is set to <code class="constant">NULL</code>. Otherwise, the
string following the prefix is unescaped and returned in the
external identifier string.</p><p>The escaping used will replace all characters which are
invalid in a bus object path by "<code class="literal">_</code>", followed by a
hexadecimal value. As a special case, the empty string will be
replaced by a lone "<code class="literal">_</code>".</p></div><div class="refsect1"><a name="idm47623235632784"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value">¶</a></h2><p>On success, <code class="function">sd_bus_path_encode()</code>
returns positive or 0, and a valid bus path in the return
argument. On success, <code class="function">sd_bus_path_decode()</code>
returns a positive value if the prefixed matched, or 0 if it
did not. If the prefix matched, the external identifier is returned
in the return parameter. If it did not match, NULL is returned in
the return parameter. On failure, a negative errno-style error
number is returned by either function. The returned strings must
be
<a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a>'d
by the caller.</p></div><div class="refsect1"><a name="idm47623235089248"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p><code class="function">sd_bus_path_encode()</code> and
<code class="function">sd_bus_path_decode()</code> are available as a
shared library, which can be compiled and linked to with the
<code class="constant">libsystemd</code> <a href="http://linux.die.net/man/1/pkg-config"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
file.</p></div><div class="refsect1"><a name="idm47623233520256"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p>
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
<a href="sd-bus.html"><span class="citerefentry"><span class="refentrytitle">sd-bus</span>(3)</span></a>,
<a href="http://man7.org/linux/man-pages/man3/free.3.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a>
</p></div></div></body></html>
|