chiark / gitweb /
11aa7f24fd4cf1b68af1891b9d5f31ce91dd895b
[elogind.git] / man / sd_id128_to_string.xml
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   SPDX-License-Identifier: LGPL-2.1+
7
8   Copyright 2012 Lennart Poettering
9 -->
10
11 <refentry id="sd_id128_to_string" xmlns:xi="http://www.w3.org/2001/XInclude">
12
13   <refentryinfo>
14     <title>sd_id128_to_string</title>
15     <productname>elogind</productname>
16
17     <authorgroup>
18       <author>
19         <contrib>Developer</contrib>
20         <firstname>Lennart</firstname>
21         <surname>Poettering</surname>
22         <email>lennart@poettering.net</email>
23       </author>
24     </authorgroup>
25   </refentryinfo>
26
27   <refmeta>
28     <refentrytitle>sd_id128_to_string</refentrytitle>
29     <manvolnum>3</manvolnum>
30   </refmeta>
31
32   <refnamediv>
33     <refname>sd_id128_to_string</refname>
34     <refname>sd_id128_from_string</refname>
35     <refpurpose>Format or parse 128-bit IDs as strings</refpurpose>
36   </refnamediv>
37
38   <refsynopsisdiv>
39     <funcsynopsis>
40       <funcsynopsisinfo>#include &lt;elogind/sd-id128.h&gt;</funcsynopsisinfo>
41
42       <funcprototype>
43         <funcdef>char *<function>sd_id128_to_string</function></funcdef>
44         <paramdef>sd_id128_t <parameter>id</parameter>, char <parameter>s</parameter>[33]</paramdef>
45       </funcprototype>
46
47       <funcprototype>
48         <funcdef>int <function>sd_id128_from_string</function></funcdef>
49         <paramdef>const char *<parameter>s</parameter>, sd_id128_t *<parameter>ret</parameter></paramdef>
50       </funcprototype>
51
52     </funcsynopsis>
53   </refsynopsisdiv>
54
55   <refsect1>
56     <title>Description</title>
57
58     <para><function>sd_id128_to_string()</function> formats a 128-bit
59     ID as a character string. It expects the ID and a string array
60     capable of storing 33 characters. The ID will be formatted as 32
61     lowercase hexadecimal digits and be terminated by a
62     <constant>NUL</constant> byte.</para>
63
64     <para><function>sd_id128_from_string()</function> implements the reverse operation: it takes a 33 character string
65     with 32 hexadecimal digits (either lowercase or uppercase, terminated by <constant>NUL</constant>) and parses them
66     back into a 128-bit ID returned in <parameter>ret</parameter>. Alternatively, this call can also parse a
67     37-character string with a 128-bit ID formatted as RFC UUID. If <parameter>ret</parameter> is passed as NULL the
68     function will validate the passed ID string, but not actually return it in parsed form.</para>
69
70     <para>For more information about the <literal>sd_id128_t</literal>
71     type see
72     <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
73     Note that these calls operate the same way on all architectures,
74     i.e. the results do not depend on endianness.</para>
75
76     <para>When formatting a 128-bit ID into a string, it is often
77     easier to use a format string for
78     <citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
79     This is easily done using the
80     <function>SD_ID128_FORMAT_STR</function> and
81     <function>SD_ID128_FORMAT_VAL()</function> macros. For more
82     information see
83     <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
84   </refsect1>
85
86   <refsect1>
87     <title>Return Value</title>
88
89     <para><function>sd_id128_to_string()</function> always succeeds
90     and returns a pointer to the string array passed in.
91     <function>sd_id128_from_string</function> returns 0 on success, in
92     which case <parameter>ret</parameter> is filled in, or a negative
93     errno-style error code.</para>
94   </refsect1>
95
96   <xi:include href="libelogind-pkgconfig.xml" />
97
98   <refsect1>
99     <title>See Also</title>
100
101     <para>
102       <!-- 0 /// elogind is in section 8
103       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
104       --><!-- else -->
105       <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
106       <!-- // 0 -->
107       <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
108       <citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
109     </para>
110   </refsect1>
111
112 </refentry>