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