[virt-tools-list] [libosinfo 1/4] Return matched OS media
Christophe Fergeau
cfergeau at redhat.com
Thu Nov 24 08:26:13 UTC 2011
On Thu, Nov 24, 2011 at 12:07:55AM +0200, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at 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;
Imo it's nicer to make out arguments optional, ie
if (matched_media != NULL)
*matched_media = os_media;
Christophe
> 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
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20111124/298f3ff3/attachment.sig>
More information about the virt-tools-list
mailing list