This is a helper function that apps can take advantage of in orther to easily figure out whether some feature is supported by the os or not. Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- osinfo/libosinfo.syms | 2 ++ osinfo/osinfo_os.c | 31 +++++++++++++++++++++++++++++++ osinfo/osinfo_os.h | 1 + 3 files changed, 34 insertions(+) diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms index 99a7843..4a3d5cd 100644 --- a/osinfo/libosinfo.syms +++ b/osinfo/libosinfo.syms @@ -570,6 +570,8 @@ LIBOSINFO_1.3.0 { osinfo_os_get_image_list; osinfo_os_get_maximum_resources; + osinfo_os_is_feature_supported; + osinfo_tree_has_treeinfo; } LIBOSINFO_0.2.13; diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c index c29ffd2..9d24a64 100644 --- a/osinfo/osinfo_os.c +++ b/osinfo/osinfo_os.c @@ -693,6 +693,37 @@ void osinfo_os_add_feature(OsinfoOs *os, OsinfoFeature *feature) osinfo_list_add(OSINFO_LIST(os->priv->features), OSINFO_ENTITY(feature)); } +/** + * osinfo_os_is_feature_supported: + * @os: an operating system + * @arch: the target architecture + * @name: the feature's name + * + * Returns whether the named feature is supported or not by @os on @arch + * + * Returns: TRUE if the named feature is supported. Otherwise, FALSE. + */ +gboolean osinfo_os_is_feature_supported(OsinfoOs *os, + const gchar *name, + const gchar *arch) +{ + OsinfoFeatureList *list; + gboolean supports = FALSE; + + g_return_val_if_fail(OSINFO_IS_OS(os), FALSE); + g_return_val_if_fail(arch != NULL, FALSE); + g_return_val_if_fail(name != NULL, FALSE); + + list = osinfo_os_get_feature_list(os, arch); + + if (feature_exists_in_list(name, OSINFO_LIST(list))) + supports = TRUE; + + g_object_unref(list); + + return supports; +} + /** * osinfo_os_get_family: * @os: an #OsinfoOs diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h index 6ea825d..19c31ce 100644 --- a/osinfo/osinfo_os.h +++ b/osinfo/osinfo_os.h @@ -140,6 +140,7 @@ void osinfo_os_add_device_driver(OsinfoOs *os, OsinfoDeviceDriver *driver); OsinfoFeatureList *osinfo_os_get_feature_list(OsinfoOs *os, const gchar *arch); void osinfo_os_add_feature(OsinfoOs *os, OsinfoFeature *feature); +gboolean osinfo_os_is_feature_supported(OsinfoOs *os, const gchar *name, const gchar *arch); #endif /* __OSINFO_OS_H__ */ /* -- 2.19.2 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo