1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2014 Zbigniew Jędrzejewski-Szmek
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.
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.
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/>.
24 <refentry id="sd_bus_label_escape" conditional="ENABLE_KDBUS">
27 <title>sd_bus_label_escape</title>
28 <productname>systemd</productname>
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>
41 <refentrytitle>sd_bus_label_escape</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_bus_label_escape</refname>
47 <refname>sd_bus_label_unescape</refname>
49 <refpurpose>Escape D-Bus object path special characters</refpurpose>
54 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
57 <funcdef>char *<function>sd_bus_label_escape</function></funcdef>
58 <paramdef>const char *<parameter>s</parameter></paramdef>
62 <funcdef>char *<function>sd_bus_label_unescape</function></funcdef>
63 <paramdef>const char *<parameter>f</parameter></paramdef>
69 <title>Description</title>
71 <para><function>sd_bus_label_escape()</function> takes a
72 <constant>NUL</constant>-terminated string as a argument. It will
73 replace all characters which are invalid in a D-Bus object path by
74 <literal>_</literal> and a hexadecimal number. As a special case,
75 the empty string will be replaced by a lone <literal>_</literal>.
76 <function>sd_bus_label_unescape()</function> can be used to
77 reverse this process.</para>
81 <title>Return Value</title>
83 <para>On success, a new <constant>NUL</constant>-terminated string
84 will be returned. It must be
85 <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>d
86 by the caller. If a memory allocation failure occurs,
87 <constant>NULL</constant> will be returned.
94 <para><function>sd_bus_label_escape()</function> and
95 <function>sd_bus_label_unescape()</function> are available as a
96 shared library, which can be compiled and linked to with the
97 <constant>libsystemd</constant> <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
102 <title>See Also</title>
105 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
106 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>