glib-aux: add NMUuidType enum for nm_uuid_generate_from_string()

Let's have an enum instead of plain "int" and #define.
This commit is contained in:
Thomas Haller 2021-05-02 21:41:43 +02:00
parent 995c78245e
commit 414ce2236e
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 15 additions and 8 deletions

View file

@ -176,7 +176,7 @@ NMUuid *
nm_uuid_generate_from_string(NMUuid * uuid,
const char *s,
gssize slen,
int uuid_type,
NMUuidType uuid_type,
gpointer type_args)
{
g_return_val_if_fail(uuid, FALSE);
@ -250,7 +250,10 @@ nm_uuid_generate_from_string(NMUuid * uuid,
* object's #NMSettingConnection:id: property
**/
char *
nm_uuid_generate_from_string_str(const char *s, gssize slen, int uuid_type, gpointer type_args)
nm_uuid_generate_from_string_str(const char *s,
gssize slen,
NMUuidType uuid_type,
gpointer type_args)
{
NMUuid uuid;

View file

@ -47,18 +47,22 @@ char *nm_uuid_generate_random_str(char buf[static 37]);
/*****************************************************************************/
#define NM_UUID_TYPE_LEGACY 0
#define NM_UUID_TYPE_VERSION3 3
#define NM_UUID_TYPE_VERSION5 5
typedef enum {
NM_UUID_TYPE_LEGACY = 0,
NM_UUID_TYPE_VERSION3 = 3,
NM_UUID_TYPE_VERSION5 = 5,
} NMUuidType;
NMUuid *nm_uuid_generate_from_string(NMUuid * uuid,
const char *s,
gssize slen,
int uuid_type,
NMUuidType uuid_type,
gpointer type_args);
char *
nm_uuid_generate_from_string_str(const char *s, gssize slen, int uuid_type, gpointer type_args);
char *nm_uuid_generate_from_string_str(const char *s,
gssize slen,
NMUuidType uuid_type,
gpointer type_args);
/* arbitrarily chosen namespace UUID for nm_uuid_generate_from_strings() */
#define NM_UUID_NS1 "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"