From 2eb97b92556a7766d7cdfbbd445b85c359b40d54 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 2 Jan 2018 14:43:05 +0900 Subject: [PATCH] API: add gum_user_type_to_prefix () Signed-off-by: INSUN PYO Change-Id: Idcab8cfec27c8aec1bda66c718bc405b46d38ced --- include/gum/common/gum-user-types.h | 4 ++++ src/common/gum-user-types.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/gum/common/gum-user-types.h b/include/gum/common/gum-user-types.h index d574c35..eb2db2b 100644 --- a/include/gum/common/gum-user-types.h +++ b/include/gum/common/gum-user-types.h @@ -90,6 +90,10 @@ const gchar * gum_user_type_to_string ( GumUserType type); +const gchar * +gum_user_type_to_prefix ( + GumUserType type); + GumUserType gum_user_type_from_string ( const gchar *type); diff --git a/src/common/gum-user-types.c b/src/common/gum-user-types.c index bd91679..8973947 100644 --- a/src/common/gum-user-types.c +++ b/src/common/gum-user-types.c @@ -52,6 +52,15 @@ GumUserTypeString user_type_strings[GUM_USERTYPE_COUNT] = { {GUM_USERTYPE_SECURITY, "security"} }; +GumUserTypeString user_type_prefix[GUM_USERTYPE_COUNT] = { + {GUM_USERTYPE_NONE, ""}, + {GUM_USERTYPE_SYSTEM, ""}, + {GUM_USERTYPE_ADMIN, ""}, + {GUM_USERTYPE_GUEST, ""}, + {GUM_USERTYPE_NORMAL, ""}, + {GUM_USERTYPE_SECURITY, "cont_"} +}; + gint16 _get_user_type_strings_index ( GumUserType type) @@ -85,6 +94,24 @@ gum_user_type_to_string ( } /** + * gum_user_type_to_prefix: + * @type: the user type enum to convert + * + * Converts the user type enum to prefix string + * + * Returns: (transfer none): usertype if conversion succeeds, NULL otherwise. + */ +const gchar * +gum_user_type_to_prefix ( + GumUserType type) +{ + gint16 ind = _get_user_type_strings_index (type); + if (ind <= 0 || ind >= GUM_USERTYPE_COUNT) + return ""; + return user_type_prefix[ind].str; +} + +/** * gum_user_type_from_string: * @type: (transfer none): the user type string to convert * -- 2.7.4