mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-18 15:20:37 +01:00
glib-aux: add nm_uuid_unparse()
This commit is contained in:
parent
daebb11af8
commit
cd45ad4acf
2 changed files with 33 additions and 0 deletions
|
|
@ -3,3 +3,28 @@
|
|||
#include "libnm-glib-aux/nm-default-glib.h"
|
||||
|
||||
#include "nm-uuid.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char *
|
||||
nm_uuid_unparse_case(const NMUuid *uuid, char out_str[static 37], gboolean upper_case)
|
||||
{
|
||||
char *s;
|
||||
int i;
|
||||
|
||||
nm_assert(uuid);
|
||||
nm_assert(out_str);
|
||||
|
||||
s = out_str;
|
||||
for (i = 0; i < 16; i++) {
|
||||
const guint8 c = uuid->uuid[i];
|
||||
|
||||
if (NM_IN_SET(i, 4, 6, 8, 10))
|
||||
*(s++) = '-';
|
||||
*(s++) = nm_hexchar(c >> 4, upper_case);
|
||||
*(s++) = nm_hexchar(c, upper_case);
|
||||
}
|
||||
*s = '\0';
|
||||
|
||||
return out_str;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,12 @@ typedef struct _NMUuid {
|
|||
guint8 uuid[16];
|
||||
} NMUuid;
|
||||
|
||||
char *nm_uuid_unparse_case(const NMUuid *uuid, char out_str[static 37], gboolean upper_case);
|
||||
|
||||
static inline char *
|
||||
nm_uuid_unparse(const NMUuid *uuid, char out_str[static 37])
|
||||
{
|
||||
return nm_uuid_unparse_case(uuid, out_str, FALSE);
|
||||
}
|
||||
|
||||
#endif /* __NM_UUID_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue