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

[virt-tools-list] [libosinfo 1/4] Return matched OS media



From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>

osinfo_db_guess_os_from_media() now has an out parameter that provides
the caller a reference to returned OS's media that was matched against
the passed media instance.

WARNING: This commit breaks API but its not really an issue since we
haven't yet promised API stability.
---
 osinfo/osinfo_db.c    |    6 +++++-
 osinfo/osinfo_db.h    |    4 +++-
 tools/osinfo-detect.c |    3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index 0cf8584..4394dcf 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -324,12 +324,15 @@ void osinfo_db_add_deployment(OsinfoDb *db, OsinfoDeployment *deployment)
  * osinfo_db_guess_os_from_media:
  * @db: the database
  * @media: the installation media
+ * @matched_media: (out) (transfer none): the matched operating system media
  *
  * Guess operating system given a #OsinfoMedia object.
  *
  * Returns: (transfer none): the operating system, or NULL if guessing failed
  */
-OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db, OsinfoMedia *media)
+OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db,
+                                        OsinfoMedia *media,
+                                        OsinfoMedia **matched_media)
 {
     OsinfoOs *ret = NULL;
     GList *oss = NULL;
@@ -362,6 +365,7 @@ OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db, OsinfoMedia *media)
                 (match_regex (os_system, media_system) ||
                  match_regex (os_publisher, media_publisher))) {
                 ret = os;
+                *matched_media = os_media;
                 break;
             }
         }
diff --git a/osinfo/osinfo_db.h b/osinfo/osinfo_db.h
index 0165c30..70724ba 100644
--- a/osinfo/osinfo_db.h
+++ b/osinfo/osinfo_db.h
@@ -93,7 +93,9 @@ void osinfo_db_add_platform(OsinfoDb *db, OsinfoPlatform *platform);
 void osinfo_db_add_device(OsinfoDb *db, OsinfoDevice *device);
 void osinfo_db_add_deployment(OsinfoDb *db, OsinfoDeployment *deployment);
 
-OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db, OsinfoMedia *media);
+OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db,
+                                        OsinfoMedia *media,
+                                        OsinfoMedia **matched_media);
 
 // Get me all unique values for property "vendor" among operating systems
 GList *osinfo_db_unique_values_for_property_in_os(OsinfoDb *db, const gchar *propName);
diff --git a/tools/osinfo-detect.c b/tools/osinfo-detect.c
index be36afb..0051cf4 100644
--- a/tools/osinfo-detect.c
+++ b/tools/osinfo-detect.c
@@ -97,6 +97,7 @@ gint main(gint argc, gchar **argv)
     GOptionContext *context;
     GError *error = NULL;
     OsinfoMedia *media = NULL;
+    OsinfoMedia *matched_media = NULL;
     OsinfoLoader *loader = NULL;
     OsinfoDb *db = NULL;
     OsinfoOs *os = NULL;
@@ -145,7 +146,7 @@ gint main(gint argc, gchar **argv)
     }
 
     db = osinfo_loader_get_db(loader);
-    os = osinfo_db_guess_os_from_media(db, media);
+    os = osinfo_db_guess_os_from_media(db, media, &matched_media);
 
     print_os(os);
 
-- 
1.7.7.1


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