]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_id128_to_string.xml
journal-remote: tool to receive messages over the network
[thirdparty/systemd.git] / man / sd_id128_to_string.xml
CommitLineData
12355095
LP
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">
4
5<!--
6 This file is part of systemd.
7
8 Copyright 2012 Lennart Poettering
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_id128_to_string">
25
26 <refentryinfo>
27 <title>sd_id128_to_string</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>sd_id128_to_string</refentrytitle>
42 <manvolnum>3</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd_id128_to_string</refname>
47 <refname>sd_id128_from_string</refname>
e9dd9f95 48 <refpurpose>Format or parse 128-bit IDs as strings</refpurpose>
12355095
LP
49 </refnamediv>
50
51 <refsynopsisdiv>
52 <funcsynopsis>
53 <funcsynopsisinfo>#include &lt;systemd/sd-id128.h&gt;</funcsynopsisinfo>
54
55 <funcprototype>
56 <funcdef>char* <function>sd_id128_to_string</function></funcdef>
57 <paramdef>sd_id128_t <parameter>id</parameter>, char <parameter>s</parameter>[33]</paramdef>
58 </funcprototype>
59
60 <funcprototype>
61 <funcdef>int <function>sd_id128_from_string</function></funcdef>
aa96c6cb 62 <paramdef>const char* <parameter>s</parameter>, sd_id128_t* <parameter>ret</parameter></paramdef>
12355095
LP
63 </funcprototype>
64
65 </funcsynopsis>
66 </refsynopsisdiv>
67
68 <refsect1>
69 <title>Description</title>
70
71 <para><function>sd_id128_to_string()</function>
e9dd9f95 72 formats a 128-bit ID as a character string. It expects
12355095
LP
73 the ID and a string array capable of storing 33
74 characters. The ID will be formatted as 32 lowercase
05cc7267
ZJS
75 hexadecimal digits and be terminated by a
76 <constant>NUL</constant> byte.</para>
12355095
LP
77
78 <para><function>sd_id128_from_string()</function>
79 implements the reverse operation: it takes a 33
05cc7267
ZJS
80 character string with 32 hexadecimal digits (either
81 lowercase or uppercase, terminated by
82 <constant>NUL</constant>) and parses them back into a
83 128-bit ID returned in
aa96c6cb 84 <parameter>ret</parameter>. Alternatively, this call
e9dd9f95 85 can also parse a 37-character string with a 128-bit ID
aa96c6cb 86 formatted as RFC UUID.</para>
12355095
LP
87
88 <para>For more information about the
89 <literal>sd_id128_t</literal> type see
aa96c6cb
LP
90 <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Note
91 that these calls operate the same way on all
92 architectures, i.e. the results do not depend on
e9dd9f95 93 endianness.</para>
12355095 94
e9dd9f95 95 <para>When formatting a 128-bit ID into a string, it is
12355095
LP
96 often easier to use a format string for
97 <citerefentry><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>. This
bb31a4ac 98 is easily done using the
12355095
LP
99 <function>SD_ID128_FORMAT_STR</function> and
100 <function>SD_ID128_FORMAT_VAL()</function> macros. For
101 more information see
cb07866b 102 <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
12355095
LP
103 </refsect1>
104
105 <refsect1>
106 <title>Return Value</title>
107
108 <para><function>sd_id128_to_string()</function> always
109 succeeds and returns a pointer to the string array
e9dd9f95
JSJ
110 passed in. <function>sd_id128_from_string</function>
111 returns 0 on success, in which case
112 <parameter>ret</parameter> is filled in, or a negative
12355095
LP
113 errno-style error code.</para>
114 </refsect1>
115
116 <refsect1>
117 <title>Notes</title>
118
119 <para>The <function>sd_id128_to_string()</function>
120 and <function>sd_id128_from_string()</function> interfaces are
494a6682 121 available as a shared library, which can be compiled and
14bf8788 122 linked to with the <literal>libsystemd</literal> <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
12355095
LP
123 file.</para>
124 </refsect1>
125
126 <refsect1>
127 <title>See Also</title>
128
129 <para>
130 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
cb07866b 131 <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
12355095
LP
132 <citerefentry><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
133 </para>
134 </refsect1>
135
136</refentry>