Quite often we compare uuids/id128 formatted as strings with specific
values. So far we usually used streq() for that. let's add a new
explicit helper for this in id128_equal_string() that compares a string
with an sd_id128_t and is more robust than a simple string comparison.
Moreover, we can mroe easily reuse the various defines we have for
specific UUIDs, for example those from gpt.h.
*ret = uuid;
return 0;
}
+
+int id128_equal_string(const char *s, sd_id128_t id) {
+ sd_id128_t parsed;
+ int r;
+
+ if (!s)
+ return false;
+
+ /* Checks if the specified string matches a valid string representation of the specified 128 bit ID/uuid */
+
+ r = sd_id128_from_string(s, &parsed);
+ if (r < 0)
+ return r;
+
+ return sd_id128_equal(parsed, id);
+}
sd_id128_t id128_make_v4_uuid(sd_id128_t id);
int id128_get_product(sd_id128_t *ret);
+
+int id128_equal_string(const char *s, sd_id128_t id);