]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_path_encode.xml
man: generate configured paths in manpages
[thirdparty/systemd.git] / man / sd_bus_path_encode.xml
CommitLineData
3802a3d3 1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
a6278b88 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
681eb9cf
FB
3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4<!ENTITY % entities SYSTEM "custom-entities.ent" >
5%entities;
6]>
a6278b88
LP
7
8<!--
b975b0d5 9 This file is part of systemd.
a6278b88 10
b975b0d5 11 Copyright 2014 Zbigniew Jędrzejewski-Szmek
a6278b88 12
b975b0d5
ZJS
13 systemd is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
a6278b88 17
b975b0d5
ZJS
18 systemd is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
a6278b88 22
b975b0d5
ZJS
23 You should have received a copy of the GNU Lesser General Public License
24 along with systemd; If not, see <http://www.gnu.org/licenses/>.
a6278b88
LP
25-->
26
27<refentry id="sd_bus_path_encode" conditional="ENABLE_KDBUS">
28
29 <refentryinfo>
30 <title>sd_bus_path_encode</title>
31 <productname>systemd</productname>
32
33 <authorgroup>
34 <author>
35 <contrib>A monkey with a typewriter</contrib>
36 <firstname>Zbigniew</firstname>
37 <surname>Jędrzejewski-Szmek</surname>
38 <email>zbyszek@in.waw.pl</email>
39 </author>
40 </authorgroup>
41 </refentryinfo>
42
43 <refmeta>
44 <refentrytitle>sd_bus_path_encode</refentrytitle>
45 <manvolnum>3</manvolnum>
46 </refmeta>
47
48 <refnamediv>
49 <refname>sd_bus_path_encode</refname>
50 <refname>sd_bus_path_decode</refname>
51
52 <refpurpose>Convert an external identifier into an object path and back</refpurpose>
53 </refnamediv>
54
55 <refsynopsisdiv>
56 <funcsynopsis>
57 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
58
59 <funcprototype>
60 <funcdef>int <function>sd_bus_path_encode</function></funcdef>
61 <paramdef>const char *<parameter>prefix</parameter></paramdef>
62 <paramdef>const char *<parameter>external_id</parameter></paramdef>
63 <paramdef>char **<parameter>ret_path</parameter></paramdef>
64 </funcprototype>
65
66 <funcprototype>
67 <funcdef>int <function>sd_bus_path_decode</function></funcdef>
a6278b88 68 <paramdef>const char *<parameter>path</parameter></paramdef>
53d68375 69 <paramdef>const char *<parameter>prefix</parameter></paramdef>
a6278b88
LP
70 <paramdef>char **<parameter>ret_external_id</parameter></paramdef>
71 </funcprototype>
72 </funcsynopsis>
73 </refsynopsisdiv>
74
75 <refsect1>
76 <title>Description</title>
77
78 <para><function>sd_bus_path_encode()</function> and
79 <function>sd_bus_path_decode()</function> convert external
80 identifier strings into object paths and back. These functions are
81 useful to map application-specific string identifiers of any kind
82 into bus object paths in a simple, reversible and safe way.</para>
83
84 <para><function>sd_bus_path_encode()</function> takes a bus path
85 prefix and an external identifier string as arguments, plus a
86 place to store the returned bus path string. The bus path prefix
87 must be a valid bus path, starting with a slash
b8bde116
JE
88 <literal>/</literal>, and not ending in one. The external
89 identifier string may be in any format, may be the empty string,
90 and has no restrictions on the charset — however, it must
a6278b88
LP
91 always be <constant>NUL</constant>-terminated. The returned string
92 will be the concatenation of the bus path prefix plus an escaped
93 version of the external identifier string. This operation may be
94 reversed with <function>sd_bus_decode()</function>. It is
b8bde116 95 recommended to only use external identifiers that generally
a6278b88 96 require little escaping to be turned into valid bus path
b8bde116 97 identifiers (for example, by sticking to a 7-bit ASCII character
a6278b88
LP
98 set), in order to ensure the resulting bus path is still short and
99 easily processed.</para>
100
101 <para><function>sd_bus_path_decode()</function> reverses the
102 operation of <function>sd_bus_path_encode()</function> and thus
103 regenerates an external identifier string from a bus path. It
104 takes a bus path and a prefix string, plus a place to store the
105 returned external identifier string. If the bus path does not
106 start with the specified prefix, 0 is returned and the returned
b8bde116 107 string is set to <constant>NULL</constant>. Otherwise, the
a6278b88
LP
108 string following the prefix is unescaped and returned in the
109 external identifier string.</para>
110
dca348bc 111 <para>The escaping used will replace all characters which are
b8bde116 112 invalid in a bus object path by <literal>_</literal>, followed by a
a6278b88
LP
113 hexadecimal value. As a special case, the empty string will be
114 replaced by a lone <literal>_</literal>.</para>
115 </refsect1>
116
117 <refsect1>
118 <title>Return Value</title>
119
120 <para>On success, <function>sd_bus_path_encode()</function>
121 returns positive or 0, and a valid bus path in the return
122 argument. On success, <function>sd_bus_path_decode()</function>
123 returns a positive value if the prefixed matched, or 0 if it
b8bde116
JE
124 did not. If the prefix matched, the external identifier is returned
125 in the return parameter. If it did not match, NULL is returned in
a6278b88
LP
126 the return parameter. On failure, a negative errno-style error
127 number is returned by either function. The returned strings must
128 be
5aded369 129 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>'d
a6278b88
LP
130 by the caller.</para>
131 </refsect1>
132
133 <refsect1>
134 <title>Notes</title>
135
136 <para><function>sd_bus_path_encode()</function> and
137 <function>sd_bus_path_decode()</function> are available as a
138 shared library, which can be compiled and linked to with the
5aded369 139 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
a6278b88
LP
140 file.</para>
141 </refsect1>
142
143 <refsect1>
144 <title>See Also</title>
145
146 <para>
147 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
148 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
5aded369 149 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
a6278b88
LP
150 </para>
151 </refsect1>
152
153</refentry>