1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-27 01:55:32 +03:00

sd-id128: add SD_ID128_MAKE_UUID_STR

It's like SD_ID128_MAKE_STR, but with hyphens.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-06-11 18:17:00 +02:00
parent 8156422c8f
commit 7c7683f36c
3 changed files with 11 additions and 4 deletions

View File

@ -125,6 +125,7 @@ manpages = [
'SD_ID128_FORMAT_VAL',
'SD_ID128_MAKE',
'SD_ID128_MAKE_STR',
'SD_ID128_MAKE_UUID_STR',
'SD_ID128_NULL',
'SD_ID128_UUID_FORMAT_STR',
'sd_id128_equal',

View File

@ -24,6 +24,7 @@
<refname>SD_ID128_FORMAT_VAL</refname>
<refname>SD_ID128_MAKE</refname>
<refname>SD_ID128_MAKE_STR</refname>
<refname>SD_ID128_MAKE_UUID_STR</refname>
<refname>SD_ID128_NULL</refname>
<refname>SD_ID128_UUID_FORMAT_STR</refname>
<refname>sd_id128_equal</refname>
@ -121,10 +122,12 @@ int main(int argc, char **argv) {
return 0;
}</programlisting>
<para><constant>SD_ID128_UUID_FORMAT_STR</constant> is similar to
<constant>SD_ID128_FORMAT_STR</constant> but includes separating hyphens to conform to the "<ulink
url="https://en.wikipedia.org/wiki/Universally_unique_identifier#Format">canonical
representation</ulink>". This formats the string based on <ulink
<para><constant>SD_ID128_UUID_FORMAT_STR</constant> and <function>SD_ID128_MAKE_UUID_STR()</function>
are similar to
<constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_MAKE_STR()</function>,
but include separating hyphens to conform to the
"<ulink url="https://en.wikipedia.org/wiki/Universally_unique_identifier#Format">canonical representation</ulink>".
They format the string based on <ulink
url="https://tools.ietf.org/html/rfc4122">RFC4122</ulink> Variant 1 rules, i.e. converting from Big
Endian byte order. This matches behaviour of most other Linux userspace infrastructure. It's probably
best to avoid UUIDs of other variants, in order to avoid unnecessary ambiguities. All 128-bit IDs

View File

@ -107,6 +107,9 @@ int sd_id128_get_boot_app_specific(sd_id128_t app_id, sd_id128_t *ret);
#define SD_ID128_MAKE_STR(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
#a #b #c #d #e #f #g #h #i #j #k #l #m #n #o #p
#define SD_ID128_MAKE_UUID_STR(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
#a #b #c #d "-" #e #f "-" #g #h "-" #i #j "-" #k #l #m #n #o #p
_sd_pure_ static __inline__ int sd_id128_equal(sd_id128_t a, sd_id128_t b) {
return memcmp(&a, &b, 16) == 0;
}