1SD_ID128_TO_STRING(3) sd_id128_to_string SD_ID128_TO_STRING(3)
2
3
4
6 sd_id128_to_string, sd_id128_from_string - Format or parse 128-bit IDs
7 as strings
8
10 #include <systemd/sd-id128.h>
11
12 char *sd_id128_to_string(sd_id128_t id, char s[33]);
13
14 int sd_id128_from_string(const char *s, sd_id128_t *ret);
15
17 sd_id128_to_string() formats a 128-bit ID as a character string. It
18 expects the ID and a string array capable of storing 33 characters. The
19 ID will be formatted as 32 lowercase hexadecimal digits and be
20 terminated by a NUL byte.
21
22 sd_id128_from_string() implements the reverse operation: it takes a 33
23 character string with 32 hexadecimal digits (either lowercase or
24 uppercase, terminated by NUL) and parses them back into a 128-bit ID
25 returned in ret. Alternatively, this call can also parse a 37-character
26 string with a 128-bit ID formatted as RFC UUID. If ret is passed as
27 NULL the function will validate the passed ID string, but not actually
28 return it in parsed form.
29
30 Note that when parsing 37 character UUIDs this is done strictly in Big
31 Endian byte order, i.e. according to RFC4122[1] Variant 1 rules, even
32 if the UUID encodes a different variant. This matches behaviour in
33 various other Linux userspace tools. It's probably wise to avoid UUIDs
34 of other variant types.
35
36 For more information about the "sd_id128_t" type see sd-id128(3). Note
37 that these calls operate the same way on all architectures, i.e. the
38 results do not depend on endianness.
39
40 When formatting a 128-bit ID into a string, it is often easier to use a
41 format string for printf(3). This is easily done using the
42 SD_ID128_FORMAT_STR and SD_ID128_FORMAT_VAL() macros. For more
43 information see sd-id128(3).
44
46 sd_id128_to_string() always succeeds and returns a pointer to the
47 string array passed in. sd_id128_from_string() returns 0 on success,
48 in which case ret is filled in, or a negative errno-style error code.
49
51 These APIs are implemented as a shared library, which can be compiled
52 and linked to with the libsystemd pkg-config(1) file.
53
55 systemd(1), sd-id128(3), printf(3)
56
58 1. RFC4122
59 https://tools.ietf.org/html/rfc4122
60
61
62
63systemd 249 SD_ID128_TO_STRING(3)