sd-id128: rename and export sd_id128_string_equal()
We find this function useful in our code, so no reason not to export it. I changed the order of last two words in the name to match the arguments. (With "equal_string" I expected sd_id128_t first, string second, but in actual use, the second argument is usually a long constant so it's nice to keep this order of arguments.)
This commit is contained in:
@@ -783,6 +783,8 @@ LIBSYSTEMD_252 {
|
||||
global:
|
||||
sd_bus_error_setfv;
|
||||
|
||||
sd_id128_string_equal;
|
||||
|
||||
sd_hwdb_new_from_path;
|
||||
|
||||
sd_netlink_new_from_fd;
|
||||
|
||||
@@ -206,19 +206,3 @@ int id128_get_product(sd_id128_t *ret) {
|
||||
*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);
|
||||
}
|
||||
|
||||
@@ -34,5 +34,3 @@ extern const struct hash_ops id128_hash_ops;
|
||||
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);
|
||||
|
||||
@@ -101,6 +101,22 @@ _public_ int sd_id128_from_string(const char s[], sd_id128_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_public_ int sd_id128_string_equal(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);
|
||||
}
|
||||
|
||||
_public_ int sd_id128_get_machine(sd_id128_t *ret) {
|
||||
static thread_local sd_id128_t saved_machine_id = {};
|
||||
int r;
|
||||
|
||||
Reference in New Issue
Block a user