uuidparse: use uuid type definitions from libuuid header

While on it add missing UUID_TYPE_DCE_NIL to the header.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2020-11-22 20:48:38 +00:00
parent facafe2edb
commit ab85f756a0
No known key found for this signature in database
GPG Key ID: 0D46FEF7E61DBB46
2 changed files with 8 additions and 7 deletions

View File

@ -53,6 +53,7 @@ typedef unsigned char uuid_t[16];
#define UUID_VARIANT_MASK 0x7 #define UUID_VARIANT_MASK 0x7
/* UUID Type definitions */ /* UUID Type definitions */
#define UUID_TYPE_DCE_NIL 0
#define UUID_TYPE_DCE_TIME 1 #define UUID_TYPE_DCE_TIME 1
#define UUID_TYPE_DCE_SECURITY 2 #define UUID_TYPE_DCE_SECURITY 2
#define UUID_TYPE_DCE_MD5 3 #define UUID_TYPE_DCE_MD5 3

View File

@ -192,25 +192,25 @@ static void fill_table_row(struct libscols_table *tb, char const *const uuid)
break; break;
} }
switch (type) { switch (type) {
case 0: case UUID_TYPE_DCE_NIL:
if (uuid_is_null(buf)) if (uuid_is_null(buf))
str = xstrdup(_("nil")); str = xstrdup(_("nil"));
else else
str = xstrdup(_("unknown")); str = xstrdup(_("unknown"));
break; break;
case 1: case UUID_TYPE_DCE_TIME:
str = xstrdup(_("time-based")); str = xstrdup(_("time-based"));
break; break;
case 2: case UUID_TYPE_DCE_SECURITY:
str = xstrdup("DCE"); str = xstrdup("DCE");
break; break;
case 3: case UUID_TYPE_DCE_MD5:
str = xstrdup(_("name-based")); str = xstrdup(_("name-based"));
break; break;
case 4: case UUID_TYPE_DCE_RANDOM:
str = xstrdup(_("random")); str = xstrdup(_("random"));
break; break;
case 5: case UUID_TYPE_DCE_SHA1:
str = xstrdup(_("sha1-based")); str = xstrdup(_("sha1-based"));
break; break;
default: default:
@ -222,7 +222,7 @@ static void fill_table_row(struct libscols_table *tb, char const *const uuid)
str = xstrdup(_("invalid")); str = xstrdup(_("invalid"));
break; break;
} }
if (variant == UUID_VARIANT_DCE && type == 1) { if (variant == UUID_VARIANT_DCE && type == UUID_TYPE_DCE_TIME) {
struct timeval tv; struct timeval tv;
char date_buf[ISO_BUFSIZ]; char date_buf[ISO_BUFSIZ];