fu-common-version

fu-common-version

Functions

Description

Functions

fu_common_vercmp ()

gint
fu_common_vercmp (const gchar *version_a,
                  const gchar *version_b);

fu_common_vercmp is deprecated and should not be used in newly-written code.

Compares version numbers for sorting.

Parameters

version_a

the semver release version, e.g. 1.2.3

 

version_b

the semver release version, e.g. 1.2.3.1

 

Returns

-1 if a < b, +1 if a > b, 0 if they are equal, and G_MAXINT on error

Since: 0.3.5


fu_common_vercmp_full ()

gint
fu_common_vercmp_full (const gchar *version_a,
                       const gchar *version_b,
                       FwupdVersionFormat fmt);

Compares version numbers for sorting taking into account the version format if required.

Parameters

version_a

the semver release version, e.g. 1.2.3

 

version_b

the semver release version, e.g. 1.2.3.1

 

fmt

a FwupdVersionFormat, e.g. FWUPD_VERSION_FORMAT_PLAIN

 

Returns

-1 if a < b, +1 if a > b, 0 if they are equal, and G_MAXINT on error

Since: 1.3.9


fu_common_version_from_uint64 ()

gchar *
fu_common_version_from_uint64 (guint64 val,
                               FwupdVersionFormat kind);

Returns a dotted decimal version string from a 64 bit number.

Parameters

val

A raw version number

 

kind

version kind used for formatting, e.g. FWUPD_VERSION_FORMAT_QUAD

 

Returns

A version number, e.g. "1.2.3.4", or NULL if not supported

Since: 1.3.6


fu_common_version_from_uint32 ()

gchar *
fu_common_version_from_uint32 (guint32 val,
                               FwupdVersionFormat kind);

Returns a dotted decimal version string from a 32 bit number.

Parameters

val

A uint32le version number

 

kind

version kind used for formatting, e.g. FWUPD_VERSION_FORMAT_TRIPLET

 

Returns

A version number, e.g. "1.0.3", or NULL if not supported

Since: 1.2.0


fu_common_version_from_uint16 ()

gchar *
fu_common_version_from_uint16 (guint16 val,
                               FwupdVersionFormat kind);

Returns a dotted decimal version string from a 16 bit number.

Parameters

val

A uint16le version number

 

kind

version kind used for formatting, e.g. FWUPD_VERSION_FORMAT_TRIPLET

 

Returns

A version number, e.g. "1.3", or NULL if not supported

Since: 1.2.0


fu_common_version_parse ()

gchar *
fu_common_version_parse (const gchar *version);

fu_common_version_parse is deprecated and should not be used in newly-written code.

Returns a dotted decimal version string from a version string. The supported formats are:

  • Dotted decimal, e.g. "1.2.3"

  • Base 16, a hex number *with* a 0x prefix, e.g. "0x10203"

  • Base 10, a string containing just [0-9], e.g. "66051"

  • Date in YYYYMMDD format, e.g. 20150915

Anything with a '.' or that doesn't match [0-9] or 0x[a-f,0-9] is considered a string and returned without modification.

Parameters

version

A version number

 

Returns

A version number, e.g. "1.0.3"

Since: 1.2.0


fu_common_version_parse_from_format ()

gchar *
fu_common_version_parse_from_format (const gchar *version,
                                     FwupdVersionFormat fmt);

Returns a dotted decimal version string from a version string using fmt. The supported formats are:

  • Dotted decimal, e.g. "1.2.3"

  • Base 16, a hex number *with* a 0x prefix, e.g. "0x10203"

  • Base 10, a string containing just [0-9], e.g. "66051"

  • Date in YYYYMMDD format, e.g. 20150915

Anything with a '.' or that doesn't match [0-9] or 0x[a-f,0-9] is considered a string and returned without modification.

Parameters

version

A version number

 

fmt

A FwupdVersionFormat, e.g. FWUPD_VERSION_FORMAT_TRIPLET

 

Returns

A version number, e.g. "1.0.3"

Since: 1.3.3


fu_common_version_ensure_semver ()

gchar *
fu_common_version_ensure_semver (const gchar *version);

Builds a semver from the possibly crazy version number.

Parameters

version

A version number, e.g. V1.2.3

 

Returns

A version number, e.g. "1.2.3", or NULL if the version was not valid

Since: 1.2.9


fu_common_version_guess_format ()

FwupdVersionFormat
fu_common_version_guess_format (const gchar *version);

Guesses the version format from the version number. This is only a heuristic and plugins and components should explicitly set the version format whenever possible.

If the version format cannot be guessed with any degree of accuracy, the FWUPD_VERSION_FORMAT_UNKNOWN constant is returned.

Parameters

version

A version number, e.g. "1.2.3"

 

Since: 1.2.0


fu_common_version_verify_format ()

gboolean
fu_common_version_verify_format (const gchar *version,
                                 FwupdVersionFormat fmt,
                                 GError **error);

Verifies if a version matches the input format.

Parameters

version

A string, e.g. "0x1234"

 

fmt

a FwupdVersionFormat

 

error

A GError or NULL

 

Returns

TRUE or FALSE

Since: 1.2.9

Types and Values