man-pages/man3/sd_id128_to_string.3.html
2021-03-31 01:06:50 +01:00

129 lines
3.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SD_ID128_TO_STRING</TITLE>
</HEAD><BODY>
<H1>SD_ID128_TO_STRING</H1>
Section: sd_id128_to_string (3)<BR>Updated: <BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
sd_id128_to_string, sd_id128_from_string - Format or parse 128-bit IDs as strings
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<B>
</B><PRE>
#include &lt;<A HREF="file:///usr/include/systemd/sd-id128.h">systemd/sd-id128.h</A>&gt;
</PRE>
<DL COMPACT>
<DT id="1">
<B>char *sd_id128_to_string(sd_id128_t&nbsp;</B><I>id</I><B>,&nbsp;char&nbsp;</B><I>s</I><B>[33]);</B>
<DT id="2">
<B>int sd_id128_from_string(const&nbsp;char&nbsp;*</B><I>s</I><B>,&nbsp;sd_id128_t&nbsp;*</B><I>ret</I><B>);</B>
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
<B>sd_id128_to_string()</B>
<DD>formats a 128-bit ID as a character string. It expects the ID and a string array capable of storing 33 characters. The ID will be formatted as 32 lowercase hexadecimal digits and be terminated by a
<B>NUL</B>
byte.
<P>
<B>sd_id128_from_string()</B>
implements the reverse operation: it takes a 33 character string with 32 hexadecimal digits (either lowercase or uppercase, terminated by
<B>NUL</B>) and parses them back into a 128-bit ID returned in
<I>ret</I>. Alternatively, this call can also parse a 37-character string with a 128-bit ID formatted as RFC UUID. If
<I>ret</I>
is passed as NULL the function will validate the passed ID string, but not actually return it in parsed form.
<P>
For more information about the
&quot;sd_id128_t&quot;
type see
<B><A HREF="/cgi-bin/man/man2html?3+sd-id128">sd-id128</A></B>(3). Note that these calls operate the same way on all architectures, i.e. the results do not depend on endianness.
<P>
When formatting a 128-bit ID into a string, it is often easier to use a format string for
<B><A HREF="/cgi-bin/man/man2html?3+printf">printf</A></B>(3). This is easily done using the
<B>SD_ID128_FORMAT_STR</B>
and
<B>SD_ID128_FORMAT_VAL()</B>
macros. For more information see
<B><A HREF="/cgi-bin/man/man2html?3+sd-id128">sd-id128</A></B>(3).
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
<P>
<B>sd_id128_to_string()</B>
always succeeds and returns a pointer to the string array passed in.
<B>sd_id128_from_string</B>
returns 0 on success, in which case
<I>ret</I>
is filled in, or a negative errno-style error code.
<A NAME="lbAF">&nbsp;</A>
<H2>NOTES</H2>
<P>
These APIs are implemented as a shared library, which can be compiled and linked to with the
<B>libsystemd</B>&nbsp;<B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
file.
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>
<P>
<B><A HREF="/cgi-bin/man/man2html?1+systemd">systemd</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?3+sd-id128">sd-id128</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+printf">printf</A></B>(3)
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="6"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="7"><A HREF="#lbAF">NOTES</A><DD>
<DT id="8"><A HREF="#lbAG">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:55 GMT, March 31, 2021
</BODY>
</HTML>