mirror of
https://git.proxmox.com/git/systemd
synced 2025-05-29 09:50:39 +00:00
71 lines
6.6 KiB
HTML
71 lines
6.6 KiB
HTML
<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>·
|
||
<a href="../libudev/index.html">libudev </a>·
|
||
<a href="../libudev/index.html">gudev </a><span style="float:right">systemd 219</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="idm140323855230496"></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="idm140323855219520"></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="idm140323859117808"></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="idm140323859113632"></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>
|