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