[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [libosinfo v2 2/3] install_script: add get_config_param function



Return, if exists, the sought OsinfoInstallConfigParam from an
OsinfoInstallScript. Otherwise, NULL is returned.
---
 osinfo/libosinfo.syms          |  1 +
 osinfo/osinfo_install_script.c | 33 +++++++++++++++++++++++++++++++++
 osinfo/osinfo_install_script.h |  2 ++
 3 files changed, 36 insertions(+)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 772e89c..df76108 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -309,6 +309,7 @@ LIBOSINFO_0.2.1 {
 	osinfo_entity_get_param_value_int64_with_default;
 	osinfo_entity_set_param_int64;
 	osinfo_install_script_get_expected_filename;
+	osinfo_install_script_get_config_param;
 } LIBOSINFO_0.2.0;
 
 /* Symbols in next release...
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index c9e2024..aaef08c 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -264,6 +264,39 @@ GList *osinfo_install_script_get_config_param_list(const OsinfoInstallScript *sc
     return g_list_copy(script->priv->config_param_list);
 }
 
+/**
+ * osinfo_install_script_get_config_param:
+ *
+ * Get a config param from the config param's list
+ *
+ * Returns: (transfer full): the sought config param, if exists.
+ *                           NULL otherwise.
+ */
+OsinfoInstallConfigParam *osinfo_install_script_get_config_param(const OsinfoInstallScript *script, const gchar *name)
+{
+    GList *l;
+
+    for (l = script->priv->config_param_list; l != NULL; l = l->next)
+    {
+        OsinfoInstallConfigParam *tmp = l->data;
+        const gchar *param_name = osinfo_install_config_param_get_name(tmp);
+
+        if (g_strcmp0(param_name, name) == 0) {
+            const gchar *param_policy;
+            OsinfoInstallConfigParamPolicy policy =
+                osinfo_install_config_param_get_policy(tmp);
+
+            if (policy == OSINFO_INSTALL_CONFIG_PARAM_POLICY_REQUIRED)
+                param_policy = "required";
+            else if (policy == OSINFO_INSTALL_CONFIG_PARAM_POLICY_OPTIONAL)
+                param_policy = "optional";
+
+            return osinfo_install_config_param_new(param_name, param_policy);
+        }
+    }
+    return NULL;
+}
+
 static void
 osinfo_install_script_init (OsinfoInstallScript *list)
 {
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index 4af62e0..372bacc 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -137,6 +137,8 @@ gboolean osinfo_install_script_has_config_param(const OsinfoInstallScript *scrip
 
 gboolean osinfo_install_script_has_config_param_name(const OsinfoInstallScript *script, const gchar *name);
 
+OsinfoInstallConfigParam *osinfo_install_script_get_config_param(const OsinfoInstallScript *script, const gchar *name);
+
 void osinfo_install_script_add_config_param(OsinfoInstallScript *script, OsinfoInstallConfigParam *param);
 
 GList *osinfo_install_script_get_config_param_list(const OsinfoInstallScript *script);
-- 
1.7.12.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]